llvm-project/llvm/lib/ExecutionEngine
Lang Hames f9aef477eb [ORC][ORC-RT] Rewrite the MachO platform to use allocation actions.
This patch updates the MachO platform (both the ORC MachOPlatform class and the
ORC-Runtime macho_platform.* files) to use allocation actions, rather than EPC
calls, to transfer the initializer information scraped from each linked object.
Interactions between the ORC and ORC-Runtime sides of the platform are
substantially redesigned to accomodate the change.

The high-level changes in this patch are:

1. The MachOPlatform::setupJITDylib method now calls into the runtime to set up
   a dylib name <-> header mapping, and a dylib state object (JITDylibState).

2. The MachOPlatformPlugin builds an allocation action that calls the
   __orc_rt_macho_register_object_platform_sections and
   __orc_rt_macho_deregister_object_platform_sections functions in the runtime
   to register the address ranges for all "interesting" sections in the object
   being allocated (TLS data sections, initializers, language runtime metadata
   sections, etc.).

3. The MachOPlatform::rt_getInitializers method (the entry point in the
   controller for requests from the runtime for initializer information) is
   replaced by MachOPlatform::rt_pushInitializers. The former returned a data
   structure containing the "interesting" section address ranges, but these are
   now handled by __orc_rt_macho_register_object_platform_sections. The new
   rt_pushInitializers method first issues a lookup to trigger materialization
   of the "interesting" sections, then returns the dylib dependence tree rooted
   at the requested dylib for dlopen to consume. (The dylib dependence tree is
   returned by rt_pushInitializers, rather than being handled by some dedicated
   call, because rt_pushInitializers can alter the dependence tree).

The advantage of these changes (beyond the performance advantages of using
allocation actions) is that it moves more information about the materialized
portions of the JITDylib into the executor. This tends to make the runtime
easier to reason about, e.g. the implementation of dlopen in the runtime is now
recursive, rather than relying on recursive calls in the controller to build a
linear data structure for consumption by the runtime. This change can also make
some operations more efficient, e.g. JITDylibs can be dlclosed and then
re-dlopened without having to pull all initializers over from the controller
again.

In addition to the high-level changes, there are some low-level changes to ORC
and the runtime:

* In ORC, at ExecutionSession teardown time JITDylibs are now destroyed in
reverse creation order. This is on the assumption that the ORC runtime will be
loaded into an earlier dylib that will be used by later JITDylibs. This is a
short-term solution to crashes that arose during testing when the runtime was
torn down before its users. Longer term we will likely destroy dylibs in
dependence order.

* toSPSSerializable(Expected<T> E) is updated to explicitly initialize the T
value, allowing it to be used by Ts that have explicit constructors.

* The ORC runtime now (1) attempts to track ref-counts, and (2) distinguishes
not-yet-processed "interesting" sections from previously processed ones. (1)
is necessary for standard dlopen/dlclose emulation. (2) is intended as a step
towards better REPL support -- it should enable future runtime calls that
run only newly registered initializers ("dlopen_more", "dlopen_additions",
...?).
2022-02-08 17:28:13 +11:00
..
IntelJITEvents New tag for ittapi - fix an error related to cross-compiling ITTAPI in LLVM with mingw 2021-05-14 08:18:49 +03:00
Interpreter [llvm] Use = default (NFC) 2022-02-06 22:18:35 -08:00
JITLink [JITLink] Fix the incorrect relocation behavior for R_RISCV_BRANCH 2022-02-07 14:34:19 +08:00
MCJIT [llvm] Use = default (NFC) 2022-02-06 22:18:35 -08:00
OProfileJIT llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
Orc [ORC][ORC-RT] Rewrite the MachO platform to use allocation actions. 2022-02-08 17:28:13 +11:00
PerfJITEvents [perf] Fix a data race in the PerfJITEventListener 2021-06-29 08:30:31 -07:00
RuntimeDyld [llvm] Use = default (NFC) 2022-02-06 22:18:35 -08:00
CMakeLists.txt [lli] Add JITLink in-process debug support 2021-03-02 15:07:36 +01:00
ExecutionEngine.cpp [llvm] Use range-based for loops (NFC) 2021-11-28 18:14:49 -08:00
ExecutionEngineBindings.cpp [NFC] Cleanup more AttributeList::addAttribute() 2021-08-17 21:05:41 -07:00
GDBRegistrationListener.cpp [llvm] Use = default (NFC) 2022-02-06 22:18:35 -08:00
SectionMemoryManager.cpp [llvm] Use = default (NFC) 2022-02-06 22:18:35 -08:00
TargetSelect.cpp Move TargetRegistry.(h|cpp) from Support to MC 2021-10-08 14:51:48 -07:00