Skip to content

Commit 599d329

Browse files
authored
Revert "Switch to LLVM ORC v2" #38008 (#38785)
* Revert "Let Orc handle JITEventListerners" This reverts commit ef84df1. * Revert "ExecutionSession no longer takes VModuleKey" This reverts commit b8c5da1. * Revert "LLVM: switch to Orc v2 API" This reverts commit 2d178e4.
1 parent 0c10641 commit 599d329

File tree

11 files changed

+258
-265
lines changed

11 files changed

+258
-265
lines changed

deps/llvm.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ LLVM_CMAKE += -DLLVM_BINDINGS_LIST="" -DLLVM_INCLUDE_DOCS=Off -DLLVM_ENABLE_TERM
129129
ifeq ($(LLVM_ASSERTIONS), 1)
130130
LLVM_CMAKE += -DLLVM_ENABLE_ASSERTIONS:BOOL=ON
131131
endif # LLVM_ASSERTIONS
132+
ifeq ($(LLVM_DEBUG), 1)
133+
ifeq ($(OS), WINNT)
134+
LLVM_CXXFLAGS += -Wa,-mbig-obj
135+
endif # OS == WINNT
136+
endif # LLVM_DEBUG
132137
ifeq ($(OS), WINNT)
133138
LLVM_CPPFLAGS += -D__USING_SJLJ_EXCEPTIONS__ -D__CRT__NO_INLINE
134139
endif # OS == WINNT

src/anticodegen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ void jl_write_malloc_log(void) UNAVAILABLE
1313
void jl_write_coverage_data(void) UNAVAILABLE
1414

1515
JL_DLLEXPORT void jl_clear_malloc_data(void) UNAVAILABLE
16-
JL_DLLEXPORT int jl_extern_c(jl_function_t *f, jl_value_t *rt, jl_value_t *argt, char *name) UNAVAILABLE
16+
JL_DLLEXPORT void jl_extern_c(jl_function_t *f, jl_value_t *rt, jl_value_t *argt, char *name) UNAVAILABLE
1717
JL_DLLEXPORT void *jl_function_ptr(jl_function_t *f, jl_value_t *rt, jl_value_t *argt) UNAVAILABLE
1818
JL_DLLEXPORT jl_value_t *jl_dump_method_asm(jl_method_instance_t *linfo, size_t world, int raw_mc, char getwrapper, const char* asm_variant, const char *debuginfo) UNAVAILABLE
1919
JL_DLLEXPORT const jl_value_t *jl_dump_function_ir(void *f, uint8_t strip_ir_metadata, uint8_t dump_module, const char *debuginfo) UNAVAILABLE

src/codegen.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5396,7 +5396,7 @@ static jl_cgval_t emit_cfunction(jl_codectx_t &ctx, jl_value_t *output_type, con
53965396

53975397
// do codegen to create a C-callable alias/wrapper, or if sysimg_handle is set,
53985398
// restore one from a loaded system image.
5399-
const char *jl_generate_ccallable(void *llvmmod, void *sysimg_handle, jl_value_t *declrt, jl_value_t *sigt, jl_codegen_params_t &params)
5399+
void jl_generate_ccallable(void *llvmmod, void *sysimg_handle, jl_value_t *declrt, jl_value_t *sigt, jl_codegen_params_t &params)
54005400
{
54015401
jl_datatype_t *ft = (jl_datatype_t*)jl_tparam0(sigt);
54025402
jl_value_t *ff = ft->instance;
@@ -5438,7 +5438,7 @@ const char *jl_generate_ccallable(void *llvmmod, void *sysimg_handle, jl_value_t
54385438
gen_cfun_wrapper((Module*)llvmmod, params, sig, ff, name, declrt, lam, NULL, NULL, NULL);
54395439
}
54405440
JL_GC_POP();
5441-
return name;
5441+
return;
54425442
}
54435443
err = jl_get_exceptionf(jl_errorexception_type, "%s", sig.err_msg.c_str());
54445444
}
@@ -7595,6 +7595,7 @@ static void init_jit_functions(void)
75957595
add_named_global(except_enter_func, (void*)NULL);
75967596

75977597
#ifdef _OS_WINDOWS_
7598+
#ifndef FORCE_ELF
75987599
#if defined(_CPU_X86_64_)
75997600
#if defined(_COMPILER_GCC_)
76007601
add_named_global("___chkstk_ms", &___chkstk_ms);
@@ -7609,6 +7610,7 @@ static void init_jit_functions(void)
76097610
#endif
76107611
#endif
76117612
#endif
7613+
#endif
76127614

76137615
#define BOX_F(ct) add_named_global("jl_box_"#ct, &jl_box_##ct);
76147616
BOX_F(int8); BOX_F(uint8);
@@ -7757,7 +7759,7 @@ extern "C" void jl_init_llvm(void)
77577759
#endif
77587760

77597761
init_julia_llvm_meta();
7760-
jl_ExecutionEngine = new JuliaOJIT(*jl_TargetMachine, &jl_LLVMContext);
7762+
jl_ExecutionEngine = new JuliaOJIT(*jl_TargetMachine);
77617763

77627764
// Mark our address spaces as non-integral
77637765
jl_data_layout = jl_ExecutionEngine->getDataLayout();

src/debuginfo.cpp

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,10 @@ class JuliaJITEventListener: public JITEventListener
313313
#endif
314314

315315
#if defined(_OS_WINDOWS_)
316-
uint64_t SectionAddrCheck = 0;
317-
uint64_t SectionLoadCheck = 0;
318-
uint64_t SectionWriteCheck = 0;
316+
uint64_t SectionAddrCheck = 0; // assert that all of the Sections are at the same location
319317
uint8_t *UnwindData = NULL;
320318
#if defined(_CPU_X86_64_)
319+
uint64_t SectionLoadOffset = 1; // The real offset shouldn't be 1.
321320
uint8_t *catchjmp = NULL;
322321
for (const object::SymbolRef &sym_iter : debugObj.symbols()) {
323322
StringRef sName = cantFail(sym_iter.getName());
@@ -339,38 +338,41 @@ class JuliaJITEventListener: public JITEventListener
339338
Section->getName(sName);
340339
#endif
341340
uint64_t SectionLoadAddr = getLoadAddress(sName);
342-
assert(SectionLoadAddr);
343-
if (SectionAddrCheck) // assert that all of the Sections are at the same location
344-
assert(SectionAddrCheck == SectionAddr &&
345-
SectionLoadCheck == SectionLoadAddr);
346-
SectionAddrCheck = SectionAddr;
347-
SectionLoadCheck = SectionLoadAddr;
348-
SectionWriteCheck = SectionLoadAddr;
349-
if (memmgr)
350-
SectionWriteCheck = (uintptr_t)lookupWriteAddressFor(memmgr,
351-
(void*)SectionLoadAddr);
352-
Addr += SectionWriteCheck - SectionLoadAddr;
341+
Addr -= SectionAddr - SectionLoadAddr;
353342
*pAddr = (uint8_t*)Addr;
343+
if (SectionAddrCheck)
344+
assert(SectionAddrCheck == SectionLoadAddr);
345+
else
346+
SectionAddrCheck = SectionLoadAddr;
347+
if (memmgr)
348+
SectionAddr =
349+
(uintptr_t)lookupWriteAddressFor(memmgr,
350+
(void*)SectionLoadAddr);
351+
if (SectionLoadOffset != 1)
352+
assert(SectionLoadOffset == SectionAddr - SectionLoadAddr);
353+
else
354+
SectionLoadOffset = SectionAddr - SectionLoadAddr;
354355
}
355356
}
356357
assert(catchjmp);
357358
assert(UnwindData);
358359
assert(SectionAddrCheck);
359-
assert(SectionLoadCheck);
360-
catchjmp[0] = 0x48;
361-
catchjmp[1] = 0xb8; // mov RAX, QWORD PTR [&__julia_personality]
362-
*(uint64_t*)(&catchjmp[2]) = (uint64_t)&__julia_personality;
363-
catchjmp[10] = 0xff;
364-
catchjmp[11] = 0xe0; // jmp RAX
365-
UnwindData[0] = 0x09; // version info, UNW_FLAG_EHANDLER
366-
UnwindData[1] = 4; // size of prolog (bytes)
367-
UnwindData[2] = 2; // count of unwind codes (slots)
368-
UnwindData[3] = 0x05; // frame register (rbp) = rsp
369-
UnwindData[4] = 4; // second instruction
370-
UnwindData[5] = 0x03; // mov RBP, RSP
371-
UnwindData[6] = 1; // first instruction
372-
UnwindData[7] = 0x50; // push RBP
373-
*(DWORD*)&UnwindData[8] = (DWORD)(catchjmp - (uint8_t*)SectionWriteCheck); // relative location of catchjmp
360+
assert(SectionLoadOffset != 1);
361+
catchjmp[SectionLoadOffset] = 0x48;
362+
catchjmp[SectionLoadOffset + 1] = 0xb8; // mov RAX, QWORD PTR [&__julia_personality]
363+
*(uint64_t*)(&catchjmp[SectionLoadOffset + 2]) =
364+
(uint64_t)&__julia_personality;
365+
catchjmp[SectionLoadOffset + 10] = 0xff;
366+
catchjmp[SectionLoadOffset + 11] = 0xe0; // jmp RAX
367+
UnwindData[SectionLoadOffset] = 0x09; // version info, UNW_FLAG_EHANDLER
368+
UnwindData[SectionLoadOffset + 1] = 4; // size of prolog (bytes)
369+
UnwindData[SectionLoadOffset + 2] = 2; // count of unwind codes (slots)
370+
UnwindData[SectionLoadOffset + 3] = 0x05; // frame register (rbp) = rsp
371+
UnwindData[SectionLoadOffset + 4] = 4; // second instruction
372+
UnwindData[SectionLoadOffset + 5] = 0x03; // mov RBP, RSP
373+
UnwindData[SectionLoadOffset + 6] = 1; // first instruction
374+
UnwindData[SectionLoadOffset + 7] = 0x50; // push RBP
375+
*(DWORD*)&UnwindData[SectionLoadOffset + 8] = (DWORD)(catchjmp - (uint8_t*)SectionAddrCheck); // relative location of catchjmp
374376
#endif // defined(_OS_X86_64_)
375377
#endif // defined(_OS_WINDOWS_)
376378

@@ -398,10 +400,9 @@ class JuliaJITEventListener: public JITEventListener
398400
size_t Size = sym_size.second;
399401
#if defined(_OS_WINDOWS_)
400402
if (SectionAddrCheck)
401-
assert(SectionAddrCheck == SectionAddr &&
402-
SectionLoadCheck == SectionLoadAddr);
403-
SectionAddrCheck = SectionAddr;
404-
SectionLoadCheck = SectionLoadAddr;
403+
assert(SectionAddrCheck == SectionLoadAddr);
404+
else
405+
SectionAddrCheck = SectionLoadAddr;
405406
create_PRUNTIME_FUNCTION(
406407
(uint8_t*)(uintptr_t)Addr, (size_t)Size, sName,
407408
(uint8_t*)(uintptr_t)SectionLoadAddr, (size_t)SectionSize, UnwindData);

src/dump.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2576,9 +2576,7 @@ static jl_value_t *_jl_restore_incremental(ios_t *f, jl_array_t *mod_array)
25762576
for (int i = 0; i < ccallable_list.len; i++) {
25772577
jl_svec_t *item = (jl_svec_t*)ccallable_list.items[i];
25782578
JL_GC_PROMISE_ROOTED(item);
2579-
int success = jl_compile_extern_c(NULL, NULL, NULL, jl_svecref(item, 0), jl_svecref(item, 1));
2580-
if (!success)
2581-
jl_safe_printf("@ccallable was already defined for this method name\n");
2579+
jl_compile_extern_c(NULL, NULL, NULL, jl_svecref(item, 0), jl_svecref(item, 1));
25822580
}
25832581
arraylist_free(&ccallable_list);
25842582
jl_value_t *ret = (jl_value_t*)jl_svec(2, restored, init_order);

0 commit comments

Comments
 (0)