15 Commits

Author SHA1 Message Date
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
28b3f2f04b
[orc-rt] Add SPSExecutorAddr <-> T* serialization. (#162992)
This replaces SPS transparent conversion for pointers. Transparent
conversion only applies to argument/return types, not nested types. We
want to be able to serialize / deserialize structs containing pointers.

We may need to replace this in the near future with a new SPSPointer tag
type, since SPSExecutorAddr is meant to be serialization for pure
addresses, and pointers may carry other information (e.g. tag bits), but
we can do that in a follow-up commit.
2025-10-11 22:24:03 +11:00
Lang Hames
ef4598fbc6
[orc-rt] Enable span<const char> use in SPSWrapperFunctions. (#162792)
SPS deserialization for span<const char> produces a value that points
directly into the argument buffer for efficiency. This was broken by an
unnecessary std::move of the buffer inside WrapperFunction, which this
commit removes.
2025-10-10 19:38:10 +11:00
Lang Hames
d0d2162341
[orc-rt] Enable SPS transparent conversion for reference arguments. (#162563)
Ensures that SPS transparent conversion will apply to arguments passed
by reference.
2025-10-09 10:19:05 +11:00
Lang Hames
eac3788b4e [orc-rt] Rename unit tests for consistency. NFCI.
Related tests use "TransparentConversion" rather than
"TransparentSerialization".
2025-10-08 22:36:11 +11:00
Lang Hames
70b7a3502e
[orc-rt] Hoist DirectCaller test utility into header to enable re-use. (#162405)
The DirectCaller utility allows "direct" calls (with arguments
serialized into, and then immediately back out of a
WrapperFunctionBuffer) to wrapper functions. It was introduced for the
SPSWrapperFunction tests, but will be useful for testing WrapperFunction
interfaces for various orc-rt APIs too, so this commit hoists it
somewhere where it can be reused.
2025-10-08 11:48:27 +11:00
Lang Hames
c410e88f0f
[orc-rt] Enable transparent SPS conversion for Expected<T*>. (#162073)
Expected<T*> values will be converted to/from Expected<ExecutorAddr>
values.
2025-10-07 12:47:59 +11:00
Lang Hames
f8baf07c7c [orc-rt] Clean up SPSWrapperFunction unittest names.
Drop the redundant 'Test' prefix and rename transparent serialization tests to
clarify their purpose.
2025-10-06 22:31:26 +11:00
Lang Hames
9a111ff91c
[orc-rt] Enable transparent SPS conversion for ptrs via ExecutorAddr. (#162069)
Allows SPS wrapper function calls and handles to use pointer arguments.
These will be converted to ExecutorAddr for serialization /
deserialization.
2025-10-06 22:30:57 +11:00
Lang Hames
36cfdebe92
[orc-rt] Add method-wrapper utils for use with WrapperFunction::handle. (#162035)
WrapperFunction::handleWithAsyncMethod can be used to wrap asynchronous
methods (void methods whose first arguments are Return callbacks) for
use with WrapperFunction::handle.

WrapperFunction::handleWithSyncMethod can be used to wrap regular
(non-asynchronous) methods for use with WrapperFunction::handle.

Both variants return function objects that take a Return callback as
their first argument, and an ExecutorAddr representing the address of
the instance to call the object on. For asynchronous methods the
resulting function object (AsyncMethod<method-ptr>) forwards the Return
callback through to the method. For synchronous methods the method is
called and the result passed to the Return callback.
2025-10-06 15:46:42 +11:00
Lang Hames
e8489c162b
[orc-rt] WrapperFunction::handle: add by-ref args, minimize temporaries. (#161999)
This adds support for WrapperFunction::handle handlers that take their
arguments by reference, rather than by value.

This commit also reduces the number of temporary objects created to
support SPS-transparent conversion in SPSWrapperFunction.
2025-10-05 18:21:00 +11:00
Lang Hames
715e0fab00
[orc-rt] Add transparent SPS conversion for error/expected types. (#161768)
This commit aims to reduce boilerplate by adding transparent conversion
between Error/Expected types and their SPS-serializable counterparts
(SPSSerializableError/SPSSerializableExpected). This allows
SPSWrapperFunction calls and handles to be written in terms of
Error/Expected directly.

This functionality can also be extended to transparently convert between
other types. This may be used in the future to provide conversion
between ExecutorAddr and native pointer types.
2025-10-03 13:26:20 +10:00
Lang Hames
27719745e3
[orc-rt] Add WrapperFunction::handle support for fns, fn-ptrs. (#157787)
Adds support for using functions and function pointers to the
WrapperFunction::handle utility.
2025-09-10 14:15:32 +10:00
Lang Hames
e031a56a18
[orc-rt] Introduce WrapperFunction APIs. (#157091)
Introduces the following key APIs:

`orc_rt_WrapperFunction` defines the signature of an ORC asynchronous
wrapper function:

```
typedef void (*orc_rt_WrapperFunctionReturn)(
    orc_rt_SessionRef Session, void *CallCtx,
    orc_rt_WrapperFunctionBuffer ResultBytes);

typedef void (*orc_rt_WrapperFunction)(orc_rt_SessionRef Session, void *CallCtx,
                                       orc_rt_WrapperFunctionReturn Return,
                                       orc_rt_WrapperFunctionBuffer ArgBytes);
```

A wrapper function takes a reference to the session object, a context
pointer for the call being made, and a pointer to an
orc_rt_WrapperFunctionReturn function that can be used to send the
result bytes.

The `orc_rt::WrapperFunction` utility simplifies the writing of wrapper
functions whose arguments and return values are serialized/deserialized
using an abstract serialization utility.

The `orc_rt::SPSWrapperFunction` utility provides a specialized version
of `orc_rt::WrapperFunction` that uses SPS serialization.
2025-09-05 22:39:54 +10:00