Commit Graph

1119 Commits

Author SHA1 Message Date
Hamish Knight
1a3b42cd63 Revert "Prevent noncopyable metatypes from being converted to Any" 2023-05-04 12:10:10 +01:00
Kavon Farvardin
1df3912794 Merge pull request #65606 from kavon/noncopyable-metatypes
Prevent noncopyable metatypes from being converted to `Any`
2023-05-03 22:05:17 -07:00
Konrad `ktoso` Malawski
0bdb39f51e Merge pull request #65455 from ktoso/wip-bincompat-job-rename 2023-05-04 07:34:45 +09:00
Kavon Farvardin
4710fc675b Prevent noncopyable metatypes from being converted to Any
These metatypes are a gateway to more incorrect
uses of these noncopyable values because we don't
yet have the corresponding runtime support yet.
The other use cases of using metatypes of
noncopyable types in generics is not high enough to
warrant people using them yet.

resolves rdar://106452518
2023-05-03 10:23:11 -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
Konrad `ktoso` Malawski
8d6980ec10 [Executors] Make move to ExecutorJob binary compatible; deprecate Job 2023-05-02 14:44:11 +09:00
Konrad `ktoso` Malawski
fe90d44e4c [Executors] Remove accidentally added availability on asUnownedSerialExecutor (#65407) 2023-04-26 06:14:12 +09:00
nate-chandler
d20b8d26b8 Merge pull request #65274 from nate-chandler/rdar107275872
[Concurrency] Nest stack traffic in withValue.
2023-04-19 11:52:41 -07:00
Evan Wilde
b8396e6449 Merge pull request #65271 from etcwilde/ewilde/fix-startOnMainActor
Fix main executor check in `startOnMainActor`
2023-04-19 07:49:18 -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
Evan Wilde
ad81f8d557 Allow discarding startOnMainActor results
Adding discardableResult to startOnMainActor
2023-04-18 16:40:54 -07:00
Evan Wilde
c18c37b6ba Use isCurrentExecutor check in startOnMainActorImpl
startOnMainActor checked the current executor directly, which in some
cases came back as a `nullptr`. This happens with older API which don't
know to set the current executor. `swift_task_isCurrentExecutor` knows
how to check for the current dispatch queue and the main thread though,
so switching the main-executor check to use that API instead.
2023-04-18 16:38:29 -07:00
Konrad `ktoso` Malawski
97d2f4fd36 Fix pointer auth issues for discarding task group operation pointer (#65220) 2023-04-18 12:51:45 +09:00
Kavon Farvardin
8f13679582 add missing rename of Job -> ExecutorJob 2023-04-12 13:37:43 -07:00
Konrad `ktoso` Malawski
80b93863a9 [Concurrency] Rename Job to ExecutorJob, ease transition with typealias (#65006) 2023-04-11 14:52:10 +09:00
Konrad `ktoso` Malawski
b666fc672e [Executors] Remote distributed actors get "crash on enqueue" default executor (#64969) 2023-04-10 19:12:03 +09:00
Konrad `ktoso` Malawski
b8780c9d9e [Executors] Move assert/assume APIs onto actors; assumeIsolated() (#64812) 2023-04-04 07:44:43 +09:00
swift-ci
3be14e0a4a Merge pull request #64622 from kavon/bifurcate-moveonly-featureflag
Fix minimal stdlib builds with noncopyable types
2023-03-28 14:44:24 -07:00
Konrad `ktoso` Malawski
0586c14b60 [Concurrency] SerialExecutor.isSameExclusiveExecutionContext (#64604) 2023-03-28 15:56:28 +09:00
Kavon Farvardin
5c8447587f explicitly enable MoveOnly feature when building _Concurrency lib
We ran into an issue on minimal stdlib build configurations, because they
pull slightly older toolchains to build and test the stdlib. The noncopyable
`Job` type was adopted immediately after such types were enabled by default,
before the toolchain builds could catch up. Adding this flag to the build of
the `_Concurrency` lib should make things more robust when somewhat older
compilers are building this part of the stdlib.

part of resolving rdar://106849189
2023-03-24 16:00:22 -07:00
Kavon Farvardin
363448a0d7 bring back the noncopyable Job type in the _Concurrency lib
This reverts commit abe377ce68.

Co-authored-by: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
2023-03-24 08:58:40 -07:00
Konrad `ktoso` Malawski
abe377ce68 [Workaround][Concurrency] Mark Job as NOT moveonly until we fix moveonly types (#64536) 2023-03-23 07:43:51 +09:00
Konrad `ktoso` Malawski
345c221f56 [Concurrency] Distributed actor's unownedExecutor should be optional (#64499) 2023-03-22 08:40:41 +09:00
Konrad `ktoso` Malawski
e0877594da [Concurrency] Custom executors with move-only Job (#63569) 2023-03-18 14:02:43 +09:00
Konrad `ktoso` Malawski
5d2a311dda [Executors] assumeOnLocalDistributedActorExecutor (isolated Act) -> 2023-03-16 13:23:47 +09:00
Konrad `ktoso` Malawski
41f99fc2ae [Executors][Distributed] custom executors for distributed actor (#64237)
* [Executors][Distributed] custom executors for distributed actor

* harden ordering guarantees of synthesised fields

* the issue was that a non-default actor must implement the is remote check differently

* NonDefaultDistributedActor to complete support and remote flag handling

* invoke nonDefaultDistributedActorInitialize when necessary in SILGen

* refactor inline assertion into method

* cleanup

* [Executors][Distributed] Update module version for NonDefaultDistributedActor

* Minor docs cleanup

* we solved those fixme's

* add mangling test for non-def-dist-actor
2023-03-15 23:42:55 +09:00
Konrad `ktoso` Malawski
ac0c3b75c6 [Concurrency] Freeze JobPriority, comment that Flags location is assumed (#64267) 2023-03-10 16:49:37 +09:00
Kavon Farvardin
4c65c33668 Merge pull request #64211 from kavon/assumeOn-task2thread-guarding
guard assume on executor API against task-to-thread runtimes
2023-03-09 09:34:01 -08:00
Kavon Farvardin
c100fe01bc guard use of enqueueStealer when using actors-as-locks
skip escalation in this case.
2023-03-08 14:55:36 -08:00
Kavon Farvardin
f40d90f885 fix another unguarded use of MainActor 2023-03-08 14:12:13 -08:00
Kavon Farvardin
18d976f8fa guard assume on executor API against task-to-thread runtimes 2023-03-08 12:02:06 -08:00
Konrad `ktoso` Malawski
5fbdd8197d Minor mistake in group docs comment cocs snippet
We say in a comment here that we print the error and cancel, but we don't actually have the print below. This PR adds that missing print in the docs snippet.
2023-03-08 22:56:09 +09:00
swift-ci
f284e72956 Merge pull request #62201 from mdznr/documentation_grammar
[NFC] Correct grammar in documentation for `AsyncStream.Continuation.finish()`
2023-03-07 15:02:41 -08:00
Evan Wilde
2c49700ed5 Merge pull request #64054 from etcwilde/ewilde/startOnMainActor
Concurrency: swift_task_startOnMainActor
2023-03-06 18:57:51 -08:00
Evan Wilde
f8e1272097 Concurrency: appease the api-digester
Looks like simply putting the availability attribute on the extension
does not suffice. Putting the availability attr on the function itself
to appease the api-digester.
2023-03-06 13:33:22 -08:00
Evan Wilde
1bd1c468a0 Concurrency: Task.startOnMainActor
This patch adds an SPI to run the first partial function of a MainActor
asynchronous function on the MainActor synchronously. This is
effectively like the asynchronous program entrypoint behavior. The first
partial function is run synchronously. Following continuations are
enqueued for execution like any other asynchronous function.
2023-03-06 13:33:22 -08:00
Evan Wilde
9fd0f26112 Delete trailing whitespace in AsyncStreamBuffer.swift
Verifying that the ANSI color control sequences don't show up in CI
logs. AsyncStreamBuffer.swift emits warnings, so dirtying it will ensure
it gets rebuilt in CI.
2023-03-06 09:13:45 -08:00
Franz Busch
791b2a0298 Implement convenience factory methods for Async[Throwing]Stream (#62968)
* Implement convenience factory methods for Async[Throwing]Stream

This is the implementation for https://github.com/apple/swift-evolution/pull/1824

* Apply suggestions from code review

Co-authored-by: Konrad `ktoso` Malawski <konrad.malawski@project13.pl>

---------

Co-authored-by: Konrad `ktoso` Malawski <konrad.malawski@project13.pl>
2023-03-04 17:43:56 -08:00
Rokhini Prabhu
4c92890a42 Remove overly strict assert that only the thread which was previously running the task, can mark the task as no-longer running. 2023-03-03 18:04:26 -08:00
Konrad `ktoso` Malawski
93decb6141 [Concurrency] Complement assume... APIs with the assert and precondition ones (#64062) 2023-03-04 08:03:29 +09:00
Rokhini Prabhu
0bb5a89d56 Fixup isEnqueued call on actor state which really is isScheduled
Radar-Id: rdar://problem/101864092
2023-03-03 11:44:56 -08:00
Doug Gregor
1b3fda7857 Merge pull request #64060 from DougGregor/enable-swift-syntax-formatter 2023-03-03 06:24:29 -08:00
swift-ci
5fe47bf8fb Merge pull request #64030 from ktoso/wip-assume
[Concurrency] Add "assume on (actor) executor" APIs
2023-03-03 00:40:02 -08:00
swift-ci
814488f7db Merge pull request #64050 from ktoso/wip-continuation-docs-fix
[Concurrency] Fix continuation documentation about execution semantics
2023-03-02 23:19:27 -08:00
Doug Gregor
9074b94d5f Enable the Swift diagnostic formatter for standard library builds 2023-03-02 22:08:12 -08:00
Konrad `ktoso` Malawski
3eb04e24a2 fix complete_concurrency_keyword's too imprecise assertions 2023-03-03 14:16:03 +09:00
Konrad `ktoso` Malawski
c446f4cb12 review followup 2023-03-03 13:37:57 +09:00
Konrad `ktoso` Malawski
293440dbb2 remove underscore from assume funcs 2023-03-03 12:40:55 +09:00
Konrad `ktoso` Malawski
d0c68c0176 [Concurrency] Add "assume on (actor) executor" APIs 2023-03-03 12:40:55 +09:00
Evan Wilde
877d03f4f5 Merge pull request #61692 from etcwilde/ewilde/fix-noreturn-warning
Fix asyncMainDrainQueue noreturn warning
2023-03-02 18:21:38 -08:00