Commit Graph

12 Commits

Author SHA1 Message Date
Allan Shortlidge
5cc7fff4ca Concurrency: Restore consume in TaskLocal.withValueImpl<R>(_:operation:).
It is no longer necessary to avoid using the `consume` keyword in inlinable
function bodies in the standard library in order to support older compilers.

Partially reverts https://github.com/apple/swift/pull/65599.

Resolves rdar://109165937.
2023-08-14 22:19:56 -07:00
Allan Shortlidge
860b8cdf48 Concurrency: Revert workarounds for @backDeployed condfails.
All compilers that must be able to compile the standard library's textual
interface accept the following:
- back deployed functions declared without `@available`
- `@inlinable` back deployed functions
- `defer` blocks in back deployed functions

We can therefore revert the workarounds added in
https://github.com/apple/swift/pull/62946/ and
https://github.com/apple/swift/pull/62928/.

Resolves rdar://104085810
2023-05-08 18:21:08 -07:00
Allan Shortlidge
c0ee3ac866 Concurrency: Make _Concurrency module interface parsable by older compilers.
Revert a few unnecessary changes have been made to the _Concurrency module
recently that make its swiftinterface un-parseable by older compilers that we
need to support.

- The `consume` keyword is not understood by older compilers, so including it
  in inlinable code is a problem. It has no actual effect on lifetimes where it
  was used, so just omit it.
- Don't build the _Concurrency module with -enable-experimental-feature
  MoveOnly. The MoveOnly feature is now enabled by default in recent compilers,
  so the flag is superfluous when building the dylib. When emitting the
  interface, having the feature enabled explicitly exposes code guarded by
  `$MoveOnly` to older compilers that do not accept all of the code.

Resolves rdar://108793606
2023-05-02 15:27:05 -07:00
Nate Chandler
4fe988b7c2 [Concurrency] Nest stack traffic in withValue.
Because `_taskLocalValuePush` and `_taskLocalValuePop` can result in calls
to `swift_task_alloc` and `swift_task_dealloc` respectively, and because
the compiler hasn't been taught about that (e.g.
`SILInstruction::isAllocatingStack`,
`SILInstruction::isDeallocatingStack`, etc), calling them (push and pop)
from a function which makes use the stack for dynamically sized
allocations can result in violations of stack discipline of the form

```
swift_task_alloc // allocates %ptr_1
copy_value_witness // copies into %ptr_1
swift_task_localValuePush // calls swift_task_alloc and allocates %ptr_2
swift_task_dealloc // deallocates %ptr_1
swift_task_localValuePop // calls swift_task_dealloc and deallocates %ptr_2
```

Avoid the problem by not allocating dynamically sized stack space in the
function which calls `_taskLocalValuePush` and `_taskLocalValuePop`.
Split the calls to those functions into `withValueImpl` function which
takes its argument `__owned`.  Call that function from `withValue`,
ensuring that the necessary copy (to account for the fact that withValue
takes its argument `__guaranteed` but `_taskLocalValuePush` takes its
`__owned`) and associated stack traffic occur in `withValue`.

Still, allow `withValueImpl` to be inlined.  The stack nesting will be
preserved across it.

rdar://107275872
2023-04-18 19:51:34 -07:00
Allan Shortlidge
087aacc9fd [TaskLocals] Avoid use of defer in back deployed functions in the standard library.
Older versions of the 5.8 compiler have a bug when generating SIL for functions with `@_backDeploy` containing defer blocks (https://github.com/apple/swift/pull/62444) and for now we need the standard library interface to be compatible with those older compilers.

Resolves rdar://104045168
2023-01-10 10:44:15 -08:00
Allan Shortlidge
c7c806f768 [TaskLocals] Remove use of @inlinable with @_backDeploy temporarily. 2023-01-09 10:59:53 -08:00
Konrad `ktoso` Malawski
f9c2bc0402 Apply suggestions from code review
Co-authored-by: Doug Gregor <dgregor@apple.com>
2022-12-13 10:39:46 +09:00
Konrad `ktoso` Malawski
342ce7ea19 cleaning up attributes 2022-12-12 12:02:31 +09:00
Konrad `ktoso` Malawski
d122fd68fa add _backDeploy and availability necessary for it 2022-12-09 17:46:34 +09:00
Konrad `ktoso` Malawski
b3c335798d Better fix, using inheriting executor 2022-12-09 10:22:48 +09:00
Konrad `ktoso` Malawski
2178d9893f [Concurrency] tasklocal withValue inside actor is safe 2022-12-09 10:22:47 +09:00
Doug Gregor
ffb37ed057 Inline the Swift 5.6 concurrency library as a separate back-deploy library 2022-06-06 10:38:25 -07:00