Skip to content

Commit 94b3274

Browse files
Slight changes to the garbage collector
1 parent d3ef28c commit 94b3274

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/runtime.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,11 +1124,7 @@ static void* gc_flatmalloc(size_t sz)
11241124
__attribute__((hot))
11251125
static _Bool is_gc_ptr(uintptr_t object)
11261126
{
1127-
const uintptr_t upper_bits = object & ~PTR_MASK;
1128-
if (upper_bits) return 0;
1129-
const uintptr_t index = (uintptr_t*)(object & PTR_MASK & ~7) - space[!z];
1130-
if (index >= alloc[!z]) return 0;
1131-
return 1;
1127+
return (uint64_t*)object - space[!z] < alloc[!z];
11321128
}
11331129

11341130
__attribute__((hot))
@@ -1146,13 +1142,12 @@ static void gc_collect_root(uintptr_t* restrict addr)
11461142
{
11471143
uintptr_t from = act_stk_top->from;
11481144
uintptr_t* to = act_stk_top->to;
1149-
const uintptr_t upper_bits = from & ~PTR_MASK;
11501145
const uintptr_t lower_bits = from & 7;
1151-
uintptr_t index = (uintptr_t*)(from & PTR_MASK & ~7) - space[!z];
1146+
uintptr_t index = (uintptr_t*)(from & ~7) - space[!z];
11521147
ptrdiff_t offset = 0;
11531148
while (bitmap[!z][index] == EMPTY) index--, offset++; // Ptr to middle of object
11541149
if (bitmap[!z][index] == FORWARD)
1155-
*to = lower_bits | upper_bits | (uintptr_t)((uintptr_t*)space[!z][index] + offset);
1150+
*to = lower_bits | (uintptr_t)((uintptr_t*)space[!z][index] + offset);
11561151
else
11571152
{
11581153
_Bool flat = bitmap[!z][index] == FLATALLOC;
@@ -1173,7 +1168,7 @@ static void gc_collect_root(uintptr_t* restrict addr)
11731168
}
11741169
space[!z][index] = (uintptr_t)buf; // Set forwarding address
11751170
bitmap[!z][index] = FORWARD;
1176-
*to = lower_bits | upper_bits | (uintptr_t)(buf + offset);
1171+
*to = lower_bits | (uintptr_t)(buf + offset);
11771172
}
11781173
}
11791174
}

0 commit comments

Comments
 (0)