]> git.llucax.com Git - software/druntime.git/blobdiff - src/gc/basic/gcx.d
Changed D 2.0 runtime to account for 'this' being changed from a pointer to a referen...
[software/druntime.git] / src / gc / basic / gcx.d
index 4c6396e72f7586e3a3403e8bd85f9d55b167e129..b913c36c7510a1cb71efe5857f0f51b320f93e25 100644 (file)
@@ -1163,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
      */
@@ -1207,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
      */
@@ -1436,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)
@@ -1570,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;
+    }
+
+
     /**
      *
      */
@@ -1623,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.