Commit Graph

21665 Commits

Author SHA1 Message Date
Egor Zhdan
4513ca2447 [cxx-interop] Faster std::string initialization from String
Instead of appending characters one-by-one, which resizes the resulting string multiple times, let's reserve the required number of bytes beforehand.

rdar://127423949
2024-05-02 14:07:07 +01:00
Konrad `ktoso` Malawski
dc5e354d69 [Concurrency] Reimplement @TaskLocal as a macro (#73078) 2024-05-01 20:57:20 -07:00
Becca Royal-Gordon
981233ad37 Merge pull request #73128 from beccadax/objcimpl-resilient
Handle resilient stored properties in objcImpl
2024-04-30 20:50:33 -07:00
Holly Borla
43681259e9 Merge pull request #73310 from hborla/async-stream-sendable-error
[Concurrency] Stage in new `Async{Throwing}Stream.init(unfolding:)` errors as warnings.
2024-04-30 19:23:19 -07:00
Kuba (Brecka) Mracek
4e474d81da Merge pull request #73347 from kubamracek/keypath-fix-equality
[KeyPath] Fix regression in == on keypaths
2024-04-30 19:05:58 -07:00
Philippe Hausler
54b3a9b64a [Observation] Optimize cancellation path to avoid excessive copies (#73288) 2024-04-30 14:40:02 -07:00
Kuba Mracek
1d48f28d84 [KeyPath] Fix regression in == on keypaths 2024-04-30 12:50:03 -07:00
Becca Royal-Gordon
4578be2810 Set a minimum deployment target for objcImpl
We’re not committing to @objc @implementation back-deploying to pre-stable Apple platforms.
2024-04-30 12:03:46 -07:00
Becca Royal-Gordon
915a49a1c0 [NFC] Refactor swift_updatePureObjCClassMetadata()
Merge the three-stage operation originally designed for field vectors into a single unified loop that acts directly on the ivar offsets instead of using a faux field offset vector.
2024-04-30 12:03:46 -07:00
Becca Royal-Gordon
d1f14e5814 Eliminate objcImpl field offset vectors
We really don’t need ‘em; we can just adjust the direct field offsets.

The runtime entry point currently uses a weird little hack that we will refactor away shortly.
2024-04-30 12:03:46 -07:00
Becca Royal-Gordon
427386feea Support resilient stored properties in objcImpl
When an @objc @implementation class requires the use of `ClassMetadataStrategy::Update` because some of its stored properties do not have fixed sizes, we adjust the direct field offsets during class realization by emitting a custom metadata update function which calls a new entry point in the Swift runtime. That entry point adjusts field offsets like `swift_updateClassMetadata2()`, but it only assumes that the class has Objective-C metadata, not Swift metadata.

This commit introduces an alternative mechanism which does the same thing without using any Swift-only metadata. It’s a rough implementation with important limitations:

• We’re currently using the field offset vector, which means that field offsets are being emitted into @objc @implementation classes; these will be removed.
• The new Swift runtime entry point duplicates a lot of `swift_updateClassMetadata2()`’s implementation; it will be refactored into something much smaller and more compact.
• Availability bounds for this feature have not yet been implemented.

Future commits in this PR will correct these issues.
2024-04-30 12:03:44 -07:00
Holly Borla
2c2090201e [Concurrency] Preserve the mangling of AsyncStream.init(unfolding:onCancel:). 2024-04-30 09:25:23 -07:00
Tim Kientzle
e546684e9a Extract the BitMask support to a separate file 2024-04-29 16:50:58 -07:00
Alex Lorenz
7815f843a3 [android] do not build the builtin float overlay for android (NDK's clang module map doesn't have it) 2024-04-29 15:57:27 -07:00
Alex Lorenz
7a5a0aad22 [android] misc stdlib build fixes 2024-04-29 15:54:05 -07:00
Alastair Houghton
7df249b67c [Runtime] Tidy up a couple of minor nits.
This doesn't change any code, just makes things look slightly
neater.

rdar://123504095
2024-04-29 10:48:23 +01:00
Alastair Houghton
554c402f11 [Runtime] Add the retain attribute to make the backtracer work.
Without `retain` here, we might remove the reference that pulls in
the backtracing support code.

rdar://123504095
2024-04-29 10:48:23 +01:00
Alastair Houghton
b7557247a7 [Runtime] Tidy up section declarations slightly.
This also calls out the reflection sections, even though we don't
actually need to do anything special for them (as it turns out).

rdar://123504095
2024-04-29 10:48:22 +01:00
Allan Shortlidge
250758335c Merge pull request #73306 from tshortli/the-condfails-never-end
stdlib: Fix more typed throws and non-copyable generics condfails
2024-04-27 16:07:28 -07:00
Karoy Lorentey
8f223e98bc Merge pull request #73296 from lorentey/rdar127015095
[stdlib] Optional.map, .flatMap: Remove @_disfavoredOverload
2024-04-26 19:16:50 -07:00
Holly Borla
38cc9511ee [Concurrency] Stage in new Async{Throwing}Stream.init(unfolding:) errors
as warnings.

Marking the closure parameter to these inits as `@Sendable` changed the
inferred isolation of closure arguments in actor-isolated contexts, which
caused new effects checker errors when accessing isolated properties and
methods without `await`. Mark these `init`s as `@preconcurrency`, and fix
the effects checker to downgrade those errors to warnings when the context
of the call is `@preconcurrency`.
2024-04-26 18:09:37 -07:00
Allan Shortlidge
7fc2179c31 stdlib: Fix more typed throws and non-copyable generics condfails.
There were two categories of problem for older compilers that consume the
stdlib `.swiftinterface`:

- The `case .some(borrowing x)` syntax isn't accepted; use `_borrowing`
- Various functions that addopted `~Copyable` generic constraints conflict with
  the `@usableFromInline` ABI stubs that were left in to preserve compatibility
  when the functions are printed with `~Copyable` constraints stripped. The stubs
  need to have different names to get out of the way.

Resolves rdar://127132742
2024-04-26 16:37:09 -07:00
Karoy Lorentey
775aab0c8e [stdlib] Optional.map, .flatMap: Remove @_disfavoredOverload
We don’t need this to worka round the known source compat issue, and it is triggering “expression too complex” errors, causing harm.

rdar://127015095
2024-04-26 11:58:09 -07:00
Mike Ash
4d62c521bd [Runtime] Avoid dlsym of objc_isUniquelyReferenced.
We attempted to use the declaration if it exists, and fall back to dlsym. This didn't actually work and we always call dlsym. Include the right header (when available) and add a weak check to the direct call.

rdar://127116080
2024-04-26 11:44:28 -04:00
Joe Groff
2f954ef5d7 Merge pull request #73259 from jckarter/external-key-path-generic-environment-binding
IRGen: Fix key path generic environment marshalling for external property descriptors.
2024-04-25 16:24:42 -07:00
Nate Chandler
b12def9c6a [BitwiseCopyable] Deprecate unbound overloads.
The unconstrained overloads of loadUnaligned and storeBytes were
deprecated in SE-0426.
2024-04-25 11:44:15 -07:00
Nate Chandler
f9ad81e106 [BitwiseCopyable] Remove #ifs. 2024-04-25 11:44:15 -07:00
Nate Chandler
b1fbe4ea91 [BitwiseCopyable] Remove underscore. 2024-04-25 11:44:15 -07:00
Alex Martini
587c79b6f1 Fix plurals
Incorporates feedback from Slava Pestov <spestov@apple.com>
2024-04-25 11:05:35 -07:00
Joe Groff
02e1f2ea15 IRGen: Fix key path generic environment marshalling for external property descriptors.
The layout of a computed key path component carries an argument buffer for captures, which has
the following layout:

```
---
captured values (subscript indices)
---
generic arguments
---
```

When we reference an externally-defined public property or subscript from a key path, and the
external declaration has a property descriptor, then the generic arguments for the external
declaration get appended to the end of this buffer, giving:

```
---
captured values (subscript indices)
---
generic arguments
---
external property's generic arguments
---
```

The convention for key path accessors to bind their generic environment is thus to unpack them
from the end of the argument buffer, so that the external keypath's accessors can find the
arguments to bind the external generic environment while still allowing the enclosing key path
to save the original captured generic environment (which may be necessary to capture the
appropriate conditional and/or retroactive `Equatable` and `Hashable` conformances for
subscript indices).

However, our code generation for binding the generic arguments out of the argument buffer
contained a flawed optimization: for a property, we know there are never any captured values,
so I had assumed that the generic parameters could always be bound from the beginning of the
argument buffer, assuming that the generic parameters make up the totality of the buffer. This
falls over for external property descriptor references when the key path itself captures a
generic environment, since the external property's expected generic environment appears after
the key path's original generic environment. We can fix this by removing the conditional
entirely, and always adjusting the offset we load the generic environment from to look at the
end of the buffer. Fixes rdar://125886333.
2024-04-25 10:36:13 -07:00
Dave Lee
d7426e2e75 [RemoteInspection] Fix format of dumped spare bit mask (#73231)
Even with `std::hex`, the `uint8_t` values are being printed as characters, not hex 
values. This change casts the value to `int`, which results in the hex representation 
being properly printed.
2024-04-25 09:51:22 -07:00
Alex Martini
3c54f6819b Fill in reference for Copyable 2024-04-24 16:58:00 -07:00
Nate Chandler
6e975da805 [BitwiseCopyable] Promote ConformanceSuppression.
The ability to suppress conformance to BitwiseCopyable was part of the
accepted SE-428.
2024-04-24 15:52:20 -07:00
Nate Chandler
ed5c7ef7ae [BitwiseCopyable] Promote to feature.
SE-0426 was accepted.
2024-04-24 15:52:20 -07:00
Michael Gottesman
8c7be03001 Merge pull request #73225 from gottesmm/pr-8b42b60f27fcdfdf5502a79e2a874ce1987d5838
[cmake] Make the hosttools lib SwiftMacros a dependency of the stdlib when we aren't cross compiling.
2024-04-24 16:26:06 -05:00
Michael Gottesman
b6e9c9cb24 [cmake] Make the hosttools lib SwiftMacros a dependency of the stdlib when we aren't cross compiling.
This just matches the dependency behavior of the stdlib for swift-frontend. So
we should always have SwiftMacros as needed.

rdar://126998047
2024-04-24 13:22:43 -05:00
Mike Ash
e373cae729 Merge pull request #73205 from mikeash/libprespecialize-stack-allocated-demangler
[Runtime] Use StackAllocatedDemangler in getLibPrespecializedMetadata.
2024-04-24 09:01:54 -04:00
Pavel Yaskevich
9542216c6a Merge pull request #73188 from xedin/se-0428-renable-dist-protocol-macro-to-resolvable
[SE-0428] NFC: Rename `_DistributedProtocol` macro into `Resolvable`
2024-04-24 00:18:52 -07:00
Mike Ash
717b03b5a5 [Runtime] Use StackAllocatedDemangler in getLibPrespecializedMetadata.
Reduce the amount of time spent freeing demangler slabs by starting out with a stack allocation that doesn't need to be freed.

rdar://126932780
2024-04-23 14:44:40 -04:00
Alex Martini
8468088e55 Add requirements & sketch TSPL cross reference 2024-04-23 09:12:15 -07:00
Kavon Farvardin
590c7cd925 Merge pull request #73133 from kavon/no-escapable-for-u
prevent uses of `Escapable` in general
2024-04-23 01:49:08 -07:00
Dario Rexin
b97fbac9a6 [Runtime] Fix CVW for genreic single payload enums with no extra inha… (#73186)
* [Runtime] Fix CVW for genreic single payload enums with no extra inhabitants

rdar://126728925

When the payload of a generic SPE did not have any extra inhabitants, we erroneously always treated it as the no payload case.
Additionally the offset and skip values were improperly computed.

* Fixed FileCheck string
2024-04-22 22:56:57 -07:00
Kavon Farvardin
f0a69a3ef1 prevent uses of Escapable in general
This protocol appears in the stdlib as scaffolding for the
`NonescapableTypes` feature, which is still experimental and not gone
through evolution as an approved addition to the stdlib.

Rather than delete it from the stdlib, because it needs to still remain
to support that feature work, gate references to it behind a feature
flag.

Additionally, prevent documentation from seeing this declaration.

rdar://126705184
2024-04-22 20:40:11 -07:00
Pavel Yaskevich
e6b445b8d1 [SE-0428] NFC: Rename _DistributedProtocol macro into Resolvable
The proposal was [accepted with modifications](https://forums.swift.org/t/accepted-with-modifications-se-0428-resolve-distributedactor-protocols/71366)

The decision was made to change the spelling of the attached macro
in the proposal from @DistributedProtocol to `@Resolvable`
(or `@Distributed.Resolvable` if disambiguation is needed).
2024-04-22 14:18:11 -07:00
Mike Ash
720ca4b4d9 Merge pull request #73138 from mikeash/symbolic-reference-lookup-better-error
[Runtime] Add the pointer location to the "failed to look up symbolic reference" error.
2024-04-22 14:15:56 -04:00
Daniel Rodríguez Troitiño
a7ff8159f1 [cmake] Check correctly for different flags. Don't check twice -Wall (#73144)
check_cxx_compiler_flag caches its results for the same variable, since
all the flags were using the same variable, only the first check was
done, and the rest of the flags were just using the result of the first
flag.

Make each of the check_cxx_compiler_flag use a different variable (by
interpolating the flag name) and reorder the list of compiler flags to
check. -Wall was added twice, and in the case of MSVC, the equivalent
was added last.

It doesn't really seem to affect a lot of things.
2024-04-22 08:40:57 -07:00
GG
739ff6f0c2 Fix typo in Result.swift 2024-04-21 21:17:22 +09:00
Mike Ash
84983353d3 [Runtime] Add the pointer location to the "failed to look up symbolic reference" error.
The pointer location can be computed from the symbolic reference location and offset, which we already provide, but it's not clear that you should add them together, nor is it clear why this failure would occur. Add the location of the NULL pointer itself to the error message, and also mention that it's probably caused by a missing weak symbol.
2024-04-19 10:48:44 -04:00
Dave Lee
e57f70bd4d [Debugging] Add DebugDescriptionMacro experimental feature (#73107)
This removes the leading underscore from the macro.
2024-04-18 17:25:44 -07:00
nate-chandler
b00b5aad4f Merge pull request #72646 from nate-chandler/bitwise-copyable/20240327/1
[BitwiseCopyable] Allow suppression via ~.
2024-04-18 07:05:10 -07:00