Skip to content

Commit f5b99c7

Browse files
committed
[Serialization] Stop pre-loading generic environments.
Make generic environment deserialization lazy, which eliminates a significant amount of up-front work. Most clients only need the generic signature, not the full generic environment.
1 parent f792aea commit f5b99c7

File tree

3 files changed

+1
-24
lines changed

3 files changed

+1
-24
lines changed

include/swift/Serialization/ModuleFile.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,6 @@ class ModuleFile : public LazyMemberLoader {
8484
/// The number of entities that are currently being deserialized.
8585
unsigned NumCurrentDeserializingEntities = 0;
8686

87-
/// Declaration contexts with delayed generic environments, which will be
88-
/// completed as a pending action.
89-
///
90-
/// This should only be used on the module returned by
91-
/// getModuleFileForDelayedActions().
92-
///
93-
/// FIXME: This is needed because completing a generic environment can
94-
/// require the type checker, which might be gone if we delay generic
95-
/// environments too far. It is a hack.
96-
std::vector<DeclContext *> DelayedGenericEnvironments;
97-
9887
/// RAII class to be used when deserializing an entity.
9988
class DeserializingEntityRAII {
10089
ModuleFile &MF;

lib/Serialization/Deserialization.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,6 @@ ModuleFile &ModuleFile::getModuleFileForDelayedActions() {
207207
void ModuleFile::finishPendingActions() {
208208
assert(&getModuleFileForDelayedActions() == this &&
209209
"wrong module used for delayed actions");
210-
while (!DelayedGenericEnvironments.empty()) {
211-
// Force completion of the last generic environment.
212-
auto genericEnvDC = DelayedGenericEnvironments.back();
213-
DelayedGenericEnvironments.pop_back();
214-
(void)genericEnvDC->getGenericEnvironmentOfContext();
215-
}
216210
}
217211

218212
/// Translate from the serialization DefaultArgumentKind enumerators, which are
@@ -922,8 +916,6 @@ void ModuleFile::configureGenericEnvironment(
922916
// creation.
923917
if (auto genericSig = sigOrEnv.dyn_cast<GenericSignature *>()) {
924918
genericDecl->setLazyGenericEnvironment(this, genericSig, envID);
925-
ModuleFile &delayedActionFile = getModuleFileForDelayedActions();
926-
delayedActionFile.DelayedGenericEnvironments.push_back(genericDecl);
927919
return;
928920
}
929921

lib/Serialization/ModuleFile.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,11 +1297,7 @@ Status ModuleFile::associateWithFileContext(FileUnit *file,
12971297
return getStatus();
12981298
}
12991299

1300-
ModuleFile::~ModuleFile() {
1301-
assert(DelayedGenericEnvironments.empty() &&
1302-
"either finishPendingActions() was never called, or someone forgot "
1303-
"to use getModuleFileForDelayedActions()");
1304-
}
1300+
ModuleFile::~ModuleFile() { }
13051301

13061302
void ModuleFile::lookupValue(DeclName name,
13071303
SmallVectorImpl<ValueDecl*> &results) {

0 commit comments

Comments
 (0)