Commit Graph

99 Commits

Author SHA1 Message Date
Konrad `ktoso` Malawski
4e2c059e20 review feedback, cleanup getting decode func 2022-04-18 16:53:47 -07:00
Pavel Yaskevich
75d155829a [Distributed] Accessor: Add support for generic distributed actors
Augment accessor to support generic distributed actor declarations
e.g. `distributed actor X<T: Codable>`.
2022-03-24 14:12:06 -07:00
Pavel Yaskevich
72fca4ca07 [Distributed] IRGen: Make distributed accessors generic over invocation decoder type
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.
2022-02-16 14:23:55 -08:00
John McCall
58fe89f359 [NFC] Split up the "special convention" for runtime async functions
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.
2022-02-15 04:12:05 -05:00
Pavel Yaskevich
67628b7330 Merge pull request #41218 from xedin/dist-watchos-32bit-issues
[Distributed] IRGen: Fix loading of the witness tables
2022-02-05 08:37:17 -08:00
Pavel Yaskevich
ab25d4e62a [Distributed] IRGen: Fix loading of the witness tables
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
2022-02-05 01:12:47 -08:00
Pavel Yaskevich
df3d47f6e5 [Distributed] IRGen: Let debug info know about distributed accessor
Use `emitArtificialFunction` to let debug info know that compiler
is about to generate code for distributed accessor.
2022-02-03 14:47:12 -08:00
Pavel Yaskevich
9694597790 [Distributed] IRGen: Cache protocol requirements of decode method 2022-01-31 00:38:26 -08:00
Pavel Yaskevich
b43d341ef1 [Distributed] IRGen: Augment accessor to lookup witness tables for decode call
`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.
2022-01-30 19:04:36 -08:00
Pavel Yaskevich
35e639fc35 [Distributed] IRGen: Don't use designated initializers to create ArgumentDecoderInfo 2022-01-29 14:33:41 -08:00
Pavel Yaskevich
80e6f5039e [Distributed] IRGen: Use direct reference to decodeNextArgument if decoder is final 2022-01-29 14:33:41 -08:00
Pavel Yaskevich
aa44c1dbe1 [Distributed] IRGen: Emit an early return upon argument decoding failure 2022-01-29 14:33:41 -08:00
Pavel Yaskevich
7b159d3edd [Distributed] IRGen: Switch accessor to accept argument decoder instance instead of argument buffer
This obsoletes `HeterogeneousBuffer` and instead emits calls to
`decodeNextArgument` directly in distributed accessor.
2022-01-29 14:33:41 -08:00
Pavel Yaskevich
3a754cbbf2 [Distributed] IRGen: Find a suitable decoder method to decode argument values
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.
2022-01-29 14:33:41 -08:00
Pavel Yaskevich
0e03f1e3c7 [Distributed] IRGen: Switch to use InvocationDecoder instead of argument value buffer 2022-01-29 14:33:41 -08:00
Pavel Yaskevich
4cfd1d0adc [Distributed] Switch accessor parameter convention to Direct_Unowned since all of them are trivial 2022-01-24 16:19:53 -08:00
Pavel Yaskevich
59ff689f28 [Distributed] IRGen: Teach distributed thunk accessor to load witness tables (when needed) 2022-01-24 10:18:00 -08:00
Pavel Yaskevich
dc978f2934 [Distributed] IRGen: Support argument with generic parameters passed directly
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.
2022-01-24 10:18:00 -08:00
Pavel Yaskevich
cf47cfa7b2 [Distributed] IRGen: Add generic argument substitutions to argument explosion of thunk call 2022-01-24 10:18:00 -08:00
Pavel Yaskevich
406af83329 [Distributed] Runtime/IRGen: Allow passing substitutions to distributed accessor
Accept an optional list of substitutions which are required to form
a call to a generic distributed thunk.
2022-01-24 10:18:00 -08:00
Pavel Yaskevich
925b59826d [Distributed] IRGen: Drop result type for accessor parameters 2022-01-24 10:18:00 -08:00
Pavel Yaskevich
51df87447a [Distributed] IRGen: Support loading both concrete and generic argument values
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 *`.
2022-01-24 10:17:59 -08:00
Pavel Yaskevich
e7ceddc564 [Distributed] IRGen: Provide argument/result types to the accessor 2022-01-24 10:17:59 -08:00
Pavel Yaskevich
0c2121a1a4 [Distributed] IRGen: Fix misspelling in getRawPointerParameter 2022-01-14 15:39:04 -08:00
Konrad `ktoso` Malawski
9438cf6b2e [Distributed] Func metadata operations and implement executeDistributedTarget entry (#40605)
* [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
2022-01-09 23:55:06 +09:00
Pavel Yaskevich
d516281da9 [Distributed] NFC: Remove Method from accessor APIs
The API is not constrained to methods only, it should support
computed properties as well.
2021-12-23 14:10:05 -08:00
Pavel Yaskevich
375494b3fc [Distributed] IRGen: Fix method pointer retrieval
`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.
2021-12-22 18:11:01 -08:00
Pavel Yaskevich
bcf2d5a1aa [Distributed] IRGen: Make accessor thin and require actor as (last) guaranteed argument 2021-12-22 16:17:53 -08:00
Pavel Yaskevich
2180e4deed [Distributed] IRGen: Make sure that arguments extracted from buffer have correct ownership
Use parameter convention information to determine ownership of the extracted arguments.
2021-12-17 10:52:57 -08:00
Pavel Yaskevich
304f3db05b [Distributed] IRGen: Load arguments directly into argument explosion
It's incorrect to load from the pointer directly, instead accessor
should use `loadAsCopy` for loadable types.
2021-12-17 10:52:57 -08:00
Pavel Yaskevich
111ceb189a [Distributed] IRGen: Adjust distributed method accessor to store result into a provided buffer
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`.
2021-12-17 10:52:56 -08:00
Pavel Yaskevich
0060859c18 [Distributed] IRGen: Don't allocate offset pointer if there is nothing to load
If underlying function does not have any parameter, then let's
exit early and avoid stack allocating the argument buffer cursor.
2021-12-17 10:52:56 -08:00
Pavel Yaskevich
2156fb04e4 [Distributed/Accessor] IRGen: Don't move argument buffer pointer past the last element 2021-12-17 10:52:55 -08:00
Pavel Yaskevich
71e7355e8c [Distributed] IRGen: Don't load arguments they turn into void in native schema
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.
2021-12-17 10:52:55 -08:00
Pavel Yaskevich
56fdf34f0a [Distributed] NFC: Remove outdated FIXME about async task/executor parameters 2021-12-17 10:52:55 -08:00
Pavel Yaskevich
3ec9986a83 [Distributed] IRGen: Support returning results indirectly from accessor 2021-12-17 10:52:55 -08:00
Pavel Yaskevich
8980922a53 [Distributed] IRGen: Mark accessor as throws and forward error values from distributed method
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.
2021-12-17 10:52:55 -08:00
Pavel Yaskevich
9d1c103f5e [Distributed] IRGen: Turn distributed method accessor into async function 2021-12-17 10:52:55 -08:00
Pavel Yaskevich
185a6630f1 [Distributed] IRGen: Forward distributed method results through accessor
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.
2021-12-17 10:52:55 -08:00
Pavel Yaskevich
a866a7a53e [Distributed] IRGen: Emit a call to a distributed method
Note that results are not handled yet.
2021-12-17 10:52:55 -08:00
Pavel Yaskevich
ac2973d211 [Distributed] IRGen: Form a callee for a distributed method 2021-12-17 10:52:55 -08:00
Pavel Yaskevich
19bf160ed0 [Distributed] IRGen: Add argument loading from UnsafeRawPointer into an explosion
`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.
2021-12-17 10:52:55 -08:00
Pavel Yaskevich
9ebdf36ca6 [IRGen] Add skeleton implementation of distributed method accessor 2021-12-17 10:52:55 -08:00
Kavon Farvardin
006e2b446b Replace destoryDistributedActor builtin with destroyDefaultActor
Currently, they both end up doing the exact same thing, so there's
no need for both.
2021-10-21 19:41:31 -07:00
Dario Rexin
d43ea45b6a Revert "Revert "Merge pull request #38938 from drexin/wip-dist-resolve" (#38994)" (#39011)
This reverts commit f6ae9f3387.
2021-08-24 13:33:37 +09:00
Konrad `ktoso` Malawski
f6ae9f3387 Revert "Merge pull request #38938 from drexin/wip-dist-resolve" (#38994)
This reverts commit a4f3f2fb48, reversing
changes made to 8cf6c2e71b.
2021-08-23 20:30:41 +09:00
Dario Rexin
810e2cff84 [Distributed] Fix type lowering for Builtin.initializeDistributedRemoteActor 2021-08-19 17:31:11 -07:00
Konrad `ktoso` Malawski
829a5d6895 [Distributed] Review followup and cleanups 2021-08-12 14:09:03 +09:00
Konrad `ktoso` Malawski
0c3720bc92 [Distributed] introduce GenDistributed.h/cpp for code organization 2021-08-12 14:09:01 +09:00