Commit Graph

272 Commits

Author SHA1 Message Date
Nate Chandler
9501371cb7 [Test] Added for part_ap of async @conv(method). 2021-03-15 13:37:40 -07:00
Nate Chandler
c8c39f82b9 [Test] Passed -g in IRGen/async/partial_apply.sil. 2021-03-15 13:37:40 -07:00
Nate Chandler
6c7063d475 [Test] Gave async/partial_apply[_forwarder].sil pa'd funcs sizes.
Previously, the partially applied functions were not defined and as such
had no sizes.  That resulted in downstream issues as an attempt was made
to replace the size in the AsyncFunctionPointer for the functions'
forwarders with the size in the AsyncFunctionPointer for functions
because the latter did not exist.
2021-03-15 13:37:40 -07:00
Andrew Trick
9b016cbc06 Merge pull request #36423 from aschwaighofer/fix_i368_hop_to_executor
Fix hop_to_executor.sil on i386 which does not do swifttailcc yet
2021-03-12 23:06:28 -08:00
Arnold Schwaighofer
564d1d25b2 Fix hop_to_executor.sil on i386 which does not do swifttailcc yet 2021-03-12 09:55:51 -08:00
Doug Gregor
eeffb0785f Mangle the _Concurrency module as the Swift module in the ABI.
The `_Concurrency` module provides APIs and runtime entry points that
are part of the core Swift model, but are separated into their own
module because it's helpful for staging development.

Use the new `-module-abi-name` feature to mangle contents of the
`_Concurrency` module as if they were already in the Swift module.
This sets the ABI up for the `_Concurrency` module being merged in to
the Swift module at some future point without changing mangling or
metadata.

Fixes rdar://74285139.
2021-03-12 07:42:07 -08:00
nate-chandler
940a155ea3 Merge pull request #36398 from aschwaighofer/xfail_concurrency_test_windows
Disable failing concurrency tests on windows
2021-03-11 18:28:46 -08:00
Varun Gandhi
4be2f3a62d Merge pull request #36376 from varungandhi-apple/vg-coro-end-async
[IRGen] Use coro.end.async to return from an async function
2021-03-11 13:39:39 -08:00
Arnold Schwaighofer
5f96635188 OS=windows does not seem to do it 2021-03-11 09:54:07 -08:00
Arnold Schwaighofer
8c4278f33f Disable failing concurrency tests on windows
SR-14333
2021-03-11 08:05:36 -08:00
Arnold Schwaighofer
8c5fc073fd [IRGen] Use coro.end.async to return from an async function
The `coro.end.async` intrinsic allow specifying a function that is to be
tail-called as the last thing before returning.

LLVM lowering will inline the `must-tail-call` function argument to
`coro.end.async`. This `must-tail-call` function can contain a
`musttail` call.

```
define @my_must_tail_call_func(void (*)(i64) %fnptr, i64 %args) {
  musttail call void %fnptr(i64 %args)
  ret void
}

define @async_func() {
  ...
  coro.end.async(..., @my_must_tail_call_func, %return_continuation, i64 %args)
  unreachable
}
```
2021-03-10 10:15:27 -08:00
Joe Groff
872afda50b Merge pull request #36298 from jckarter/created-task-closure-context-leak
SIL: Clean up ownership handling in `createAsyncTask` builtins.
2021-03-09 14:17:13 -08:00
Joe Groff
d9798c0868 Concurrency: Redo non-_f variants of swift_task_create to accept closures as is.
In their previous form, the non-`_f` variants of these entry points were unused, and IRGen
lowered the `createAsyncTask` builtins to use the `_f` variants with a large amount of caller-side
codegen to manually unpack closure values. Amid all this, it also failed to make anyone responsible
for releasing the closure context after the task completed, causing every task creation to leak.
Redo the `swift_task_create_*` entry points to accept the two words of an async closure value
directly, and unpack the closure to get its invocation entry point and initial context size
inside the runtime. (Also get rid of the non-future `swift_task_create` variant, since it's unused
and it's subtly different in a lot of hairy ways from the future forms. Better to add it later
when it's needed than to have a broken unexercised version now.)
2021-03-08 16:54:19 -08:00
Nate Chandler
9aced92dd6 [Test] Added -g to IRGen/async test invocations.
Emitting the debug info exercises more functionality.
2021-03-08 14:43:16 -08:00
Joe Groff
511f9aaa19 SIL: Clean up ownership handling in createAsyncTask builtins.
The underlying runtime functions really want to be able to consume the closure being used
to spawn the task, but the implementation was trying to hide this by introducing a retain
at IRGen time, which is not very ARC-optimizer-friendly. Correctly model the builtin operands
as consumed so that the ownership verifier allows them to be taken +1.
2021-03-05 12:00:45 -08:00
Arnold Schwaighofer
cb3703c47d Adjust to llvm change that requires suspend.async to specify the index of the async context 2021-02-23 13:28:38 -08:00
Arnold Schwaighofer
4373bdd6d0 Conditionally start using llvm::CallingConv::SwiftTail for async functions
This is conditional on UseAsyncLowering and in the future should also be
conditional on `clangTargetInfo.isSwiftAsyncCCSupported()` once that
support is merged.

Update tests to work either with swiftcc or swifttailcc.
2021-02-18 09:25:15 -08:00
nate-chandler
de63a23e77 Merge pull request #35603 from nate-chandler/concurrency/irgen/rdar71378532
[Async CC] Make error indirect.
2021-02-16 07:39:14 -08:00
Arnold Schwaighofer
59c5841bc2 Merge pull request #35946 from aschwaighofer/use_polymorphic_supend_async
[IRGen] Use the result polymorphic coro.suspend.async intrinsic
2021-02-15 08:14:25 -08:00
nate-chandler
d639ee880c Merge pull request #35947 from nate-chandler/rdar74098395
[Test] Adapt async/hop_to_executor.sil to arm64e.
2021-02-12 16:49:43 -08:00
Slava Pestov
72e1f02ae2 IRGen: Fix async dispatch thunk emission with loadable return value
Fixes <rdar://problem/74246091>.
2021-02-12 14:06:07 -05:00
Nate Chandler
d37714f02e [Test] Adapt async/hop_to_executor.sil to arm64e.
rdar://74098395
2021-02-12 10:47:07 -08:00
Arnold Schwaighofer
84eac93568 [IRGen] Use the result polymorphic coro.suspend.async intrinsic
This needs llvm-project PR 2481.
2021-02-12 10:17:11 -08:00
Slava Pestov
1c69d4fe83 Disable test/IRGen/async/hop_to_executor.sil 2021-02-11 16:07:06 -05:00
Nate Chandler
e2a8abc9e5 [Async CC] Make error indirect.
Previously, the error stored in the async context was of type SwiftError
*.  In order to enable the context to be callee released, make it
indirect and change its type to SwiftError **.

rdar://71378532
2021-02-11 11:34:47 -08:00
Evan Wilde
8b80331c3d Updating tests to use actor
This patch updates the `actor class` spelling to `actor` in almost all
of the tests. There are places where I verify that we sanely handle
`actor` as an attribute though. These include:

 - test/decl/class/actor/basic.swift
 - test/decl/protocol/special/Actor.swift
 - test/SourceKit/CursorInfo/cursor_info_concurrency.swift
 - test/attr/attr_objc_async.swift
 - test/ModuleInterface/actor_protocol.swift
2021-02-10 08:09:13 -08:00
Erik Eckstein
334bad3463 tests: fix hop_to_executor test for 32-bit
rdar://71951411
2021-02-10 09:35:42 +01:00
Nate Chandler
893d28c9b3 [IRGen] Signed parent async context. 2021-02-03 17:51:18 -08:00
Nate Chandler
5261c31ed0 [IRGen] Sign TaskResumeFunction. 2021-02-03 17:51:02 -08:00
Nate Chandler
c31cb54d35 [IRGen] Sign TaskResumeContext. 2021-02-03 17:50:50 -08:00
Nate Chandler
5536114296 [IRGen] Return unsigned context from resume_project_context.
In __swift_async_resume_project_context, the context is stored into the
extended frame.  On arm64e, it is signed first.  Previously, that signed
context was returned fro the function.  That resulted in code like

    pacda  x16, x10
    str    x16, [x9]
    ldr    x9, [x16, #0x48]

where the context is signed (pacda), stored into the extended frame
(str) and then an attempt is made to load from the signed context (ldr).
Here, the unsigned context is returned from the function.
2021-02-03 08:25:05 -08:00
Nate Chandler
85ade03d67 [Test] Moved all IRGen/async tests off runAndBlockThread. 2021-02-03 08:23:57 -08:00
nate-chandler
3d6006c632 Merge pull request #35696 from nate-chandler/rdar72906989
[Test] Tested async cc's handling of constrained generic extensions.
2021-02-01 20:43:50 -08:00
nate-chandler
e82544ce5b Merge pull request #35695 from nate-chandler/rdar73742483
[Async CC] Put extra sources before unfulfilled requirements.
2021-02-01 20:43:00 -08:00
Nate Chandler
f361901c19 [Test] Tested async cc's handling of constrained generic extensions.
The issue was resolved at https://github.com/apple/swift/pull/35695 .
Here, a test is added for the case of methods on generic types which
appear in a constrained extension.

rdar://72906989
2021-02-01 16:15:27 -08:00
Nate Chandler
0f7e368e80 [Async CC] Put extra sources before unfulfilled requirements.
EmitPolymorphicArguments puts the extra sources before the unfulfilled
requirements into the explosion.  The NecessaryBindings instance must
have the type parameters in the same order.  Previously, though, they
were added after enumerating unfulfilled requirements.  Here, they are
added _before_ enumerating, matching the ordering of
EmitPolymorphicArguments.

rdar://73742483
2021-02-01 16:13:35 -08:00
Slava Pestov
f368364bac Merge pull request #35565 from slavapestov/resilient-async-dispatch-thunks
Support async calling convention for resilient class and protocol method dispatch thunks
2021-01-29 22:40:19 -05:00
nate-chandler
be1e8f60d6 Merge pull request #35642 from nate-chandler/test/20210128/1
[Test] Replaced temporary function with async main.
2021-01-28 20:54:42 -08:00
Slava Pestov
0768d1eb1a IRGen: Fix resilient witness tables and vtables to correctly reference async methods
Resilient witness tables and resilient class vtables are built from
descriptors. Make sure we reference the AsyncFunctionPointer of a
method implementation, and not the implementation itself, if the
method is async.

Part of rdar://problem/73625623.
2021-01-28 21:55:47 -05:00
Nate Chandler
798f86981f [Test] Replaced runAsyncAndBlock with async @main.
The last outstanding usage is in

    Concurrency/Runtime/checked_continuation.swift
2021-01-28 17:14:55 -08:00
Slava Pestov
844ce09124 IRGen: Refer to dispatch thunk async function pointers when making calls
Part of rdar://problem/73625623.
2021-01-28 18:04:27 -05:00
David Zarzycki
d67a3aecd7 [testing] Add missing REQUIRES 2021-01-28 06:12:24 -05:00
Slava Pestov
c79de40225 IRGen: Emit async function pointers for resilient class and protocol dispatch thunks
This adds new kinds of link entities corresponding to the three
dispatch thunk link entity kinds:

- DispatchThunkAsyncFunctionPointer
- DispatchThunkInitializerAsyncFunctionPointer
- DispatchThunkAllocatorAsyncFunctionPointer
2021-01-27 15:21:22 -05:00
Arnold Schwaighofer
12e6ec1daf Fix one more test 2021-01-22 10:52:34 -08:00
Arnold Schwaighofer
daa72d3cc5 Add llvm::Attribute::SwiftAsync to the context parameter
* Adds support for generating code that uses swiftasync parameter lowering.

* Currently only arm64's llvm lowering supports the swift_async_context_addr intrinsic.

* Add arm64e pointer signing of updated swift_async_context_addr.

This commit needs the PR llvm-project#2291.

* [runtime] unittests should use just-built compiler if the runtime did

This will start to matter with the introduction of usage of swiftasync parameters which only very recent compilers support.

rdar://71499498
2021-01-22 10:01:55 -08:00
nate-chandler
341a1194e9 Merge pull request #35437 from nate-chandler/rdar73203508
[TBDGen] Use effective linkage for class member async function pointers.
2021-01-19 19:56:37 -08:00
Arnold Schwaighofer
17109ccfc7 IRGen: Fix unreachable lowering in async functions
We need to add the coro.end intrinsic call for lowering to process
functions correctly.

rdar://73274012
2021-01-19 08:48:11 -08:00
Nate Chandler
2e880af6a0 [TBDGen] Use effective linkage for class member async function pointers.
Previously, the "bare" linkage of a link entity was used to determine
whether to put an async function pointer into the tbd.  That did not
match the mechanism by which the linkage was determined in IRGen.
There, the linkage is the "_effective_" linkage (i.e. the value returned
from SILFunction::getEffectiveSymbolLinkage).

Here, whether to put the async function pointer corresponding to a class
method is determined on the basis of that effective linkage.

rdar://problem/73203508
2021-01-19 08:45:04 -08:00
Nate Chandler
130c5185d3 [Async CC] Handle dynamic functions.
Ensure that the FunctionPointer we pass to CreateCall has the Function
type.

rdar://problem/73026036
2021-01-14 17:20:07 -08:00
Nate Chandler
22d6395478 [Test] Temporarily disable run-switch-executor.
rdar://problem/72893124
2021-01-12 12:48:38 -08:00