mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #85551 from aschwaighofer/wip_embedded_exit
Preliminary support for existential in embedded Swift
This commit is contained in:
@@ -89,11 +89,18 @@ enum class TypeMetadataAddress {
|
||||
inline bool isEmbedded(CanType t) {
|
||||
return t->getASTContext().LangOpts.hasFeature(Feature::Embedded);
|
||||
}
|
||||
|
||||
inline bool isEmbeddedWithoutEmbeddedExitentials(CanType t) {
|
||||
auto &langOpts = t->getASTContext().LangOpts;
|
||||
return langOpts.hasFeature(Feature::Embedded) &&
|
||||
!langOpts.hasFeature(Feature::EmbeddedExistentials);
|
||||
}
|
||||
// Metadata is not generated and not allowed to be referenced in Embedded Swift,
|
||||
// expect for classes (both generic and non-generic), dynamic self, and
|
||||
// class-bound existentials.
|
||||
inline bool isMetadataAllowedInEmbedded(CanType t) {
|
||||
bool embeddedExistentials =
|
||||
t->getASTContext().LangOpts.hasFeature(Feature::EmbeddedExistentials);
|
||||
|
||||
if (isa<ClassType>(t) || isa<BoundGenericClassType>(t) ||
|
||||
isa<DynamicSelfType>(t)) {
|
||||
return true;
|
||||
@@ -106,6 +113,9 @@ inline bool isMetadataAllowedInEmbedded(CanType t) {
|
||||
if (archeTy->requiresClass())
|
||||
return true;
|
||||
}
|
||||
|
||||
if (embeddedExistentials)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -117,6 +127,11 @@ inline bool isEmbedded(const ProtocolConformance *c) {
|
||||
return c->getType()->getASTContext().LangOpts.hasFeature(Feature::Embedded);
|
||||
}
|
||||
|
||||
inline bool isEmbeddedWithoutEmbeddedExitentials(const ProtocolConformance *c) {
|
||||
return isEmbedded(c) && !c->getType()->getASTContext().
|
||||
LangOpts.hasFeature(Feature::EmbeddedExistentials);
|
||||
}
|
||||
|
||||
/// A link entity is some sort of named declaration, combined with all
|
||||
/// the information necessary to distinguish specific implementations
|
||||
/// of the declaration from each other.
|
||||
@@ -1098,7 +1113,7 @@ public:
|
||||
}
|
||||
|
||||
static LinkEntity forValueWitnessTable(CanType type) {
|
||||
assert(!isEmbedded(type));
|
||||
assert(!isEmbeddedWithoutEmbeddedExitentials(type));
|
||||
LinkEntity entity;
|
||||
entity.setForType(Kind::ValueWitnessTable, type);
|
||||
return entity;
|
||||
@@ -1128,7 +1143,7 @@ public:
|
||||
}
|
||||
|
||||
static LinkEntity forProtocolWitnessTable(const ProtocolConformance *C) {
|
||||
if (isEmbedded(C)) {
|
||||
if (isEmbeddedWithoutEmbeddedExitentials(C)) {
|
||||
assert(C->getProtocol()->requiresClass());
|
||||
}
|
||||
|
||||
|
||||
@@ -236,6 +236,14 @@ FUNCTION(NativeStrongReleaseDirect, Swift, swift_releaseDirect, SwiftDirectRR_CC
|
||||
EFFECT(RuntimeEffect::RefCounting, RuntimeEffect::Deallocating),
|
||||
UNKNOWN_MEMEFFECTS)
|
||||
|
||||
// void swift_releaseBox(void *ptr);
|
||||
FUNCTION(ReleaseBox, Swift, swift_releaseBox, C_CC, AlwaysAvailable,
|
||||
RETURNS(VoidTy),
|
||||
ARGS(RefCountedPtrTy),
|
||||
ATTRS(NoUnwind),
|
||||
EFFECT(RuntimeEffect::RefCounting, RuntimeEffect::Deallocating),
|
||||
UNKNOWN_MEMEFFECTS)
|
||||
|
||||
// void *swift_retain_n(void *ptr, int32_t n);
|
||||
FUNCTION(NativeStrongRetainN, Swift, swift_retain_n, C_CC, AlwaysAvailable,
|
||||
RETURNS(RefCountedPtrTy),
|
||||
|
||||
Reference in New Issue
Block a user