Commit Graph

14787 Commits

Author SHA1 Message Date
Doug Gregor
ace5f49790 [Concurrency] Switch _runTaskForBridgedAsyncMethod over to using 'async' 2021-04-26 15:02:49 -07:00
Doug Gregor
ff4b0f335e [Concurrency] Speculatively add asyncDetached as a synonym for async.
Given that `async` is the dominant way to initiate asynchronous work from
a synchronous function, speculatively rename `detach` to `asyncDetached`
to both fit into the naming scheme and clearly bias toward `async.
2021-04-26 12:49:07 -07:00
Max Desiatov
d9ef216779 Concurrency: Avoid importing Dispatch with no global executor (#37059)
Dispatch is not available on platforms where `SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR` is defined `0`, e.g. WebAssembly/WASI..
2021-04-26 12:10:03 +01:00
Erik Eckstein
075ad87a40 Concurrency: allocate an async-let task with its parent's stack allocator.
Also, do this for the initial slab for the task's allocator itself.
This avoids memory allocations for async-lets.
In case the async-task's memory demand does not exceed the initial slab size, it is now completely malloc-free.

The refcount bits of an async-let task are initialized to "immortal" so that ARC operations don't have an effect on the task.
2021-04-26 13:07:32 +02: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
Mishal Shah
3116eed2e4 Update the branch to build with Xcode 12.5 (#37046) 2021-04-23 16:24:11 -07:00
Arnold Schwaighofer
eb60c7c66b Runtime: Fix async dynamic replacements
For async function async function pointers will be stored in dynamic
replacement records.

rdar://77072669
2021-04-23 09:01:34 -07:00
Mike Ash
22ef406163 Merge pull request #37018 from mikeash/remove-dynamic-class-is-swift-mask
[Runtime] Remove the _swift_classIsSwiftMask variable.
2021-04-23 11:46:20 -04:00
Konrad `ktoso` Malawski
e71a88508e [Concurrency] Deprecate Task.current and instance properties 2021-04-23 09:09:55 +09:00
Mike Ash
44d06a7faf [Runtime] Remove the _swift_classIsSwiftMask variable.
SWIFT_CLASS_IS_SWIFT_MASK is optionally defined to a global variable _swift_classIsSwiftMask, which allows the runtime to choose the appropriate mask when running on OS versions earlier than macOS 10.14.4. This is no longer a supported target for newly built runtimes (Swift apps built with such a target will embed a copy of the back deployment runtime, which is separate) and this global is no longer useful. Instead, unconditionally define SWIFT_CLASS_IS_SWIFT_MASK to 2 on Apple platforms, which is the correct value for current OS versions.

rdar://48413153
2021-04-22 16:25:46 -04: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
181ffaf733 Fix a typo in async comment 2021-04-22 09:12:37 -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
eeckstein
7611ecca2b Merge pull request #36975 from eeckstein/optimize-async-let
concurrency: make the startAsyncLet closure no-escaping
2021-04-21 08:50:17 +02:00
swift-ci
512be2cec6 Merge pull request #36945 from tbkka/tbkka/rdar76728925 2021-04-20 18:12:34 -07:00
Robert Widmann
b65777eabe Merge pull request #36963 from CodaFi/arm64_32
Add arm64_32 support for Swift
2021-04-20 17:42:56 -07:00
Alex Martini
4b2f4874b3 Use markup for a note box. 2021-04-20 15:46:45 -07:00
Tim Kientzle
fbec09bd56 Consolidate format-independent discussion at the end 2021-04-20 15:40:39 -07:00
Robert Widmann
0149ccd0ca Add arm64_32 support for Swift
Commit the platform definition and build script work necessary to
cross-compile for arm64_32.

arm64_32 is a variant of AARCH64 that supports an ILP32 architecture.
2021-04-20 14:59:04 -07:00
Stephen Canon
8736683cf7 Prevent arbitrary objects from conforming to RNG. (#36969)
Me, sobbing: "Look, you can't just point at an empty struct and call it a RandomNumberGenerator."
Swift 5.4, pointing at anything: "RNG."
2021-04-20 16:39:16 -04:00
Erik Eckstein
93367ed587 concurrency: make the startAsyncLet closure no-escaping
The closure does not escape the startAsyncLet - endAsyncLet scope. Even though it's (potentially) running on a different thread.

The substantial change in the runtime is to not call swift_release on the closure context if it's a non-escaping closure.
2021-04-20 21:57:19 +02:00
Tim Kientzle
2a476586d7 Backwards compatibility note 2021-04-20 11:25:03 -07:00
Tim Kientzle
1d5eb5b2be Wordsmithing 2021-04-19 10:30:31 -07:00
Tim Kientzle
0c7f85c56d Feedback 2021-04-19 10:25:09 -07:00
Tim Kientzle
33226b0505 Distinguish "string" (input), "value" or "number" (abstract real number that the string represents), and "instance" (the resulting ${Self}). 2021-04-19 09:09:11 -07:00
Konrad `ktoso` Malawski
a5469c438a [AsyncLet] remove some commented out code 2021-04-19 10:06:23 +09:00
Konrad `ktoso` Malawski
fae3c96874 [AsyncLet] ending an async let cancels the task 2021-04-19 10:06:23 +09:00
Konrad `ktoso` Malawski
eed96d21bb [AsyncLet] remove runChild; it is now asyncLetStart 2021-04-19 10:06:23 +09:00
Konrad `ktoso` Malawski
d3c5ebc9b7 [AsyncLet] reimplemented with new ABI and builtins 2021-04-19 10:06:23 +09:00
Konrad `ktoso` Malawski
ba615029c7 [Concurrency] Store child record when async let child task spawned 2021-04-19 10:06:23 +09:00
Tim Kientzle
b183c7d6c3 present, not future 2021-04-16 16:12:12 -07:00
David Zarzycki
654234ad64 [Testing] Unbreak minimal Swift builds
For various reasons, it can be useful/interesting to create builds of
Swift that minimize dependencies. Let's try to keep that working as long
as we can.
2021-04-16 17:39:01 -04:00
Tim Kientzle
20ba149dc3 More wordsmithing. 2021-04-16 14:00:11 -07:00
Tim Kientzle
98cec1321d Document how out-of-range inputs are handled
This changed recently so that overflow and underflow consistently return signed
infinity or zero instead of nil.  (Previously, overflow returned nil, underflow
returned zero.)

Among other benefits:
 * The new behavior distinguishes malformed input (nil) from valid but out-of-range input.
 * The new behavior preserves the sign of the input
 * The new behavior is consistent with how floating-point parsing behaves in other langauges

Resolves rdar://76728925
2021-04-16 10:22:59 -07:00
Evan Wilde
9b82fec131 Merge pull request #36457 from etcwilde/ewilde/delete-runAsyncAndBlock
[Concurrency] Delete runAsyncAndBlock
2021-04-16 08:40:30 -07:00
Doug Gregor
194536472a [AnyHashable] Work around older compiler limitation.
An older Swift compiler failed to account for the witnesses in a
conformance with platform availability having their own availability,
which causes that compiler to reject the Swift module's .swiftinterface
file when it includes `AnyHashable` 's conformance to
`_HasCustomAnyHashableRepresentation`. Work around the issue by making
the one witness (`_toCustomAnyHashable`, which is trivial)
always-emit-into-client, so it does not need any availability.

Fixes rdar://76370138.
2021-04-15 21:21:41 -07:00
Mike Ash
2dc06c5fe2 [Concurrency] Fix Dispatch linkage offset on 32-bit.
rdar://76703675
2021-04-15 12:18:38 -04:00
Evan Wilde
9b15a9ffad Delete runAsyncAndBlock once and for all! 2021-04-14 15:04:56 -07:00
Evan Wilde
1d06521f32 Plumb async-ness through StdlibUnittest
This patch plumbs through the ability to run async code in the standard
library unittests. The async start-point is `runAllTestsAsync` and must
be called from an async context. For now, that means calling through
async-main.
2021-04-14 15:04:56 -07:00
Konrad `ktoso` Malawski
5e0593f1d3 [Concurrency] detach should not take Failure type param 2021-04-15 06:59:35 +09:00
heoblitz
20ffc036ed Add whitespace to markup 2021-04-14 14:43:14 +09:00
Evan Wilde
6c7b2af580 Remove await from spawnUnlessCancelled
spawnUnlessCancelled is not an asynchronous function, so awaiting on it
in the standard library resulted in warnings.
2021-04-13 18:29:17 -07:00
Doug Gregor
f7fb5a1a9f Merge pull request #36874 from DougGregor/dynamic-data-race-actor-isolation
[Concurrency] Introduce runtime detection of data races.
2021-04-13 14:56:02 -07:00
Doug Gregor
b5e818b266 Don't use CompareObjectHandles on Windows 2021-04-13 10:29:00 -07:00
Doug Gregor
159ffcc5fd Fix silly error in our attempt at Windows support 2021-04-13 09:39:49 -07:00
Doug Gregor
f25369d69b Minor fixes 2021-04-13 08:35:44 -07:00
Joe Groff
aecb8f3c57 Merge pull request #36872 from jckarter/faster-main-exe-check-in-compat-hook
Compatibility50: Use __dso_handle for cheaper main executable check.
2021-04-13 08:04:36 -07:00
Doug Gregor
a722748681 More Windows workarounds 2021-04-13 00:52:26 -07:00