diff --git a/include/runtime/arena.h b/include/runtime/arena.h index 9b40f66ca..fc72155fb 100644 --- a/include/runtime/arena.h +++ b/include/runtime/arena.h @@ -73,7 +73,7 @@ class arena { // Return value: the address allocated in the arena after size bytes from the // starting pointer, or 0 if this is equal to the 3rd argument. static char *move_ptr(char *ptr, size_t size, char const *arena_end_ptr); - + // Returns the ID of the semispace where the given address was allocated. // The behavior is undefined if called with an address that has not been // allocated within an arena. @@ -91,14 +91,14 @@ class arena { // helper function for `kore_arena_alloc`. Do not call directly. void *do_alloc_slow(size_t requested); - char *first_block; // beginning of first block - char *block; // where allocations are being made in current block - char *block_start; // start of current block - char *block_end; // 1 past end of current block - char *first_collection_block; // beginning of other semispace - size_t num_blocks; // number of blocks in current semispace - size_t num_collection_blocks; // number of blocks in other semispace - char allocation_semispace_id; // id of current semispace + char *first_block; // beginning of first block + char *block; // where allocations are being made in current block + char *block_start; // start of current block + char *block_end; // 1 past end of current block + char *first_collection_block; // beginning of other semispace + size_t num_blocks; // number of blocks in current semispace + size_t num_collection_blocks; // number of blocks in other semispace + char allocation_semispace_id; // id of current semispace }; // Macro to define a new arena with the given ID. Supports IDs ranging from 0 to @@ -130,7 +130,6 @@ inline void *arena::kore_arena_alloc(size_t requested) { requested, block); return result; } - } #endif // ARENA_H diff --git a/runtime/alloc/arena.cpp b/runtime/alloc/arena.cpp index 961b2c3be..c4384642e 100644 --- a/runtime/alloc/arena.cpp +++ b/runtime/alloc/arena.cpp @@ -172,13 +172,15 @@ __attribute__((always_inline)) void arena::arena_swap_and_clear() { } __attribute__((always_inline)) void arena::arena_clear() { - block = first_block ? first_block + sizeof(arena::memory_block_header) : nullptr; + block = first_block ? first_block + sizeof(arena::memory_block_header) + : nullptr; block_start = first_block; block_end = first_block ? first_block + BLOCK_SIZE : nullptr; } __attribute__((always_inline)) char *arena::arena_start_ptr() const { - return first_block ? first_block + sizeof(arena::memory_block_header) : nullptr; + return first_block ? first_block + sizeof(arena::memory_block_header) + : nullptr; } __attribute__((always_inline)) char **arena::arena_end_ptr() { diff --git a/runtime/collect/collect.cpp b/runtime/collect/collect.cpp index cd6881718..cc596d205 100644 --- a/runtime/collect/collect.cpp +++ b/runtime/collect/collect.cpp @@ -85,9 +85,9 @@ void migrate_once(block **block_ptr) { return; } if (youngspace_collection_id() - == arena::get_arena_semispace_id_of_object((void *)curr_block) + == arena::get_arena_semispace_id_of_object((void *)curr_block) || oldspace_collection_id() - == arena::get_arena_semispace_id_of_object((void *)curr_block)) { + == arena::get_arena_semispace_id_of_object((void *)curr_block)) { migrate(block_ptr); } } @@ -327,7 +327,8 @@ void kore_collect( // kore_arena_alloc, which will have allocated a fresh memory block and put // the allocation at the start of it. Thus, we use arena::move_ptr with a size // of zero to adjust and get the true address of the allocation. - scan_ptr = arena::move_ptr(previous_oldspace_alloc_ptr, 0, *old_alloc_ptr()); + scan_ptr + = arena::move_ptr(previous_oldspace_alloc_ptr, 0, *old_alloc_ptr()); } else { scan_ptr = previous_oldspace_alloc_ptr; } @@ -340,7 +341,7 @@ void kore_collect( } #ifdef GC_DBG ssize_t numBytesAllocedSinceLastCollection - = arena::ptr_diff(current_alloc_ptr, last_alloc_ptr); + = arena::ptr_diff(current_alloc_ptr, last_alloc_ptr); assert(numBytesAllocedSinceLastCollection >= 0); fwrite(&numBytesAllocedSinceLastCollection, sizeof(ssize_t), 1, stderr); last_alloc_ptr = *young_alloc_ptr(); diff --git a/runtime/collect/migrate_collection.cpp b/runtime/collect/migrate_collection.cpp index e83e873ce..c6e644e0e 100644 --- a/runtime/collect/migrate_collection.cpp +++ b/runtime/collect/migrate_collection.cpp @@ -7,9 +7,9 @@ void migrate_collection_node(void **node_ptr) { string *curr_block = STRUCT_BASE(string, data, *node_ptr); if (youngspace_collection_id() - != arena::get_arena_semispace_id_of_object((void *)curr_block) + != arena::get_arena_semispace_id_of_object((void *)curr_block) && oldspace_collection_id() - != arena::get_arena_semispace_id_of_object((void *)curr_block)) { + != arena::get_arena_semispace_id_of_object((void *)curr_block)) { return; } uint64_t const hdr = curr_block->h.hdr;