Commit Graph

21434 Commits

Author SHA1 Message Date
Nate Chandler
367d71d74f Revert "[stdlib] Uncheck pointers' conf to BitwiseCopyable"
This reverts commit 4dc9713a7a.
2024-01-31 17:11:54 -08:00
Mike Ash
590c33ed70 [Runtime] Correctly initialize side tables of immortal objects on 32-bit.
The code to copy the refcounts from the object to a new side table wasn't quite right on 32-bit. Fix it to copy the PureSwiftDealloc field, and if the object is immortal, mark the side table's refcount as immortal too.

rdar://121943608
2024-01-31 17:08:06 -05:00
Mike Ash
b8b59c4bac [ExternalGenericMetadataBuilder] Add a test that validates built metadata against the runtime.
We run the builder, then use a small program that converts the JSON output into C code that generates the data. Compile that into a bundle, then load it as the prespecializations library. Then scan all the entries in the table and compare them with what the runtime builds dynamically.
2024-01-31 17:03:27 -05:00
Michael Gottesman
42a4d2d0cd Merge pull request #71236 from gottesmm/pr-213cb762cfa24a27de8dc40f5c2929451d1825cb
[stdlib] Add an option SWIFT_STDLIB_ENABLE_STRICT_CONCURRENCY_COMPLETE to enable building the stdlib with strict-concurrency=complete.
2024-01-31 11:20:32 -08:00
Kuba Mracek
e22aedbcc3 [embedded] Implicitly define __APPLE__ and __MACH__ when on -apple-none triples 2024-01-31 09:22:31 -08:00
nate-chandler
a43faf89c8 Merge pull request #71242 from nate-chandler/bitwise-copyable/not-for-unchecked
[BitwiseCopyable] Don't derive on @unchecked field
2024-01-31 05:55:38 -08:00
Nate Chandler
c8119e3c01 [stdlib] FixedWidthInteger is BitwiseCopyable. 2024-01-30 14:38:07 -08:00
Nate Chandler
4c5d1006c4 [stdlib] SIMD extends BitwiseCopyable. 2024-01-30 14:38:07 -08:00
Nate Chandler
4dc9713a7a [stdlib] Uncheck pointers' conf to BitwiseCopyable
The pitch calls for such types to obstruct inference of _BitwiseCopyable
in aggregates containing them.
2024-01-30 14:38:07 -08:00
Ian Anderson
9a35f83e25 Merge pull request #71075 from ian-twilightcoder/no-exit-in-shims
[Concurrency] [shims] Don't declare `exit` in  the concurrency shims
2024-01-30 11:29:11 -08:00
Kuba (Brecka) Mracek
0655578718 Merge pull request #71226 from kubamracek/embedded-cdecls-runtime
[embedded] Fix calling convention on embedded runtime APIs (switch @_silgen_name for @_cdecl)
2024-01-30 09:24:17 -08:00
Michael Gottesman
2db4b5ca52 [stdlib] Add an option SWIFT_STDLIB_ENABLE_STRICT_CONCURRENCY_COMPLETE to enable building the stdlib with strict-concurrency=complete.
It is currently by default off.
2024-01-29 21:21:05 -08:00
Ian Anderson
288f37b2c1 [Concurrency] [shims] Don't declare exit in the concurrency shims
Don't delete the OS declaration of `exit` because the concurrency shims aren't always imported, and so the shim declaration might not always be available.
Don't override the OS declaration of `exit` in the concurrency shims since we can't just delete the OS one. Instead, set up internal shims just for building Concurrency that forward declares `exit`.
2024-01-29 16:25:46 -08:00
Kuba Mracek
6383d05ea1 [embedded] Fix calling convention on embedded runtime APIs (switch @_silgen_name for @_cdecl) 2024-01-29 15:37:46 -08:00
Konrad `ktoso` Malawski
bd19d937f0 [TaskExecutor] Remove underscore from new APIs (#71145) 2024-01-30 06:27:54 +09:00
Doug Gregor
0cc529768a Merge pull request #70635 from DougGregor/async-sequence-typed-throws
Adopt typed throws in AsyncIteratorProtocol and AsyncSequence
2024-01-29 11:51:25 -08:00
Doug Gregor
8f4adb3fd0 Merge pull request #71207 from DougGregor/typed-throws-in-main-type
Allow the main function for `@main` types to use typed throws
2024-01-29 11:38:08 -08:00
Ben Troller
5ed9f34761 Merge pull request #71168 from btroller/allow-remote-mirror-client-to-specify-whether-objc-interop-is-enabled
[RemoteMirror] Allow clients to specify whether Obj-C interop is enabled.
2024-01-29 09:54:42 -08:00
Eric Miotto
28e2f079b5 CMake: on Darwin be explicit about inclusion in the dyld shared cache (#70856)
This entails passing a linker flags to Apple linkers when the standard
library is not meant for inclusion in such cache.

For this to have effect on every library, propagate link flags when
building _Concurrency and Observation.

This is needed for Apple internal configurations.

Addresses rdar://120653968
2024-01-29 09:42:38 -08:00
Mike Ash
46ddceb7d4 Merge pull request #71184 from mikeash/libprespecialize-metadata-name-lookup
[Runtime] Do a proper hash table lookup in the prespecializations library.
2024-01-29 12:10:35 -05:00
Mike Ash
ccdcf6f27d Merge pull request #71201 from mikeash/libprespecialize-dyld-call-fix
[Runtime] Fix dyld call for Swift prespecialized data.
2024-01-29 10:23:44 -05:00
Saleem Abdulrasool
0dc8fbdb96 Merge pull request #70814 from compnerd/format
build: migrate to CMake based build of swift-format
2024-01-28 11:29:30 -08:00
Doug Gregor
da08b96371 Allow the main function for @main types to use typed throws
Allow the use of typed throws for the main functions of `@main` types,
and thread the thrown error through to a new entry point in the library,
`_errorInMainTyped`, which is generic in the thrown error type.

Fixes rdar://121603043.
2024-01-28 11:21:00 -08:00
Max Desiatov
50785b5fc7 Merge pull request #71203 from apple/maxd/embedded-x86-windows-triples
Add `i686-pc-windows-coff`/`x86_64-pc-windows-coff` embedded triples
2024-01-28 19:17:54 +00:00
Konrad `ktoso` Malawski
dfdbe457bf [Distributed] Support complex generic distributed actors in thunk gen (#70842) 2024-01-28 01:26:52 -08:00
Max Desiatov
670e8a8a2b Replace pc component with unknown in stdlib/CMakeLists.txt 2024-01-28 08:03:10 +00:00
Zev Eisenberg
5a67adde2d Clarify wording. (#71191)
“And” is a continuation of a prior statement. “But” is a negation of a prior statement.
2024-01-28 15:56:13 +09:00
David Smith
0843891eb9 Switch to malloc_good_size instead of malloc_size (#70532)
Switch to malloc_good_size instead of malloc_size
2024-01-27 19:20:33 -08:00
Guillaume Lessard
6b328f9c07 [gardening] add a missing license header 2024-01-27 13:15:16 -08:00
Max Desiatov
426c4f9f1c Add i686-pc-windows-coff/x86_64-pc-windows-coff embedded triples
These triples don't need additional adjustments in the standard library and complement existing embedded triples for i686 and x86_64 CPU architectures.
2024-01-27 21:10:11 +00:00
Mike Ash
ade4b8e989 [Runtime] Fix dyld call for Swift prespecialized data.
Make our variables const to match the call signature, and do a weak check of the symbol before calling it.
2024-01-27 12:53:23 -05:00
Guillaume Lessard
384a66aa59 Merge pull request #71186 from apple/jgrynspan/121674502-fix-deprecation-of-validatingUTF8-cchar-array-overload
Fix the deprecation of `String.init(validatingUTF8: [CChar])`.
2024-01-26 17:27:54 -08:00
Saleem Abdulrasool
1864caad5e build: migrate to CMake based build of swift-format
This allows us to build swift-format with dynamic linking against the
toolchain build of the swift-syntax and swift-argument-parser packages.
Wire up the swift-markdown build and hoist the swift-format build prior
to sourcekit-lsp. This sets us up for supporting swift-format based
formatting in the LSP.
2024-01-26 15:51:29 -08:00
Max Desiatov
633d5bc45a Enable x86_64 and i686 ELF triples for embedded Swift (#70642)
This is just as useful for x86 bare metal as the already enabled `arm*-none-none-eabi` triples.
2024-01-26 21:39:17 +00:00
Ben Troller
bb3c7f5ee8 [RemoteMirror] Allow clients to specify whether Obj-C interop is enabled.
rdar://119570103
2024-01-26 13:11:10 -08:00
Jonathan Grynspan
3da7483c5f Fix the deprecation of String.init(validatingUTF8: [CChar]).
This PR changes the deprecation annotation of `String.init(validatingUTF8: [CChar])` to match that of `String.init(validatingUTF8: UnsafePointer<CChar>)`. Both have been given new, undeprecated, renamed replacements (`validatingCString:`).

Resolves rdar://121674502.
2024-01-26 13:40:27 -05:00
Mike Ash
edb292dda5 [Runtime] Do a proper hash table lookup in the prespecializations library.
We were doing a linear scan of the table contents as a stopgap. Stop doing that, and compute the proper key for the lookup, matching the one used in the builder.
2024-01-26 12:04:02 -05:00
Mike Ash
4bc7726d43 Merge pull request #70900 from mikeash/swift-generic-metadata-builder-out-of-process
[Tools] Add a library to build specialized generic metadata out of process.
2024-01-26 10:50:34 -05:00
John McCall
443489f011 Merge pull request #71152 from rjmccall/centralize-function-type-isolation
Create a uniform representation for function type isolation
2024-01-26 04:40:24 -05:00
Philippe Hausler
ed23973e89 [Observation] Add generation for _modify to fields such that we avoid extra CoW (#71122) 2024-01-25 22:51:38 -08:00
John McCall
b0fb03d8c7 Create a uniform representation for function type isolation.
Not quite NFC because apparently the representation bleeds into what's
accepted in some situations where we're supposed to be warning about
conflicts and then making an arbitrary choice.  But what we're doing
is nonsense, so we definitely need to break behavior here.

This is setting up for isolated(any) and isolated(caller).  I tried
to keep that out of the patch as much as possible, though.
2024-01-25 22:11:01 -05:00
Rick van Voorden
f8ae46b3f3 [inclusive-language] changed sanity to soundness 2024-01-25 18:18:02 -08:00
Doug Gregor
4c990dc0b9 Introduce an egregious source-compatibility hack for AsyncSequence.flatMap
Allow `AsyncSequence.flatMap` to be defined with "incorrect" availability,
meaning that the function can refer to the `Failure` associated type
in its where clause even though the function is back-deployed to
before the `Failure` associated type was introduced.

We believe this is safe, and that this notion can be generalized to any
use of an associated type in a same-type constraint of a function
(yes, it sounds weird), but for now introduce a narrower hack to see
how things work in practice and whether it addresses all of the
source-compatibility concerns we've uncovered.
2024-01-25 16:04:58 -08:00
Doug Gregor
9bacd3ed07 Remove workaround for do..catch not handling concrete error types 2024-01-25 16:04:49 -08:00
Doug Gregor
6ebb0ff560 Replace AsyncIteratorProtocol.nextElement() with isolated next(_:)
Use an optional isolated parameter to this new `next(_:)` overload to
keep it on the same actor as the caller, and pass `#isolation` when
desugaring the async for..in loop. This keeps async iteration loops on
the same actor, allowing non-Sendable values to be used with many
async sequences.
2024-01-25 16:04:48 -08:00
Doug Gregor
ec945bf3d9 Implement AsyncThrowingStream.nextElement() with typed throws 2024-01-25 16:04:47 -08:00
Doug Gregor
3482ca02ad Add availability for the Failure associated type of async sequences 2024-01-25 16:04:46 -08:00
Doug Gregor
0baa5b978b Typed throws is enabled by default, we don't need to opt in 2024-01-25 16:04:45 -08:00
Doug Gregor
b0029b24f5 Add AsyncThrowingFlatMapSequence.nextElement() 2024-01-25 16:04:45 -08:00
Doug Gregor
1b6a18f52b Adopt nextElement() in AsyncFlatMapSequence
`AsyncFlatMapSequence` is somewhat troublesome for typed throws,
because it can produce errors from two different sources: the `Base`
async sequence and the `SegmentOfResult` async sequence. However, we
need to pick one `Failure` type for the `AsyncFlatMapSequence`, and
there is no surface-language equivalent to the `errorUnion` operation
described in SE-0413.

So, we do something a little bit sneaky. We effectively require that
`SegmentOfResult.Failure` either be equivalent to `Base.Failure` or be
`Never`, such so that when the async sequence retruned by the closure
throws, it throws the same thing as the base sequence. Therefore, the
`Failure` type is defined to be `Base.Failure`.

This property isn't enforced at the type level, but instead in the
`AsyncSequence.flatMap` signatures: we replace the one signature that
returned `AsyncFlatMapSequence` with three overloads that differ only
in their generic requirements, adding:
1. `where SegmentOfResult.Failure == Failure`
2. `where SegmentOfResult.Failure == Never`
3. `where SegmentOfResult.Failure == Never, Failure == Never` (a
tiebreaker between the two above)

For cases where `SegmentOfResult.Failure` is neither `Never` nor
`Failure`, overloading will choose the `flatMap` function that returns
an `AsyncThrowingFlatMapSequence`. This can mean that existing code
will choose a different overload and get a different type, but other
than the type identity changing, the resulting sequence will behave
the same way.
2024-01-25 16:04:45 -08:00