Skip to content

Commit 8b47c1e

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents 2852f4a + c59e3c4 commit 8b47c1e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

include/runtime/arena.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,20 @@ class arena {
111111
// allocated within an arena.
112112
static char get_arena_semispace_id_of_object(void *ptr);
113113

114+
// Unmaps the current and collection address spaces and resets them and the tripwire.
115+
// This is needed when the client switches thread contexts without properly deallocating
116+
// them. This is not a common use case and shoul be used carefully.
117+
void munmap_arena_and_reset() {
118+
if (current_addr_ptr)
119+
munmap(current_addr_ptr, HYPERBLOCK_SIZE);
120+
if (collection_addr_ptr)
121+
munmap(collection_addr_ptr, HYPERBLOCK_SIZE);
122+
123+
current_addr_ptr = nullptr;
124+
collection_addr_ptr = nullptr;
125+
tripwire = nullptr;
126+
}
127+
114128
private:
115129
void initialize_semispace();
116130
//

runtime/collect/collect.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
extern "C" {
1313
extern thread_local arena youngspace;
1414
extern thread_local arena oldspace;
15+
extern thread_local arena alwaysgcspace;
1516

1617
char *youngspace_ptr(void);
1718
char *oldspace_ptr(void);
@@ -345,5 +346,8 @@ void kore_collect(
345346
void free_all_kore_mem() {
346347
kore_collect(nullptr, 0, nullptr, true);
347348
kore_clear();
349+
youngspace.munmap_arena_and_reset();
350+
oldspace.munmap_arena_and_reset();
351+
alwaysgcspace.munmap_arena_and_reset();
348352
}
349353
}

0 commit comments

Comments
 (0)