Commit Graph

21434 Commits

Author SHA1 Message Date
Joe Groff
b9f91144d1 Fix ABI breakage caused by ValueOwnership order change.
The `ABI` headers had accidentally grown an `#include` into compiler headers,
allowing the enum constant values of the `ValueOwnership` enum to leak into
the runtime ABI. Sever this inappropriate relationship by declaring a separate
`ParameterOwnership` enum with ABI-stable values in the ABI headers, and
explicitly converting between the AST and ABI representation where needed.
Fixes rdar://122435628.
2024-02-20 07:55:16 -08:00
Michael Gottesman
a11d5f9ea2 Merge pull request #71693 from gottesmm/transferring-mangling
[transferring] Add mangling support for transferring.
2024-02-19 23:52:57 -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
Konrad `ktoso` Malawski
551b07ba80 [Distributed] Fix _executeDistributedTarget ABI (#71725) 2024-02-19 21:23:11 -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
Michael Gottesman
f4efcec55c [transferring] Add mangling support for transferring.
This includes runtime support for instantiating transferring param/result in
function types. This is especially important since that is how we instantiate
function types like: typealias Fn = (transferring X) -> ().

rdar://123118061
2024-02-19 12:11:57 -08:00
Jonathan Grynspan
d35dcc8f9c Add swift5_tests to MetadataSections. (#71509) 2024-02-19 13:47:40 -05:00
Doug Gregor
8ed35de4e0 Switch to the 'Swift' diagnostic style as the default 2024-02-19 02:48:23 -10:00
Mike Ash
d6f9401c28 Merge pull request #71627 from mikeash/externalgenericmetadatabuilder-fix-targets-exports-recursion
[ExternalGenericMetadataBuilder] Fix pointer targets, exports, and recursive metadata.
2024-02-17 18:28:01 -05:00
Holly Borla
26621b804c [Concurrency] Enable optional isolated parameters. 2024-02-16 16:28:45 -08:00
Holly Borla
ddf2fc44f4 [Concurrency] Allow #isolation to have a more specific contextual type. 2024-02-16 16:27:54 -08:00
David Smith
ea7d07714f Switch grapheme break property searching to Eytzinger binary search (#71668) 2024-02-16 16:06:20 -08:00
Jonathan Grynspan
0664c3f333 Add a distinct hook for swift_willThrowTypedImpl(). (#71651)
Add a distinct hook for `swift_willThrowTypedImpl()`.

This PR adds a hook for `swift_willThrowTypedImpl()` that is distinct from
`swift_willThrow()`. The current implementation of `swift_willThrowTypedImpl()` creates a
temporary existential box for the thrown error and calls the `_swift_willThrow` hook that
is set by XCTest and swift-testing. Unfortunately, this temporary existential box isn't
very useful because its address is not expected to be stable.

Instead, expose a separate hook, `_swift_willThrowTypedImpl`, whose signature matches
that of the new ABI function. This hook can then be used by XCTest and swift-testing to
distinguish between typed throws and untyped throws and avoids creating a temporary
existential box when it won't be useful.

As implemented, if `_swift_willThrowTypedImpl` is not set but `_swift_willThrow` is, the
`swift_willThrowTypedImpl()` will fall back to calling `_swift_willThrow` with a temporary
existential box. We might decide this is unnecessary, but I figured it would allow us more
time to stage adoption of the new hook in the testing libraries.

Resolves rdar://122824443.
2024-02-16 17:30:44 -05:00
Ian Anderson
1ce3935eb7 [overlay] Make an overlay for the clang _Builtin_float module
Clang's builtin float.h is no longer included in OS/SDK modules, and so it needs its own overlay.

rdar://122351557
2024-02-16 12:31:47 -08:00
Mishal Shah
81dbc534d6 Merge pull request #71678 from al45tair/eng/PR-122995672 2024-02-16 10:04:46 -08:00
Dario Rexin
7a4fcc6841 [Runtime] Mask out reserved bits for SwiftError in BytecodeLayouts.cpp (#71669)
rdar://122911427

These bits can be used for storing multi payload enum tags and not masking them out can cause crashes an other unexpected behavior.
2024-02-16 08:59:22 -08:00
nate-chandler
1ecd9388ec Merge pull request #71673 from nate-chandler/bitwise-copyable/opt-store-bytes
[BitwiseCopyable] Optimize storeBytes overload.
2024-02-16 07:20:17 -08:00
Konrad `ktoso` Malawski
e9c7f3c382 [Distributed] Target identifiers for protocol calls (#70928) 2024-02-16 07:19: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
Alastair Houghton
88aa111677 [Runtime] Don't try to call __cxa_begin_catch if -fno-exceptions.
We shouldn't call `__cxa_begin_catch` if built with `-fno-exceptions`,
because it's possible that the environment we're in won't include
the `__cxa_begin_catch` routine.

rdar://122995672
2024-02-16 09:35:03 +00:00
Mike Ash
f66b57c7fb Merge pull request #71666 from mikeash/libprespecialize-no-packs
[Runtime] Skip types with pack parameters in LibPrespecialized.
2024-02-15 23:30:06 -05:00
David Smith
de50b0a387 Eliminate pointer auth overhead in interposable refcount support (#71448)
Fixes rdar://122595662
2024-02-15 18:21:34 -08: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
Mike Ash
923bf1fdea Merge pull request #71664 from mikeash/build-metadata-demangling-null-checks
[Runtime] Add some missing NULL checks to _swift_buildDemanglingForMetadata calls.
2024-02-15 20:11:48 -05:00
Mike Ash
dba0859b5c [Runtime] Skip types with pack parameters in LibPrespecialized.
We don't yet support pack parameters anyway, and `_buildDemanglingForGenericType` has trouble with them, so skip them altogether.
2024-02-15 17:37:31 -05:00
Konrad `ktoso` Malawski
827e6a5708 [Distributed] Add DistributedProtocol macro (#71090) 2024-02-16 07:27:34 +09:00
Mike Ash
8dc4bc13b1 [Runtime] Add some missing NULL checks to _swift_buildDemanglingForMetadata calls.
The call can fail but many callers assumed it always succeeds.
2024-02-15 16:30:09 -05:00
Mike Ash
5f7421b7a7 [Runtime] Check for demangling failure when looking up prespecialized metadata.
_buildDemanglingForGenericType can fail, so we need to check for NULL.
2024-02-15 10:25:46 -05:00
Tim Kientzle
0308b167a8 Merge pull request #71620 from tbkka/tbkka-bincompat-objc-hash-isequal-interop
Bincompat hooks for revised hash/isEqual interop
2024-02-15 07:11:02 -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
60f9c035af Merge pull request #71625 from nate-chandler/bitwise-copyable/store-bytes
[stdlib] BitwiseCopyable storeBytes overload.
2024-02-14 18:12:33 -08:00
Mike Ash
752f0fb2f8 [ExternalGenericMetadataBuilder] Fix pointer targets, exports, and recursive metadata.
Use exports, not symbols, when emitting a pointer target. Exports are what the linker can actually work with.

When searching for a nearby export to use for a pointer target, accept anything within the same segment, not just the same section. Only segments can be rearranged relative to each other, not sections within a segment, so this is safe and allows for more possible targets.

Disallow pointer targets with no export within the same segment. We attempted to emit a target that's relative to the section starting point in this case, but that didn't work. We'll revisit if it looks useful to do so.

In order to make this work, we resolve the export when writing a pointer instead of when emitting JSON, and make the writePointer functions failable. If writePointer fails, we'll fail to build the metadata and skip it.

Correctly handle the case where the names JSON contains a metadata we already constructed as part of a prior name. Previously we'd emit it twice, now it checks to see if it's already been built and do nothing in that case. Also save errors when a metadata can't be built, so subsequent attempts to build it can fail immediately.

When emitting fixups with ptrauth attributes, use the correct target kind "arm64_auth_ptr".

Fix the VerifyExternalMetadata.swift test not to load an arm64e runtime slice when testing arm64. That's normally fine, but we depend on loading the exact same dylib that we built prespecializations for.

rdar://122968337
2024-02-14 16:57:18 -05: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
Tim Kientzle
b3ed7aee24 Bincompat hooks for revised hash/isEqual interop
This adds in hooks so that the new hash/isEqual interop
(which bridges Obj-C hash/isEqual: calls to the corresponding
Swift Hashable/Equatable conformances) can be selectively
disabled based on the OS and/or client.

For now, enable the new semantics everywhere except Apple platforms
(which have legacy apps that may be relying on the old semantics).
2024-02-14 12:13:07 -08:00
Mike Ash
5ce824f042 Merge pull request #71522 from mikeash/externalgenericmetadatabuilder-arm64e-fix
[ExternalGenericMetadataBuilder] Support ARM64e fixups.
2024-02-14 14:47:01 -05:00
Alastair Houghton
04c496c1e9 [CommandLine][Linux] Don't read the command line from /proc/self/cmdline.
Instead of reading from `/proc/self/cmdline`, take advantage of the fact
that the initial stack layout is ABI specified, and that we already have
a pointer into it (`environ`).  This lets us walk up the stack until we
find `argc`, at which point we also know where `argv` is.

We do this from a static initializer because a `setenv()` or `putenv()`
can change `environ` (if you add a new environment variable), and it's
even permissible to just outright change `environ` yourself too.  It
seems reasonable to suggest to people that they shouldn't be doing
those things from a static initializer, and as long as they don't,
they won't run before we've had a chance to find `argv`.

Just in case someone _does_ do this, we also check that `environ`
points into the stack.  If it doesn't, they won't get any arguments,
so if that happens, that's a clue that they're messing with `environ`
too early.

This works around a problem (#69658) with Docker Desktop 4.25.0 and
Rosetta, wherein we end up with an extra argument visible in
`/proc/self/cmdline`, and also avoids allocating memory for the
command line arguments.

rdar://117963394
2024-02-14 17:32:47 +00:00
Mike Ash
89e5a80847 [ExternalGenericMetadataBuilder] Support ARM64e fixups.
Add ptrauth attributes to the witness tables and descriptor pointers, and have the test support ARM64e.

rdar://122660111
2024-02-14 09:52:58 -05: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
Mishal Shah
61ed95a32f Merge pull request #71599 from hborla/update-build-task-executor-feature-guard
[Features] Rename the `BuiltinBuildTaskExecutor` feature guard.
2024-02-14 00:09:54 -08:00
Holly Borla
56c2b34071 [Features] Rename the BuiltinBuildTaskExecutor feature guard.
The name of the `TaskExecutor` protocol was recently changed to remove
underscores after the feature was accepted in Swift Evolution. An implication
of that rename is that the `buildOrdinaryTaskExecutorRef` builtin changed
the type that it expected as the argument. However, the original change
landed in the standard library which as since produced swiftinterfaces
that contain the following inlinable code:

```
@inlinable public init<E>(ordinary executor: __shared E) where E : _Concurrency._TaskExecutor {
  #if $BuiltinBuildTaskExecutor
  self.executor = Builtin.buildOrdinaryTaskExecutorRef(executor)
  #else
  fatalError("Swift compiler is incompatible with this SDK version")
  #endif
}
```

When a compiler containing the protocol rename attempts to type check the
above inlinable code, it crashes because the builtin is expecting an argument
conforming to `TaskExecutor`, which doesn't exist in this version of the
standard library. The issue is that the current compiler still supports
the `$BuiltinBuildTaskExecutor` feature guard, but the builtin supported
has since changed.

To resolve this issue, we need to stop supporting the `$BuiltinBuildTaskExecutor`
feature guard and introduce a new one that is only supported by compiler versions
that contain the rename. This approach relies on nothing having adopted the
API, otherwise we would need to stage in the rename as a parallel set of APIs,
and only remove the old APIs once nothing is relying on the old _Concurrency
swiftinterfaces.
2024-02-13 20:16:42 -08:00
Konrad `ktoso` Malawski
c5dbeca0b1 [TaskExecutor] Remove un-necessary nonisolated(unsafe) (#71594) 2024-02-13 19:40:30 -08:00
Saleem Abdulrasool
06d4d8cecf Merge pull request #71565 from compnerd/sddl
Windows: include SDDL conversion headers
2024-02-13 11:15:24 -08:00
Finagolfin
fcf7614638 [CMake] Add broader support for cross-compiling the portions of the compiler that are written in Swift to non-Darwin Unix
Add cross-compilation flags for the newly added Swift source in `lib/ASTGen/`,
similar to how `SwiftCompilerSources/` is already cross-compiled for other
platforms. Make sure the Swift source in the compiler builds and links against
`SWIFTLIB_DIR` in this cross-compilation build directory, not the one that comes
with the native host compiler.

This requires changing the dependency chain in `CROSSCOMPILE` mode, as normally
the Swift compiler is built first when building natively for the host, then it's
used to build the stdlib. However, when cross-compiling the toolchain, the stdlib
must be cross-compiled first by the host compiler, then the portions of the
Swift compiler written in Swift must be cross-compiled with that new stdlib. All
these dependency changes simply change that compilation order when cross-compiling,
including removing the dependency that the Swift compiler is built before the
stdlib when cross-compiling the Swift compiler.

All changes in this pull are gated on the `CROSSCOMPILE` mode, so they will
not affect any of the existing CI or build presets.
2024-02-13 12:24:24 +05:30
Saleem Abdulrasool
2d72906b97 Windows: include SDDL conversion headers
This is allows us to use `ConvertSidToStringSidW`.
2024-02-12 14:37:37 -08:00
Pavel Yaskevich
a2caaa3d03 [Distributed] Promote SerializationRequirement as a primary associated type for encoder/decoder/result 2024-02-12 14:26:30 -08:00
Pavel Yaskevich
961aa30d46 [stdlib] Distributed: Remove invokeOnReturn requirement and its synthesis
This is no longer necessary because `onReturn` is a protocol
requirement now.
2024-02-12 14:26:30 -08:00
Pavel Yaskevich
6c7000ae0b [Sema/IRGen] Extend ad-hoc requirement handling to DistributedTargetInvocationResultHandler.onReturn 2024-02-12 14:26:30 -08:00