www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Tell GC to use shared memory

reply tcak <1ltkrs+3wyh1ow7kzn1k sharklasers.com> writes:
Is it possible to modify GC (without rebuilding the compiler), so 
it uses a given shared memory area instead of heap for 
allocations?
Oct 07 2015
parent reply ketmar <ketmar ketmar.no-ip.org> writes:
On Thursday, 8 October 2015 at 04:38:43 UTC, tcak wrote:
 Is it possible to modify GC (without rebuilding the compiler), 
 so it uses a given shared memory area instead of heap for 
 allocations?
sure. you don't need to rebuild the compiler, only druntime.
Oct 07 2015
parent reply tcak <1ltkrs+3wyh1ow7kzn1k sharklasers.com> writes:
On Thursday, 8 October 2015 at 05:46:31 UTC, ketmar wrote:
 On Thursday, 8 October 2015 at 04:38:43 UTC, tcak wrote:
 Is it possible to modify GC (without rebuilding the compiler), 
 so it uses a given shared memory area instead of heap for 
 allocations?
sure. you don't need to rebuild the compiler, only druntime.
Any better solution? Like overriding GC class, etc.
Oct 08 2015
next sibling parent Kagamin <spam here.lot> writes:
GC is chosen at link time simply to satisfy unresolved symbols. 
You only need to compile your modified GC and link with it, it 
will be chosen instead of GC from druntime, no need to recompile 
anything else.
Oct 08 2015
prev sibling parent thedeemon <dlang thedeemon.com> writes:
On Thursday, 8 October 2015 at 09:25:36 UTC, tcak wrote:
 On Thursday, 8 October 2015 at 05:46:31 UTC, ketmar wrote:
 On Thursday, 8 October 2015 at 04:38:43 UTC, tcak wrote:
 Is it possible to modify GC (without rebuilding the 
 compiler), so it uses a given shared memory area instead of 
 heap for allocations?
sure. you don't need to rebuild the compiler, only druntime.
Any better solution? Like overriding GC class, etc.
You can install your own GC proxy, see module gc.proxy in druntime, the struct Proxy and functions gc_getProxy, gc_setProxy. No need to recompile druntime. Here's an example where I install my own GC proxy to do all allocations in my arena: https://bitbucket.org/infognition/dstuff/src/97cef6d4a0438f9a9f4ff0d18f819262b8a74888/gcarena.d?at=default&fileviewer=file-view-default
Oct 11 2015