Skip to content

Commit

Permalink
don't mmap() until first call to kore_arena_alloc()
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenmeker committed Dec 17, 2024
1 parent 4c66b1f commit 3b2f36c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions include/runtime/arena.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ size_t const HYPERBLOCK_SIZE = (size_t)BLOCK_SIZE * 1024 * 1024;
class arena {
public:
arena(char id)
: allocation_semispace_id(id) {
}
: allocation_semispace_id(id) { }

~arena() {
munmap(current_addr_ptr, HYPERBLOCK_SIZE);
if (current_addr_ptr)
munmap(current_addr_ptr, HYPERBLOCK_SIZE);
if (collection_addr_ptr)
munmap(collection_addr_ptr, HYPERBLOCK_SIZE);
}
Expand Down Expand Up @@ -111,10 +111,11 @@ class arena {
// Current semispace where allocations are being made.
//
char *current_addr_ptr = nullptr; // pointer to start of current address space
char *allocation_ptr = nullptr; // next available location in current semispace
char *allocation_ptr
= nullptr; // next available location in current semispace
char *tripwire = nullptr; // allocating past this triggers slow allocation
mutable size_t
num_blocks; // notional number of BLOCK_SIZE blocks in current semispace
mutable size_t num_blocks
= 0; // notional number of BLOCK_SIZE blocks in current semispace
char allocation_semispace_id; // id of current semispace
//
// Semispace where allocations will be made during and after garbage collect.
Expand Down Expand Up @@ -159,8 +160,7 @@ inline void *arena::kore_arena_alloc(size_t requested) {
// Semispace not yet initialized.
//
initialize_semispace();
}
else if (allocation_ptr + requested >= tripwire) {
} else if (allocation_ptr + requested >= tripwire) {
{
//
// We got close to or past the last location accessed in this address range so far,
Expand Down

0 comments on commit 3b2f36c

Please sign in to comment.