Commit Graph

7802 Commits

Author SHA1 Message Date
Guillaume Lessard
148a7e2eff [stdlib] make __SharedStringStorage able to own a pointer 2023-12-21 10:44:52 -08:00
Guillaume Lessard
566fbf4fec [se-0405] update availability to a realistic release target 2023-12-21 10:44:52 -08:00
Guillaume Lessard
92df9b4bdb Apply suggestions from code review
Co-authored-by: Ben Rimmington <me@benrimmington.com>
2023-12-21 10:44:52 -08:00
Guillaume Lessard
f7006880c7 [se-0405] adapt implementation from staging package 2023-12-21 10:44:52 -08:00
Kuba Mracek
bde23e2c2f [embedded] Avoid using reinterpretCast in set bridging 2023-12-20 14:39:38 +01:00
Kuba Mracek
29a7c52433 [embedded] #if the entire _BridgeStorage struct instead of sprinkling a bunch of #ifs inside 2023-12-20 14:32:48 +01:00
Kuba Mracek
25f971d344 [embedded] Add explaining comment about _swiftEmptyArrayStorage/_swiftEmptySetSingleton 2023-12-20 14:08:16 +01:00
Kuba Mracek
943c7c2ee5 [embedded] Drop 'public' from forward declaration of arc4random_buf 2023-12-20 14:04:35 +01:00
Allan Shortlidge
9a0eb73302 Merge pull request #70547 from tshortli/diagnose-unreachable-cant-back-deploy
AST/SILGen: Use @_alwaysEmitIntoClient diagnostic helper in unavailable code
2023-12-20 00:16:29 -08:00
Stephen Canon
154454e16a Use specialized [u]int64 -> FloatingPoint conversions even on 32b platforms. (#70541)
This means that we'll end up going int32 -> int64 -> float/double sometiems, but LLVM knows how to optimize away the intermediate conversion so we end up with just a normal 32b->float conversion as desired, and we get much, much better performance on oddball platforms like arm64_32.
2023-12-19 20:29:30 -05:00
Allan Shortlidge
6d22433d0f AST/SILGen: Use @_alwaysEmitIntoClient diagnostic helper in unavailable code.
The `_diagnoseUnavailableCodeReached()` function was introduced in the Swift
5.9 standard library and employs `@backDeployed` to support compilation of
binaries that target OS releases aligned with earlier Swift releases.
Unfortunately, though, this backdeployment strategy doesn't work well for some
unusual build environments. Specifically, in some configurations code may be
built with a compiler from a recent Swift toolchain and then linked against the
dylibs in an older toolchain. When linking against the older dylibs, the
`_diagnoseUnavailableCodeReached()` function does not exist but the
`@backDeployed` thunks emitted into the binary reference that function and
therefore linking fails.

The idea of building with one toolchain and then linking to the dylibs in a
different, older toolchain is extremely dubious. However, it exists and for now
we need to support it. This PR introduces an alternative
`_diagnoseUnavailableCodeReached()` function that is annotated with
`@_alwaysEmitIntoClient`. Calls to the AEIC variant are now emitted by the
compiler when the deployment target is before Swift 5.9.

Once these unusual build environments upgrade and start linking against a Swift
5.9 toolchain or later we can revert all of this.

Resolves rdar://119046537
2023-12-19 16:26:56 -08:00
Alejandro Alonso
f96ed95b8a Remove some hold over in core 2023-12-18 14:01:16 -05:00
Alejandro Alonso
2c0b473b8d Add Synchronization module 2023-12-18 14:01:16 -05:00
Alejandro Alonso
87974a83af Some documentation work, some work from review, add tests 2023-12-18 14:01:16 -05:00
Alejandro Alonso
6d6e55a931 Apply feedback from pitch 2023-12-18 14:01:15 -05:00
Alejandro Alonso
f747162084 Implement the Atomic type 2023-12-18 14:01:15 -05:00
Doug Gregor
82ebc54857 Merge pull request #70520 from DougGregor/no-opaque-parameters-in-stdlib
Don't use opaque parameters in the standard library
2023-12-18 10:33:25 -08:00
Doug Gregor
3b4e37e5fe Don't use opaque parameters in the standard library
The SIL printer is printing opaque parameters as <anonymous>, which
breaks the SIL parser. Stop using opaque parameters in the standard
library for the moment to unbreak SIL parsing of the standard library.
2023-12-18 10:14:57 -08:00
Doug Gregor
6536f57ab5 Merge pull request #70516 from DougGregor/typed-throw-try-bang
[Typed throws] Terminate with an error message for typed try! failures.
2023-12-17 02:41:48 -08:00
Doug Gregor
d740965753 [Typed throws] Terminate with an error message for typed try! failures. 2023-12-16 23:58:51 -08:00
Kavon Farvardin
b43f861827 [NCGenerics] delete _Copyable from stdlib
resolves rdar://115793371
2023-12-16 11:17:31 -08:00
Kuba Mracek
490ffe28f7 [embedded] Fix build of the stdlib, avoid changing non-embedded codepaths in BridgeStorage.swift 2023-12-13 17:39:42 -08:00
Rose
9998161e97 Prevent modulo in places where we can check the length
NFC.

We know maxLength must be positive and non-zero, and therefore, i += 1 will be the next index until we reach maxLength, in which case the result is 0. Rather than perform a modulo, which requires division, every time, we can just reset i when it reaches the end of the buffer.
2023-12-13 19:13:54 -05:00
Kuba Mracek
d3849fe843 [embedded] Use @_extern(c) instead of @_silgen_name on arc4random_buf 2023-12-13 11:28:17 -08:00
Kuba Mracek
2f0883ab24 [embedded] Add Set to the embedded stdlib 2023-12-13 11:28:17 -08:00
Kuba (Brecka) Mracek
4f592f0022 Merge pull request #70407 from kubamracek/embedded-placeholders
[embedded] Fix editor placeholders by adding a StaticString variant of _undefined
2023-12-13 09:00:10 -08:00
Erik Eckstein
e4ea7491a2 IRGen: fix and re-enable static read-only arrays
Static read-only arrays didn't work when passed to ObjectiveC as NSArray.
The storage class of static read-only arrays doesn't carry information about the Element type.
The new `__SwiftDeferredStaticNSArray` is generic over the element type and doesn't have to rely on the element type information of the array storage.

rdar://94185998
2023-12-13 11:45:01 +01:00
Dave Lee
a56c89f97e [Debug] Conditional _DebugDescription macro declaration (#70351)
Make `_DebugDescription` macro conditional upon macro availability in the build.

The `Macros` feature is based on the value of `SWIFT_BUILD_SWIFT_SYNTAX`.

See https://github.com/apple/swift/pull/69626#issuecomment-1848221971
2023-12-12 15:19:49 -08:00
Kuba Mracek
8ee33d2260 [embedded] Use #if instead of unavailability for _undefined 2023-12-12 13:06:16 -08:00
Kuba Mracek
996f51e3be [embedded] Fix editor placeholders by adding a StaticString variant of _undefined 2023-12-12 11:04:14 -08:00
eeckstein
484fc77a8c Merge pull request #70301 from eeckstein/fixed-array
Add experimental support for fixed arrays
2023-12-11 09:36:29 +01:00
Kavon Farvardin
a4a6c69e97 Merge pull request #70277 from kavon/inverse-escapable
[NCGenerics] add `~Escapable`
2023-12-10 05:42:24 -08:00
Kavon Farvardin
e99ce1cc5d [NCGenerics] add ~Escapable
Basic implementation of `~Escapable` in the type system.

rdar://119216918
2023-12-10 01:25:43 -08:00
Erik Eckstein
43c4fce773 stdlib: make Array.count an array semantic function
So far the semantic annotation was just added to the internal `_getCount` function.
But for FixedArray it is also required to add the `@_semantics("array.get_count")` to the public API.
2023-12-09 18:49:58 +01:00
Erik Eckstein
dd9ce40ba1 add the allocVector builtin 2023-12-09 18:49:57 +01:00
Dave Lee
ad585b3195 [Debug] Add _DebugDescription macro (#69626)
Implementation of the DebugDescription macro pitched on the forums: 
https://forums.swift.org/t/pitch-debug-description-macro/67711. In this initial commit, 
the macro is named `_DebugDescription` to indicate it's internal use at this time, 
pending Swift Evolution.

rdar://115180949
2023-12-08 15:19:16 -08:00
Stephen Canon
d66f233839 Add concrete overload for != on all stdlib integer types. (#70043)
* Add concrete overload for  on all stdlib integer types.

* Add very basic tests for type inference of comparands.

* Add a comment explaining why these overloads are present.
2023-12-06 16:40:16 -05:00
Nate Chandler
b7f5171b83 [stdlib] BitwiseCopyable loadUnaligned overloads.
The new overloads will make use the new BitwiseCopyableArchetypeTypeInfo
to avoid the extra copy that is currently done.
2023-12-05 17:21:05 -08:00
Kavon Farvardin
b6c7ff4140 Merge pull request #70142 from kavon/ncgenerics-stdlib-workarounds
[stdlib] add missing `Element` type witnesses
2023-12-01 10:47:05 -08:00
nate-chandler
54a152f284 Merge pull request #69938 from nate-chandler/rdar96919870/1/bitwise-copyable-protocol
[BitwiseCopyable] Add a marker protocol.
2023-12-01 06:57:11 -08:00
Nate Chandler
b266abe5c0 [BitwiseCopyable] Add a marker protocol.
Behind the experimental feature BitwiseCopyable.
2023-11-30 15:25:46 -08:00
Kavon Farvardin
4096ca39b2 [stdlib] add missing Element type witnesses
With `NoncopyableGenerics` enabled, we currently lose some ability for
associatedtype inference to find a suitable type witness based on a
value witness. (rdar://118998138)

The stdlib accidentally uses that inference for Sequence.Element,
due to the default witness for `_customContainsEquatableElement`
mentioning `Iterator.Element` whereas the requirement only states
`Element`.
2023-11-30 15:05:20 -08:00
Kuba Mracek
fa7da75cdc [embedded] Port and start building Darwin.swiftmodule as embedded 2023-11-27 20:16:58 -08:00
Doug Gregor
3baf6ac31a Revert "[Typed throws] Support overrides that are contravariant in the thrown error" 2023-11-16 10:40:23 -08:00
Doug Gregor
5db3685e1c [Existential collections] Switch internal _map rethrows methods to throws
These class methods are internal, but because they are overridden and are
part of a `@usableFromInline`, `@_fixed_layout` class, we they can't be
moved over to typed throws without breaking ABI. However, they are
only ever called from typed-throws functions, which already need a
do...catch dance to downcast the error itself. Make them `throws`
instead, which is ABI-compatible, but eliminates the need for
do...catch hackery in the function itself.
2023-11-13 11:47:00 -08:00
Doug Gregor
1892396e14 Improve ABI-only rethrowing map shims based on code review
Replace the hackish use of `@_disfavoredOverload` with the more principled
use of `@_silgen_name` for the entrypoint we are maintaining, then rename
these functions in source to `__rethrows_map` to indicate what they're for.

While here, make them `throws` instead of `rethrows`. The ABI is the
same, and `throws` allows us do avoid to do/catch tricks with rethrows
functions.
2023-11-13 11:47:00 -08:00
Doug Gregor
0d15d4edbe Replace rethrowing map with generic typed throws
Adopt typed throws for the `map` operation to propagate thrown error
types through the `map` API. This is done in a manner that is backward
compatible for almost all cases:

* The new typed-throws entrypoint is `@_alwaysEmitIntoClient` so it
can back-deploy all the way back.
* The old `rethrows` entrypoint is left in place, using
`@usableFromInline` with `internal` so it is part of the ABI but not
the public interface, and `@_disfavoredOverload` so the type checker
avoids it while building the standard library itself. The old
entrypoint is implemented in terms of the new one.

Note that the implementation details for the existential collection
"box" classes rely on method overriding of `_map` operations, and the
types are frozen, so  we don't get to change their signatures. However,
these are only implementations, not API: the actual API `map`
functions can be upgraded to typed throws.

Note that this code makes use of a known hole in `rethrows` checking
to allow calling between `rethrows` and typed throws. We'll need to do
something about this for source-compatibility reasons, but I'll follow
up with that separately.
2023-11-13 11:47:00 -08:00
Doug Gregor
c433740c08 Enable TypedThrows in the standard library build 2023-11-13 11:47:00 -08:00
eeckstein
1e9135f7cd Merge pull request #69718 from eeckstein/embedded-stdlib
Two small fixes for the embedded stdlib
2023-11-09 07:51:05 +01:00
Alejandro Alonso
16cbb76fc6 Merge pull request #69710 from Azoy/stdlib-warning-cleanup
[stdlib] Silence some standard library warnings
2023-11-08 20:09:13 -08:00