Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make global/static variables thread_local; use mmap() for managing memory #1159

Closed
wants to merge 190 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
190 commits
Select commit Hold shift + click to select a range
65cd137
Set Version: 0.1.6
May 7, 2024
453cf1b
Merge remote-tracking branch 'origin/develop'
May 8, 2024
b6a1b07
Set Version: 0.1.7
May 8, 2024
2116723
Merge remote-tracking branch 'origin/develop'
May 8, 2024
db1784e
Set Version: 0.1.8
May 8, 2024
04ed7bc
Merge remote-tracking branch 'origin/develop'
May 9, 2024
245bf95
Set Version: 0.1.9
May 9, 2024
b54fa4c
Merge remote-tracking branch 'origin/develop'
May 9, 2024
ece4d09
Set Version: 0.1.10
May 9, 2024
ec1ac35
Merge remote-tracking branch 'origin/develop'
May 9, 2024
016e130
Set Version: 0.1.11
May 9, 2024
5928e31
Merge remote-tracking branch 'origin/develop'
May 9, 2024
da09d4e
Set Version: 0.1.12
May 9, 2024
b589be2
Merge remote-tracking branch 'origin/develop'
May 13, 2024
6ddebf8
Set Version: 0.1.13
May 13, 2024
e0dcd6d
Merge remote-tracking branch 'origin/develop'
May 13, 2024
872a278
Set Version: 0.1.14
May 13, 2024
880145e
Merge remote-tracking branch 'origin/develop'
May 14, 2024
553f3d4
Set Version: 0.1.15
May 14, 2024
4807b04
Merge remote-tracking branch 'origin/develop'
May 15, 2024
0e2b646
Set Version: 0.1.16
May 15, 2024
2d4ab32
Merge remote-tracking branch 'origin/develop'
May 16, 2024
f2460e3
Set Version: 0.1.17
May 16, 2024
e5e7562
Merge remote-tracking branch 'origin/develop'
May 17, 2024
bd5baac
Set Version: 0.1.18
May 17, 2024
f60dd9a
Merge remote-tracking branch 'origin/develop'
May 17, 2024
0a117e0
Set Version: 0.1.19
May 17, 2024
804424e
Merge remote-tracking branch 'origin/develop'
May 17, 2024
f52eaba
Set Version: 0.1.20
May 17, 2024
1ecb265
Merge remote-tracking branch 'origin/develop'
May 17, 2024
cd3c756
Set Version: 0.1.21
May 17, 2024
3e26a6d
Merge remote-tracking branch 'origin/develop'
May 20, 2024
58d1328
Set Version: 0.1.22
May 20, 2024
1049279
Merge remote-tracking branch 'origin/develop'
May 21, 2024
b7069c4
Set Version: 0.1.23
May 21, 2024
757aca4
Merge remote-tracking branch 'origin/develop'
May 22, 2024
be6fcbf
Set Version: 0.1.24
May 22, 2024
cac6a20
Merge remote-tracking branch 'origin/develop'
May 22, 2024
4859270
Set Version: 0.1.25
May 22, 2024
a71f397
Merge remote-tracking branch 'origin/develop'
May 22, 2024
0f10a29
Set Version: 0.1.26
May 22, 2024
c588ca6
Merge remote-tracking branch 'origin/develop'
May 23, 2024
cb6a770
Set Version: 0.1.27
May 23, 2024
2c7202b
Merge remote-tracking branch 'origin/develop'
May 23, 2024
765f930
Set Version: 0.1.28
May 23, 2024
d94a182
Merge remote-tracking branch 'origin/develop'
May 23, 2024
cd15a54
Set Version: 0.1.29
May 23, 2024
3ce690b
Merge remote-tracking branch 'origin/develop'
May 24, 2024
7a0e64a
Set Version: 0.1.30
May 24, 2024
ce7673e
Merge remote-tracking branch 'origin/develop'
May 24, 2024
0b0bdae
Set Version: 0.1.31
May 24, 2024
e35c119
Merge remote-tracking branch 'origin/develop'
May 31, 2024
33bb26a
Set Version: 0.1.32
May 31, 2024
ca0916f
Merge remote-tracking branch 'origin/develop'
May 31, 2024
2983a01
Set Version: 0.1.33
May 31, 2024
ed32fbc
Merge remote-tracking branch 'origin/develop'
Jun 3, 2024
ff7f89b
Set Version: 0.1.34
Jun 3, 2024
a6a39c7
Merge remote-tracking branch 'origin/develop'
Jun 3, 2024
936e2d7
Set Version: 0.1.35
Jun 3, 2024
7b8900d
Merge remote-tracking branch 'origin/develop'
Jun 3, 2024
10bc556
Set Version: 0.1.36
Jun 3, 2024
370972c
Merge remote-tracking branch 'origin/develop'
Jun 4, 2024
679b13f
Set Version: 0.1.37
Jun 4, 2024
ca735ef
Merge remote-tracking branch 'origin/develop'
Jun 4, 2024
00f2d59
Set Version: 0.1.38
Jun 4, 2024
e711679
Merge remote-tracking branch 'origin/develop'
Jun 4, 2024
9b84828
Set Version: 0.1.39
Jun 4, 2024
29d9dbd
Merge remote-tracking branch 'origin/develop'
Jun 4, 2024
e0c848f
Set Version: 0.1.40
Jun 4, 2024
be50c0b
Merge remote-tracking branch 'origin/develop'
Jun 4, 2024
490ccfc
Set Version: 0.1.41
Jun 4, 2024
2588b0f
Merge remote-tracking branch 'origin/develop'
Jun 4, 2024
caca83f
Set Version: 0.1.42
Jun 4, 2024
00e1cfa
Merge remote-tracking branch 'origin/develop'
Jun 5, 2024
6051aaa
Set Version: 0.1.43
Jun 5, 2024
722605a
Merge remote-tracking branch 'origin/develop'
Jun 5, 2024
744a615
Set Version: 0.1.44
Jun 5, 2024
6aa3ed2
Merge remote-tracking branch 'origin/develop'
Jun 6, 2024
efd2647
Set Version: 0.1.45
Jun 6, 2024
76c5757
Merge remote-tracking branch 'origin/develop'
Jun 6, 2024
8f15667
Set Version: 0.1.46
Jun 6, 2024
2b617d6
Merge remote-tracking branch 'origin/develop'
Jun 7, 2024
0ac6525
Set Version: 0.1.47
Jun 7, 2024
5147d42
Merge remote-tracking branch 'origin/develop'
Jun 7, 2024
b22795d
Set Version: 0.1.48
Jun 7, 2024
0ecc3f5
Merge remote-tracking branch 'origin/develop'
Jun 10, 2024
2a33228
Set Version: 0.1.49
Jun 10, 2024
e25cf7d
Merge remote-tracking branch 'origin/develop'
Jun 18, 2024
a7e3213
Set Version: 0.1.50
Jun 18, 2024
be8565e
Merge remote-tracking branch 'origin/develop'
Jun 20, 2024
6671fe4
Set Version: 0.1.51
Jun 20, 2024
8592ae8
Merge remote-tracking branch 'origin/develop'
Jun 27, 2024
9dfc379
Set Version: 0.1.52
Jun 27, 2024
c655100
Merge remote-tracking branch 'origin/develop'
Jul 5, 2024
3bfb6db
Set Version: 0.1.53
Jul 5, 2024
edbb34d
Merge remote-tracking branch 'origin/develop'
Jul 9, 2024
4a2b609
Set Version: 0.1.54
Jul 9, 2024
e244c97
Merge remote-tracking branch 'origin/develop'
Jul 9, 2024
faf2ce6
Set Version: 0.1.55
Jul 9, 2024
310dbf1
Merge remote-tracking branch 'origin/develop'
Jul 10, 2024
bd12ae4
Set Version: 0.1.56
Jul 10, 2024
df88006
Merge remote-tracking branch 'origin/develop'
Jul 12, 2024
66f9273
Set Version: 0.1.57
Jul 12, 2024
4b95ff7
Merge remote-tracking branch 'origin/develop'
Jul 19, 2024
038a6fe
Set Version: 0.1.58
Jul 19, 2024
c140fff
Merge remote-tracking branch 'origin/develop'
Jul 19, 2024
ed79b7e
Set Version: 0.1.59
Jul 19, 2024
3602278
Merge remote-tracking branch 'origin/develop'
Jul 20, 2024
548a54c
Set Version: 0.1.60
Jul 20, 2024
0e5c5ce
Merge remote-tracking branch 'origin/develop'
Jul 23, 2024
a77c3ec
Set Version: 0.1.61
Jul 23, 2024
f55a357
Merge remote-tracking branch 'origin/develop'
Jul 23, 2024
9b505ea
Set Version: 0.1.62
Jul 23, 2024
6498c52
Merge remote-tracking branch 'origin/develop'
Jul 24, 2024
f5c71ff
Set Version: 0.1.63
Jul 24, 2024
50f97aa
Merge remote-tracking branch 'origin/develop'
Jul 26, 2024
79011ff
Set Version: 0.1.64
Jul 26, 2024
66d1cfc
Merge remote-tracking branch 'origin/develop'
Jul 26, 2024
4c15186
Set Version: 0.1.65
Jul 26, 2024
65b1dfc
Merge remote-tracking branch 'origin/develop'
Jul 29, 2024
e0aeeb5
Set Version: 0.1.66
Jul 29, 2024
af135b6
Merge remote-tracking branch 'origin/develop'
Jul 29, 2024
5f84f0c
Set Version: 0.1.67
Jul 29, 2024
6932a41
Merge remote-tracking branch 'origin/develop'
Jul 29, 2024
7ad5d2c
Set Version: 0.1.68
Jul 29, 2024
00ab7bb
Merge remote-tracking branch 'origin/develop'
Jul 31, 2024
5be14fe
Set Version: 0.1.69
Jul 31, 2024
1cf325d
Merge remote-tracking branch 'origin/develop'
Aug 1, 2024
3968914
Set Version: 0.1.70
Aug 1, 2024
deb7967
Merge remote-tracking branch 'origin/develop'
Aug 1, 2024
9fb93cf
Set Version: 0.1.71
Aug 1, 2024
74fad20
Merge remote-tracking branch 'origin/develop'
Aug 5, 2024
9ed61d6
Set Version: 0.1.72
Aug 5, 2024
3f0686d
Merge remote-tracking branch 'origin/develop'
Aug 6, 2024
6f622c8
Set Version: 0.1.73
Aug 6, 2024
930211c
Merge remote-tracking branch 'origin/develop'
Aug 6, 2024
647f0ed
Set Version: 0.1.74
Aug 6, 2024
37bcb32
Merge remote-tracking branch 'origin/develop'
Aug 6, 2024
9cb2137
Set Version: 0.1.75
Aug 6, 2024
353ef9d
Merge remote-tracking branch 'origin/develop'
Aug 8, 2024
1bfee4d
Set Version: 0.1.76
Aug 8, 2024
f5f7b3e
Merge remote-tracking branch 'origin/develop'
Aug 8, 2024
e7266f7
Set Version: 0.1.77
Aug 8, 2024
c578d04
Merge remote-tracking branch 'origin/develop'
Aug 9, 2024
9f340e1
Set Version: 0.1.78
Aug 9, 2024
f172c61
Merge remote-tracking branch 'origin/develop'
Aug 9, 2024
3f9ce24
Set Version: 0.1.79
Aug 9, 2024
17d47ce
Merge remote-tracking branch 'origin/develop'
Aug 20, 2024
5b77750
Set Version: 0.1.80
Aug 20, 2024
aa26093
Merge remote-tracking branch 'origin/develop'
Aug 20, 2024
b9dc4ff
Set Version: 0.1.81
Aug 20, 2024
dfad14f
Merge remote-tracking branch 'origin/develop'
Aug 20, 2024
5f712a6
Set Version: 0.1.82
Aug 20, 2024
e0be53f
Merge remote-tracking branch 'origin/develop'
Aug 21, 2024
430353d
Set Version: 0.1.83
Aug 21, 2024
bea1be6
Merge remote-tracking branch 'origin/develop'
Aug 22, 2024
b9d2a6d
Set Version: 0.1.84
Aug 22, 2024
02e50b5
Merge remote-tracking branch 'origin/develop'
Sep 3, 2024
04b0ba0
Set Version: 0.1.85
Sep 3, 2024
eaf43b8
Merge remote-tracking branch 'origin/develop'
Sep 9, 2024
fae460b
Set Version: 0.1.86
Sep 9, 2024
b3588d7
Merge remote-tracking branch 'origin/develop'
Sep 11, 2024
bc4a184
Set Version: 0.1.87
Sep 11, 2024
3657b71
Merge remote-tracking branch 'origin/develop'
Sep 11, 2024
344d133
Set Version: 0.1.88
Sep 11, 2024
f5a5091
Merge remote-tracking branch 'origin/develop'
Sep 13, 2024
a1459e3
Set Version: 0.1.89
Sep 13, 2024
f85b115
Merge remote-tracking branch 'origin/develop'
Sep 13, 2024
cdf4c3b
Set Version: 0.1.90
Sep 13, 2024
a1b4a2a
Merge remote-tracking branch 'origin/develop'
Sep 17, 2024
bb6c1a6
Set Version: 0.1.91
Sep 17, 2024
4cdd700
Merge remote-tracking branch 'origin/develop'
Sep 18, 2024
bf51ee4
Set Version: 0.1.92
Sep 18, 2024
c00b6a7
Merge remote-tracking branch 'origin/develop'
Sep 19, 2024
8b860f9
Set Version: 0.1.93
Sep 19, 2024
444e9ee
Merge remote-tracking branch 'origin/develop'
Sep 19, 2024
c023bc5
Set Version: 0.1.94
Sep 19, 2024
c262351
Merge remote-tracking branch 'origin/develop'
Sep 23, 2024
b830daa
Set Version: 0.1.95
Sep 23, 2024
e829263
Merge remote-tracking branch 'origin/develop'
Sep 30, 2024
0947635
Set Version: 0.1.96
Sep 30, 2024
bc339d6
Merge remote-tracking branch 'origin/develop'
Oct 1, 2024
9b362e5
Set Version: 0.1.97
Oct 1, 2024
2b9c79f
Merge remote-tracking branch 'origin/develop'
Oct 1, 2024
812ea2a
Set Version: 0.1.98
Oct 1, 2024
a5a7279
Use demand paging
Oct 10, 2024
ce32457
use thread_local for global and static variables
Oct 11, 2024
cc3d168
use setThreadLocal() for generated thread_local variables
Oct 18, 2024
6aa4e60
Merge branch 'develop' into thread_safe
Oct 18, 2024
4142caa
deal with BLOCK_SIZE not be size_t
Oct 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/runtime/arena.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ using memory_block_header = struct {
// Macro to define a new arena with the given ID. Supports IDs ranging from 0 to
// 127.
#define REGISTER_ARENA(name, id) \
static struct arena name = {.allocation_semispace_id = (id)}
static thread_local struct arena name = {.allocation_semispace_id = (id)}

#define MEM_BLOCK_START(ptr) \
((char *)(((uintptr_t)(ptr)-1) & ~(BLOCK_SIZE - 1)))

extern bool time_for_collection;
extern thread_local bool time_for_collection;

size_t get_gc_threshold();

Expand Down
4 changes: 2 additions & 2 deletions include/runtime/collect.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ using set_node = set::iterator::node_t;
using set_impl = set::iterator::tree_t;

extern "C" {
extern size_t numBytesLiveAtCollection[1 << AGE_WIDTH];
extern bool collect_old;
extern thread_local size_t numBytesLiveAtCollection[1 << AGE_WIDTH];
extern thread_local bool collect_old;
size_t get_size(uint64_t, uint16_t);
void migrate_static_roots(void);
void migrate(block **block_ptr);
Expand Down
2 changes: 1 addition & 1 deletion include/runtime/header.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void k_hash(block *, void *);
bool hash_enter(void);
void hash_exit(void);

extern bool gc_enabled;
extern thread_local bool gc_enabled;
}

class k_elem {
Expand Down
2 changes: 2 additions & 0 deletions lib/codegen/CreateTerm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,7 @@ llvm::Value *create_term::disable_gc() {
llvm::Constant *global
= module_->getOrInsertGlobal("gc_enabled", llvm::Type::getInt1Ty(ctx_));
auto *global_var = llvm::cast<llvm::GlobalVariable>(global);
global_var->setThreadLocal(true);
auto *old_val = new llvm::LoadInst(
llvm::Type::getInt1Ty(ctx_), global_var, "was_enabled", current_block_);
new llvm::StoreInst(
Expand All @@ -793,6 +794,7 @@ void create_term::enable_gc(llvm::Value *was_enabled) {
llvm::Constant *global
= module_->getOrInsertGlobal("gc_enabled", llvm::Type::getInt1Ty(ctx_));
auto *global_var = llvm::cast<llvm::GlobalVariable>(global);
global_var->setThreadLocal(true);
new llvm::StoreInst(was_enabled, global_var, current_block_);
}

Expand Down
1 change: 1 addition & 0 deletions lib/codegen/Decision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,7 @@ std::pair<std::vector<llvm::Value *>, llvm::BasicBlock *> step_function_header(

auto *collection = module->getOrInsertGlobal(
"time_for_collection", llvm::Type::getInt1Ty(module->getContext()));
llvm::cast<llvm::GlobalVariable>(collection)->setThreadLocal(true);
auto *is_collection = new llvm::LoadInst(
llvm::Type::getInt1Ty(module->getContext()), collection, "is_collection",
check_collect);
Expand Down
2 changes: 1 addition & 1 deletion package/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
k-llvm-backend (0.1.5) unstable; urgency=medium
k-llvm-backend (0.1.98) unstable; urgency=medium

* Initial release

Expand Down
2 changes: 1 addition & 1 deletion package/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.5
0.1.98
96 changes: 57 additions & 39 deletions runtime/alloc/arena.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <memory>
#include <sys/mman.h>

#include "runtime/alloc.h"
#include "runtime/arena.h"
Expand Down Expand Up @@ -47,36 +49,65 @@ get_arena_semispace_id_of_object(void *ptr) {
return mem_block_header(ptr)->semispace;
}

static void *first_superblock_ptr = nullptr;
static void *superblock_ptr = nullptr;
static char **next_superblock_ptr = nullptr;
static unsigned blocks_left = 0;
//
// We will reserve enough address space for 1 million 1MB blocks. Might want to increase this on a > 1TB server.
//
size_t const HYPERBLOCK_SIZE = (size_t) BLOCK_SIZE * 1024 * 1024;
static thread_local void* hyperblock_ptr = nullptr; // only needed for munmap()

static void *megabyte_malloc() {
if (blocks_left == 0) {
blocks_left = 15;
if (int result
= posix_memalign(&superblock_ptr, BLOCK_SIZE, BLOCK_SIZE * 15)) {
errno = result;
perror("posix_memalign");
static void*
megabyte_malloc()
{
//
// Return pointer to a BLOCK_SIZE chunk of memory with BLOCK_SIZE alignment.
//
static thread_local char* currentblock_ptr = nullptr; // char* rather than void* to permit pointer arithmetic
if (currentblock_ptr)
{
//
// We expect an page fault due to not being able to map physical memory to this block or the
// process to be killed by the OOM killer long before we run off the end of our address space.
//
currentblock_ptr += BLOCK_SIZE;
}
if (!first_superblock_ptr) {
first_superblock_ptr = superblock_ptr;
else
{
//
// First call - need to reserve the address space.
//
size_t request = HYPERBLOCK_SIZE;
void* addr = mmap(NULL, // let OS choose the address
request, // Linux and MacOS both allow up to 64TB
PROT_READ | PROT_WRITE, // read, write but not execute
MAP_ANONYMOUS | MAP_PRIVATE | MAP_NORESERVE, // allocate address space only
-1, // no file backing
0); // no offset
if (addr == MAP_FAILED)
{
perror("mmap()");
abort();
}
hyperblock_ptr = addr;
//
// We ask for one block worth of address space less than we allocated so alignment will always succeed.
// We don't worry about unused address space either side of our aligned address space because there will be no
// memory mapped to it.
//
currentblock_ptr = reinterpret_cast<char*>(std::align(BLOCK_SIZE, HYPERBLOCK_SIZE - BLOCK_SIZE, addr, request));
}
if (next_superblock_ptr) {
*next_superblock_ptr = (char *)superblock_ptr;
}
auto *hdr = (memory_block_header *)superblock_ptr;
next_superblock_ptr = &hdr->next_superblock;
hdr->next_superblock = nullptr;
}
blocks_left--;
void *result = superblock_ptr;
superblock_ptr = (char *)superblock_ptr + BLOCK_SIZE;
return result;
return currentblock_ptr;
}

void
free_all_memory()
{
//
// Frees all memory that was demand paged into this address range.
//
munmap(hyperblock_ptr, HYPERBLOCK_SIZE);
}

bool time_for_collection;
thread_local bool time_for_collection;

static void fresh_block(struct arena *arena) {
char *next_block = nullptr;
Expand Down Expand Up @@ -122,7 +153,7 @@ static void fresh_block(struct arena *arena) {
BLOCK_SIZE - sizeof(memory_block_header));
}

bool gc_enabled = true;
thread_local bool gc_enabled = true;

__attribute__((noinline)) void *
do_alloc_slow(size_t requested, struct arena *arena) {
Expand Down Expand Up @@ -229,16 +260,3 @@ size_t arena_size(const struct arena *arena) {
: arena->num_collection_blocks)
* (BLOCK_SIZE - sizeof(memory_block_header));
}

void free_all_memory() {
auto *superblock = (memory_block_header *)first_superblock_ptr;
while (superblock) {
auto *next_superblock = (memory_block_header *)superblock->next_superblock;
free(superblock);
superblock = next_superblock;
}
first_superblock_ptr = nullptr;
superblock_ptr = nullptr;
next_superblock_ptr = nullptr;
blocks_left = 0;
}
2 changes: 1 addition & 1 deletion runtime/alloc/register_gc_roots_enum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "runtime/collect.h"
#include "runtime/header.h"

std::vector<BlockEnumerator> block_enumerators;
thread_local std::vector<BlockEnumerator> block_enumerators;

void register_gc_roots_enumerator(BlockEnumerator f) {
block_enumerators.push_back(f);
Expand Down
4 changes: 2 additions & 2 deletions runtime/arithmetic/int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,8 @@ void int_hash(mpz_t i, void *hasher) {
}
}

gmp_randstate_t kllvm_rand_state;
bool kllvm_rand_state_initialized = false;
thread_local gmp_randstate_t kllvm_rand_state;
thread_local bool kllvm_rand_state_initialized = false;

SortK hook_INT_srand(SortInt seed) {
if (!kllvm_rand_state_initialized) {
Expand Down
10 changes: 5 additions & 5 deletions runtime/collect/collect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ char **old_alloc_ptr(void);
char *youngspace_ptr(void);
char *oldspace_ptr(void);

static bool is_gc = false;
bool collect_old = false;
static thread_local bool is_gc = false;
bool thread_local collect_old = false;
#ifndef GC_DBG
static uint8_t num_collection_only_young = 0;
static thread_local uint8_t num_collection_only_young = 0;
#else
static char *last_alloc_ptr;
static thread_local char *last_alloc_ptr;
#endif

size_t numBytesLiveAtCollection[1 << AGE_WIDTH];
size_t thread_local numBytesLiveAtCollection[1 << AGE_WIDTH];

bool during_gc() {
return is_gc;
Expand Down
6 changes: 3 additions & 3 deletions runtime/collect/migrate_static_roots.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

#include "runtime/collect.h"

extern std::vector<BlockEnumerator> block_enumerators;
extern thread_local std::vector<BlockEnumerator> block_enumerators;

extern gmp_randstate_t kllvm_rand_state;
extern bool kllvm_rand_state_initialized;
extern thread_local gmp_randstate_t kllvm_rand_state;
extern thread_local bool kllvm_rand_state_initialized;

extern "C" {

Expand Down
4 changes: 2 additions & 2 deletions runtime/lto/alloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ static inline void *kore_alloc_collection(kllvm::sort_category cat) {
void *mem
= kore_alloc(sizeof(blockheader) + sizeof(collection) + sizeof(uint64_t));
auto *hdr = (blockheader *)mem;
static std::string name = get_raw_symbol_name(cat) + "{}";
static blockheader hdr_val
static thread_local std::string name = get_raw_symbol_name(cat) + "{}";
static thread_local blockheader hdr_val
= get_block_header_for_symbol(get_tag_for_symbol_name(name.c_str()));
*hdr = hdr_val;
auto *offset = (uint64_t *)(hdr + 1);
Expand Down
2 changes: 1 addition & 1 deletion unittests/runtime-collections/lists.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ block D1 = {{1}};
block *DUMMY1 = &D1;
}

bool gc_enabled;
thread_local bool gc_enabled;
size_t get_gc_threshold() {
return SIZE_MAX;
}
Expand Down
Loading