Commit Graph

45066 Commits

Author SHA1 Message Date
Alexis Laferrière
c0a4056768 Merge pull request #79851 from xymus/deser-recover-conformance-xref
Serialization: Diagnose broken conformances from stale swiftmodule files
2025-03-11 15:07:38 -07:00
Slava Pestov
4c60e036ac Merge pull request #79882 from slavapestov/sizeof-constraint
Sema: Optimize Constraint layout to save 24 bytes
2025-03-11 14:30:44 -04:00
eeckstein
ca76efabb4 Merge pull request #79908 from eeckstein/fix-witness-table-specialization
embedded: fix specialization of associated conformance entries in witness tables
2025-03-11 18:16:23 +01:00
eeckstein
19c51e2ae2 Merge pull request #79872 from WeZZard/bugfix/unchecked-ref-casting-with-optional-any-object
[SILOptimizer] Fixes the ValueDefUseWalker to handle potential unchecked_ref_cast between optional and non-optional class types.
2025-03-11 17:15:10 +01:00
Anthony Latsis
5a92bc5e12 Merge pull request #79897 from AnthonyLatsis/danaus-plexippus-3
Small adjustments to adoption mode modeling
2025-03-11 11:47:18 +00:00
Erik Eckstein
ecfa808425 IRGen: convert two asserts to ASSERT to check the conditions also in a release-built compiler 2025-03-11 11:20:16 +01:00
Erik Eckstein
5212d92b57 Swift AST: add Conformance.getAssociatedConformance 2025-03-11 11:17:00 +01:00
Michael Gottesman
04bb69f426 Merge pull request #79727 from gottesmm/pr-025c1133954b74e7b4eda77e1a6f3bcafd4eb6cf
[concurrency] Add initial support for SwiftSettings to control defaultIsolation at the file level.
2025-03-10 22:35:00 -07:00
WeZZard
2237faca04 [SILOptimizer] Refines the implementation of of the bridged SILType for Swift. 2025-03-11 09:29:11 +08:00
Anthony Latsis
ae70d384e0 [NFC] Basic: Restrict adoption mode to upcoming and experimental features 2025-03-11 01:15:33 +00:00
Anthony Latsis
b102c986aa [NFC] Basic: Use scoped enum for feature states
To prevent unexpected implicit conversions to integral types.
2025-03-11 01:14:39 +00:00
Konrad `ktoso` Malawski
e056c63c89 [Concurrency] Implement isIsolatingCurrentContext requirement and mode (#79788) 2025-03-11 09:48:38 +09:00
Michael Gottesman
f64dd5a8d5 [concurrency] Add initial support for SwiftSettings to control defaultIsolation at the file level.
We introduce a new macro called #SwiftSettings that can be used in conjunction
with a new stdlib type called SwiftSetting to control the default isolation at
the file level. It overrides the current default isolation whether it is the
current nonisolated state or main actor (when -enable-experimental-feature
UnspecifiedMeansMainActorIsolated is set).
2025-03-10 17:33:45 -07:00
Alejandro Alonso
33a1a66728 Update Features.def 2025-03-10 15:57:04 -07:00
Alejandro Alonso
d0513a7aec Merge pull request #79665 from Azoy/value-generics-no-more-experiment
[AST] Make ValueGenerics feature always available
2025-03-10 15:14:34 -07:00
Dave Lee
8ad295aa02 Fix a comment reference to TaskGroupBase (#79622)
Update a reference to `TaskGroupImpl` to `TaskGroupBase`.
2025-03-10 13:16:03 -07:00
Kuba (Brecka) Mracek
43919e8b8a Merge pull request #79706 from kubamracek/embedded-concurrency-deleted-method
[embedded][Concurrency] Fix missing swift_deletedAsyncMethodError
2025-03-10 12:27:00 -07:00
Slava Pestov
6d90d16f61 Sema: Use ASSERT before getting trailing objects of Constraint
If the precondition doesn't hold, we will return a pointer to
some random memory, so it's best to always crash since this
indicates something is seriously wrong.
2025-03-10 15:10:20 -04:00
Slava Pestov
83118a73ed Sema: Shave another 8 bytes off of Constraint 2025-03-10 14:53:48 -04:00
Slava Pestov
ada6f77655 Sema: Track solver arena size in statistics 2025-03-10 14:03:05 -04:00
Slava Pestov
a7a19a0915 Sema: Optimize Constraint layout to save 16 bytes
The largest union member was for SyntacticElement constraints;
let's tail-allocate the ContextualTypeInfo instead of storing
one in every constraint.
2025-03-10 13:28:17 -04:00
Artem Chikin
cd7db230a3 Merge pull request #79809 from artemcm/UniqueCrossImportOverlayFiles
[Dependency Scanning] Unique collected cross-import overlay files with a set
2025-03-10 10:04:30 -07:00
Doug Gregor
a866f5d4ab Merge pull request #79874 from DougGregor/category-footnotes
[Diagnostics] Print category footnotes at the end of translation
2025-03-10 08:45:39 -07:00
WeZZard
35f82ba402 [SILOptimizer] Fixes the ValueDefUseWalker to handle potential unchecked_ref_cast between optional and non-optional class types.
The `unchecked_ref_cast` is designed to be able to cast between
`Optional<ClassType>` and `ClassType`. We need to handle these cases by
checking if the type is optional and adjust the path accordingly.
2025-03-10 19:17:31 +08:00
eeckstein
737b5ec924 Merge pull request #79674 from eeckstein/simplify-open-existential-metatype
Optimizer: Rework peephole optimizations to replace existential (archetypes) with concrete types
2025-03-10 08:18:52 +01:00
eeckstein
cbba008ac3 Merge pull request #79835 from eeckstein/fix-generic-specializer
GenericSpecializer: avoid an infinite loop when looking up GenericSpecializationInformation
2025-03-10 08:15:13 +01:00
Rintaro Ishizaki
accd108e4a Merge pull request #79857 from rintaro/retire-pound-diagnostics-decl
[Parse/AST] Remove PoundDiagnosticDecl
2025-03-09 21:23:16 -07:00
Doug Gregor
29b4f3ddbd [Diagnostics] Print category footnotes at the end of translation
When printing diagnostics, category names are printed as [#<category-name>]
at the end of a diagnostic. For all of the category names that are mentioned
in this manner, print "footnotes" at the end of compilation providing
documentation references to each category, e.g.,

    [#deprecated]: <http://example.com/deprecated>
    [#StrictMemorySafety]: <http://example.com/memory-safety>

Right now, these point into the markdown files in the installed toolchain,
same as the URLs behind references. That is subject to change in the future.
2025-03-09 14:36:51 -07:00
Doug Gregor
537be30f22 Merge pull request #79785 from DougGregor/isolated-conformances-metadata-runtime 2025-03-09 08:27:40 -07:00
Hamish Knight
deac7012cb [AST] Avoid setting questionLoc for implicit OptionalSomePatterns
Instead fix `getSourceRange` to handle cases where the question
location is missing.
2025-03-08 18:45:39 +00:00
Rintaro Ishizaki
5eac58e1e0 [AST] SwitchStmt only hold CaseStmt
Now that there is no way SwitchStmt to hold AST nodes other than
CaseStmt.
2025-03-08 09:14:40 -08:00
Doug Gregor
296e14662a Rework runtime entrypoints for isolated conformance checking
Replace the pair of global actor type/conformance we are passing around with
a general "conformance execution context" that could grow new functionality
over time. Add three external symbols to the runtime:

* swift_conformsToProtocolWithExecutionContext: a conforms-to-protocol check
  that also captures the execution context that should be checked before
  using the conformance for anything. The only execution context right now
  is for an isolated conformance.
* swift_isInConformanceExecutionContext: checks whether the function is
  being executed in the given execution context, i.e., running on the
  executor for the given global actor.
* swift_ConformanceExecutionContextSize: the size of the conformance
  execution context. Client code outside of the Swift runtime can allocate
  a pointer-aligned region of memory of this size to use with the runtime
  functions above.
2025-03-07 23:52:20 -08:00
Doug Gregor
48aa75d86f [Isolated conformances] Cache resolved global actor for conformances
In the prior implementation of runtime resolution of isolated conformances,
the runtime had to look in both the protocol conformance descriptor and
in all conditional conformance requirements (recursively) to find any
isolated conformances. If it found one, it had to demangle the global
actor type to metadata. Since swift_conformsToProtocol is a hot path through
the runtime, we can't afford this non-constant-time work in the common
case.

Instead, cache the resolved global actor and witness table as part of the
conformance cache, so that we have access to this information every time
we look up a witness table for a conformance. Propagate this up through
various callers (e.g., generic requirement checking) to the point where
we either stash it in the cache or check it at runtime. This gets us down
to a very quick check (basically, NULL-or-not) for nonisolated conformances,
and just one check for isolated conformances.
2025-03-07 23:51:46 -08:00
Doug Gregor
6dd141ad54 Replace dlsym of swift_task_isCurrentGlobalActor with a constructor hook
Following the approach taken with the concurrency-specific type
descriptors, register a hook function for the "is current global actor"
check used for isolated conformances.
2025-03-07 23:51:43 -08:00
Doug Gregor
951b535608 Metadata and runtime support for checking isolated conformances at runtime
Extend the metadata representation of protocol conformance descriptors
to include information about the global actor to which the conformance is
isolated (when there is one), as well as the conformance of that type to
the GlobalActor protocol. Emit this metadata whenever a conformance is
isolated.

When performing a conforms-to-protocol check at runtime, check whether
the conformance that was found is isolated. If so, extract the serial
executor for the global actor and check whether we are running on that
executor. If not, the conformance fails.
2025-03-07 23:51:25 -08:00
Rintaro Ishizaki
002d7d7cdf [Parse/AST] Remove PoundDiagnosticDecl
There is no reson to make a AST node for '#error' and '#warning'
directives. Parser knows the diagnostics should be emitted or not.
2025-03-07 21:48:01 -08:00
nate-chandler
c0ba520fac Merge pull request #79781 from nate-chandler/general-coro/20250227/1
[CoroutineAccessors] Dispatch and PtrAuth.
2025-03-07 20:08:42 -08:00
Konrad `ktoso` Malawski
fda7f539fb Reapply "Task names" (#79562) (#79600) 2025-03-08 10:58:49 +09:00
Rintaro Ishizaki
b6918a300a Merge pull request #79843 from rintaro/astgen-misc
[ASTGen] Misc fixes
2025-03-07 16:58:44 -08:00
Michael Gottesman
e06db4a6e0 Merge pull request #79825 from gottesmm/pr-07b2e4050930bb96f12c1c63c958545d4bc20cea
[sil] Add missing flag to SILDeclRef's hash and change SILDeclRef to use llvm::hash_combine instead of rolling its own hash combiner.
2025-03-07 15:57:42 -08:00
Alexis Laferrière
fb3944f1b1 Serialization: Error on mismatch between requirements and confirmances
When deserialization a protocol conformance from a binary swiftmodule
file the compiler can encounter inconsistencies caused by stale module
files. Replace the hard crash with a proper error and print the list of
requirements and conformances being compared to stderr for manual
inspection. Recover silently when we can afford to, during indexing or
in LLDB.
2025-03-07 14:05:57 -08:00
Alexis Laferrière
ea5658eece Serialization: Protect readNormalProtocolConformanceXRef
Failures in `readNormalProtocolConformanceXRef` are usually caused by a
dependency change without the required rebuild of its dependents.
Display a proper error instead of crashing when encountering such an
issue during normal compilation. Recover silently when we can afford to,
during indexing or in LLDB.
2025-03-07 14:05:57 -08:00
Susana Monteiro
1fc5a4ef37 Merge pull request #79542 from swiftlang/susmonteiro/move-constructor-default-args
[cxx-interop] Prevent usage in Swift of C++ move constructor with default args
2025-03-07 20:55:45 +00:00
Rintaro Ishizaki
30be52db35 Merge pull request #79821 from rintaro/astgen-available-domain-or-identifier
[ASTGen] Adopt AvailabilityDomainOrIdentifier scheme
2025-03-07 12:16:11 -08:00
Anthony Latsis
5d92f7953c Merge pull request #79792 from AnthonyLatsis/danaus-plexippus-2
Introduce adoption mode for Swift features (take 2)
2025-03-07 19:47:44 +00:00
Nate Chandler
6581fec9e1 [CoroutineAccessors] PtrAuth. 2025-03-07 11:46:51 -08:00
Nate Chandler
35d06c325d [CoroutineAccessors] Witness and vtable dispatch.
And thunking.
2025-03-07 11:46:50 -08:00
Nate Chandler
f5d03a6d11 [CoroutineAccessor] Remove old ABI support.
This was useful during bringup.  Now that retcon.once.dynamic coroutine
splitting is available, it's no longer needed.
2025-03-07 11:40:38 -08:00
nate-chandler
38c8cc8ff4 Merge pull request #77661 from nate-chandler/general-coro/20241115/1
[CoroutineAccessors] Default implementations are transparent.
2025-03-07 11:39:21 -08:00
Alexis Laferrière
e814b3f66c Serialization: Intro enableExtendedDeserializationRecovery
Introduce a new deserialization mode `enableExtendedDeserializationRecovery`
for use when we can afford inconsistent information from a swiftmodule
file. It's enabled automatically in debugger mode, when user errors are
allowed and during index-while-building.
2025-03-07 10:55:00 -08:00