X-Git-Url: https://git.llucax.com/software/druntime.git/blobdiff_plain/24f79eca36d0f4294eb276ac777b2a27dfb060dd..ee20c715e3f0be23c1732938dc222d436464c254:/src/gc/basic/gcx.d?ds=sidebyside diff --git a/src/gc/basic/gcx.d b/src/gc/basic/gcx.d index 0b6d1d0..b913c36 100644 --- a/src/gc/basic/gcx.d +++ b/src/gc/basic/gcx.d @@ -86,21 +86,16 @@ private extern (C) void* rt_stackBottom(); extern (C) void* rt_stackTop(); - extern (C) void* rt_staticDataBottom(); - extern (C) void* rt_staticDataTop(); extern (C) void rt_finalize( void* p, bool det = true ); - alias void delegate( void*, void* ) scanFn; - - extern (C) void rt_scanStaticData( scanFn scan ); - version (MULTI_THREADED) { extern (C) bool thread_needLock(); extern (C) void thread_suspendAll(); extern (C) void thread_resumeAll(); + alias void delegate( void*, void* ) scanFn; extern (C) void thread_scanAll( scanFn fn, void* curStackTop = null ); } @@ -1126,21 +1121,6 @@ class GC } - static void scanStaticData(gc_t g) - { - //debug(PRINTF) printf("+GC.scanStaticData()\n"); - auto pbot = rt_staticDataBottom(); - auto ptop = rt_staticDataTop(); - g.addRange(pbot, ptop - pbot); - //debug(PRINTF) printf("-GC.scanStaticData()\n"); - } - - static void unscanStaticData(gc_t g) - { - auto pbot = rt_staticDataBottom(); - g.removeRange(pbot); - } - /** * add p to list of roots */ @@ -1183,6 +1163,22 @@ class GC } + /** + * + */ + int delegate(int delegate(inout void*)) rootIter() + { + if (!thread_needLock()) + { + return &gcx.rootIter; + } + else synchronized (gcLock) + { + return &gcx.rootIter; + } + } + + /** * add range to scan for roots */ @@ -1227,6 +1223,22 @@ class GC } + /** + * + */ + int delegate(int delegate(inout Range)) rangeIter() + { + if (!thread_needLock()) + { + return &gcx.rangeIter; + } + else synchronized (gcLock) + { + return &gcx.rangeIter; + } + } + + /** * do full garbage collection */ @@ -1456,7 +1468,7 @@ struct Gcx void initialize() { int dummy; - (cast(byte*)this)[0 .. Gcx.sizeof] = 0; + (cast(byte*)&this)[0 .. Gcx.sizeof] = 0; stackBottom = cast(char*)&dummy; log_init(); debug (THREADINVARIANT) @@ -1590,6 +1602,22 @@ struct Gcx } + /** + * + */ + int rootIter(int delegate(inout void*) dg) + { + int result = 0; + for( size_t i = 0; i < nroots; ++i ) + { + result = dg(roots[i]); + if (result) + break; + } + return result; + } + + /** * */ @@ -1643,6 +1671,22 @@ struct Gcx } + /** + * + */ + int rangeIter(int delegate(inout Range) dg) + { + int result = 0; + for( size_t i = 0; i < nranges; ++i ) + { + result = dg(ranges[i]); + if (result) + break; + } + return result; + } + + /** * Find Pool that pointer is in. * Return null if not in a Pool. @@ -2262,8 +2306,6 @@ struct Gcx pool.mark.copy(&pool.freebits); } - rt_scanStaticData( &mark ); - version (MULTI_THREADED) { if (!noStack)