diff --git a/src/gc-common.c b/src/gc-common.c index 0f6307c1db98f..5ff30bbba5ac5 100644 --- a/src/gc-common.c +++ b/src/gc-common.c @@ -576,7 +576,7 @@ void gc_premark(jl_ptls_t ptls2) // GC control // --- -_Atomic(uint32_t) jl_gc_disable_counter = 1; +JL_DLLEXPORT _Atomic(uint32_t) jl_gc_disable_counter = 1; JL_DLLEXPORT int jl_gc_enable(int on) { @@ -588,11 +588,9 @@ JL_DLLEXPORT int jl_gc_enable(int on) if (jl_atomic_fetch_add(&jl_gc_disable_counter, -1) == 1) { gc_num.allocd += gc_num.deferred_alloc; gc_num.deferred_alloc = 0; - enable_collection(); } } else if (prev && !on) { - disable_collection(); // enable -> disable jl_atomic_fetch_add(&jl_gc_disable_counter, 1); // check if the GC is running and wait for it to finish diff --git a/src/gc.c b/src/gc.c index 924cdce356a4b..c4023e922b676 100644 --- a/src/gc.c +++ b/src/gc.c @@ -3438,12 +3438,6 @@ void jl_gc_threadfun(void *arg) } // added for MMTk integration -void enable_collection(void) -{ -} -void disable_collection(void) -{ -} JL_DLLEXPORT void jl_gc_wb1_noinline(const void *parent) JL_NOTSAFEPOINT { diff --git a/src/gc.h b/src/gc.h index 0630a039f2b94..03b52fb24acbb 100644 --- a/src/gc.h +++ b/src/gc.h @@ -83,7 +83,7 @@ extern const size_t max_collect_interval; extern size_t last_long_collect_interval; extern size_t total_mem; extern memsize_t max_total_memory; -extern _Atomic(uint32_t) jl_gc_disable_counter; +extern JL_DLLEXPORT _Atomic(uint32_t) jl_gc_disable_counter; extern jl_mutex_t heapsnapshot_lock; extern uint64_t finalizer_rngState[]; extern int gc_n_threads; diff --git a/src/julia_internal.h b/src/julia_internal.h index 737553ec98845..f5c9e07ce7329 100644 --- a/src/julia_internal.h +++ b/src/julia_internal.h @@ -333,8 +333,6 @@ extern jl_array_t *jl_all_methods JL_GLOBALLY_ROOTED; JL_DLLEXPORT extern int jl_lineno; JL_DLLEXPORT extern const char *jl_filename; -extern void enable_collection(void); -extern void disable_collection(void); jl_value_t *jl_gc_pool_alloc_noinline(jl_ptls_t ptls, int pool_offset, int osize); jl_value_t *jl_gc_big_alloc_noinline(jl_ptls_t ptls, size_t allocsz); @@ -938,7 +936,7 @@ STATIC_INLINE int jl_addr_is_safepoint(uintptr_t addr) return addr >= safepoint_addr && addr < safepoint_addr + jl_page_size * 3; } extern _Atomic(uint32_t) jl_gc_running; -extern _Atomic(uint32_t) jl_gc_disable_counter; +extern JL_DLLEXPORT _Atomic(uint32_t) jl_gc_disable_counter; // All the functions are safe to be called from within a signal handler // provided that the thread will not be interrupted by another asynchronous // signal. diff --git a/src/mmtk-gc.c b/src/mmtk-gc.c index 1175c6a161750..db985b5149f8a 100644 --- a/src/mmtk-gc.c +++ b/src/mmtk-gc.c @@ -219,7 +219,7 @@ JL_DLLEXPORT void jl_gc_collect(jl_gc_collection_t collection) { jl_task_t *ct = jl_current_task; jl_ptls_t ptls = ct->ptls; - if (jl_atomic_load_relaxed(&jl_gc_disable_counter)) { + if (jl_atomic_load_acquire(&jl_gc_disable_counter)) { size_t localbytes = jl_atomic_load_relaxed(&ptls->gc_num.allocd) + gc_num.interval; jl_atomic_store_relaxed(&ptls->gc_num.allocd, -(int64_t)gc_num.interval); static_assert(sizeof(_Atomic(uint64_t)) == sizeof(gc_num.deferred_alloc), ""); @@ -503,14 +503,6 @@ void jl_gc_threadfun(void *arg) } // added for MMTk integration -void enable_collection(void) -{ - mmtk_enable_collection(); -} -void disable_collection(void) -{ - mmtk_disable_collection(); -} JL_DLLEXPORT void jl_gc_array_ptr_copy(jl_array_t *dest, void **dest_p, jl_array_t *src, void **src_p, ssize_t n) JL_NOTSAFEPOINT { diff --git a/src/threading.c b/src/threading.c index d1157a02dada0..b050b3eccd87a 100644 --- a/src/threading.c +++ b/src/threading.c @@ -351,9 +351,6 @@ jl_ptls_t jl_init_threadtls(int16_t tid) ptls->rngseed = jl_rand(); if (tid == 0) { ptls->disable_gc = 1; -#ifdef MMTK_GC - disable_collection(); -#endif } #ifdef _OS_WINDOWS_ if (tid == 0) {