Commit Graph

260 Commits

Author SHA1 Message Date
Joe Groff
8e1dcb481f Merge pull request #37393 from jckarter/disable-flaky-objc-async-test
Disable flaky test/Concurrency/Runtime/objc_async.swift test.
2021-05-13 16:13:02 -07:00
Arnold Schwaighofer
f82edf72c7 Mark test async_stream as executable_test
It fails on non_executable bots.

rdar://77963528
2021-05-13 06:26:10 -07:00
Joe Groff
74736c75ba Disable flaky test/Concurrency/Runtime/objc_async.swift test.
We need to introduce some proper synchronization between the @main task and the ObjC
completion handler to make this reliably deterministic. rdar://77934626
2021-05-12 15:24:40 -07:00
Philippe Hausler
4886bd56e4 [Concurrency] AsyncStream and AsyncThrowingStream
* Rework YieldingContinuation to service values in a buffered fashion

* Fix word size calculation for locks

* Handle terminal states and finished/failed storage

* Wrap yielding continuation into a more featureful type for better ergonomics

* Hope springs eternal, maybe windows works with this?

* Prevent value overflows at .max limits

* Add a cancellation handler

* Fix series tests missing continuation parameters

* Fix series tests for mutable itertaors

* Rename to a more general name for Series's inner continuation type

* Whitespace fixes and add more commentary about public functions on Series

* Restore YieldingContinuation for now with deprecations to favor Series

* Ensure onCancel is invoked in deinit phases, and eliminate a potential for double cancellation

* Make sure ThrowingSeries has the same nonmutating setter for onCancel as Series

* Add a swath of more unit tests that exersize cancellation behavior as well as throwing behaviors

* Remove work-around for async testing

* Fixup do/catch range to properly handle ThrowingSeries test

* Address naming consistency of resume result function

* Adopt the async main test setup

* More migration of tests to new async mechanisms

* Handle the double finish/throw case

* Ensure the dependency on Dispatch is built for the series tests (due to semaphore usage)

* Add import-libdispatch to run command for Series tests

* Use non-combine based timeout intervals (portable to linux) for dispatch semaphore

* Rename Series -> AsyncStream and resume functions to just yield, and correct a missing default Element.self value

* Fix missing naming change issue for yielding an error on AsyncThrowingStream

* Remove argument label of buffering from tests

* Extract buffer and throwing variants into their own file

* Slightly refactor for only needing to store the producer instead of producer and cancel

* Rename onCancel to onTermination

* Convert handler access into a function pair

* Add finished states to the termination handler event pipeline and a disambiguation enum to identify finish versus cancel

* Ensure all termination happens before event propigation (and outside of the locks) and warn against requirements for locking on terminate and enqueue

* Modified to use Deque to back the storage and move the storage to inner types; overall perf went from 200kE/sec to over 1ME/sec

* Update stdlib/public/Concurrency/AsyncStream.swift

Co-authored-by: Doug Gregor <dgregor@apple.com>

* Update stdlib/public/Concurrency/AsyncThrowingStream.swift

Co-authored-by: Doug Gregor <dgregor@apple.com>

* Update stdlib/public/Concurrency/AsyncStream.swift

Co-authored-by: Joseph Heck <heckj@mac.com>

* Update stdlib/public/Concurrency/AsyncThrowingStream.swift

Co-authored-by: Joseph Heck <heckj@mac.com>

* Update stdlib/public/Concurrency/AsyncThrowingStream.swift

Co-authored-by: Joseph Heck <heckj@mac.com>

* Update stdlib/public/Concurrency/AsyncThrowingStream.swift

Co-authored-by: Joseph Heck <heckj@mac.com>

* Update stdlib/public/Concurrency/AsyncStream.swift

Co-authored-by: Joseph Heck <heckj@mac.com>

* Update stdlib/public/Concurrency/AsyncThrowingStream.swift

Co-authored-by: Joseph Heck <heckj@mac.com>

* Remove local cruft for overlay disabling

* Remove local cruft for Dispatch overlay work

* Remove potential ABI impact for adding Deque

Co-authored-by: Doug Gregor <dgregor@apple.com>
Co-authored-by: Joseph Heck <heckj@mac.com>
2021-05-11 21:41:33 -07:00
Arnold Schwaighofer
bd010c3998 Merge pull request #37369 from aschwaighofer/availability_macro_concurrency_tests
Use availability macro insteada of macOS 9999 in Concurrency tests
2021-05-11 14:01:15 -07:00
Arnold Schwaighofer
753fae3fd1 Disable async_task_async_let_child_cancel.swift test
It sometimes fails on bots.

rdar://77671328
2021-05-11 10:49:17 -07:00
Arnold Schwaighofer
887902eabd Use availability macro insteada of macOS 9999 in Concurrency tests 2021-05-11 10:40:45 -07:00
Joe Groff
63613a9a83 Merge pull request #37348 from jckarter/runtime-test-async-objc-method-completion-handler-override
Add test that exercises still overriding ObjC async methods as completion handlers
2021-05-11 09:50:16 -07:00
Konrad `ktoso` Malawski
6cbb792f92 [TaskLocals] Propagate task-locals through async{} 2021-05-11 11:06:17 +09:00
Konrad `ktoso` Malawski
82e91b7785 [TaskLocals] Enable sync functions to bind task-locals; Keep Storage in TLS 2021-05-11 11:06:16 +09:00
Joe Groff
391a3bd42d Add test that exercises still overriding ObjC async methods as completion handlers 2021-05-10 12:53:32 -07:00
Alexis Laferrière
7487c12d05 Merge pull request #37269 from xymus/test-macro
[Concurrency] Define and use the SwiftStdlib 5.5 availability macro in tests
2021-05-10 10:46:53 -07:00
Arnold Schwaighofer
970034441a Disable executor_deinit1.swift test in optimized mode
It fails on some bots.

rdar://77658743
2021-05-07 09:17:00 -07:00
Doug Gregor
052cc7d022 [Concurrency] Revert 'nonisolated let' change.
The change made to SE-0306 to require 'nonisolated let' is undercutting
the effectiveness of the model. Revert while we work on a better
solution.
2021-05-06 17:30:11 -07:00
Alexis Laferrière
3310a55682 [Test] Use the SwiftStdlib 5.5 macro in Concurrency tests 2021-05-06 13:48:49 -07:00
Arnold Schwaighofer
34b532add1 Merge pull request #37274 from aschwaighofer/fix_some_concurrency_tests_for_os_stdlib
Fix some concurrency tests not to run on os stdlib bots
2021-05-05 10:37:18 -07:00
Arnold Schwaighofer
1fc81fe726 Fix some concurrency tests not to run on os stdlib bots
rdar://77564014
2021-05-05 10:35:42 -07:00
Arnold Schwaighofer
b327bc985e Disable Concurrency/Runtime/checked_continuation.swift on windows
It seems to fail sometimes.
2021-05-05 09:58:27 -07:00
Joe Groff
38497aa6b2 Merge pull request #37226 from jckarter/objc-async-bridge-block-captures
SILGen: Copy the block before detaching a task for async methods called from ObjC.
2021-05-04 15:48:00 -07:00
Joe Groff
ecc46a809e Sleep to give new test completion handler a chance to run 2021-05-04 09:25:08 -07:00
Joe Groff
acac14e757 SILGen: Copy the block before detaching a task for async methods called from ObjC.
The block needs to survive long enough for the task to get scheduled. Fixes rdar://76871310.
2021-05-03 15:31:22 -07:00
Kavon Farvardin
e17e09c294 Enable effectful properties (SE-310) by default.
1. Removes gating on -enable-experimental-concurrency.
2. Updates eff. prop tests to remove experimental flag,
   and also adjusts some tests slightly to avoid things
   that are still behind that flag.
2021-05-03 14:10:44 -07:00
John McCall
20741e059b Disable this test on Windows; it seems to not progress. (#37200)
I assume there's a common underlying problem for this and a lot of
other concurrency tests that are disabled on Windows.
2021-05-01 10:12:11 -07:00
John McCall
186c53000d Introduce basic support for custom executors.
- Introduce an UnownedSerialExecutor type into the concurrency library.
- Create a SerialExecutor protocol which allows an executor type to
  change how it executes jobs.
- Add an unownedExecutor requirement to the Actor protocol.
- Change the ABI for ExecutorRef so that it stores a SerialExecutor
  witness table pointer in the implementation field.  This effectively
  makes ExecutorRef an `unowned(unsafe) SerialExecutor`, except that
  default actors are represented without a witness table pointer (just
  a bit-pattern).
- Synthesize the unownedExecutor method for default actors (i.e. actors
  that don't provide an unownedExecutor property).
- Make synthesized unownedExecutor properties `final`, and give them
  a semantics attribute specifying that they're for default actors.
- Split `Builtin.buildSerialExecutorRef` into a few more precise
  builtins.  We're not using the main-actor one yet, though.

Pitch thread:
  https://forums.swift.org/t/support-custom-executors-in-swift-concurrency/44425
2021-04-30 03:11:56 -04:00
swift-ci
bf6c673fd3 Merge pull request #36959 from ktoso/wip-task-locals-revisions 2021-04-29 20:50:01 -07:00
Arnold Schwaighofer
cf9ed6e4e0 Disable swift function merging for swift async functions
It breaks withCheckedContinuation.

I have not gotten to the bottom of why. But for now disable the pass for
all async functions until we can fix it.

rdar://77166575
2021-04-29 11:45:52 -07:00
Konrad `ktoso` Malawski
070f9a773b [TaskLocals] review 2: projected value wrapper 2021-04-29 15:48:23 +09:00
Konrad `ktoso` Malawski
df5ff42d79 [TaskLocals] set task local value in synchronous function 2021-04-29 15:48:23 +09:00
Konrad `ktoso` Malawski
f0781b1f8b [TaskLocals] prettier API thanks to default inits 2021-04-29 15:48:23 +09:00
Konrad `ktoso` Malawski
6f3dac190a [TaskLocals] remove TaskLocalInheritance, we'll introduce when needed 2021-04-29 15:48:22 +09:00
Konrad `ktoso` Malawski
a70cd95667 [TaskLocals] move all tests to new style API 2021-04-29 15:48:22 +09:00
Konrad `ktoso` Malawski
664936cd03 [TaskLocal] crash on illegal withValue 2021-04-29 15:48:22 +09:00
Konrad `ktoso` Malawski
3d96d05546 [TaskLocals] property wrapper keys 2021-04-29 15:48:09 +09:00
Konrad `ktoso` Malawski
22c08874f1 Merge pull request #37108 from ktoso/wip-async_task_async_let_child_cancel-without-sleep
[Concurrency] Harden async_task_async_let_child_cancel so it does not need sleep
2021-04-29 14:09:53 +09:00
Konrad `ktoso` Malawski
d9a952abcc [Concurrency] Harden async_task_async_let_child_cancel so it does not need sleep 2021-04-28 22:20:10 +09:00
Joe Groff
cd6823f83b Reenable test/Concurrency/Runtime/executor_deinit1.swift on iOS simulator.
The failure no longer reproduces. rdar://76611676
2021-04-27 14:30:47 -07:00
Mishal Shah
a0d10e77a8 Concurrency/Runtime/async_initializer.swift and Concurrency/Runtime/async_task_async_let_child_cancel.swift unsupported on older OS 2021-04-26 20:05:46 -07:00
Konrad `ktoso` Malawski
fd8ec39f69 Merge branch 'main' into wip-main-remove-task-current 2021-04-26 17:39:50 +09:00
Konrad `ktoso` Malawski
e0eb940027 [Concurrency] Remove Task.current because it prevents task-local alloc #36993 2021-04-26 17:37:45 +09:00
Doug Gregor
7cc19b5807 [SE-0306] Require 'nonisolated' on lets for synchronous cross-actor access. 2021-04-23 02:20:35 -07:00
Konrad `ktoso` Malawski
ff2b2ce3b9 Update async_taskgroup_asynciterator_semantics.swift 2021-04-23 08:13:33 +09:00
Konrad `ktoso` Malawski
48ddcdcbd2 [TaskGroup] add simple test to group asynciterator test
Simple additional test, not because it's unexpected but to document what we're expecting.
2021-04-23 08:07:12 +09:00
Doug Gregor
623e54f45c Merge pull request #37007 from DougGregor/async-operation
[Concurrency] Add "async" operation for continuing work asynchronously.
2021-04-22 12:00:16 -07:00
Doug Gregor
fbc62373e0 Work around lack of qos_class_self in non-Darwin libdispatch 2021-04-22 09:11:00 -07:00
Doug Gregor
3c3f216be3 [Concurrency] Add "async" operation for continuing work asynchronously.
The `async` operation is a global function that initiates asynchronous
work on behalf of the synchronous code that calls it. Unlike `detach`,
`async` inherits priority, actor context, and other aspects of the
synchronous code that initiates it, making it a better "default"
operation for creating asynchronous work than `detach`. The `detach`
operation is still important for creating truly detached tasks that
can later be `await`'d or cancelled if needed.

Implements the main entry point for rdar://76927008.
2021-04-21 22:21:24 -07:00
Doug Gregor
e87505cb34 Merge pull request #36986 from DougGregor/data-race-checking-flags
[SILGen] Put actor data-race checking behind a flag.
2021-04-21 08:55:17 -07:00
nate-chandler
a0a60c1b65 Merge pull request #36932 from nate-chandler/wrangle/test/Concurrency/Runtime/async_task_yield.swift
[Test] Disabled two Concurrency tests for back deploy.
2021-04-21 08:34:40 -07:00
Doug Gregor
19a7fa6625 [SILGen] Put actor data-race checking behind a flag.
Introduce flags `-enable-actor-data-race-checks` and
`-disable-actor-data-race-checks` to enable/disable emission of code
that checks that we are on the correct actor. Default to `false` for
now but make it easy to enable in the future.
2021-04-20 22:30:53 -07:00
Nate Chandler
30ea9324a5 [Test] Disabled two Concurrency tests for back deploy. 2021-04-20 12:50:39 -07:00
Konrad `ktoso` Malawski
77e60cf05b silence issue on windows 2021-04-20 10:37:47 +09:00