summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/gc.c b/gc.c
index 859e8d6ac7..d3941cbaf2 100644
--- a/gc.c
+++ b/gc.c
@@ -3591,33 +3591,38 @@ rgengc_remembered(rb_objspace_t *objspace, VALUE obj)
static size_t
rgengc_rememberset_mark(rb_objspace_t *objspace)
{
- size_t i;
+ size_t i, j;
size_t shady_object_count = 0;
- RVALUE *p, *pend;
- uintptr_t *bits;
+ RVALUE *p, *offset;
+ uintptr_t *bits, bitset;
for (i=0; i<heaps_used; i++) {
- if (0 /* TODO: optimization - skip it if there are no remembered objects */) {
- continue;
- }
-
- p = objspace->heap.sorted[i]->start; pend = p + objspace->heap.sorted[i]->limit;
+ p = objspace->heap.sorted[i]->start;
bits = GET_HEAP_REMEMBERSET_BITS(p);
- while (p < pend) {
- if (MARKED_IN_BITMAP(bits, p)) {
- gc_mark(objspace, (VALUE)p);
- rgengc_report(2, objspace, "rgengc_rememberset_mark: mark %p (%s)\n", p, obj_type_name((VALUE)p));
-
- if (RVALUE_SUNNY(p)) {
- rgengc_report(2, objspace, "rgengc_rememberset_mark: clear %p (%s)\n", p, obj_type_name((VALUE)p));
- CLEAR_IN_BITMAP(bits, p);
- }
- else {
- shady_object_count++;
+ offset = p - NUM_IN_SLOT(p);
+
+ for(j=0;j< HEAP_BITMAP_LIMIT;j++){
+ if(bits[j]){
+ p = offset + j * (sizeof(uintptr_t) * CHAR_BIT);
+ bitset = bits[j];
+ while (bitset) {
+ if (bitset & 1) {
+ gc_mark(objspace, (VALUE)p);
+ rgengc_report(2, objspace, "rgengc_rememberset_mark: mark %p (%s)\n", p, obj_type_name((VALUE)p));
+
+ if (RVALUE_SUNNY(p)) {
+ rgengc_report(2, objspace, "rgengc_rememberset_mark: clear %p (%s)\n", p, obj_type_name((VALUE)p));
+ CLEAR_IN_BITMAP(bits, p);
+ }
+ else {
+ shady_object_count++;
+ }
+ }
+ p++;
+ bitset>>=1;
}
}
- p++;
}
}