mirror of
https://github.com/apple/swift.git
synced 2026-11-01 23:11:50 +01:00
Add 'Builtin.createSynchronousDiscardingTask', which creates a discarding (void returning),
non-throwing task, with a synchronous operation.
This is the builtin that oneway calls and send will be using, but I'm
staging it one by one rather than all at once. This PR doesn't add any
surface API or language to make use of the builtin yet. This will come
with a follow up PR.
This version is fairly limited; we allow a task to be discarding +
synchronous, and then create a new kind of specialized task that doesn't
have a future fragment, ignores the result, cannot throw also.
We could make this more general in the future, and optimize Task{} and
friends if they have a synchronous closure that cannot suspend etc, but
it likely isn't very common -- it is crucial for `send` however.
It lowers to the existing 'createAsyncTask' SIL builtin with a synchronous
operation; IRGen is unchanged.
For swift-inspect and lldb, we keep the flag on the job in order to be
able to say this was a synchronous target call; and the async context
allocation as well as task allocator slab are attempted to keep smaller,
as we assume we won't be making much task allocations in such a job.
So, the first task allocator slab is tail-allocated with the task and sized
for the copied task-local values, the initial task executor preference
record and the enqueue dependency record etc. So usually such task would
not need any additional allocation (that's the bet at least).