Commit Graph

21434 Commits

Author SHA1 Message Date
Yuta Saito
c32c7f55fe [wasm] Fix build failure due to lack of _Float16 support
WebAssembly does not support _Float16 type, so we need to guard the use
of the type. Unfortunately, Clang does not provide a good way to detect
the support of _Float16 type at compile time, so just disable for wasm
targets.
2024-04-07 16:34:11 +00:00
Kuba (Brecka) Mracek
70afeef480 Merge pull request #70944 from kubamracek/volatile
Add experimental _Volatile module providing low-level primitives for MMIO
2024-04-05 23:42:27 -07:00
Saleem Abdulrasool
2de6442e93 Merge pull request #72785 from compnerd/error-storage
Runtime: add a non-Darwin error message storage
2024-04-06 12:03:12 +09:00
Stephen Canon
6ac852f3f4 Move Float16 print tests to their own file and test exhaustively (#72859)
We can easily test all 2**16 values, so let's do it. Also now _Float16 is properly supported in clang, so we can pass arguments to CPP that way, which lets us get snan right on more platforms.
2024-04-05 19:55:19 -04:00
Kuba Mracek
1c66aeaa22 [Volatile] Mark VolatileMappedRegister as @frozen, transparent init, allow NULL pointer 2024-04-05 15:13:36 -07:00
Kuba Mracek
e722fc70d7 [Volatile] Rename UnsafeVolatilePointer to VolatileMappedRegister, use 'unsafe' name in initializer 2024-04-05 15:13:03 -07:00
Kuba Mracek
81f8b2a8cd [Volatile] Remove extensions on UnsafeMutablePointer 2024-04-05 15:13:03 -07:00
Kuba Mracek
90c8a8e90e Add experimental _Volatile module providing low-level primitives for MMIO 2024-04-05 15:13:03 -07:00
Allan Shortlidge
da3c12e17b Merge pull request #72871 from tshortli/extension-import-visibility
stdlib: Adopt `ExtensionImportVisibility` experimental feature
2024-04-05 14:41:11 -07:00
Saleem Abdulrasool
32a2dfc566 Runtime: add a non-Darwin error message storage
This introduces a non-Darwin (non-CrashReporter) storage for error
messages to allow extraction for crash reporting. This is initially
meant to be used on Windows, though it is generic enough to be used on
any platform.
2024-04-05 14:02:09 -07:00
Mike Ash
2841b5944a Merge pull request #72870 from mikeash/libprespecialize-address-range-rejection
[Runtime] Don't attempt to look up prespecialized metadata involving pointers outside the shared cache.
2024-04-05 14:31:04 -04:00
Alastair Houghton
6932f9e02d Merge pull request #72833 from al45tair/eng/PR-125727356
[Runtime] Disable prespecialized metadata if we have overridden images.
2024-04-05 17:49:36 +01:00
Allan Shortlidge
78cd1149bd stdlib: Adopt ExtensionImportVisibility experimental feature.
This didn't expose any missing imports in the sources of any of the standard
library modules, but that's not entirely surprising. Still, we should have the
feature enabled to test it and prevent regressions from creeping in before the
behavior becomes the default.

Exclude `ExtensionImportVisibility` from module interfaces.
2024-04-05 09:22:02 -07:00
Mike Ash
98229fe4db [Runtime] Don't attempt to look up prespecialized metadata involving pointers outside the shared cache.
The descriptor and arguments for prespecialized metadata will always be in the shared cache. Skip creating the mangling for any lookup involving pointers outside the shared cache, as an optimization.
2024-04-05 10:19:34 -04:00
Kuba (Brecka) Mracek
1371a8ca66 Merge pull request #72769 from kubamracek/embedded-concurrency-none
[embedded] Default Embedded Concurrency to SWIFT_THREADING_PACKAGE=none
2024-04-05 06:53:34 -07:00
Konrad `ktoso` Malawski
dfcf1054dd [Concurrency] Remove _unsafeInheritExecutor from public APIs, use #isolation (#72578) 2024-04-05 03:57:54 -07:00
Konrad `ktoso` Malawski
3295ddd200 [Concurrency] waitForAll and next of TaskGroups must inherit isolation (#72794) 2024-04-04 23:49:05 -07:00
Anton Korobeynikov
c7a216058f [AutoDiff] First cut of coroutines differentiation (#71461)
This PR implements first set of changes required to support autodiff for coroutines. It mostly targeted to `_modify` accessors in standard library (and beyond), but overall implementation is quite generic.

There are some specifics of implementation and known limitations:
 - Only `@yield_once` coroutines are naturally supported
 - VJP is a coroutine itself: it yields the results *and* returns a pullback closure as a normal return. This allows us to capture values produced in resume part of a coroutine (this is required for defers and other cleanups / commits)
 - Pullback is a coroutine, we assume that coroutine cannot abort and therefore we execute the original coroutine in reverse from return via yield and then back to the entry
 - It seems there is no semantically sane way to support `_read` coroutines (as we will need to "accept" adjoints via yields), therefore only coroutines with inout yields are supported (`_modify` accessors). Pullbacks of such coroutines take adjoint buffer as input argument, yield this buffer (to accumulate adjoint values in the caller) and finally return the adjoints indirectly.
 - Coroutines (as opposed to normal functions) are not first-class values: there is no AST type for them, one cannot e.g. store them into tuples, etc. So, everywhere where AST type is required, we have to hack around.
 - As there is no AST type for coroutines, there is no way one could register custom derivative for coroutines. So far only compiler-produced derivatives are supported
 - There are lots of common things wrt normal function apply's, but still there are subtle but important differences. I tried to organize the code to enable code reuse, still it was not always possible, so some code duplication could be seen
 - The order of how pullback closures are produced in VJP is a bit different: for normal apply's VJP produces both value and pullback closure via a single nested VJP apply. This is not so anymore with coroutine VJP's: yielded values are produced at `begin_apply` site and pullback closure is available only from `end_apply`, so we need to track the order in which pullbacks are produced (and arrange consumption of the values accordingly – effectively delay them)
 - On the way some complementary changes were required in e.g. mangler / demangler

This patch covers the generation of derivatives up to SIL level, however, it is not enough as codegen of `partial_apply` of a coroutine is completely broken. The fix for this will be submitted separately as it is not directly autodiff-related.

---------

Co-authored-by: Andrew Savonichev <andrew.savonichev@gmail.com>
Co-authored-by: Richard Wei <rxwei@apple.com>
2024-04-04 17:24:55 -07:00
Kuba Mracek
dcb60ab2d6 [embedded] Build even -macos Embedded Concurrency as THREADING=none, update dependency list 2024-04-04 15:37:55 -07:00
Meghana Gupta
b3b2f37262 Merge pull request #72822 from stephentyrone/a-a-ambiguity-breaker-part-ii
Further ambiguity breakers for UDC & SEDC
2024-04-04 15:10:59 -07:00
Kuba Mracek
a79e4347ab [embedded] Default Embedded Concurrency to single-threaded 2024-04-04 15:07:47 -07:00
Kuba (Brecka) Mracek
a263bca690 Merge pull request #72772 from kubamracek/embedded-concurrency-deps
[embedded] Add a test checking the dependencies of Embedded Concurrency runtime
2024-04-04 11:04:04 -07:00
Alastair Houghton
419214daf9 [Runtime] Disable prespecialized metadata if we have overridden images.
We need to check for overridden images on every image load, otherwise
XCTest (among others) may `dlopen()` an image that pulls in something
that is overridden, at which point the prespecialized metadata won't
match the image we loaded.

rdar://125727356
2024-04-04 16:20:12 +01:00
Alejandro Alonso
36569ea6b6 Merge pull request #72821 from Azoy/keypath-null-bad
[stdlib] Print a special message when we fail getting a keypath value
2024-04-03 19:56:02 -07:00
Kavon Farvardin
e759a28f56 Merge pull request #72786 from kavon/ncgenerics-associatedtype-restriction
NCGenerics: introduce `SuppressedAssociatedTypes`
2024-04-03 16:28:54 -07:00
Stephen Canon
cb400c61bb Add further ambiguity breakers for UDC & SEDC 2024-04-03 18:47:19 -04:00
Alejandro Alonso
e71a55eb19 Print a special message when we fail getting a keypath value 2024-04-03 15:35:55 -07:00
Stephen Canon
cbf9cb2734 Break ambiguity for types conforming to both UEC and SVEC (#72800)
* Break ambiguity for types conforming to both UEC and SVEC

If an encoding container conforms to _both_ UEC and SVEC and does not
itself implement support for [U]Int128, there is an ambiguity between
the two default implementations. Add additional defaults defined on
the intersection of the protocols to resolve this.

* Update abi tests for new ambiguity breakers.
2024-04-03 16:53:48 -04:00
Doug Gregor
e5d7885fc8 Merge pull request #72788 from DougGregor/metadata-runtime-inverse-conformances-assoctype
Runtime checking for associated types conforming to invertible protocols
2024-04-03 08:30:50 -07:00
Michael Gottesman
302b0101e6 Merge pull request #72763 from gottesmm/pr-d6b1f7e0bfc91f3d28ecf7bd100f45f41533688a
[region-isolation] Require T in assumeIsolated<T> to be Sendable.
2024-04-02 23:46:59 -07:00
Ben Barham
293a4341c9 Merge pull request #72744 from bnbarham/rename-endswith
Rename `StringRef::endswith` references to `StringRef::ends_with`
2024-04-02 20:08:01 -07:00
Kavon Farvardin
30983530b6 NCGenerics: introduce SuppressedAssociatedTypes
The model for associated types hasn't been fully worked-out for
noncopyable generics, but there is some support already that is being
used by the stdlib for an internal-only (and rather cursed) protocol
`_Pointer` to support `UnsafePointer`, etc.

This patch gates the existing experimental support for associated types
behind a feature flag. This flag doesn't emit feature-guards in
interfaces, since support for it is tied closely to NoncopyableGenerics
and has been there from its early days.
2024-04-02 16:53:36 -07:00
Doug Gregor
ae01d20428 Runtime checking for associated types conforming to invertible protocols
Emit metadata for runtime checks of conformances of associated types to
invertible protocols, e.g., `T.Assoc: Copyable`. This allows us to
correctly handle, e.g., dynamic casting involving conditional
conformances that have such constraints.

The model we use here is to emit an invertible-protocol constraint
that leaves only the specific bit clear in the invertible protocol
set.
2024-04-02 16:42:16 -07:00
Michael Gottesman
cf93476d0b [region-isolation] Require T in assumeIsolated<T> to be Sendable.
I had to change the APIs to always be always emit into client instead of back
deployable since silgen_name seems to interfere with @backDeployment. So I
switched the implementation so that it instead uses an always emit into client
thunk with the in source function name and a usableFromInline function that has
the silgen_name. This ensures that we still appropriately export the same symbol
as we did before, so it is ABI stable.

This was approved as part of se-0414.

rdar://122030520
2024-04-02 13:49:13 -07:00
Stephen Canon
a381589524 SE-0425 implementation (#72139) 2024-04-02 16:24:41 -04:00
Kuba Mracek
280123cb10 [embedded] Add a test checking the dependencies of Embedded Concurrency runtime 2024-04-02 10:33:33 -07:00
Ben Barham
1fdda023b3 Rename StringRef::endswith references to StringRef::ends_with
Missed this when doing the `startswith` renaming. `endswith` has also
been deprecated upstream (and presumably soon to be removed).
2024-04-01 10:59:16 -07:00
Yuta Saito
132ba8950b [Concurrency] Fix signature mismatch of _task_serialExecutor_checkIsolated
`_task_serialExecutor_checkIsolated` is defined as returning nothing in
`Executor.swift`, but it was used as returning a boolean in C++ side.
2024-03-31 04:48:50 +00:00
Kuba Mracek
a35db85e82 [embedded] Build the macOS Embedded Stdlib with a recent deployment target 2024-03-29 16:10:35 -07:00
Doug Gregor
989d4ba40e Merge pull request #72698 from DougGregor/suppress-suppressible
Rename "suppressible protocols" to "invertible protocols".
2024-03-29 14:35:05 -07:00
Nate Cook
38e1370884 Revert "Revert count(where:)" (#70816)
* Revert "Revert count(where:)"

This reverts commit 779ea19a6a.

Now that SE-0220 has been re-accepted, this adds the `count(where:)` 
Sequence method to the standard library.
2024-03-29 13:53:53 -05:00
Doug Gregor
b84f8ab080 Rename "suppressible protocols" to "invertible protocols".
We've decided to use the "invertible protocols" terminology throughout
the runtime and compiler, so move over to that terminology
consistently.
2024-03-29 11:31:48 -07:00
Doug Gregor
fb584f8934 Merge branch 'main' into async-sequence-fixes 2024-03-28 16:01:54 -07:00
Konrad `ktoso` Malawski
86f5441294 [SerialExecutor] SerialExecutor.checkIsolated() to check its own tracking for isolation checks (#71172) 2024-03-29 07:06:34 +09:00
Joe Groff
233c1675cf Merge pull request #72647 from jckarter/borrowing-switch-expr-based-ownership
Alternative noncopyable switch design based on expression kind.
2024-03-28 14:44:16 -07:00
Alejandro Alonso
af11b95f4d Merge pull request #72656 from weissi/jw-fix-json
fix GroupInfo.json: was invalid JSON
2024-03-28 13:31:23 -07:00
Doug Gregor
a8f3bb5e5e Implement AsyncIteratorProtocol.next() in terms of next(isolation:).
New async iterators should be able to implement only `next(isolation:)` and
get the older `next()` implementation via a default. Implement the
appropriate default witness.

Fixes rdar://125447861.
2024-03-28 12:59:12 -07:00
Alejandro Alonso
07eb52a80d Merge pull request #72636 from Azoy/destroy-array-opt
[IRGen] Optimize Builtin.arrayDestroy when count is 1
2024-03-28 11:32:43 -07:00
Eric Miotto
93d64e973d Merge pull request #72590 from edymtt/edymtt/no-darwin-binary-swiftmodule-in-toolchain
Do not install binary swiftmodule for Darwin
2024-03-28 09:22:32 -07:00
Joe Groff
ba3494802a Alternative noncopyable switch design based on expression kind.
If an expression refers to noncopyable storage, then default to performing
a borrowing switch, where `let` bindings in patterns borrow out of the
matched value. If an expression refers to a temporary value or explicitly
uses the `consume` keyword, then perform a consuming switch, where
`let` bindings take ownership of corresponding parts of the matched value.
Allow `_borrowing` to still be used to explicitly bind a pattern variable
as a borrow, with no-implicit-copy semantics for copyable values.
2024-03-28 08:32:48 -07:00