Since invocation decoder is no longer required to be a class-bound
type, accessors have to be made generic over actual type of decoder.
Each accessor still knows what is the expected type of a decoder is
(based on the distributed actor it's associated with), so it still
does direct method calls but it has to load data decoder instance
first iff the decoder is a class.
The special convention currently means three things:
1. There is no async FP symbol for the function. Calls should go directly
to the function symbol, and an async context of fixed static size should be
allocated. This is mandatory for calling runtime-provided async functions.
2. The callee context should be allocated but not initialized. The main
context pointer passed should be the caller's context, and the continuation
function pointer and callee context should be passed as separate arguments.
The function will resume the continuation function pointer with the caller's
context. This is a micro-optimization appropriate for functions that are
expected to frequently return immediately; other functions shouldn't bother.
3. Generic arguments should be suppressed. This is a microoptimization for
certain specific runtime functions where we happen to know that the runtime
already stores the appropriate information internally. Other functions
probably don't want this.
Obviously, these different treatments should be split into different
predicates so that functions can opt in to different subsets of them.
I've also set the code up so that runtime functions can more easily
request a specific static async context size. Previously, it was a
confusingly embedded assumption that the static context size was always
exactly two pointers more than the header.
The witness table is an array of pointers - `void **`,
which means that the list of the witnesses has type of `void ***`.
Instead of using result of `emitAddressAtOffset` accessor
should set the correct type for the list, which is `void ***`
and emit bit a lot for each of the witness table slots.
Resolves: rdar://87568630
Resolves: rdar://88340451
`decodeNextArgument` requires (at least) that argument type conform
to a serialization requirement, witness table(s) for all protocol
requirements have to be lookup up by accessor to form correct
`decodeNextArgument` invocation.
Given a distributed thunk, find and cache a pointer to suitable
argument decoder method together with its type. The decoder is
a concrete type associated with actor via `InvocationDecoder`
associated type on `DistributedActorSystem` which should have a
`decodeNextArgument` method.
This is the case of e.g. `Array<T>` where argument is `Array<Int>`
we need to compute offset/size based on argument metadata but load
the argument using parameter type information.
To load generic argument value, we need to retrieve argument type
from the argument types buffer, based on that load value size and
alignment, and only then fetch actual value from the argument buffer
as `swift.opaque *`.
* [Distributed] Implement func metadata and executeDistributedTarget
dont expose new entrypoints
able to get all the way to calling _execute
* [Distributed] reimplement distributed get type info impls
* [Distributed] comment out distributed_actor_remoteCall for now
* [Distributed] disable test on linux for now
`getPointerToMethod()` should acoount for the fact that distributed
thunk is an async function, so direct pointer should be to "async
pointer" information instead of SIL function.
Instead of trying to return result from distributed thunk directly,
modify accessor to store result into the caller-provided buffer.
Doing so helps us avoid boxing the result into `Any`.
If parameter type's size is `0` then we don't want to perform a load
at the current position in the buffer and have to move to the next
non-empty element.
Distributed method is always `async throws` outside of its isolation
context, so accessor has to be `async throws` as well, and be able
to forward error value from the call to the outside.
Accessor infers result(s) from the underlying distributed method its
going to call, and forwards all of the results produced by such call
up to the caller.
`DistributedAccessor::computeArguments` handles loading of the argument
values from the provided `UnsafeRawPointer` (managed by the caller),
coercing retrieved arguments to appropriate platform-native representation,
and exploding object to form correct argument sequence for distributed
method call.