Skip to content

Commit

Permalink
arena_start_ptr() -> start_ptr(); arena_end_ptr() -> end_ptr()
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenmeker committed Dec 10, 2024
1 parent 8c627bc commit 531bae8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions include/runtime/arena.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ class arena {

// Returns the address of the first byte that belongs in the given arena.
// Returns nullptr if nothing has been allocated ever in that arena.
char *arena_start_ptr() const { return current_addr_ptr; }
char *start_ptr() const { return current_addr_ptr; }

// Returns a pointer to a location holding the address of last allocated
// byte in the given arena plus 1.
// This address is nullptr if nothing has been allocated ever in that arena.
char *arena_end_ptr() { return allocation_ptr; }
char *end_ptr() { return allocation_ptr; }

// Clears the current allocation space by setting its start back to its first
// block. It is used during garbage collection to effectively collect all of the
Expand Down Expand Up @@ -173,7 +173,7 @@ inline void arena::arena_clear() {
//
// We set the allocation pointer to the first available address.
//
allocation_ptr = arena_start_ptr();
allocation_ptr = current_addr_ptr;
//
// If the number of blocks we've touched is >= threshold, we want to trigger
// a garbage collection if we get within 1 block of the end of this area.
Expand Down
12 changes: 6 additions & 6 deletions runtime/collect/collect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ char *arena::evacuate(char *scan_ptr) {
migrate_child(curr_block, layout_data->args, i, false);
}
}
return move_ptr(scan_ptr, get_size(hdr, layout_int), arena_end_ptr());
return move_ptr(scan_ptr, get_size(hdr, layout_int), end_ptr());
}

// Contains the decision logic for collecting the old generation.
Expand Down Expand Up @@ -293,21 +293,21 @@ void kore_collect(
if (!last_alloc_ptr) {
last_alloc_ptr = youngspace_ptr();
}
char *current_alloc_ptr = youngspace.arena_end_ptr();
char *current_alloc_ptr = youngspace.end_ptr();
#endif
kore_alloc_swap(collect_old);
#ifdef GC_DBG
for (int i = 0; i < 2048; i++) {
numBytesLiveAtCollection[i] = 0;
}
#endif
char *previous_oldspace_alloc_ptr = oldspace.arena_end_ptr();
char *previous_oldspace_alloc_ptr = oldspace.end_ptr();
for (int i = 0; i < nroots; i++) {
migrate_root(roots, type_info, i);
}
migrate_static_roots();
char *scan_ptr = youngspace_ptr();
if (scan_ptr != youngspace.arena_end_ptr()) {
if (scan_ptr != youngspace.end_ptr()) {
MEM_LOG("Evacuating young generation\n");
while (scan_ptr) {
scan_ptr = youngspace.evacuate(scan_ptr);
Expand All @@ -318,7 +318,7 @@ void kore_collect(
} else {
scan_ptr = previous_oldspace_alloc_ptr;
}
if (scan_ptr != oldspace.arena_end_ptr()) {
if (scan_ptr != oldspace.end_ptr()) {
MEM_LOG("Evacuating old generation\n");
while (scan_ptr) {
scan_ptr = oldspace.evacuate(scan_ptr);
Expand All @@ -329,7 +329,7 @@ void kore_collect(
= arena::ptr_diff(current_alloc_ptr, last_alloc_ptr);
assert(numBytesAllocedSinceLastCollection >= 0);
fwrite(&numBytesAllocedSinceLastCollection, sizeof(ssize_t), 1, stderr);
last_alloc_ptr = youngspace.arena_end_ptr();
last_alloc_ptr = youngspace.end_ptr();
fwrite(
numBytesLiveAtCollection, sizeof(numBytesLiveAtCollection[0]),
sizeof(numBytesLiveAtCollection) / sizeof(numBytesLiveAtCollection[0]),
Expand Down
6 changes: 3 additions & 3 deletions runtime/lto/alloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ REGISTER_ARENA(oldspace, OLDSPACE_ID);
REGISTER_ARENA(alwaysgcspace, ALWAYSGCSPACE_ID);

char *youngspace_ptr() {
return youngspace.arena_start_ptr();
return youngspace.start_ptr();
}

char *oldspace_ptr() {
return oldspace.arena_start_ptr();
return oldspace.start_ptr();
}

char youngspace_collection_id() {
Expand Down Expand Up @@ -73,7 +73,7 @@ kore_resize_last_alloc(void *oldptr, size_t newrequest, size_t last_size) {
newrequest = (newrequest + 7) & ~7;
last_size = (last_size + 7) & ~7;

if (oldptr != youngspace.arena_end_ptr() - last_size) {
if (oldptr != youngspace.end_ptr() - last_size) {
MEM_LOG(
"May only reallocate last allocation. Tried to reallocate %p to %zd\n",
oldptr, newrequest);
Expand Down

0 comments on commit 531bae8

Please sign in to comment.