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

Do not assume the GC is always running on the master thread. #14278

Merged
merged 2 commits into from
Dec 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 11 additions & 14 deletions src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ static size_t array_nbytes(jl_array_t *a)
return sz;
}

void jl_gc_free_array(jl_array_t *a)
static void jl_gc_free_array(jl_array_t *a)
{
if (a->how == 2) {
char *d = (char*)a->data - a->offset*a->elsize;
Expand Down Expand Up @@ -1630,19 +1630,21 @@ static void gc_mark_stack(jl_value_t* ta, jl_gcframe_t *s, ptrint_t offset, int
static void gc_mark_task_stack(jl_task_t *ta, int d)
{
int stkbuf = (ta->stkbuf != (void*)(intptr_t)-1 && ta->stkbuf != NULL);
int16_t tid = ta->tid;
jl_tls_states_t *ptls = jl_all_task_states[tid].ptls;
if (stkbuf) {
#ifndef COPY_STACKS
if (ta != jl_root_task) // stkbuf isn't owned by julia for the root task
if (ta != ptls->root_task) // stkbuf isn't owned by julia for the root task
#endif
gc_setmark_buf(ta->stkbuf, gc_bits(jl_astaggedvalue(ta)));
}
if (ta == jl_all_task_states[ta->tid].ptls->current_task) {
gc_mark_stack((jl_value_t*)ta, *jl_all_pgcstacks[ta->tid], 0, d);
if (ta == ptls->current_task) {
gc_mark_stack((jl_value_t*)ta, ptls->pgcstack, 0, d);
}
else if (stkbuf) {
ptrint_t offset;
#ifdef COPY_STACKS
offset = (char *)ta->stkbuf - ((char *)jl_stackbase - ta->ssize);
offset = (char *)ta->stkbuf - ((char *)ptls->stackbase - ta->ssize);
#else
offset = 0;
#endif
Expand Down Expand Up @@ -1907,8 +1909,6 @@ static void pre_mark(void)

// invisible builtin values
if (jl_an_empty_cell) gc_push_root(jl_an_empty_cell, 0);
gc_push_root(jl_exception_in_transit, 0);
gc_push_root(jl_task_arg_in_transit, 0);
if (jl_module_init_order != NULL)
gc_push_root(jl_module_init_order, 0);

Expand Down Expand Up @@ -2037,7 +2037,7 @@ static void print_obj_profile(htable_t nums, htable_t sizes)
}
}

void print_obj_profiles(void)
static void print_obj_profiles(void)
{
jl_printf(JL_STDERR, "Transient mark :\n");
print_obj_profile(obj_counts[0], obj_sizes[0]);
Expand All @@ -2054,10 +2054,6 @@ static int saved_mark_sp = 0;
static int sweep_mask = GC_MARKED;
#define MIN_SCAN_BYTES 1024*1024

void prepare_sweep(void)
{
}

JL_DLLEXPORT void jl_gc_collect(int full)
{
if (!is_gc_enabled) return;
Expand Down Expand Up @@ -2466,8 +2462,9 @@ void jl_print_gc_stats(JL_STREAM *s)
jl_thread_heap_t *jl_mk_thread_heap(void)
{
#ifdef JULIA_ENABLE_THREADING
// FIXME - should be cache-aligned malloc
jl_thread_heap = (jl_thread_heap_t*)malloc(sizeof(jl_thread_heap_t));
// Cache-aligned malloc
jl_thread_heap =
(jl_thread_heap_t*)jl_malloc_aligned(sizeof(jl_thread_heap_t), 64);
#endif
FOR_CURRENT_HEAP () {
const int* szc = sizeclasses;
Expand Down
4 changes: 0 additions & 4 deletions src/threading.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ JL_DLLEXPORT JL_CONST_FUNC jl_tls_states_t *(jl_get_ptls_states)(void)
JL_DLLEXPORT int jl_n_threads; // # threads we're actually using
JL_DLLEXPORT int jl_max_threads; // # threads possible
jl_thread_task_state_t *jl_all_task_states;
jl_gcframe_t ***jl_all_pgcstacks;

// return calling thread's ID
JL_DLLEXPORT int16_t jl_threadid(void) { return ti_tid; }
Expand All @@ -139,7 +138,6 @@ static void ti_initthread(int16_t tid)
{
ti_tid = tid;
jl_pgcstack = NULL;
jl_all_pgcstacks[tid] = &jl_pgcstack;
#ifdef JULIA_ENABLE_THREADING
jl_all_heaps[tid] = jl_mk_thread_heap();
#else
Expand Down Expand Up @@ -291,7 +289,6 @@ void jl_init_threading(void)

// set up space for per-thread heaps
jl_all_heaps = (struct _jl_thread_heap_t **)malloc(jl_n_threads * sizeof(void*));
jl_all_pgcstacks = (jl_gcframe_t ***)malloc(jl_n_threads * sizeof(void*));
jl_all_task_states = (jl_thread_task_state_t *)malloc(jl_n_threads * sizeof(jl_thread_task_state_t));

#if PROFILE_JL_THREADING
Expand Down Expand Up @@ -538,7 +535,6 @@ void jl_init_threading(void)
jl_all_task_states = &_jl_all_task_states;
jl_max_threads = 1;
jl_n_threads = 1;
jl_all_pgcstacks = (jl_gcframe_t***) malloc(jl_n_threads * sizeof(jl_gcframe_t**));

#if defined(__linux__) && defined(JL_USE_INTEL_JITEVENTS)
if (jl_using_intel_jitevents)
Expand Down
1 change: 0 additions & 1 deletion src/threading.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ extern JL_DLLEXPORT int jl_n_threads; // # threads we're actually using
// GC
extern struct _jl_thread_heap_t **jl_all_heaps;
#endif
extern jl_gcframe_t ***jl_all_pgcstacks;

// thread state
enum {
Expand Down