]> git.llucax.com Git - software/dgc/cdgc.git/commitdiff
Skip non-scanneable words in chunks
authorLeandro Lucarella <llucax@gmail.com>
Mon, 2 Aug 2010 01:01:50 +0000 (22:01 -0300)
committerLeandro Lucarella <llucax@gmail.com>
Fri, 6 Aug 2010 01:28:36 +0000 (22:28 -0300)
rt/gc/cdgc/gc.d

index f2d2f6ef3469f2bc75703fdd788bc7f3370064f4..c00817782db53182a1e06bc70e070306109f2945 100644 (file)
@@ -615,12 +615,25 @@ void mark(void *pbot, void *ptop, size_t* pm_bitmask)
 
     size_t type_size = pm_bitmask[0];
     size_t* pm_bits = pm_bitmask + 1;
+    bool has_type_info = type_size != 1 || pm_bits[0] != 1 || pm_bits[1] != 0;
 
     //printf("marking range: %p -> %p\n", pbot, ptop);
     for (; p1 + type_size <= p2; p1 += type_size) {
-        for (size_t n = 0; n < type_size; n++) {
+        size_t n = 0;
+        if (has_type_info) {
+            while (n < type_size && pm_bits[n / BITS_PER_WORD] == 0)
+                n += BITS_PER_WORD;
+            if (n < type_size && (pm_bits[n / BITS_PER_WORD] &
+                        ((1 << (BITS_PER_WORD / 2)) - 1)) == 0)
+                n += BITS_PER_WORD / 2;
+            else if (n < type_size && (pm_bits[n / BITS_PER_WORD] &
+                        ((1 << (BITS_PER_WORD / 4)) - 1)) == 0)
+                n += BITS_PER_WORD / 4;
+        }
+        for (; n < type_size; n++) {
             // scan bit set for this word
-            if (!(pm_bits[n / BITS_PER_WORD] & (1 << (n % BITS_PER_WORD))))
+            if (has_type_info &&
+                    !(pm_bits[n / BITS_PER_WORD] & (1 << (n % BITS_PER_WORD))))
                 continue;
 
             void* p = *(p1 + n);