mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #85707 from eeckstein/embedded-witness-method-specialization
embedded: change the function representation of directly called witness methods
This commit is contained in:
@@ -2986,6 +2986,22 @@ struct BridgedASTType {
|
||||
ObjC
|
||||
};
|
||||
|
||||
enum class FunctionTypeRepresentation {
|
||||
Thick = 0,
|
||||
Block,
|
||||
Thin,
|
||||
CFunctionPointer,
|
||||
Method = 8,
|
||||
ObjCMethod,
|
||||
WitnessMethod,
|
||||
Closure,
|
||||
CXXMethod,
|
||||
KeyPathAccessorGetter,
|
||||
KeyPathAccessorSetter,
|
||||
KeyPathAccessorEquals,
|
||||
KeyPathAccessorHash
|
||||
};
|
||||
|
||||
swift::TypeBase * _Nullable type;
|
||||
|
||||
BRIDGED_INLINE swift::Type unbridged() const;
|
||||
@@ -3048,6 +3064,7 @@ struct BridgedASTType {
|
||||
BRIDGED_INLINE BridgedOptionalInt getValueOfIntegerType() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedSubstitutionMap getContextSubstitutionMap() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedGenericSignature getInvocationGenericSignatureOfFunctionType() const;
|
||||
BRIDGED_INLINE FunctionTypeRepresentation getFunctionTypeRepresentation() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType subst(BridgedSubstitutionMap substMap) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType mapOutOfEnvironment() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedCanType
|
||||
|
||||
@@ -717,6 +717,25 @@ BridgedGenericSignature BridgedASTType::getInvocationGenericSignatureOfFunctionT
|
||||
return {unbridged()->castTo<swift::SILFunctionType>()->getInvocationGenericSignature().getPointer()};
|
||||
}
|
||||
|
||||
BridgedASTType::FunctionTypeRepresentation BridgedASTType::getFunctionTypeRepresentation() const {
|
||||
static_assert((int)FunctionTypeRepresentation::Thick == (int)swift::SILFunctionTypeRepresentation::Thick);
|
||||
static_assert((int)FunctionTypeRepresentation::Block == (int)swift::SILFunctionTypeRepresentation::Block);
|
||||
static_assert((int)FunctionTypeRepresentation::Thin == (int)swift::SILFunctionTypeRepresentation::Thin);
|
||||
static_assert((int)FunctionTypeRepresentation::CFunctionPointer == (int)swift::SILFunctionTypeRepresentation::CFunctionPointer);
|
||||
static_assert((int)FunctionTypeRepresentation::Method == (int)swift::SILFunctionTypeRepresentation::Method);
|
||||
static_assert((int)FunctionTypeRepresentation::ObjCMethod == (int)swift::SILFunctionTypeRepresentation::ObjCMethod);
|
||||
static_assert((int)FunctionTypeRepresentation::WitnessMethod == (int)swift::SILFunctionTypeRepresentation::WitnessMethod);
|
||||
static_assert((int)FunctionTypeRepresentation::Closure == (int)swift::SILFunctionTypeRepresentation::Closure);
|
||||
static_assert((int)FunctionTypeRepresentation::CXXMethod == (int)swift::SILFunctionTypeRepresentation::CXXMethod);
|
||||
static_assert((int)FunctionTypeRepresentation::KeyPathAccessorGetter == (int)swift::SILFunctionTypeRepresentation::KeyPathAccessorGetter);
|
||||
static_assert((int)FunctionTypeRepresentation::KeyPathAccessorSetter == (int)swift::SILFunctionTypeRepresentation::KeyPathAccessorSetter);
|
||||
static_assert((int)FunctionTypeRepresentation::KeyPathAccessorEquals == (int)swift::SILFunctionTypeRepresentation::KeyPathAccessorEquals);
|
||||
static_assert((int)FunctionTypeRepresentation::KeyPathAccessorHash == (int)swift::SILFunctionTypeRepresentation::KeyPathAccessorHash);
|
||||
|
||||
auto fnType = unbridged()->castTo<swift::SILFunctionType>();
|
||||
return (FunctionTypeRepresentation)(fnType->getRepresentation());
|
||||
}
|
||||
|
||||
BridgedASTType BridgedASTType::subst(BridgedSubstitutionMap substMap) const {
|
||||
return {unbridged().subst(substMap.unbridged()).getPointer()};
|
||||
}
|
||||
|
||||
@@ -165,7 +165,8 @@ enum class SpecializationPass : uint8_t {
|
||||
MoveDiagnosticInOutToOut,
|
||||
AsyncDemotion,
|
||||
PackSpecialization,
|
||||
LAST = PackSpecialization
|
||||
EmbeddedWitnessCallSpecialization,
|
||||
LAST = EmbeddedWitnessCallSpecialization
|
||||
};
|
||||
|
||||
constexpr uint8_t MAX_SPECIALIZATION_PASS = 10;
|
||||
|
||||
@@ -399,6 +399,8 @@ NODE(OutlinedEnumProjectDataForLoad)
|
||||
NODE(OutlinedEnumGetTag)
|
||||
// Added in Swift 5.9 + 1
|
||||
NODE(AsyncRemoved)
|
||||
// Added in Swift 6.3 + 1
|
||||
NODE(RepresentationChanged)
|
||||
|
||||
// Added in Swift 5.TBD
|
||||
NODE(ObjectiveCProtocolSymbolicReference)
|
||||
|
||||
@@ -202,6 +202,7 @@ struct BridgedPassContext {
|
||||
BridgedFunction bridgedOriginalFunction) const;
|
||||
BridgedOwnedString mangleWithExplodedPackArgs(BridgedArrayRef bridgedPackArgs,
|
||||
BridgedFunction applySiteCallee) const;
|
||||
BridgedOwnedString mangleWithChangedRepresentation(BridgedFunction applySiteCallee) const;
|
||||
|
||||
void inlineFunction(BridgedInstruction apply, bool mandatoryInline) const;
|
||||
BRIDGED_INLINE bool eliminateDeadAllocations(BridgedFunction f) const;
|
||||
@@ -274,7 +275,7 @@ struct BridgedPassContext {
|
||||
const BridgedResultInfo *_Nullable specializedBridgedResults,
|
||||
SwiftInt resultCount,
|
||||
BridgedFunction bridgedOriginal,
|
||||
bool makeThin,
|
||||
BridgedASTType::FunctionTypeRepresentation representation,
|
||||
bool makeBare,
|
||||
bool preserveGenericSignature) const;
|
||||
|
||||
|
||||
@@ -75,6 +75,8 @@ PASS(MandatoryDestroyHoisting, "mandatory-destroy-hoisting",
|
||||
"Hoist destroy_value instructions for non-lexical values")
|
||||
PASS(DeadEndBlockDumper, "dump-deadendblocks",
|
||||
"Tests the DeadEndBlocks utility")
|
||||
PASS(EmbeddedWitnessCallSpecialization, "embedded-witness-call-specialization",
|
||||
"Mandatory witness method call specialization")
|
||||
PASS(EscapeInfoDumper, "dump-escape-info",
|
||||
"Dumps escape information")
|
||||
PASS(AddressEscapeInfoDumper, "dump-addr-escape-info",
|
||||
|
||||
@@ -104,6 +104,8 @@ class FunctionSignatureSpecializationMangler : public SpecializationMangler {
|
||||
|
||||
ReturnValueModifierIntBase ReturnValue;
|
||||
|
||||
bool changedRepresentation = false;
|
||||
|
||||
public:
|
||||
FunctionSignatureSpecializationMangler(ASTContext &Ctx, SpecializationPass Pass,
|
||||
swift::SerializedKind_t Serialized,
|
||||
@@ -123,6 +125,7 @@ public:
|
||||
void setArgumentBoxToStack(unsigned OrigArgIdx);
|
||||
void setArgumentInOutToOut(unsigned OrigArgIdx);
|
||||
void setReturnValueOwnedToUnowned();
|
||||
void setChangedRepresentation() { changedRepresentation = true; }
|
||||
|
||||
// For effects
|
||||
void setRemovedEffect(EffectKind effect);
|
||||
|
||||
Reference in New Issue
Block a user