Commit Graph

1292 Commits

Author SHA1 Message Date
Anthony Latsis
7793f638d5 [NFC] AST: Consolidate some repeated DependentMemberType logic in Type methods 2024-12-20 02:47:29 +00:00
Konrad `ktoso` Malawski
ed5007f6b1 Merge pull request #77584 from ktoso/wip-check-array-calls 2024-12-04 21:01:36 +09:00
Konrad `ktoso` Malawski
138f145ab9 [Distributed] @Resolvable now handles primary associated types in protocols
Previously we would not propagate those into the generated distributed
actor, making a lot of generic distributed actor protocols impossible to
express.

We indeed cannot handle protocols WITHOUT primary associated types, but
we certainly can handle them with!

This resolves rdar://139332556
2024-12-03 14:59:15 +09:00
Kuba Mracek
6f4ae28520 [ASTMangler] Pass ASTContext to all instantiations of ASTMangler 2024-12-02 15:01:04 -08:00
Hamish Knight
4946c799af [AST] Remove ModuleDecl::addFile
Rather than exposing an `addFile` member on
ModuleDecl, have the `create` members take a
lambda that populates the files for the module.
Once module construction has finished, the files
are immutable.
2024-11-17 14:17:20 +00:00
Allan Shortlidge
0d581c4261 NFC: Use VersionRange::all() to represent "always available".
It doesn't make sense to use `VersionRange::empty()` to represent "universally
available" since something that is available in an empty version range is
effectively never available.
2024-11-09 19:36:03 -08:00
Dario Rexin
bbb67d1cc1 [IRGen] Prevent CVW from being emitted for non-copyable types
rdar://138028500

In some cases CVW were emitted for non-copyable types, which should not happen.
2024-10-19 11:08:32 -07:00
Arnold Schwaighofer
4e931e7638 Merge pull request #76849 from aschwaighofer/prof_thunks
IRGen: Add the ability to mark certain generic entry points in back traces
2024-10-17 05:12:06 -07:00
Egor Zhdan
3a200deee9 [cxx-interop] Add UnsafeCxxContiguousIterator & UnsafeCxxMutableContiguousIterator protocols
This adds a pair of Swift protocols that represents C++ iterator types conforming to `std::contiguous_iterator_tag` requirements. These are random access iterators that guarantee that the values are stored in consequent memory addresses.

This will be used to optimize usage of C++ containers such as `std::vector` from Swift, for instance, by providing an overload of `withContiguousStorageIfAvailable` for contiguous containers.

rdar://137877849
2024-10-15 14:30:09 +01:00
Arnold Schwaighofer
8ebb3ec473 IRGen: Add the ability to mark certain generic entry points in back traces
Mark generic function calls with concrete parameters, generic v-table calls and
generic witness table calls where self is generic.
2024-10-14 14:06:10 -07:00
Erik Eckstein
5502373018 SIL: rename AssociatedTypeProtocolWitness -> AssociatedConformanceWitness in SILWitnessTable
To be consistent with the naming convention in the AST
2024-10-02 07:10:30 +02:00
Nate Chandler
091368ba21 [CoroutineAccessors] Added read.
The name is a placeholder for the mutating single-yield coroutine
accessor.
2024-09-26 18:10:39 -07:00
Nate Chandler
98a2e6a7df [CoroutineAccessors] Added modify.
The name is a placeholder for the mutating single-yield coroutine
accessor.
2024-09-26 18:10:39 -07:00
Slava Pestov
f35c90a6b7 Merge pull request #76445 from slavapestov/maptypeintocontext
Overhaul mapTypeIntoContext()
2024-09-14 08:45:20 -04:00
Allan Shortlidge
02dbb96b94 AST: Rename AvailabilityContext to AvailabilityRange.
The generality of the `AvailabilityContext` name made it seem like it
encapsulates more than it does. Really it just augments `VersionRange` with
additional set algebra operations that are useful for availability
computations. The `AvailabilityContext` name should be reserved for something
pulls together more than just a single version.
2024-09-13 16:25:18 -07:00
Slava Pestov
354a194ad1 IRGen: Use mapConformanceRefIntoContext() in OpaqueTypeDescriptorBuilder 2024-09-12 11:49:59 -04:00
Alejandro Alonso
f2f82a7de6 Add initRawStructMetadata2 for safety 2024-09-04 15:13:51 -07:00
Alejandro Alonso
4a7fb6f5fe Some test fixes 2024-09-04 15:13:48 -07:00
Alejandro Alonso
4f07c060b7 Future proof the initRawStructMetadata entrypoint 2024-09-04 15:13:46 -07:00
Alejandro Alonso
f4f60f4344 Remove Value requirement Add GenericTypeParamKind 2024-09-04 15:13:43 -07:00
Alejandro Alonso
7c85261a77 Add runtime support 2024-09-04 15:13:27 -07:00
Alejandro Alonso
75c2cbf593 Implement value generics
Some requirement machine work

Rename requirement to Value

Rename more things to Value

Fix integer checking for requirement

some docs and parser changes

Minor fixes
2024-09-04 15:13:25 -07:00
Allan Shortlidge
3f626f50fe Merge pull request #76203 from tshortli/availability-context-cleanup
AST: Clean up `AvailabilityContext` and uses
2024-09-03 09:42:25 -07:00
Slava Pestov
ba585fd6c0 Merge pull request #76206 from slavapestov/existential-signature-rework-part-1
AST: Add new implementation of getOpenedExistentialSignature()
2024-09-03 10:05:29 -04:00
Allan Shortlidge
89ea92d550 AST: Introduce ASTContext::getTargetPlatformStringForDiagnostics().
NFC.
2024-09-02 18:24:31 -07:00
Allan Shortlidge
8ab7f54cd4 AST/Sema: Favor AvailabilityContext over VersionTuple/VersionRange.
For the purposes of availability calculations, direct use of
`llvm::VersionTuple` and `VersionRange` is discouraged, since these fundamental
version representations are divorced from their context. For example, comparing
an iOS platform version to a visionOS platform version is invalid since the
versioning systems of the two platforms differ. Although visionOS inherits
avialability from iOS, an iOS version must be converted to a visionOS version
prior to comparison. In the future, `AvailabilityContext` can be enriched to
carry the information necessary to verify that its algebraic operations are
being performed on compatible values.

NFC.
2024-09-02 18:24:31 -07:00
Allan Shortlidge
8052e3f9dc AST: Remove 'OS' from AvailabilityContext member names.
An `AvailabilityContext` represents an abstract version range in which
something is available. In the future, these version ranges may not necessarily
always correspond to operating system version ranges.

NFC.
2024-09-02 16:47:14 -07:00
Slava Pestov
2fbf2f6b81 IRGen: Use new form of getOpenedExistentialSignature() in emitExtendedExistentialTypeShape() 2024-09-01 18:03:35 -04:00
Egor Zhdan
0ab681514b [cxx-interop] Add CxxMutableRandomAccessCollection protocol
This conforms mutable C++ container types, such as `std::vector`, to `MutableCollection` via a new overlay protocol `CxxMutableRandomAccessCollection`.

rdar://134531554
2024-08-28 12:43:42 +01:00
Konrad `ktoso` Malawski
eb675c222e [Distributed] Correct tbd handling for distributed thunks (#74935) 2024-07-26 16:52:18 +09:00
smonteiro2
684e9ebf0c [cxx-interop] Implements CxxMutableSpan, created from an UnsafeMutableBufferPointer
* Added tests for generic functions
* Add some tests for mutable spans
* Initialize ConstSpan from UnsafeMutableBufferPointer
* Change hardening flag
2024-07-19 10:38:52 +01:00
Slava Pestov
977b444eb3 AST: Add a new overload of getContextSubstitutionMap() 2024-07-10 13:28:26 -04:00
Slava Pestov
ca9c09f8a1 Remove some unused variables 2024-07-06 12:05:47 -04:00
Slava Pestov
1901862afc AST: Remove LookUpConformanceInSignature 2024-07-06 12:05:46 -04:00
Slava Pestov
fae01d9776 AST: Remove ModuleDecl parameter from more places 2024-07-06 12:05:46 -04:00
Egor Zhdan
75a00adcf0 Merge pull request #74625 from swiftlang/egorzhdan/upstream-ptrauth-vwt
[IRGen] Upstream pointer auth for value witness tables
2024-07-01 22:17:59 +01:00
Egor Zhdan
b22057e637 [IRGen] Upstream pointer auth for value witness tables
This makes Swift emit a signed pointer to the value witness table in type metadata.

The original change was done by Varun Gandhi.
2024-07-01 16:38:06 +01:00
susmonteiro
e86099c26d [cxx-interop] Implements constructor for std::span from UnsafeBufferPointer
Tests: init span from UnsafeBufferPointer, for loop, map, filter, init Array from span, span of strings
2024-07-01 16:07:28 +01:00
Tim Kientzle
1d961ba22d Add #include "swift/Basic/Assertions.h" to a lot of source files
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
Dario Rexin
2d0b19484f Merge pull request #74058 from drexin/wip-127535274
[IRGen] Assign layout strings for static layout generic types in meta…
2024-05-31 15:38:00 -07:00
Dario Rexin
8e2b0ec1d6 [IRGen] Assign layout strings for static layout generic types in metadata initialization function
rdar://127535274

The layout string needs to be assigned before completion, to make it available in recursive metadata initialization. Setting it in the completion function causes a race between other metadata initializers using it and the completion function running.
2024-05-31 11:24:01 -07:00
Holly Borla
c20b0e0956 [Concurrency] Obsolete AnyActor in Swift 6 using a typealias. 2024-05-29 22:59:19 -07:00
Alejandro Alonso
d380bf9ae3 Merge pull request #73277 from Azoy/fix-conditional-invertible
[IRGen] Fix misalignment of conditional invertible requirement counts
2024-05-01 08:10:46 -07:00
Becca Royal-Gordon
f94ed6d606 Hide objcImpl resilience support behind feature
Resilence support will require changes to the Objective-C runtime to expand support for metadata initialization functions. Add a separate experimental feature flag to help with staging that support in, and modify diagnostics to not suggest increasing the minimum deployment target for now.
2024-04-30 12:03:46 -07:00
Becca Royal-Gordon
1dceb24802 Diagnose resilient properties in objcImpl
…when the deployment target is not high enough to support them.
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
Alejandro Alonso
0e673f70a4 Fix misalignment of conditional invertible requirement counts 2024-04-25 17:58:13 -07:00
Becca Royal-Gordon
9e83099279 [NFC] Refactor objcImpl matadata layout logic
Rather than having individual methods return without doing anything, arrange for ClassMetadataVisitor to never call them in the first place. This makes it so ClassMetadataScanner also knows which fields are omitted and it can compute offsets correctly.

The old logic is still present for field offsets to make this change NFC.
2024-04-24 11:39:24 -07:00
Doug Gregor
ae01d20428 Runtime checking for associated types conforming to invertible protocols
Emit metadata for runtime checks of conformances of associated types to
invertible protocols, e.g., `T.Assoc: Copyable`. This allows us to
correctly handle, e.g., dynamic casting involving conditional
conformances that have such constraints.

The model we use here is to emit an invertible-protocol constraint
that leaves only the specific bit clear in the invertible protocol
set.
2024-04-02 16:42:16 -07:00