Commit Graph

14 Commits

Author SHA1 Message Date
Slava Pestov
ec82f6bf4d SIL: Remove SILWitnessTable::AssociatedConformanceWitness::SubstType 2025-04-07 21:36:06 -04:00
Slava Pestov
8bcd09aaa4 SIL: Preliminary refactoring of SILWitnessTable::AssociatedConformanceWitness
The Protocol field isn't really necessary, because the conformance
stores the protocol. But we do need the substituted subject type
of the requirement, just temporarily, until an abstract conformance
stores its own subject type too.
2025-03-18 19:38:42 -04:00
Erik Eckstein
d52f7d1619 AST/SIL: Refactor and simplify AST.Type, AST.CanonicalType and SIL.Type
* let `SIL.Type` conform to `TypeProperties` to share the implementation of common type properties between the AST types and `SIL.Type`
* call references to an `AST.Type` `rawType` (instead of just `type`)
* remove unneeded stuff
* add comments
2025-03-14 09:40:22 +01:00
Erik Eckstein
23b4c6fc34 embedded: fix specialization of associated conformance entries in witness tables
When creating a specialized witness table, we need to get the right specialized conformance.
In IRGen don't emit associated conformance witness table entries if the protocol is not a class protocol.
In this case the associated type can never be used to create an existential. Therefore such a witness table entry is never used at runtime in embedded swift.

Fixes a compiler crash

rdar://146448091
2025-03-11 11:33:10 +01:00
Ben Barham
a2fda1d9f3 [Embedded] Do not produce cannot_specialize_class for live issues
SourceKit explicitly disables WMO, silence the diagnostic in this case
(but leave it enabled for explicit non-WMO builds otherwise).
2024-12-19 15:31:41 -08:00
Erik Eckstein
b8a91c95aa embedded: make sure to de-serialize vtable/wtable methods before trying to specialize them
Fixes a compiler crash.
rdar://138341211
2024-10-24 10:29:50 +02:00
Erik Eckstein
5c8fe55449 embedded: fix several issues with vtable specialization
* fix a false error if a derived class has different generic parameters than its base class
* fix a similar problem if a non-generic class derives from a generic class
* fix a compiler crash for calling a class method on a class metatype

rdar://137692055
2024-10-14 14:43:11 +02:00
Erik Eckstein
f7aaf7e5a5 MandatoryPerformanceOptimizations: handle all kind of witness-table entries when specializing witness-tables
Support associated-type and associated-conformance entries.
This enable existentials with associated types.
2024-10-07 09:00:32 +02:00
Erik Eckstein
a67d9c5bed embedded: Support class existentials with inherited protocols
For example:
```
protocol Base: AnyObject {}
protocol Derived: Base {}

class C: Derived {}

let e: Derived = C()
```
2024-10-07 08:49:56 +02:00
Erik Eckstein
25728853b8 GenericSpecialization: change how new specialized witness tables are added to MandatoryPerformanceOptimization's worklist
Do it by passing a closure instead of returning the new witness table.
This allows to add more than one new witness table to the worklist
2024-10-07 08:49:56 +02:00
Erik Eckstein
6fdb713e94 SwiftCompilerSources: implement WitnessTable.Entry as enum 2024-10-02 07:10:30 +02:00
Erik Eckstein
10782cf42b SwiftCompilerSources: introduce the AST module
As the optimizer uses more and more AST stuff, it's now time to create an "AST" module.
Initially it defines following AST datastructures:
* declarations: `Decl` + derived classes
* `Conformance`
* `SubstitutionMap`
* `Type` and `CanonicalType`

Some of those were already defined in the SIL module and are now moved to the AST module.
This change also cleans up a few things:
* proper definition of `NominalTypeDecl`-related APIs in `SIL.Type`
* rename `ProtocolConformance` to `Conformance`
* use `AST.Type`/`AST.CanonicalType` instead of `BridgedASTType` in SIL and the Optimizer
2024-10-02 07:10:29 +02:00
Erik Eckstein
4a1d6925e9 MandatoryPerformanceOptimizations: specialize witness tables to support class existentials with generic classes 2024-09-25 19:32:14 +02:00
Erik Eckstein
7ffd270008 embedded: move the VTableSpecializer pass into MandatoryPerformanceOptimizations
MandatoryPerformanceOptimizations already did most of the vtable specialization work.
So it makes sense to remove the VTableSpecializerPass completely and do everything in MandatoryPerformanceOptimizations.
2024-09-25 19:32:14 +02:00