Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenmeker committed Nov 26, 2024
1 parent a7ef78b commit 6d96ab4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
19 changes: 9 additions & 10 deletions include/runtime/arena.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -130,7 +130,6 @@ inline void *arena::kore_arena_alloc(size_t requested) {
requested, block);
return result;
}

}

#endif // ARENA_H
6 changes: 4 additions & 2 deletions runtime/alloc/arena.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
9 changes: 5 additions & 4 deletions runtime/collect/collect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions runtime/collect/migrate_collection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6d96ab4

Please sign in to comment.