Skip to content

Commit bc9e77e

Browse files
committed
Putting everything that is common GC tls into gc-tls-common.h
1 parent ae8f3d4 commit bc9e77e

File tree

7 files changed

+147
-116
lines changed

7 files changed

+147
-116
lines changed

src/gc-common.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -587,16 +587,16 @@ size_t jl_genericmemory_nbytes(jl_genericmemory_t *m) JL_NOTSAFEPOINT
587587
void jl_gc_track_malloced_genericmemory(jl_ptls_t ptls, jl_genericmemory_t *m, int isaligned){
588588
// This is **NOT** a GC safe point.
589589
mallocmemory_t *ma;
590-
if (ptls->gc_tls.heap.mafreelist == NULL) {
590+
if (ptls->gc_tls_common.heap.mafreelist == NULL) {
591591
ma = (mallocmemory_t*)malloc_s(sizeof(mallocmemory_t));
592592
}
593593
else {
594-
ma = ptls->gc_tls.heap.mafreelist;
595-
ptls->gc_tls.heap.mafreelist = ma->next;
594+
ma = ptls->gc_tls_common.heap.mafreelist;
595+
ptls->gc_tls_common.heap.mafreelist = ma->next;
596596
}
597597
ma->a = (jl_genericmemory_t*)((uintptr_t)m | !!isaligned);
598-
ma->next = ptls->gc_tls.heap.mallocarrays;
599-
ptls->gc_tls.heap.mallocarrays = ma;
598+
ma->next = ptls->gc_tls_common.heap.mallocarrays;
599+
ptls->gc_tls_common.heap.mallocarrays = ma;
600600
}
601601

602602
// =========================================================================== //

src/gc-stacks.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ void _jl_free_stack(jl_ptls_t ptls, void *stkbuf, size_t bufsz) JL_NOTSAFEPOINT
131131
if (bufsz <= pool_sizes[JL_N_STACK_POOLS - 1]) {
132132
unsigned pool_id = select_pool(bufsz);
133133
if (pool_sizes[pool_id] == bufsz) {
134-
small_arraylist_push(&ptls->gc_tls.heap.free_stacks[pool_id], stkbuf);
134+
small_arraylist_push(&ptls->gc_tls_common.heap.free_stacks[pool_id], stkbuf);
135135
return;
136136
}
137137
}
@@ -160,7 +160,7 @@ void jl_release_task_stack(jl_ptls_t ptls, jl_task_t *task)
160160
#ifdef _COMPILER_ASAN_ENABLED_
161161
__asan_unpoison_stack_memory((uintptr_t)stkbuf, bufsz);
162162
#endif
163-
small_arraylist_push(&ptls->gc_tls.heap.free_stacks[pool_id], stkbuf);
163+
small_arraylist_push(&ptls->gc_tls_common.heap.free_stacks[pool_id], stkbuf);
164164
}
165165
}
166166
}
@@ -175,7 +175,7 @@ JL_DLLEXPORT void *jl_malloc_stack(size_t *bufsz, jl_task_t *owner) JL_NOTSAFEPO
175175
if (ssize <= pool_sizes[JL_N_STACK_POOLS - 1]) {
176176
unsigned pool_id = select_pool(ssize);
177177
ssize = pool_sizes[pool_id];
178-
small_arraylist_t *pool = &ptls->gc_tls.heap.free_stacks[pool_id];
178+
small_arraylist_t *pool = &ptls->gc_tls_common.heap.free_stacks[pool_id];
179179
if (pool->len > 0) {
180180
stk = small_arraylist_pop(pool);
181181
}
@@ -196,7 +196,7 @@ JL_DLLEXPORT void *jl_malloc_stack(size_t *bufsz, jl_task_t *owner) JL_NOTSAFEPO
196196
}
197197
*bufsz = ssize;
198198
if (owner) {
199-
small_arraylist_t *live_tasks = &ptls->gc_tls.heap.live_tasks;
199+
small_arraylist_t *live_tasks = &ptls->gc_tls_common.heap.live_tasks;
200200
mtarraylist_push(live_tasks, owner);
201201
}
202202
return stk;
@@ -223,7 +223,7 @@ void sweep_stack_pools(void) JL_NOTSAFEPOINT
223223

224224
// free half of stacks that remain unused since last sweep
225225
for (int p = 0; p < JL_N_STACK_POOLS; p++) {
226-
small_arraylist_t *al = &ptls2->gc_tls.heap.free_stacks[p];
226+
small_arraylist_t *al = &ptls2->gc_tls_common.heap.free_stacks[p];
227227
size_t n_to_free;
228228
if (jl_atomic_load_relaxed(&ptls2->current_task) == NULL) {
229229
n_to_free = al->len; // not alive yet or dead, so it does not need these anymore
@@ -245,10 +245,10 @@ void sweep_stack_pools(void) JL_NOTSAFEPOINT
245245
}
246246
}
247247
if (jl_atomic_load_relaxed(&ptls2->current_task) == NULL) {
248-
small_arraylist_free(ptls2->gc_tls.heap.free_stacks);
248+
small_arraylist_free(ptls2->gc_tls_common.heap.free_stacks);
249249
}
250250

251-
small_arraylist_t *live_tasks = &ptls2->gc_tls.heap.live_tasks;
251+
small_arraylist_t *live_tasks = &ptls2->gc_tls_common.heap.live_tasks;
252252
size_t n = 0;
253253
size_t ndel = 0;
254254
size_t l = live_tasks->len;
@@ -299,7 +299,7 @@ JL_DLLEXPORT jl_array_t *jl_live_tasks(void)
299299
jl_ptls_t ptls2 = allstates[i];
300300
if (ptls2 == NULL)
301301
continue;
302-
small_arraylist_t *live_tasks = &ptls2->gc_tls.heap.live_tasks;
302+
small_arraylist_t *live_tasks = &ptls2->gc_tls_common.heap.live_tasks;
303303
size_t n = mtarraylist_length(live_tasks);
304304
l += n + (ptls2->root_task->ctx.stkbuf != NULL);
305305
}
@@ -318,7 +318,7 @@ JL_DLLEXPORT jl_array_t *jl_live_tasks(void)
318318
goto restart;
319319
jl_array_data(a,void*)[j++] = t;
320320
}
321-
small_arraylist_t *live_tasks = &ptls2->gc_tls.heap.live_tasks;
321+
small_arraylist_t *live_tasks = &ptls2->gc_tls_common.heap.live_tasks;
322322
size_t n = mtarraylist_length(live_tasks);
323323
for (size_t i = 0; i < n; i++) {
324324
jl_task_t *t = (jl_task_t*)mtarraylist_get(live_tasks, i);

0 commit comments

Comments
 (0)