mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
AST: GenericContexts store a GenericSignature instead of a GenericEnvironment
This eliminates the entire 'lazy generic environment' concept; essentially, all generic environments are now lazy, and since each signature has exactly one environment, their construction no longer needs to be co-ordinated with deserialization.
This commit is contained in:
@@ -68,7 +68,6 @@ namespace swift {
|
|||||||
class InFlightDiagnostic;
|
class InFlightDiagnostic;
|
||||||
class IterableDeclContext;
|
class IterableDeclContext;
|
||||||
class LazyContextData;
|
class LazyContextData;
|
||||||
class LazyGenericContextData;
|
|
||||||
class LazyIterableDeclContextData;
|
class LazyIterableDeclContextData;
|
||||||
class LazyMemberLoader;
|
class LazyMemberLoader;
|
||||||
class LazyResolver;
|
class LazyResolver;
|
||||||
@@ -817,15 +816,6 @@ public:
|
|||||||
LazyContextData *getOrCreateLazyContextData(const DeclContext *decl,
|
LazyContextData *getOrCreateLazyContextData(const DeclContext *decl,
|
||||||
LazyMemberLoader *lazyLoader);
|
LazyMemberLoader *lazyLoader);
|
||||||
|
|
||||||
/// Get the lazy function data for the given generic context.
|
|
||||||
///
|
|
||||||
/// \param lazyLoader If non-null, the lazy loader to use when creating the
|
|
||||||
/// function data. The pointer must either be null or be consistent
|
|
||||||
/// across all calls for the same \p func.
|
|
||||||
LazyGenericContextData *getOrCreateLazyGenericContextData(
|
|
||||||
const GenericContext *dc,
|
|
||||||
LazyMemberLoader *lazyLoader);
|
|
||||||
|
|
||||||
/// Get the lazy iterable context for the given iterable declaration context.
|
/// Get the lazy iterable context for the given iterable declaration context.
|
||||||
///
|
///
|
||||||
/// \param lazyLoader If non-null, the lazy loader to use when creating the
|
/// \param lazyLoader If non-null, the lazy loader to use when creating the
|
||||||
|
|||||||
@@ -1482,18 +1482,11 @@ public:
|
|||||||
/// moves the trailing where clause into the generic parameter list.
|
/// moves the trailing where clause into the generic parameter list.
|
||||||
TrailingWhereClause *TrailingWhere = nullptr;
|
TrailingWhereClause *TrailingWhere = nullptr;
|
||||||
|
|
||||||
/// The generic signature or environment of this declaration.
|
/// The generic signature of this declaration.
|
||||||
///
|
GenericSignature *GenericSig = nullptr;
|
||||||
/// When this declaration stores only a signature, the generic
|
|
||||||
/// environment will be lazily loaded.
|
|
||||||
mutable llvm::PointerUnion<GenericSignature *, GenericEnvironment *>
|
|
||||||
GenericSigOrEnv;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class GenericContext : private _GenericContext, public DeclContext {
|
class GenericContext : private _GenericContext, public DeclContext {
|
||||||
/// Lazily populate the generic environment.
|
|
||||||
GenericEnvironment *getLazyGenericEnvironmentSlow() const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
GenericContext(DeclContextKind Kind, DeclContext *Parent)
|
GenericContext(DeclContextKind Kind, DeclContext *Parent)
|
||||||
: _GenericContext(), DeclContext(Kind, Parent) { }
|
: _GenericContext(), DeclContext(Kind, Parent) { }
|
||||||
@@ -1542,18 +1535,12 @@ public:
|
|||||||
/// Retrieve the generic requirements.
|
/// Retrieve the generic requirements.
|
||||||
ArrayRef<Requirement> getGenericRequirements() const;
|
ArrayRef<Requirement> getGenericRequirements() const;
|
||||||
|
|
||||||
/// Set a lazy generic environment.
|
|
||||||
void setLazyGenericEnvironment(LazyMemberLoader *lazyLoader,
|
|
||||||
GenericSignature *genericSig,
|
|
||||||
uint64_t genericEnvData);
|
|
||||||
|
|
||||||
/// Whether this generic context has a lazily-created generic environment
|
|
||||||
/// that has not yet been constructed.
|
|
||||||
bool hasLazyGenericEnvironment() const;
|
|
||||||
|
|
||||||
/// Set the generic context of this context.
|
/// Set the generic context of this context.
|
||||||
void setGenericEnvironment(GenericEnvironment *genericEnv);
|
void setGenericEnvironment(GenericEnvironment *genericEnv);
|
||||||
|
|
||||||
|
/// Set the generic signature of this context.
|
||||||
|
void setGenericSignature(GenericSignature *genericSig);
|
||||||
|
|
||||||
/// Retrieve the position of any where clause for this context's
|
/// Retrieve the position of any where clause for this context's
|
||||||
/// generic parameters.
|
/// generic parameters.
|
||||||
SourceRange getGenericTrailingWhereClauseSourceRange() const;
|
SourceRange getGenericTrailingWhereClauseSourceRange() const;
|
||||||
|
|||||||
@@ -360,10 +360,6 @@ public:
|
|||||||
/// of its parents.
|
/// of its parents.
|
||||||
GenericEnvironment *getGenericEnvironmentOfContext() const;
|
GenericEnvironment *getGenericEnvironmentOfContext() const;
|
||||||
|
|
||||||
/// Whether the context has a generic environment that will be constructed
|
|
||||||
/// on first access (but has not yet been constructed).
|
|
||||||
bool contextHasLazyGenericEnvironment() const;
|
|
||||||
|
|
||||||
/// Map an interface type to a contextual type within this context.
|
/// Map an interface type to a contextual type within this context.
|
||||||
Type mapTypeIntoContext(Type type) const;
|
Type mapTypeIntoContext(Type type) const;
|
||||||
|
|
||||||
|
|||||||
@@ -85,15 +85,8 @@ public:
|
|||||||
LazyMemberLoader *loader;
|
LazyMemberLoader *loader;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Context data for generic contexts.
|
|
||||||
class LazyGenericContextData : public LazyContextData {
|
|
||||||
public:
|
|
||||||
/// The context data used for loading the generic environment.
|
|
||||||
uint64_t genericEnvData = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Context data for iterable decl contexts.
|
/// Context data for iterable decl contexts.
|
||||||
class LazyIterableDeclContextData : public LazyGenericContextData {
|
class LazyIterableDeclContextData : public LazyContextData {
|
||||||
public:
|
public:
|
||||||
/// The context data used for loading all of the members of the iterable
|
/// The context data used for loading all of the members of the iterable
|
||||||
/// context.
|
/// context.
|
||||||
@@ -145,10 +138,6 @@ public:
|
|||||||
virtual Type loadAssociatedTypeDefault(const AssociatedTypeDecl *ATD,
|
virtual Type loadAssociatedTypeDefault(const AssociatedTypeDecl *ATD,
|
||||||
uint64_t contextData) = 0;
|
uint64_t contextData) = 0;
|
||||||
|
|
||||||
/// Returns the generic environment.
|
|
||||||
virtual GenericEnvironment *loadGenericEnvironment(const DeclContext *decl,
|
|
||||||
uint64_t contextData) = 0;
|
|
||||||
|
|
||||||
/// Loads the requirement signature for a protocol.
|
/// Loads the requirement signature for a protocol.
|
||||||
virtual void
|
virtual void
|
||||||
loadRequirementSignature(const ProtocolDecl *proto, uint64_t contextData,
|
loadRequirementSignature(const ProtocolDecl *proto, uint64_t contextData,
|
||||||
|
|||||||
@@ -249,12 +249,6 @@ FRONTEND_STATISTIC(Sema, NumFunctionsTypechecked)
|
|||||||
/// amount of work the GSB does analyzing type signatures.
|
/// amount of work the GSB does analyzing type signatures.
|
||||||
FRONTEND_STATISTIC(Sema, NumGenericSignatureBuilders)
|
FRONTEND_STATISTIC(Sema, NumGenericSignatureBuilders)
|
||||||
|
|
||||||
/// Number of lazy generic environments registered.
|
|
||||||
FRONTEND_STATISTIC(Sema, NumLazyGenericEnvironments)
|
|
||||||
|
|
||||||
/// Number of lazy generic environments deserialized.
|
|
||||||
FRONTEND_STATISTIC(Sema, NumLazyGenericEnvironmentsLoaded)
|
|
||||||
|
|
||||||
/// Number of lazy requirement signatures registered.
|
/// Number of lazy requirement signatures registered.
|
||||||
FRONTEND_STATISTIC(Sema, NumLazyRequirementSignatures)
|
FRONTEND_STATISTIC(Sema, NumLazyRequirementSignatures)
|
||||||
|
|
||||||
|
|||||||
@@ -1970,10 +1970,10 @@ LazyContextData *ASTContext::getOrCreateLazyContextData(
|
|||||||
assert(lazyLoader && "Queried lazy data for non-lazy iterable context");
|
assert(lazyLoader && "Queried lazy data for non-lazy iterable context");
|
||||||
if (isa<ProtocolDecl>(dc))
|
if (isa<ProtocolDecl>(dc))
|
||||||
entry = Allocate<LazyProtocolData>();
|
entry = Allocate<LazyProtocolData>();
|
||||||
else if (isa<NominalTypeDecl>(dc) || isa<ExtensionDecl>(dc))
|
else {
|
||||||
|
assert(isa<NominalTypeDecl>(dc) || isa<ExtensionDecl>(dc));
|
||||||
entry = Allocate<LazyIterableDeclContextData>();
|
entry = Allocate<LazyIterableDeclContextData>();
|
||||||
else
|
}
|
||||||
entry = Allocate<LazyGenericContextData>();
|
|
||||||
|
|
||||||
entry->loader = lazyLoader;
|
entry->loader = lazyLoader;
|
||||||
return entry;
|
return entry;
|
||||||
@@ -1992,13 +1992,6 @@ LazyIterableDeclContextData *ASTContext::getOrCreateLazyIterableContextData(
|
|||||||
lazyLoader);
|
lazyLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
LazyGenericContextData *ASTContext::getOrCreateLazyGenericContextData(
|
|
||||||
const GenericContext *dc,
|
|
||||||
LazyMemberLoader *lazyLoader) {
|
|
||||||
return (LazyGenericContextData *)getOrCreateLazyContextData(dc,
|
|
||||||
lazyLoader);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ASTContext::hasDelayedConformanceErrors() const {
|
bool ASTContext::hasDelayedConformanceErrors() const {
|
||||||
for (const auto &entry : getImpl().DelayedConformanceDiags) {
|
for (const auto &entry : getImpl().DelayedConformanceDiags) {
|
||||||
auto &diagnostics = entry.getSecond();
|
auto &diagnostics = entry.getSecond();
|
||||||
|
|||||||
@@ -66,10 +66,6 @@ using namespace swift;
|
|||||||
|
|
||||||
#define DEBUG_TYPE "Serialization"
|
#define DEBUG_TYPE "Serialization"
|
||||||
|
|
||||||
STATISTIC(NumLazyGenericEnvironments,
|
|
||||||
"# of lazily-deserialized generic environments known");
|
|
||||||
STATISTIC(NumLazyGenericEnvironmentsLoaded,
|
|
||||||
"# of lazily-deserialized generic environments loaded");
|
|
||||||
STATISTIC(NumLazyRequirementSignatures,
|
STATISTIC(NumLazyRequirementSignatures,
|
||||||
"# of lazily-deserialized requirement signatures known");
|
"# of lazily-deserialized requirement signatures known");
|
||||||
|
|
||||||
@@ -829,11 +825,8 @@ void GenericContext::setGenericParams(GenericParamList *params) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GenericSignature *GenericContext::getGenericSignature() const {
|
GenericSignature *GenericContext::getGenericSignature() const {
|
||||||
if (auto genericEnv = GenericSigOrEnv.dyn_cast<GenericEnvironment *>())
|
if (GenericSig)
|
||||||
return genericEnv->getGenericSignature();
|
return GenericSig;
|
||||||
|
|
||||||
if (auto genericSig = GenericSigOrEnv.dyn_cast<GenericSignature *>())
|
|
||||||
return genericSig;
|
|
||||||
|
|
||||||
// The signature of a Protocol is trivial (Self: TheProtocol) so let's compute
|
// The signature of a Protocol is trivial (Self: TheProtocol) so let's compute
|
||||||
// it.
|
// it.
|
||||||
@@ -842,81 +835,28 @@ GenericSignature *GenericContext::getGenericSignature() const {
|
|||||||
auto self = PD->getSelfInterfaceType()->castTo<GenericTypeParamType>();
|
auto self = PD->getSelfInterfaceType()->castTo<GenericTypeParamType>();
|
||||||
auto req =
|
auto req =
|
||||||
Requirement(RequirementKind::Conformance, self, PD->getDeclaredType());
|
Requirement(RequirementKind::Conformance, self, PD->getDeclaredType());
|
||||||
auto *genericSig = GenericSignature::get({self}, {req});
|
const_cast<GenericContext *>(this)->GenericSig
|
||||||
|
= GenericSignature::get({self}, {req});
|
||||||
// Save it for next time.
|
return GenericSig;
|
||||||
const_cast<GenericContext *>(this)->GenericSigOrEnv = genericSig;
|
|
||||||
return genericSig;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
GenericEnvironment *GenericContext::getGenericEnvironment() const {
|
GenericEnvironment *GenericContext::getGenericEnvironment() const {
|
||||||
// Fast case: we already have a generic environment.
|
if (auto *genericSig = getGenericSignature())
|
||||||
if (auto genericEnv = GenericSigOrEnv.dyn_cast<GenericEnvironment *>())
|
return genericSig->getGenericEnvironment();
|
||||||
return genericEnv;
|
|
||||||
|
|
||||||
// If we only have a generic signature, build the generic environment.
|
|
||||||
if (GenericSigOrEnv.dyn_cast<GenericSignature *>() || isa<ProtocolDecl>(this))
|
|
||||||
return getLazyGenericEnvironmentSlow();
|
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GenericContext::hasLazyGenericEnvironment() const {
|
|
||||||
return GenericSigOrEnv.dyn_cast<GenericSignature *>() != nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GenericContext::setGenericEnvironment(GenericEnvironment *genericEnv) {
|
void GenericContext::setGenericEnvironment(GenericEnvironment *genericEnv) {
|
||||||
assert((GenericSigOrEnv.isNull() ||
|
setGenericSignature(genericEnv ? genericEnv->getGenericSignature() : nullptr);
|
||||||
getGenericSignature()->getCanonicalSignature() ==
|
|
||||||
genericEnv->getGenericSignature()->getCanonicalSignature()) &&
|
|
||||||
"set a generic environment with a different generic signature");
|
|
||||||
this->GenericSigOrEnv = genericEnv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GenericEnvironment *
|
void GenericContext::setGenericSignature(GenericSignature *genericSig) {
|
||||||
GenericContext::getLazyGenericEnvironmentSlow() const {
|
assert(GenericSig == nullptr && "Generic signature cannot be changed");
|
||||||
assert(GenericSigOrEnv.is<GenericSignature *>() &&
|
this->GenericSig = genericSig;
|
||||||
"not a lazily computed generic environment");
|
|
||||||
|
|
||||||
if (auto PD = dyn_cast<ProtocolDecl>(this)) {
|
|
||||||
// The signature of a Protocol is trivial (Self: TheProtocol) so let's
|
|
||||||
// compute it directly.
|
|
||||||
auto *genericEnv = getGenericSignature()->getGenericEnvironment();
|
|
||||||
const_cast<GenericContext *>(this)->setGenericEnvironment(genericEnv);
|
|
||||||
return genericEnv;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto contextData = getASTContext().getOrCreateLazyGenericContextData(
|
|
||||||
this, nullptr);
|
|
||||||
auto *genericEnv = contextData->loader->loadGenericEnvironment(
|
|
||||||
this, contextData->genericEnvData);
|
|
||||||
|
|
||||||
const_cast<GenericContext *>(this)->setGenericEnvironment(genericEnv);
|
|
||||||
++NumLazyGenericEnvironmentsLoaded;
|
|
||||||
// FIXME: (transitional) increment the redundant "always-on" counter.
|
|
||||||
if (getASTContext().Stats)
|
|
||||||
getASTContext().Stats->getFrontendCounters().NumLazyGenericEnvironmentsLoaded++;
|
|
||||||
return genericEnv;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GenericContext::setLazyGenericEnvironment(LazyMemberLoader *lazyLoader,
|
|
||||||
GenericSignature *genericSig,
|
|
||||||
uint64_t genericEnvData) {
|
|
||||||
assert(GenericSigOrEnv.isNull() && "already have a generic signature");
|
|
||||||
GenericSigOrEnv = genericSig;
|
|
||||||
|
|
||||||
auto contextData =
|
|
||||||
getASTContext().getOrCreateLazyGenericContextData(this, lazyLoader);
|
|
||||||
contextData->genericEnvData = genericEnvData;
|
|
||||||
|
|
||||||
++NumLazyGenericEnvironments;
|
|
||||||
// FIXME: (transitional) increment the redundant "always-on" counter.
|
|
||||||
if (getASTContext().Stats)
|
|
||||||
getASTContext().Stats->getFrontendCounters().NumLazyGenericEnvironments++;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SourceRange GenericContext::getGenericTrailingWhereClauseSourceRange() const {
|
SourceRange GenericContext::getGenericTrailingWhereClauseSourceRange() const {
|
||||||
|
|||||||
@@ -175,17 +175,6 @@ GenericEnvironment *DeclContext::getGenericEnvironmentOfContext() const {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeclContext::contextHasLazyGenericEnvironment() const {
|
|
||||||
auto dc = this;
|
|
||||||
do {
|
|
||||||
if (auto decl = dc->getAsDecl())
|
|
||||||
if (auto GC = decl->getAsGenericContext())
|
|
||||||
return GC->hasLazyGenericEnvironment();
|
|
||||||
} while ((dc = dc->getParent()));
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Type DeclContext::mapTypeIntoContext(Type type) const {
|
Type DeclContext::mapTypeIntoContext(Type type) const {
|
||||||
return GenericEnvironment::mapTypeIntoContext(
|
return GenericEnvironment::mapTypeIntoContext(
|
||||||
getGenericEnvironmentOfContext(), type);
|
getGenericEnvironmentOfContext(), type);
|
||||||
|
|||||||
@@ -1242,12 +1242,6 @@ public:
|
|||||||
uint64_t contextData) override {
|
uint64_t contextData) override {
|
||||||
llvm_unreachable("unimplemented for ClangImporter");
|
llvm_unreachable("unimplemented for ClangImporter");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the generic environment.
|
|
||||||
virtual GenericEnvironment *loadGenericEnvironment(const DeclContext *decl,
|
|
||||||
uint64_t contextData) override {
|
|
||||||
llvm_unreachable("unimplemented for ClangImporter");
|
|
||||||
}
|
|
||||||
|
|
||||||
void loadRequirementSignature(const ProtocolDecl *decl, uint64_t contextData,
|
void loadRequirementSignature(const ProtocolDecl *decl, uint64_t contextData,
|
||||||
SmallVectorImpl<Requirement> &reqs) override {
|
SmallVectorImpl<Requirement> &reqs) override {
|
||||||
|
|||||||
@@ -807,13 +807,6 @@ static void skipGenericRequirements(llvm::BitstreamCursor &Cursor) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleFile::configureGenericEnvironment(
|
|
||||||
GenericContext *genericDecl, serialization::GenericSignatureID sigID) {
|
|
||||||
if (sigID == 0) return;
|
|
||||||
auto *genericSig = getGenericSignature(sigID);
|
|
||||||
genericDecl->setLazyGenericEnvironment(this, genericSig, sigID);
|
|
||||||
}
|
|
||||||
|
|
||||||
GenericSignature *ModuleFile::getGenericSignature(
|
GenericSignature *ModuleFile::getGenericSignature(
|
||||||
serialization::GenericSignatureID ID) {
|
serialization::GenericSignatureID ID) {
|
||||||
using namespace decls_block;
|
using namespace decls_block;
|
||||||
@@ -2196,13 +2189,13 @@ public:
|
|||||||
DeclContextID contextID;
|
DeclContextID contextID;
|
||||||
TypeID underlyingTypeID, interfaceTypeID;
|
TypeID underlyingTypeID, interfaceTypeID;
|
||||||
bool isImplicit;
|
bool isImplicit;
|
||||||
GenericSignatureID genericEnvID;
|
GenericSignatureID genericSigID;
|
||||||
uint8_t rawAccessLevel;
|
uint8_t rawAccessLevel;
|
||||||
ArrayRef<uint64_t> dependencyIDs;
|
ArrayRef<uint64_t> dependencyIDs;
|
||||||
|
|
||||||
decls_block::TypeAliasLayout::readRecord(scratch, nameID, contextID,
|
decls_block::TypeAliasLayout::readRecord(scratch, nameID, contextID,
|
||||||
underlyingTypeID, interfaceTypeID,
|
underlyingTypeID, interfaceTypeID,
|
||||||
isImplicit, genericEnvID,
|
isImplicit, genericSigID,
|
||||||
rawAccessLevel, dependencyIDs);
|
rawAccessLevel, dependencyIDs);
|
||||||
|
|
||||||
Identifier name = MF.getIdentifier(nameID);
|
Identifier name = MF.getIdentifier(nameID);
|
||||||
@@ -2225,7 +2218,7 @@ public:
|
|||||||
SourceLoc(), genericParams, DC);
|
SourceLoc(), genericParams, DC);
|
||||||
declOrOffset = alias;
|
declOrOffset = alias;
|
||||||
|
|
||||||
MF.configureGenericEnvironment(alias, genericEnvID);
|
alias->setGenericSignature(MF.getGenericSignature(genericSigID));
|
||||||
|
|
||||||
alias->setUnderlyingType(MF.getType(underlyingTypeID));
|
alias->setUnderlyingType(MF.getType(underlyingTypeID));
|
||||||
|
|
||||||
@@ -2324,13 +2317,13 @@ public:
|
|||||||
DeclContextID contextID;
|
DeclContextID contextID;
|
||||||
bool isImplicit;
|
bool isImplicit;
|
||||||
bool isObjC;
|
bool isObjC;
|
||||||
GenericSignatureID genericEnvID;
|
GenericSignatureID genericSigID;
|
||||||
uint8_t rawAccessLevel;
|
uint8_t rawAccessLevel;
|
||||||
unsigned numConformances, numInheritedTypes;
|
unsigned numConformances, numInheritedTypes;
|
||||||
ArrayRef<uint64_t> rawInheritedAndDependencyIDs;
|
ArrayRef<uint64_t> rawInheritedAndDependencyIDs;
|
||||||
|
|
||||||
decls_block::StructLayout::readRecord(scratch, nameID, contextID,
|
decls_block::StructLayout::readRecord(scratch, nameID, contextID,
|
||||||
isImplicit, isObjC, genericEnvID,
|
isImplicit, isObjC, genericSigID,
|
||||||
rawAccessLevel,
|
rawAccessLevel,
|
||||||
numConformances, numInheritedTypes,
|
numConformances, numInheritedTypes,
|
||||||
rawInheritedAndDependencyIDs);
|
rawInheritedAndDependencyIDs);
|
||||||
@@ -2359,7 +2352,7 @@ public:
|
|||||||
declOrOffset = theStruct;
|
declOrOffset = theStruct;
|
||||||
|
|
||||||
// Read the generic environment.
|
// Read the generic environment.
|
||||||
MF.configureGenericEnvironment(theStruct, genericEnvID);
|
theStruct->setGenericSignature(MF.getGenericSignature(genericSigID));
|
||||||
|
|
||||||
if (auto accessLevel = getActualAccessLevel(rawAccessLevel))
|
if (auto accessLevel = getActualAccessLevel(rawAccessLevel))
|
||||||
theStruct->setAccess(*accessLevel);
|
theStruct->setAccess(*accessLevel);
|
||||||
@@ -2391,7 +2384,7 @@ public:
|
|||||||
DeclContextID contextID;
|
DeclContextID contextID;
|
||||||
bool isIUO, isFailable;
|
bool isIUO, isFailable;
|
||||||
bool isImplicit, isObjC, hasStubImplementation, throws;
|
bool isImplicit, isObjC, hasStubImplementation, throws;
|
||||||
GenericSignatureID genericEnvID;
|
GenericSignatureID genericSigID;
|
||||||
uint8_t storedInitKind, rawAccessLevel;
|
uint8_t storedInitKind, rawAccessLevel;
|
||||||
DeclID overriddenID;
|
DeclID overriddenID;
|
||||||
bool needsNewVTableEntry, firstTimeRequired;
|
bool needsNewVTableEntry, firstTimeRequired;
|
||||||
@@ -2402,7 +2395,7 @@ public:
|
|||||||
isFailable, isIUO, isImplicit,
|
isFailable, isIUO, isImplicit,
|
||||||
isObjC, hasStubImplementation,
|
isObjC, hasStubImplementation,
|
||||||
throws, storedInitKind,
|
throws, storedInitKind,
|
||||||
genericEnvID,
|
genericSigID,
|
||||||
overriddenID,
|
overriddenID,
|
||||||
rawAccessLevel,
|
rawAccessLevel,
|
||||||
needsNewVTableEntry,
|
needsNewVTableEntry,
|
||||||
@@ -2461,7 +2454,7 @@ public:
|
|||||||
genericParams, parent);
|
genericParams, parent);
|
||||||
declOrOffset = ctor;
|
declOrOffset = ctor;
|
||||||
|
|
||||||
MF.configureGenericEnvironment(ctor, genericEnvID);
|
ctor->setGenericSignature(MF.getGenericSignature(genericSigID));
|
||||||
|
|
||||||
if (auto accessLevel = getActualAccessLevel(rawAccessLevel))
|
if (auto accessLevel = getActualAccessLevel(rawAccessLevel))
|
||||||
ctor->setAccess(*accessLevel);
|
ctor->setAccess(*accessLevel);
|
||||||
@@ -2750,7 +2743,7 @@ public:
|
|||||||
uint8_t rawAccessorKind;
|
uint8_t rawAccessorKind;
|
||||||
bool isObjC, hasForcedStaticDispatch, throws;
|
bool isObjC, hasForcedStaticDispatch, throws;
|
||||||
unsigned numNameComponentsBiased;
|
unsigned numNameComponentsBiased;
|
||||||
GenericSignatureID genericEnvID;
|
GenericSignatureID genericSigID;
|
||||||
TypeID resultInterfaceTypeID;
|
TypeID resultInterfaceTypeID;
|
||||||
bool isIUO;
|
bool isIUO;
|
||||||
DeclID associatedDeclID;
|
DeclID associatedDeclID;
|
||||||
@@ -2765,7 +2758,7 @@ public:
|
|||||||
isStatic, rawStaticSpelling, isObjC,
|
isStatic, rawStaticSpelling, isObjC,
|
||||||
rawMutModifier,
|
rawMutModifier,
|
||||||
hasForcedStaticDispatch, throws,
|
hasForcedStaticDispatch, throws,
|
||||||
genericEnvID,
|
genericSigID,
|
||||||
resultInterfaceTypeID,
|
resultInterfaceTypeID,
|
||||||
isIUO,
|
isIUO,
|
||||||
associatedDeclID, overriddenID,
|
associatedDeclID, overriddenID,
|
||||||
@@ -2779,7 +2772,7 @@ public:
|
|||||||
isStatic, rawStaticSpelling, isObjC,
|
isStatic, rawStaticSpelling, isObjC,
|
||||||
rawMutModifier,
|
rawMutModifier,
|
||||||
hasForcedStaticDispatch, throws,
|
hasForcedStaticDispatch, throws,
|
||||||
genericEnvID,
|
genericSigID,
|
||||||
resultInterfaceTypeID,
|
resultInterfaceTypeID,
|
||||||
isIUO,
|
isIUO,
|
||||||
overriddenID,
|
overriddenID,
|
||||||
@@ -2911,7 +2904,7 @@ public:
|
|||||||
}
|
}
|
||||||
declOrOffset = fn;
|
declOrOffset = fn;
|
||||||
|
|
||||||
MF.configureGenericEnvironment(fn, genericEnvID);
|
fn->setGenericSignature(MF.getGenericSignature(genericSigID));
|
||||||
|
|
||||||
if (auto accessLevel = getActualAccessLevel(rawAccessLevel))
|
if (auto accessLevel = getActualAccessLevel(rawAccessLevel))
|
||||||
fn->setAccess(*accessLevel);
|
fn->setAccess(*accessLevel);
|
||||||
@@ -3295,7 +3288,7 @@ public:
|
|||||||
DeclContextID contextID;
|
DeclContextID contextID;
|
||||||
bool isImplicit, isObjC;
|
bool isImplicit, isObjC;
|
||||||
bool inheritsSuperclassInitializers;
|
bool inheritsSuperclassInitializers;
|
||||||
GenericSignatureID genericEnvID;
|
GenericSignatureID genericSigID;
|
||||||
TypeID superclassID;
|
TypeID superclassID;
|
||||||
uint8_t rawAccessLevel;
|
uint8_t rawAccessLevel;
|
||||||
unsigned numConformances, numInheritedTypes;
|
unsigned numConformances, numInheritedTypes;
|
||||||
@@ -3303,7 +3296,7 @@ public:
|
|||||||
decls_block::ClassLayout::readRecord(scratch, nameID, contextID,
|
decls_block::ClassLayout::readRecord(scratch, nameID, contextID,
|
||||||
isImplicit, isObjC,
|
isImplicit, isObjC,
|
||||||
inheritsSuperclassInitializers,
|
inheritsSuperclassInitializers,
|
||||||
genericEnvID, superclassID,
|
genericSigID, superclassID,
|
||||||
rawAccessLevel, numConformances,
|
rawAccessLevel, numConformances,
|
||||||
numInheritedTypes,
|
numInheritedTypes,
|
||||||
rawInheritedAndDependencyIDs);
|
rawInheritedAndDependencyIDs);
|
||||||
@@ -3331,7 +3324,7 @@ public:
|
|||||||
None, genericParams, DC);
|
None, genericParams, DC);
|
||||||
declOrOffset = theClass;
|
declOrOffset = theClass;
|
||||||
|
|
||||||
MF.configureGenericEnvironment(theClass, genericEnvID);
|
theClass->setGenericSignature(MF.getGenericSignature(genericSigID));
|
||||||
|
|
||||||
if (auto accessLevel = getActualAccessLevel(rawAccessLevel))
|
if (auto accessLevel = getActualAccessLevel(rawAccessLevel))
|
||||||
theClass->setAccess(*accessLevel);
|
theClass->setAccess(*accessLevel);
|
||||||
@@ -3368,14 +3361,14 @@ public:
|
|||||||
DeclContextID contextID;
|
DeclContextID contextID;
|
||||||
bool isImplicit;
|
bool isImplicit;
|
||||||
bool isObjC;
|
bool isObjC;
|
||||||
GenericSignatureID genericEnvID;
|
GenericSignatureID genericSigID;
|
||||||
TypeID rawTypeID;
|
TypeID rawTypeID;
|
||||||
uint8_t rawAccessLevel;
|
uint8_t rawAccessLevel;
|
||||||
unsigned numConformances, numInherited;
|
unsigned numConformances, numInherited;
|
||||||
ArrayRef<uint64_t> rawInheritedAndDependencyIDs;
|
ArrayRef<uint64_t> rawInheritedAndDependencyIDs;
|
||||||
|
|
||||||
decls_block::EnumLayout::readRecord(scratch, nameID, contextID,
|
decls_block::EnumLayout::readRecord(scratch, nameID, contextID,
|
||||||
isImplicit, isObjC, genericEnvID,
|
isImplicit, isObjC, genericSigID,
|
||||||
rawTypeID, rawAccessLevel,
|
rawTypeID, rawAccessLevel,
|
||||||
numConformances, numInherited,
|
numConformances, numInherited,
|
||||||
rawInheritedAndDependencyIDs);
|
rawInheritedAndDependencyIDs);
|
||||||
@@ -3403,7 +3396,7 @@ public:
|
|||||||
|
|
||||||
declOrOffset = theEnum;
|
declOrOffset = theEnum;
|
||||||
|
|
||||||
MF.configureGenericEnvironment(theEnum, genericEnvID);
|
theEnum->setGenericSignature(MF.getGenericSignature(genericSigID));
|
||||||
|
|
||||||
if (auto accessLevel = getActualAccessLevel(rawAccessLevel))
|
if (auto accessLevel = getActualAccessLevel(rawAccessLevel))
|
||||||
theEnum->setAccess(*accessLevel);
|
theEnum->setAccess(*accessLevel);
|
||||||
@@ -3518,7 +3511,7 @@ public:
|
|||||||
StringRef blobData) {
|
StringRef blobData) {
|
||||||
DeclContextID contextID;
|
DeclContextID contextID;
|
||||||
bool isImplicit, isObjC, isGetterMutating, isSetterMutating;
|
bool isImplicit, isObjC, isGetterMutating, isSetterMutating;
|
||||||
GenericSignatureID genericEnvID;
|
GenericSignatureID genericSigID;
|
||||||
TypeID elemInterfaceTypeID;
|
TypeID elemInterfaceTypeID;
|
||||||
bool isIUO;
|
bool isIUO;
|
||||||
ModuleFile::AccessorRecord accessors;
|
ModuleFile::AccessorRecord accessors;
|
||||||
@@ -3535,7 +3528,7 @@ public:
|
|||||||
opaqueReadOwnership,
|
opaqueReadOwnership,
|
||||||
readImpl, writeImpl, readWriteImpl,
|
readImpl, writeImpl, readWriteImpl,
|
||||||
numAccessors,
|
numAccessors,
|
||||||
genericEnvID,
|
genericSigID,
|
||||||
elemInterfaceTypeID,
|
elemInterfaceTypeID,
|
||||||
isIUO,
|
isIUO,
|
||||||
overriddenID, rawAccessLevel,
|
overriddenID, rawAccessLevel,
|
||||||
@@ -3597,7 +3590,7 @@ public:
|
|||||||
subscript->setIsSetterMutating(isSetterMutating);
|
subscript->setIsSetterMutating(isSetterMutating);
|
||||||
declOrOffset = subscript;
|
declOrOffset = subscript;
|
||||||
|
|
||||||
MF.configureGenericEnvironment(subscript, genericEnvID);
|
subscript->setGenericSignature(MF.getGenericSignature(genericSigID));
|
||||||
|
|
||||||
subscript->setIndices(MF.readParameterList());
|
subscript->setIndices(MF.readParameterList());
|
||||||
|
|
||||||
@@ -3642,13 +3635,13 @@ public:
|
|||||||
DeclID extendedNominalID;
|
DeclID extendedNominalID;
|
||||||
DeclContextID contextID;
|
DeclContextID contextID;
|
||||||
bool isImplicit;
|
bool isImplicit;
|
||||||
GenericSignatureID genericEnvID;
|
GenericSignatureID genericSigID;
|
||||||
unsigned numConformances, numInherited;
|
unsigned numConformances, numInherited;
|
||||||
ArrayRef<uint64_t> inheritedAndDependencyIDs;
|
ArrayRef<uint64_t> inheritedAndDependencyIDs;
|
||||||
|
|
||||||
decls_block::ExtensionLayout::readRecord(scratch, extendedTypeID,
|
decls_block::ExtensionLayout::readRecord(scratch, extendedTypeID,
|
||||||
extendedNominalID, contextID,
|
extendedNominalID, contextID,
|
||||||
isImplicit, genericEnvID,
|
isImplicit, genericSigID,
|
||||||
numConformances, numInherited,
|
numConformances, numInherited,
|
||||||
inheritedAndDependencyIDs);
|
inheritedAndDependencyIDs);
|
||||||
|
|
||||||
@@ -3682,7 +3675,7 @@ public:
|
|||||||
outerParams = genericParams;
|
outerParams = genericParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
MF.configureGenericEnvironment(extension, genericEnvID);
|
extension->setGenericSignature(MF.getGenericSignature(genericSigID));
|
||||||
|
|
||||||
auto extendedType = MF.getType(extendedTypeID);
|
auto extendedType = MF.getType(extendedTypeID);
|
||||||
ctx.evaluator.cacheOutput(ExtendedTypeRequest{extension},
|
ctx.evaluator.cacheOutput(ExtendedTypeRequest{extension},
|
||||||
@@ -3726,11 +3719,11 @@ public:
|
|||||||
StringRef blobData) {
|
StringRef blobData) {
|
||||||
DeclContextID contextID;
|
DeclContextID contextID;
|
||||||
bool isImplicit, isObjC;
|
bool isImplicit, isObjC;
|
||||||
GenericSignatureID genericEnvID;
|
GenericSignatureID genericSigID;
|
||||||
|
|
||||||
decls_block::DestructorLayout::readRecord(scratch, contextID,
|
decls_block::DestructorLayout::readRecord(scratch, contextID,
|
||||||
isImplicit, isObjC,
|
isImplicit, isObjC,
|
||||||
genericEnvID);
|
genericSigID);
|
||||||
|
|
||||||
DeclContext *DC = MF.getDeclContext(contextID);
|
DeclContext *DC = MF.getDeclContext(contextID);
|
||||||
if (declOrOffset.isComplete())
|
if (declOrOffset.isComplete())
|
||||||
@@ -3742,7 +3735,7 @@ public:
|
|||||||
if (auto bodyText = MF.maybeReadInlinableBodyText())
|
if (auto bodyText = MF.maybeReadInlinableBodyText())
|
||||||
dtor->setBodyStringRepresentation(*bodyText);
|
dtor->setBodyStringRepresentation(*bodyText);
|
||||||
|
|
||||||
MF.configureGenericEnvironment(dtor, genericEnvID);
|
dtor->setGenericSignature(MF.getGenericSignature(genericSigID));
|
||||||
|
|
||||||
dtor->setAccess(std::max(cast<ClassDecl>(DC)->getFormalAccess(),
|
dtor->setAccess(std::max(cast<ClassDecl>(DC)->getFormalAccess(),
|
||||||
AccessLevel::Internal));
|
AccessLevel::Internal));
|
||||||
@@ -5498,11 +5491,6 @@ void ModuleFile::finishNormalConformance(NormalProtocolConformance *conformance,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GenericEnvironment *ModuleFile::loadGenericEnvironment(const DeclContext *decl,
|
|
||||||
uint64_t contextData) {
|
|
||||||
return decl->getGenericSignatureOfContext()->getGenericEnvironment();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ModuleFile::loadRequirementSignature(const ProtocolDecl *decl,
|
void ModuleFile::loadRequirementSignature(const ProtocolDecl *decl,
|
||||||
uint64_t contextData,
|
uint64_t contextData,
|
||||||
SmallVectorImpl<Requirement> &reqs) {
|
SmallVectorImpl<Requirement> &reqs) {
|
||||||
|
|||||||
@@ -554,11 +554,6 @@ private:
|
|||||||
void readGenericRequirements(SmallVectorImpl<Requirement> &requirements,
|
void readGenericRequirements(SmallVectorImpl<Requirement> &requirements,
|
||||||
llvm::BitstreamCursor &Cursor);
|
llvm::BitstreamCursor &Cursor);
|
||||||
|
|
||||||
/// Set up a (potentially lazy) generic environment for the given type,
|
|
||||||
/// function or extension.
|
|
||||||
void configureGenericEnvironment(GenericContext *genericDecl,
|
|
||||||
serialization::GenericSignatureID envID);
|
|
||||||
|
|
||||||
/// Populates the protocol's default witness table.
|
/// Populates the protocol's default witness table.
|
||||||
///
|
///
|
||||||
/// Returns true if there is an error.
|
/// Returns true if there is an error.
|
||||||
@@ -789,9 +784,6 @@ public:
|
|||||||
virtual void finishNormalConformance(NormalProtocolConformance *conformance,
|
virtual void finishNormalConformance(NormalProtocolConformance *conformance,
|
||||||
uint64_t contextData) override;
|
uint64_t contextData) override;
|
||||||
|
|
||||||
GenericEnvironment *loadGenericEnvironment(const DeclContext *decl,
|
|
||||||
uint64_t contextData) override;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
loadRequirementSignature(const ProtocolDecl *proto, uint64_t contextData,
|
loadRequirementSignature(const ProtocolDecl *proto, uint64_t contextData,
|
||||||
SmallVectorImpl<Requirement> &requirements) override;
|
SmallVectorImpl<Requirement> &requirements) override;
|
||||||
|
|||||||
Reference in New Issue
Block a user