Skip to content
Open
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
8 changes: 4 additions & 4 deletions src/aotcompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ void *jl_create_native_impl(jl_array_t *methods, LLVMOrcThreadSafeModuleRef llvm

// compile all methods for the current world and type-inference world

JL_SPIN_LOCK(&jl_codegen_lock);
JL_SLEEP_LOCK(&jl_codegen_lock);
auto target_info = clone.withModuleDo([&](Module &M) {
return std::make_pair(M.getDataLayout(), Triple(M.getTargetTriple()));
});
Expand Down Expand Up @@ -351,7 +351,7 @@ void *jl_create_native_impl(jl_array_t *methods, LLVMOrcThreadSafeModuleRef llvm
// finally, make sure all referenced methods also get compiled or fixed up
jl_compile_workqueue(params, policy);
}
JL_SPIN_UNLOCK(&jl_codegen_lock); // Might GC
JL_SLEEP_UNLOCK(&jl_codegen_lock); // Might GC
JL_GC_POP();

// process the globals array, before jl_merge_module destroys them
Expand Down Expand Up @@ -2130,7 +2130,7 @@ void jl_get_llvmf_defn_impl(jl_llvmf_dump_t* dump, jl_method_instance_t *mi, siz
uint8_t measure_compile_time_enabled = jl_atomic_load_relaxed(&jl_measure_compile_time_enabled);
if (measure_compile_time_enabled)
compiler_start_time = jl_hrtime();
JL_SPIN_LOCK(&jl_codegen_lock);
JL_SLEEP_LOCK(&jl_codegen_lock);
auto target_info = m.withModuleDo([&](Module &M) {
return std::make_pair(M.getDataLayout(), Triple(M.getTargetTriple()));
});
Expand All @@ -2148,7 +2148,7 @@ void jl_get_llvmf_defn_impl(jl_llvmf_dump_t* dump, jl_method_instance_t *mi, siz
// max debug info = llvm.dbg.declare/value intrinsics which clutter IR output
output.debug_level = std::max(2, static_cast<int>(jl_options.debug_level));
auto decls = jl_emit_code(m, mi, src, jlrettype, output);
JL_SPIN_UNLOCK(&jl_codegen_lock); // Might GC
JL_SLEEP_UNLOCK(&jl_codegen_lock); // Might GC

Function *F = NULL;
if (m) {
Expand Down
4 changes: 2 additions & 2 deletions src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -3966,12 +3966,12 @@ JL_DLLEXPORT void jl_typeinf_timing_end(uint64_t start)

JL_DLLEXPORT void jl_typeinf_lock_begin(void)
{
JL_SPIN_LOCK(&jl_codegen_lock);
JL_SLEEP_LOCK(&jl_codegen_lock);
}

JL_DLLEXPORT void jl_typeinf_lock_end(void)
{
JL_SPIN_UNLOCK(&jl_codegen_lock);
JL_SLEEP_UNLOCK(&jl_codegen_lock);
}

#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ static void init_global_mutexes(void) {
JL_SPIN_MUTEX_INIT(&precomp_statement_out_lock, "precomp_statement_out_lock");
JL_SPIN_MUTEX_INIT(&newly_inferred_mutex, "newly_inferred_mutex");
JL_SPIN_MUTEX_INIT(&global_roots_lock, "global_roots_lock");
JL_SPIN_MUTEX_INIT(&jl_codegen_lock, "jl_codegen_lock");
JL_SLEEP_MUTEX_INIT(&jl_codegen_lock, "jl_codegen_lock");
JL_SPIN_MUTEX_INIT(&typecache_lock, "typecache_lock");
}

Expand Down
20 changes: 10 additions & 10 deletions src/jitlayers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ int jl_compile_extern_c_impl(LLVMOrcThreadSafeModuleRef llvmmod, void *p, void *
backing = jl_create_ts_module("cextern", pparams ? pparams->tsctx : ctx, pparams ? pparams->imaging_mode : imaging_default(), pparams ? pparams->DL : jl_ExecutionEngine->getDataLayout(), pparams ? pparams->TargetTriple : jl_ExecutionEngine->getTargetTriple());
into = &backing;
}
JL_SPIN_LOCK(&jl_codegen_lock);
JL_SLEEP_LOCK(&jl_codegen_lock);
auto target_info = into->withModuleDo([&](Module &M) {
return std::make_pair(M.getDataLayout(), Triple(M.getTargetTriple()));
});
Expand Down Expand Up @@ -411,7 +411,7 @@ int jl_compile_extern_c_impl(LLVMOrcThreadSafeModuleRef llvmmod, void *p, void *
jl_ExecutionEngine->addModule(std::move(*into));
}
}
JL_SPIN_UNLOCK(&jl_codegen_lock);
JL_SLEEP_UNLOCK(&jl_codegen_lock);
if (timed) {
if (measure_compile_time_enabled) {
auto end = jl_hrtime();
Expand Down Expand Up @@ -485,7 +485,7 @@ jl_code_instance_t *jl_generate_fptr_impl(jl_method_instance_t *mi JL_PROPAGATES
jl_code_info_t *src = NULL;
jl_code_instance_t *codeinst = NULL;
JL_GC_PUSH2(&src, &codeinst);
JL_SPIN_LOCK(&jl_codegen_lock); // also disables finalizers, to prevent any unexpected recursion
JL_SLEEP_LOCK(&jl_codegen_lock); // also disables finalizers, to prevent any unexpected recursion
jl_value_t *ci = jl_rettype_inferred_addr(mi, world, world);
if (ci != jl_nothing)
codeinst = (jl_code_instance_t*)ci;
Expand Down Expand Up @@ -529,7 +529,7 @@ jl_code_instance_t *jl_generate_fptr_impl(jl_method_instance_t *mi JL_PROPAGATES
else {
codeinst = NULL;
}
JL_SPIN_UNLOCK(&jl_codegen_lock);
JL_SLEEP_UNLOCK(&jl_codegen_lock);
if (timed) {
if (measure_compile_time_enabled) {
uint64_t t_comp = jl_hrtime() - compiler_start_time;
Expand All @@ -550,11 +550,11 @@ void jl_generate_fptr_for_oc_wrapper_impl(jl_code_instance_t *oc_wrap)
if (jl_atomic_load_relaxed(&oc_wrap->invoke) != NULL) {
return;
}
JL_SPIN_LOCK(&jl_codegen_lock); // also disables finalizers, to prevent any unexpected recursion
JL_SLEEP_LOCK(&jl_codegen_lock); // also disables finalizers, to prevent any unexpected recursion
if (jl_atomic_load_relaxed(&oc_wrap->invoke) == NULL) {
_jl_compile_codeinst(oc_wrap, NULL, 1, *jl_ExecutionEngine->getContext(), 0);
}
JL_SPIN_UNLOCK(&jl_codegen_lock); // Might GC
JL_SLEEP_UNLOCK(&jl_codegen_lock); // Might GC
}

extern "C" JL_DLLEXPORT_CODEGEN
Expand All @@ -571,7 +571,7 @@ void jl_generate_fptr_for_unspecialized_impl(jl_code_instance_t *unspec)
uint8_t measure_compile_time_enabled = jl_atomic_load_relaxed(&jl_measure_compile_time_enabled);
if (measure_compile_time_enabled)
compiler_start_time = jl_hrtime();
JL_SPIN_LOCK(&jl_codegen_lock);
JL_SLEEP_LOCK(&jl_codegen_lock);
if (jl_atomic_load_relaxed(&unspec->invoke) == NULL) {
jl_code_info_t *src = NULL;
JL_GC_PUSH1(&src);
Expand All @@ -595,7 +595,7 @@ void jl_generate_fptr_for_unspecialized_impl(jl_code_instance_t *unspec)
jl_atomic_cmpswap(&unspec->invoke, &null, jl_fptr_interpret_call_addr);
JL_GC_POP();
}
JL_SPIN_UNLOCK(&jl_codegen_lock); // Might GC
JL_SLEEP_UNLOCK(&jl_codegen_lock); // Might GC
if (timed) {
if (measure_compile_time_enabled) {
auto end = jl_hrtime();
Expand Down Expand Up @@ -630,7 +630,7 @@ jl_value_t *jl_dump_method_asm_impl(jl_method_instance_t *mi, size_t world,
uint8_t measure_compile_time_enabled = jl_atomic_load_relaxed(&jl_measure_compile_time_enabled);
if (measure_compile_time_enabled)
compiler_start_time = jl_hrtime();
JL_SPIN_LOCK(&jl_codegen_lock); // also disables finalizers, to prevent any unexpected recursion
JL_SLEEP_LOCK(&jl_codegen_lock); // also disables finalizers, to prevent any unexpected recursion
specfptr = (uintptr_t)jl_atomic_load_relaxed(&codeinst->specptr.fptr);
if (specfptr == 0) {
jl_code_info_t *src = jl_type_infer(mi, world, 0);
Expand All @@ -654,7 +654,7 @@ jl_value_t *jl_dump_method_asm_impl(jl_method_instance_t *mi, size_t world,
}
JL_GC_POP();
}
JL_SPIN_UNLOCK(&jl_codegen_lock);
JL_SLEEP_UNLOCK(&jl_codegen_lock);
if (timed) {
if (measure_compile_time_enabled) {
auto end = jl_hrtime();
Expand Down
2 changes: 1 addition & 1 deletion src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1378,7 +1378,7 @@ JL_DLLEXPORT void jl_set_next_task(jl_task_t *task) JL_NOTSAFEPOINT;
// -- synchronization utilities -- //

extern jl_spin_mutex_t typecache_lock;
extern JL_DLLEXPORT jl_spin_mutex_t jl_codegen_lock;
extern JL_DLLEXPORT jl_sleep_mutex_t jl_codegen_lock;

#if defined(__APPLE__)
void jl_mach_gc_end(void);
Expand Down
2 changes: 1 addition & 1 deletion src/threading.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ static void jl_delete_thread(void *value) JL_NOTSAFEPOINT_ENTER
//// the other threads time to fail and emit their failure message
//__attribute__((destructor)) static void _waitthreaddeath(void) { sleep(1); }

JL_DLLEXPORT jl_spin_mutex_t jl_codegen_lock;
JL_DLLEXPORT jl_sleep_mutex_t jl_codegen_lock;
jl_spin_mutex_t typecache_lock;

JL_DLLEXPORT ssize_t jl_tls_offset = -1;
Expand Down