Commit Graph

7182 Commits

Author SHA1 Message Date
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
Alejandro Alonso
e41fe5a173 Special case some unknown builtin macros 2023-11-08 16:02:31 -08:00
Alejandro Alonso
3deacf8944 Fix backwards iteration of word breaking 2023-11-08 13:26:20 -08:00
Yuta Saito
7df19b86ea [stdlib] Fix calling convention mismatch for debugger utility functions (#69352)
This is the 3rd attempt to fix the mismatch, where the actual definition
(e.g. `swift_retainCount`) are defined with C calling-convention and the
callers wrongly expect Swift calling-convention.

The 1st fix broke ABI compatibility by introducing new symbol references
from app-side without any availability checks.
The 2nd fix broke lldb's retain counting feature due to new x-ref to
Clang module in serialized function body by `@_alwaysEmitIntoClient`.

This attemps to avoid introducing serialized x-ref to Clang module by
using new `@_extern(c)` attribute.

Resolves rdar://113910821

Co-authored-by: Karoy Lorentey <klorentey@apple.com>
2023-11-08 10:45:28 -08:00
Erik Eckstein
c8db45907f EmbeddedRuntime: add swift_willThrow 2023-11-08 16:23:28 +01:00
Erik Eckstein
de6edc70e8 stdlib: build the embedded stdlib core with -enable-ossa-modules
As it is the case for the regular stdlib core
2023-11-08 14:01:25 +01:00
Alejandro Alonso
17c30f162d Merge pull request #69194 from karwa/patch-17
[NFC][In Both Senses] Use _NormData type instead of performing a lookup directly
2023-11-07 21:44:19 -08:00
Alejandro Alonso
31aed274c4 Silence some standard library warnings 2023-11-07 15:03:53 -08:00
Philippe Hausler
7a2c21d312 [Embedded] enable random APIs if a RandomNumberGenerator is provided, but leave system random number generators unavailable (#69645) 2023-11-03 21:12:22 -07:00
Kuba (Brecka) Mracek
9d846a07e1 Merge pull request #69498 from kubamracek/embedded-once-thread-safe
[embedded] Make embedded swift_once thread-safe
2023-11-02 08:58:21 -07:00
Kuba Mracek
95d5d71d51 [embedded] Add asserts on predicate value into swift_once 2023-10-30 09:10:30 -07:00
Kuba Mracek
b057417e52 [embedded] Make embedded swift_once thread-safe 2023-10-29 20:33:43 -07:00
Karoy Lorentey
7176bd386e [5.11][stdlib] Bump runtime version indicator to 5.11 2023-10-26 13:52:37 -07:00
Karoy Lorentey
02531db29b [5.10][stdlib] Bump runtime version indicator to 5.10
(cherry picked from commit 6181609559)
2023-10-26 13:50:56 -07:00
Nate Cook
2c244b9698 Fix precondition in UMRBP.initialize(as:fromContentsOf:)
This precondition checks to make sure that the content-providing
collection isn't larger than the allocated buffer, but was preventing
using a buffer that is the exact same size as the collection.
2023-10-25 17:17:36 -05:00
Arnold Schwaighofer
235c27b749 Don't keep generic versions of PtrAuth functions alive
We don't support generating code for ptrauth builtins with generic
inputs (or non-constant inputs). We rely on specialization/inlining for
such code to work.

After a recent commit (#68843 ) code in IRGen keeps internal unreferenced
functions alive for debugging purposes.

This is a problem for the generic functions in PtrAuth.swift using
ptrauth builtins.

Opt out of this new behavior by sprinkling some pixie dust.

Fixes debug swift standard library builds targeting arm64e.

rdar://117411740
2023-10-24 11:52:47 -07:00
Kyle
f96ae2f2db [Documentation] Fix UnsafeMutablePointer's documentation 2023-10-20 10:54:44 +08:00
Kuba (Brecka) Mracek
ed105d02f4 Merge pull request #69256 from kubamracek/embedded-arc-crash
[embedded] Fix an LLVMARCOpts crash by avoiding direct calls to swift_retain/swift_release
2023-10-19 09:14:30 -07:00
Kuba Mracek
db10e78eb2 [embedded] Start diagnosing metatype/value_metatype instructions in embedded Swift 2023-10-18 16:51:10 -07:00
Philippe Hausler
e9b01a35d8 [Embedded] Include OptionSet as part of the embedded build (#69197)
* [Embedded] Include OptionSet as part of the embedded build

* [Embedded] Include SetAlgebra as part of the embedded build
2023-10-18 15:49:08 -07:00
Kuba Mracek
6900efe42c [embedded] Fix an LLVMARCOpts crash by avoiding direct calls to swift_retain/swift_release 2023-10-18 14:44:18 -07:00