Commit Graph

7182 Commits

Author SHA1 Message Date
Dave Lee
41add6df9f [Debugging] Disable use of DebugDescriptionMacro when bootstrapping is off (#71820) 2024-02-22 16:21:24 -08:00
Allan Shortlidge
2a03207e54 Merge pull request #71802 from tshortli/typed-throws-in-inlinable-code
stdlib: Avoid condfails resulting from typed throws adoption
2024-02-22 14:03:26 -08:00
Mishal Shah
cb96ec2893 Merge remote-tracking branch 'origin/main' into bump-swift-version-to-6 2024-02-22 09:44:44 -08:00
Allan Shortlidge
25c0ed6008 stdlib: Avoid condfails resulting from typed throws adoption.
The standard library's swiftinterface must temporarily remain buildable when
`$TypedThrows` evaluates to false since there are still supported Swift 5.11
compilers that did not have the feature enabled by default. Declarations using
typed throws in their signatures are guarded in printed swiftinterface files
with `#if $TypedThrows` and therefore `@inlinable` code that uses those
declarations must also be conditionalized on `$TypedThrows`.
2024-02-21 20:38:39 -08:00
Guillaume Lessard
e90df7ef47 Merge pull request #71199 from glessard/utf8-license-header
[gardening] add a missing license header
2024-02-21 16:05:15 -08:00
Mishal Shah
b8cd763b21 Merge branch 'main' into bump-swift-version-to-6 2024-02-21 12:40:54 -08:00
Joe Groff
ce0a04393c Revert "Switch to malloc_good_size instead of malloc_size (#70532)"
This reverts commit 0843891eb9.
2024-02-21 10:26:37 -08:00
Dave Lee
5b35938e5b [Debug] Introduce use of DebugDescription macro in stdlib (#71425)
Introduces the first use of `@_DebugDescription` in the standard library, applying it 
to `ObjectIdentifier`. In order to use the DebugDescription macro in the stdlib, the 
following changes are required:

1. Compilation must reference the just built macros (ie `libSwiftMacros.dylib`), not 
those from the SDK. This is addressed by adding an explicit `-external-plugin-path` 
flag that overrides the defaults generated by the compiler (which uses SDK paths, where 
the macro may or may not exist, and may not be the current version).
2. As DebugDescription uses `@_section`, compilation enables the `SymbolLinkageMarkers` 
feature.

Note that the use of DebugDescription is conditionally enabled for the following 
reasons:

1. Use is disabled in freestanding builds, where the stdlib macros are not built.
2. Use is temporarily disabled in Linux builds due to a dynamic loader issue that needs 
further investigation

The dynamic loader error causing issues with Linux CI is:
> swift-plugin-server: error while loading shared libraries: libswiftGlibc.so: cannot 
open shared object file: No such file or directory

This PR depended on #71639, #71588, and #71685.
2024-02-21 09:17:10 -08:00
Oscar Byström Ericsson
9abed8c833 FlattenSequence/distance(from:to:) enhancements v3.
A half-open range is a better expression of intent.
2024-02-21 09:59:54 +01:00
David Smith
f1feba0e42 Eytzingerize word break data (#71731)
Switch word break property searching to Eytzinger binary search
2024-02-20 22:49:34 -08:00
Mishal Shah
b488702cc9 Merge remote-tracking branch 'origin/main' into bump-swift-version-to-6 2024-02-20 21:04:47 -08:00
Mishal Shah
96d61d3c5c Merge remote-tracking branch 'origin/main' into bump-swift-version-to-6 2024-02-20 14:31:55 -08:00
Dave Lee
b79c4ded76 [Debugging] Expand DebugDescriptionMacro docstring (#71700)
Describe more details of `DebugDescriptionMacro`.
2024-02-20 10:28:31 -08:00
nate-chandler
3fa784920c Merge pull request #71736 from nate-chandler/add-missing-flag
Add missing guard around new builtin.
2024-02-19 23:06:56 -08:00
Mishal Shah
af112c1591 Update the Swift version to 6.0 from 5.11 2024-02-19 17:47:16 -08:00
Nate Chandler
1906b28f2b Add missing guard around new builtin.
Avoid a condfail.
2024-02-19 16:04:29 -08:00
Alejandro Alonso
1f4bdd4bc9 Merge pull request #71481 from Azoy/fast-nfc-check-fix
[stdlib] Do a fast NFC check over the slice instead of guts
2024-02-19 15:19:08 -08:00
David Smith
ea7d07714f Switch grapheme break property searching to Eytzinger binary search (#71668) 2024-02-16 16:06:20 -08:00
Oscar Byström Ericsson
e7b9fbbe12 FlattenSequence/distance(from:to:) enhancements v2.
1. The unchecked and force-unwrapped stuff did not matter.
2. Calling distance(from:to:) is a bit faster than SubSequence/count.
2024-02-16 11:41:10 +01:00
Nate Chandler
60d7ff80c7 [stdlib] Used storeRaw for constrained storeBytes.
Implement the overload of storeBytes where value is constrained to
BitwiseCopyable via Builtin.storeRaw.
2024-02-15 18:05:16 -08:00
Oscar Byström Ericsson
11c0231d20 FlattenSequence/distance(from:to:) enhancements.
I was looking through Swift's issues tab and found this issue (#57496), which points out the poor performance of `FlattenSequence/count`. The current `count` implementation calls `distance(from:to:)`, which iterates through the entire collection, so I thought I'd improve that method. The new version computes the distance as the sum of three parts, with a fast path when both indices belong to the same underlying collection. Note that it does this by calling either `count` or `distance(from:to:)` on each underlying collection, which makes `[repeatElement(0, count: Int.max)].joined().count` instant, for example.
2024-02-15 12:45:42 +01:00
Nate Chandler
5a2d1621ec [KeyPath] Restrict push and pop to BitwiseCopyable
Promotes the runtime isPOD check to a compile time constraint.
2024-02-14 13:02:09 -08:00
Nate Chandler
134fc4dfdd [stdlib] BitwiseCopyable storeBytes overload.
The new overload is constrained to BitwiseCopyable and so enjoys the use
of BitwiseCopyableArchetypeTypeInfo.
2024-02-14 13:02:09 -08:00
Erik Eckstein
75e2f363a0 embedded stdlib: make the ManagedBuffer initializer public in the embedded stdlib
Otherwise derived classes cannot be specialized.

Fixes a compile time error when using ManagedBuffer in embedded mode.
rdar://122414669
2024-02-14 09:51:43 +01:00
Alejandro Alonso
aadf4a13a2 Do a fast NFC check over the slice instead of guts 2024-02-08 10:50:03 -08:00
Alejandro Alonso
3923e2e621 Merge pull request #71443 from Azoy/fix-specialize-function
[stdlib] Fix _specialize implementation
2024-02-07 15:46:38 -08:00
Guillaume Lessard
71640be109 Merge pull request #71363 from glessard/rdar115296219
[stdlib] properly rename validatingUTF8 to validatingCString
2024-02-07 14:37:23 -08:00
Alejandro Alonso
71fccd1696 Fix _specialize implementation 2024-02-07 11:58:57 -08:00
Doug Gregor
e4d6bee153 Merge pull request #71400 from DougGregor/will-throw-typed
Implement `swift_willThrow` variant for typed throws.
2024-02-06 03:22:22 -08:00
Kuba (Brecka) Mracek
ea6295e47f Merge pull request #71392 from kubamracek/revert-embedded-defines
Revert "Merge pull request #71278 from kubamracek/embedded-no-mach-defines"
2024-02-05 17:48:40 -08:00
Doug Gregor
3fa07a0e7a Implement swift_willThrow variant for typed throws.
`swift_willThrow` is called with an error right before it is thrown.
This existing entrypoint requires an already-boxed error existential;
with typed errors, we don't have the error existential on hand, so we
would need to allocate the box to throw a typed error. That's not okay.

Introduce a new `swift_willThrowTypedImpl` entry point into the runtime
that will first check for the presence of an error handler and, if one
is present, box the error to provide to the error handler. This
maintains the no-allocations path for typed errors while still
allowing existing error handlers to work.

This new entrypoint isn't available on older Swift runtimes, so create
a back-deployable shim called by the compiler. On new-enough platforms,
this will call through to `swift_willThrowTypedImpl`. On older
platforms, we drop the error and don't call the registered will-throw
handler at all. This is a compromise that avoids boxing when throwing
typed errors, at the cost of a slightly different experience for this
new feature on older runtimes.

Fixes rdar://119828459.
2024-02-05 15:06:55 -08:00
Kuba Mracek
dba8d5d3a0 Revert "Merge pull request #71278 from kubamracek/embedded-no-mach-defines"
This reverts commit 21eddf0b1a, reversing
changes made to e2d516f3c9.
2024-02-05 09:05:22 -08:00
Guillaume Lessard
da5b41a0f8 [stdlib] properly rename validatingUTF8 to validatingCString
https://github.com/apple/swift/issues/68433 was fixed
in commit d19f082665.
2024-02-03 16:19:04 -08:00
Oscar Byström Ericsson
d7b3d3e319 Minor advanced(by:) enhancement. 2024-02-03 15:18:02 +01:00
Oscar Byström Ericsson
17187e38f5 This patch fixes two unnecessary traps in BinaryInteger's advanced(to:) method.
- `Int8.min.advanced(by: 128)`, etc.
- `UInt.max.advanced(by: Int.min)`, etc.
2024-02-03 13:56:33 +01:00
Kavon Farvardin
b67ace7de1 Merge pull request #71137 from kavon/ncgenerics-enable-stdlib-v1
NCGenerics: synthesize Copyable/Escapable decls
2024-02-02 21:16:14 -08:00
Kuba (Brecka) Mracek
21eddf0b1a Merge pull request #71278 from kubamracek/embedded-no-mach-defines
[embedded] Implicitly define __APPLE__ and __MACH__ when on -apple-none triples
2024-02-02 19:30:56 -08:00
Kavon Farvardin
3908c8182d NCGenerics: sometimes synth. Copyable/Escapable
When the Swift module is not available, we'll synthesize the
Copyable/Escapable decls into the Builtin module.

In the future, it might be nice to just do this always, and define
typealiases for those types in the stdlib to refer to the ones in the
builtin module.
2024-02-02 18:47:03 -08:00
Guillaume Lessard
0ec6397053 Merge pull request #71224 from glessard/rdar121395821
[stdlib] Improve documentation for the various "String from C-string" initializers
2024-02-02 12:17:50 -08:00
Guillaume Lessard
114f235d17 Merge pull request #71167 from vanvoorden/vanvoorden/inclusive-language
[Inclusive Language][Comments][Documentation] migrate "sanity" checks to "soundness" checks
2024-02-02 10:27:34 -08:00
Guillaume Lessard
e10899eff7 [stdlib] tweak deprecation message 2024-02-01 15:34:18 -08:00
Guillaume Lessard
11485e5026 [doc] fix note visibility for docc-generated pages 2024-02-01 15:34:18 -08:00
Guillaume Lessard
a74b5b7b3c [stdlib] make parameter label the same as in peer functions
These functions were the odd ones out in not using `encoding` for this parameter label. Harmonizing this term will also make the documentation more consistent.
2024-02-01 15:34:18 -08:00
Guillaume Lessard
048a948f12 [stdlib] document some deprecated initializers 2024-02-01 15:34:18 -08:00
Guillaume Lessard
e3ede3ad3a [stdlib] improve phrasing in some doc-comments 2024-02-01 15:34:18 -08:00
Guillaume Lessard
ae9892d46b [stdlib] remove useless annotations 2024-02-01 15:34:18 -08:00
Guillaume Lessard
047092a0a5 [stdlib] mark deprecated in swift 6, point to better API 2024-02-01 15:34:18 -08:00
Guillaume Lessard
4c00395b66 [stdlib] fix preconditionFailure message 2024-02-01 15:34:18 -08:00
Nate Chandler
367d71d74f Revert "[stdlib] Uncheck pointers' conf to BitwiseCopyable"
This reverts commit 4dc9713a7a.
2024-01-31 17:11:54 -08:00
Kuba Mracek
e22aedbcc3 [embedded] Implicitly define __APPLE__ and __MACH__ when on -apple-none triples 2024-01-31 09:22:31 -08:00