Commit 069d309e authored by Kevin Modzelewski's avatar Kevin Modzelewski

Can optimize the initial branch away since we know we'll always execute the loop at least once

parent 2558ff26
...@@ -200,20 +200,19 @@ Heap::ThreadBlockCache::~ThreadBlockCache() { ...@@ -200,20 +200,19 @@ Heap::ThreadBlockCache::~ThreadBlockCache() {
static GCAllocation* allocFromBlock(Block* b) { static GCAllocation* allocFromBlock(Block* b) {
uint64_t mask = 0; uint64_t mask = 0;
int elts_scanned = 0; while (true) {
for (; b->next_to_check < BITFIELD_ELTS; b->next_to_check++) {
elts_scanned++;
mask = b->isfree[b->next_to_check]; mask = b->isfree[b->next_to_check];
if (mask != 0L) { if (mask != 0L) {
break; break;
} }
}
int i = b->next_to_check;
if (i == BITFIELD_ELTS) { b->next_to_check++;
if (b->next_to_check == BITFIELD_ELTS) {
b->next_to_check = 0; b->next_to_check = 0;
return NULL; return NULL;
} }
}
int i = b->next_to_check;
int first = __builtin_ctzll(mask); int first = __builtin_ctzll(mask);
assert(first < 64); assert(first < 64);
......
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