Created
July 12, 2018 11:37
-
-
Save samcv/1955ad025b1822876dc642b3e1b3e00b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/6model/reprs/MVMHash.c b/src/6model/reprs/MVMHash.c | |
index 51d0d4af9..859850344 100644 | |
--- a/src/6model/reprs/MVMHash.c | |
+++ b/src/6model/reprs/MVMHash.c | |
@@ -40,14 +40,40 @@ static void copy_to(MVMThreadContext *tc, MVMSTable *st, void *src, MVMObject *d | |
}); | |
} | |
+#define MVM_gc_worklist_add_include_gen2(tc, worklist, item) \ | |
+do { \ | |
+ if (MVM_UNLIKELY(worklist->items == worklist->alloc)) \ | |
+ MVM_gc_worklist_add_slow(tc, worklist, &item); \ | |
+ else \ | |
+ worklist->list[worklist->items++] = &item; \ | |
+} while (0) | |
+ | |
+#define MVM_gc_worklist_add_no_include_gen2(tc, worklist, item) \ | |
+do { \ | |
+ if (!( ((MVMCollectable*)item)->flags & MVM_CF_SECOND_GEN)) { \ | |
+ if (MVM_UNLIKELY(worklist->items == worklist->alloc)) \ | |
+ MVM_gc_worklist_add_slow(tc, worklist, &item); \ | |
+ else \ | |
+ worklist->list[worklist->items++] = &item; \ | |
+ } \ | |
+} while (0) | |
+ | |
/* Adds held objects to the GC worklist. */ | |
static void MVMHash_gc_mark(MVMThreadContext *tc, MVMSTable *st, void *data, MVMGCWorklist *worklist) { | |
MVMHashBody *body = (MVMHashBody *)data; | |
MVMHashEntry *current = NULL; | |
- HASH_ITER_FAST(tc, hash_handle, body->hash_head, current, { | |
- MVM_gc_worklist_add(tc, worklist, ¤t->hash_handle.key); | |
- MVM_gc_worklist_add(tc, worklist, ¤t->value); | |
- }); | |
+ if (worklist->include_gen2) { | |
+ HASH_ITER_FAST(tc, hash_handle, body->hash_head, current, { | |
+ MVM_gc_worklist_add_include_gen2(tc, worklist, current->hash_handle.key); | |
+ MVM_gc_worklist_add_include_gen2(tc, worklist, current->value); | |
+ }); | |
+ } | |
+ else { | |
+ HASH_ITER_FAST(tc, hash_handle, body->hash_head, current, { | |
+ MVM_gc_worklist_add_no_include_gen2(tc, worklist, current->hash_handle.key); | |
+ MVM_gc_worklist_add_no_include_gen2(tc, worklist, current->value); | |
+ }); | |
+ } | |
} | |
/* Called by the VM in order to free memory associated with this object. */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment