16 Commits

Author SHA1 Message Date
Jared Wyles
42a77ce3d6
[orc-rt] Add missing includes for Linux/ARM builds (#188702)
Fixes compilation errors due to missing includes.
2026-03-26 20:43:19 +11:00
Lang Hames
6bfb44f320
[orc-rt] Add ShutdownRequested flag to Service::onDetach. (#187230)
The ShutdownRequested flag indicates to Services whether a shutdown
operation is already pending. Services may use this information to
optimize their book-keeping: either preparing for a (potentially
lengthy) detached state, or for an upcoming shutdown.

Session does not call onDetached yet: That (including setting the
ShutdownRequested argument) will happen in a follow-up patch.
2026-03-18 21:39:21 +11:00
Lang Hames
63dd9966d3
[orc-rt] Capture a Session& in SimpleNativeMemoryMap, fix TODOs. (#187200)
SimpleNativeMemoryMap now captures a reference to the Session that it
was constructed for. This is used to fix some outstanding TODOs: using
the real page size for the process, and reporting errors that were
previously discarded.
2026-03-18 17:44:57 +11:00
Lang Hames
14b42335c6
[orc-rt] Publish controller interface from SimpleNativeMemoryMap ctor. (#187198)
Add named constructors to SimpleNativeMemoryMap to publish
SimpleNativeMemoryMap's controller interface when an instance is
constructed.

This supports correct setup by construction, since API clients can't
forget to publish the interface that the controller will need to
interact with the SimpleNativeMemoryMap object.
2026-03-18 17:29:46 +11:00
Lang Hames
612d80348f
[orc-rt] Move SPS controller interface funcs into their own headers. (#186991)
This provides clean separation between the ORC runtime code that
implements runtime functionality and the wrapper functions that permit
this code to be called from the controller via the
ExecutorProcessControl API.

Separating the controller interface from the implementation functions
should allow clients to introduce alternative serialization schemes if
they want (e.g. JSON).

In particular, this commit adds a new orc-rt/include/orc-rt/sps-ci
directory and moves SimpleNativeMemoryMap SPS controller interface into
a new header in that directory. This commit also splits the
implementation and testing of the SPS controller interface for
SimpleNativeMemoryMap into separate files.
2026-03-17 21:39:09 +11:00
Lang Hames
53a1e056f3
[orc-rt] Don't return Error in Service::OnComplete. (#186708)
The Session can't do anything useful with these errors, it can only
report them. It's cleaner if the Service objects just report the error
directly.
2026-03-16 09:01:18 +11:00
Lang Hames
96e7fc2c9a
[orc-rt] Rename "ResourceManager" to "Service". NFCI. (#186639)
The name "Service" better reflects the general purpose of this class: It
provides *something* (often resource management) to the Session, is
owned by the Session, and receives notifications from the Session when
the controller detaches / is detached, and when the Session is shut
down.

An example of a non-resource-managing Service (to be added in an
upcoming patch) is a detach / shutdown notification service: Clients can
add this service to register arbitrary callbacks to be run on detach /
shutdown. The advantage of this over the current Session detach /
shutdown callback system is that clients can control both the order of
the callbacks, and their order relative to notification of other
services.
2026-03-15 14:37:48 +11:00
Lang Hames
d82d261a9a
[orc-rt] Rename ResourceManager detach/shutdown. NFCI. (#183285)
These methods are called by the session in the event of a detach or
shutdown. The new names reflect their roles as event handlers.
2026-02-25 22:57:48 +11:00
Lang Hames
04d69fc8e1 [orc-rt] Fix typo in comment. 2026-01-21 12:05:06 +11:00
Lang Hames
ea9ec7cfb5
[orc-rt] Rename 'Session' variables to avoid ambiguity with type. NFCI. (#168999)
Re-using Session as a variable name risks confusion with the Session
type.
2025-11-21 18:01:23 +11:00
Lang Hames
4c4b1a905e
[orc-rt] Replace wrapper fn void *CallCtx arg with uint64_t CallId. (#167452)
This argument serves as an opaque id (outside the ControllerAccess
object) for a call to a wrapper function. I expect that most
ControllerAccess implementations will want to use this argument as a
sequence number (plain integer), for which uint64_t will be a better fit
than void*. For ControllerAccess implementations that want to use a
pointer, uint64_t should be sufficiently large.
2025-11-11 18:11:41 +11:00
Lang Hames
2ba960c404 [orc-rt] Rename InitializeRequest variables after 7381558ef8b. NFCI.
7381558ef8b renamed the FinalizeRequest type to InitializeRequest. This commit
updates InitializeRequest variable names to follow suit ("FR"s become "IR"s).
2025-10-13 20:21:05 +11:00
Lang Hames
7381558ef8
[orc-rt] Rename SimpleNativeMemoryMap finalize & deallocate. NFCI. (#163114)
This commit renames the "finalize" operation to "initialize", and
"deallocate" to "deinitialize".

The new names are chosen to better fit the point of view of the
ORC-runtime and executor-process: After memory is *reserved* it can be
*initialized* with some content, and *deinitialized* to return that
memory to the reserved region.

This seems more understandable to me than the original scheme, which
named these operations after the controller-side JITLinkMemoryManager
operations that they partially implemented. I.e.
SimpleNativeMemoryMap::finalize implemented the final step of
JITLinkMemoryManager::finalize, initializing the memory in the executor;
and SimpleNativeMemoryMap::deallocate implemented the final step of
JITLinkMemoryManager::deallocate, running dealloc actions and releasing
the finalized region.

The proper way to think of the relationship between these operations now
is that:

1. The final step of finalization is to initialize the memory in the
executor.

2. The final step of deallocation is to deinitialize the memory in the
executor.
2025-10-13 12:33:16 +11:00
Lang Hames
d4a4137976
[orc-rt] Add multi-addr dealloc/release to SimpleNativeMemoryMap. (#163025)
In an ORC JIT it's common for multiple memory regions to be deallocated
at once, e.g. when a ResourceTracker covering multiple object files is
removed. This commit adds SimpleNativeMemoryMap::deallocateMultiple and
SimpleNativeMemoryMap::releaseMultiple APIs that can be used to reduce
the number of calls (and consequently IPC messages in cross-process
setups) in these cases.

Adding these operations will make it easier to write an
llvm::orc::MemoryMapper class that can use SimpleNativeMemoryMap as a
backend.
2025-10-12 12:03:11 +11:00
Lang Hames
27e2d5c46f
[orc-rt] Align SimpleNativeMemoryMap Segment with LLVM type. (#162823)
This commit aims to align SimpleNativeMemoryMap::FinalizeRequest::Segment with
llvm::orc::tpctypes::SegFinalizeRequest. This will simplify construction of a
new LLVM JITLinkMemoryManager that's capable of using SimpleNativeMemoryMap as
a backend.
2025-10-11 10:33:28 +11:00
Lang Hames
891f002026
[orc-rt] Add SimpleNativeMemoryMap. (#162584)
SimpleNativeMemoryMap is a memory allocation backend for use with ORC.
It can...

1. Reserve slabs of address space.
2. Finalize regions of memory within a reserved slab: copying content
into requested addresses, applying memory protections, running
finalization actions, and storing deallocation actions to be run by
deallocate.
3. Deallocate finalized memory regions: running deallocate actions and,
if possible, making memory in these regions available for use by future
finalization operations. (Some systems prohibit reuse of executable
memory. On these systems deallocated memory is no longer usable within
the process).
4. Release reserved slabs. This runs deallocate for any
not-yet-deallocated finalized regions, and then (if possible) returns
the address space to system. (On systems that prohibit reuse of
executable memory parts of the released address space may be permanently
unusable by the process).

SimpleNativeMemoryMap is intended primarily for use by
llvm::orc::JITLinkMemoryManager implementations to allocate JIT'd code
and data.
2025-10-09 13:10:34 +11:00