Commit 35bc4d48 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Round up to a multiple of the pointer width for conservative allocations

So that we have a whole number of pointers to scan.  I think there's a bunch
more we can do to optimize this situation (do we even need to scan these at
all?) but this seems like the simplest way to make this work for now.
parent e041df0a
......@@ -48,6 +48,13 @@ extern "C" inline void* gc_alloc(size_t bytes, GCKind kind_id) {
alloc->gc_flags = 0;
if (kind_id == GCKind::CONSERVATIVE) {
// Round the size up to the nearest multiple of the pointer width, so that
// we have an integer number of pointers to scan.
// TODO We can probably this better; we could round down when we scan, or even
// not scan this at all -- a non-pointerwidth-multiple allocation seems to mean
// that it won't be storing pointers (or it will be storing them non-aligned,
// which we don't support).
bytes = (bytes + sizeof(void*) - 1) & (~(sizeof(void*) - 1));
assert(bytes < (1 << 31));
alloc->kind_data = bytes;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment