diff --git a/src/codegen.cpp b/src/codegen.cpp index c0269e69a31ecf..f663bf8d9d15a2 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -186,11 +186,10 @@ typedef Instruction TerminatorInst; #include "processor.h" #include "julia_assert.h" -jl_locked_stream dump_emitted_mi_name_stream; extern "C" JL_DLLEXPORT void jl_dump_emitted_mi_name_impl(void *s) { - **dump_emitted_mi_name_stream = (JL_STREAM*)s; + **jl_ExecutionEngine->get_dump_emitted_mi_name_stream() = (JL_STREAM*)s; } extern "C" { @@ -7978,7 +7977,7 @@ jl_llvm_functions_t jl_emit_code( "functions compiled with custom codegen params must not be cached"); JL_TRY { decls = emit_function(m, li, src, jlrettype, params); - auto stream = *dump_emitted_mi_name_stream; + auto stream = *jl_ExecutionEngine->get_dump_emitted_mi_name_stream(); if (stream) { jl_printf(stream, "%s\t", decls.specFunctionObject.c_str()); // NOTE: We print the Type Tuple without surrounding quotes, because the quotes diff --git a/src/jitlayers.cpp b/src/jitlayers.cpp index f694d0a22cf9df..bd9e2a3ae1bc7e 100644 --- a/src/jitlayers.cpp +++ b/src/jitlayers.cpp @@ -54,17 +54,15 @@ using namespace llvm; #define DEBUG_TYPE "jitlayers" // Snooping on which functions are being compiled, and how long it takes -jl_locked_stream dump_compiles_stream; extern "C" JL_DLLEXPORT void jl_dump_compiles_impl(void *s) { - **dump_compiles_stream = (JL_STREAM*)s; + **jl_ExecutionEngine->get_dump_compiles_stream() = (JL_STREAM*)s; } -jl_locked_stream dump_llvm_opt_stream; extern "C" JL_DLLEXPORT void jl_dump_llvm_opt_impl(void *s) { - **dump_llvm_opt_stream = (JL_STREAM*)s; + **jl_ExecutionEngine->get_dump_llvm_opt_stream() = (JL_STREAM*)s; } static void jl_add_to_ee(orc::ThreadSafeModule &M, StringMap &NewExports); @@ -108,7 +106,7 @@ static jl_callptr_t _jl_compile_codeinst( // caller must hold codegen_lock // and have disabled finalizers uint64_t start_time = 0; - bool timed = !!*dump_compiles_stream; + bool timed = !!*jl_ExecutionEngine->get_dump_compiles_stream(); if (timed) start_time = jl_hrtime(); @@ -206,7 +204,7 @@ static jl_callptr_t _jl_compile_codeinst( // then dump the method-instance specialization type to the stream jl_method_instance_t *mi = codeinst->def; if (jl_is_method(mi->def.method)) { - auto stream = *dump_compiles_stream; + auto stream = *jl_ExecutionEngine->get_dump_compiles_stream(); if (stream) { jl_printf(stream, "%" PRIu64 "\t\"", end_time - start_time); jl_static_show(stream, mi->specTypes); @@ -894,7 +892,7 @@ namespace { TSM.withModuleDo([&](Module &M) { uint64_t start_time = 0; { - auto stream = *dump_llvm_opt_stream; + auto stream = *jl_ExecutionEngine->get_dump_llvm_opt_stream(); if (stream) { // Print LLVM function statistics _before_ optimization // Print all the information about this invocation as a YAML object @@ -923,7 +921,7 @@ namespace { uint64_t end_time = 0; { - auto stream = *dump_llvm_opt_stream; + auto stream = *jl_ExecutionEngine->get_dump_llvm_opt_stream(); if (stream) { end_time = jl_hrtime(); jl_printf(stream, " time_ns: %" PRIu64 "\n", end_time - start_time); diff --git a/src/jitlayers.h b/src/jitlayers.h index 260cafab285ac9..dde8ebf13ca9b8 100644 --- a/src/jitlayers.h +++ b/src/jitlayers.h @@ -379,6 +379,16 @@ class JuliaOJIT { JITDebugInfoRegistry &getDebugInfoRegistry() JL_NOTSAFEPOINT { return DebugRegistry; } + + jl_locked_stream &get_dump_emitted_mi_name_stream() JL_NOTSAFEPOINT { + return dump_emitted_mi_name_stream; + } + jl_locked_stream &get_dump_compiles_stream() JL_NOTSAFEPOINT { + return dump_compiles_stream; + } + jl_locked_stream &get_dump_llvm_opt_stream() JL_NOTSAFEPOINT { + return dump_llvm_opt_stream; + } private: std::string getMangledName(StringRef Name); std::string getMangledName(const GlobalValue *GV); @@ -398,6 +408,11 @@ class JuliaOJIT { int RLST_inc = 0; DenseMap ReverseLocalSymbolTable; + //Compilation streams + jl_locked_stream dump_emitted_mi_name_stream; + jl_locked_stream dump_compiles_stream; + jl_locked_stream dump_llvm_opt_stream; + ResourcePool ContextPool; #ifndef JL_USE_JITLINK