Skip to content

Commit

Permalink
Initialize name generator to provide unique names while building a ch…
Browse files Browse the repository at this point in the history
…ained system image
  • Loading branch information
petvana committed Aug 7, 2022
1 parent e1f12fd commit 431b6ba
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/codegen-stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ JL_DLLEXPORT void *jl_LLVMCreateDisasm_fallback(const char *TripleName, void *Di
JL_DLLEXPORT size_t jl_LLVMDisasmInstruction_fallback(void *DC, uint8_t *Bytes, uint64_t BytesSize, uint64_t PC, char *OutString, size_t OutStringSize) UNAVAILABLE

JL_DLLEXPORT void jl_init_codegen_fallback(void) { }
JL_DLLEXPORT void jl_init_codegen_name_generator_fallback(int init_value) { }

JL_DLLEXPORT int jl_getFunctionInfo_fallback(jl_frame_t **frames, uintptr_t pointer, int skipC, int noInline)
{
Expand Down
5 changes: 5 additions & 0 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8661,6 +8661,11 @@ extern "C" JL_DLLEXPORT void jl_init_codegen_impl(void)
init_jit_functions();
}

extern "C" JL_DLLEXPORT void jl_init_codegen_name_generator_impl(int init_value)
{
globalUniqueGeneratedNames.store(init_value);
}

extern "C" JL_DLLEXPORT void jl_teardown_codegen_impl()
{
// output LLVM timings and statistics
Expand Down
7 changes: 7 additions & 0 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,13 @@ static NOINLINE void _finish_julia_init(JL_IMAGE_SEARCH rel, jl_ptls_t ptls, jl_

if (jl_options.handle_signals == JL_OPTIONS_HANDLE_SIGNALS_ON)
jl_install_sigint_handler();

if (jl_options.image_file) {
// TODO: set the number of existing symbols more precisely
// This is probably important to do at the end because some symbols
// depend on the specific order of its initialization.
jl_init_codegen_name_generator(80000);
}
}

static jl_value_t *core(const char *name)
Expand Down
1 change: 1 addition & 0 deletions src/jl_exported_funcs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@
YY(jl_LLVMCreateDisasm) \
YY(jl_LLVMDisasmInstruction) \
YY(jl_init_codegen) \
YY(jl_init_codegen_name_generator) \
YY(jl_getFunctionInfo) \
YY(jl_register_fptrs) \
YY(jl_generate_fptr) \
Expand Down
1 change: 1 addition & 0 deletions src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,7 @@ void jl_init_common_symbols(void);
void jl_init_primitives(void) JL_GC_DISABLED;
void jl_init_llvm(void);
void jl_init_codegen(void);
void jl_init_codegen_name_generator(int);
void jl_init_runtime_ccall(void);
void jl_init_intrinsic_functions(void);
void jl_init_intrinsic_properties(void);
Expand Down

0 comments on commit 431b6ba

Please sign in to comment.