diff --git a/include/swift/Serialization/ModuleFile.h b/include/swift/Serialization/ModuleFile.h index 917d790dbb5..0c54fb92599 100644 --- a/include/swift/Serialization/ModuleFile.h +++ b/include/swift/Serialization/ModuleFile.h @@ -87,46 +87,11 @@ class ModuleFile /// A callback to be invoked every time a type was deserialized. std::function DeserializedTypeCallback; - /// The number of entities that are currently being deserialized. - unsigned NumCurrentDeserializingEntities = 0; - /// Is this module file actually a .sib file? .sib files are serialized SIL at /// arbitrary granularity and arbitrary stage; unlike serialized Swift /// modules, which are assumed to contain canonical SIL for an entire module. bool IsSIB = false; - /// RAII class to be used when deserializing an entity. - class DeserializingEntityRAII { - ModuleFile &MF; - - public: - DeserializingEntityRAII(ModuleFile &mf) - : MF(mf.getModuleFileForDelayedActions()) { - ++MF.NumCurrentDeserializingEntities; - } - ~DeserializingEntityRAII() { - assert(MF.NumCurrentDeserializingEntities > 0 && - "Imbalanced currently-deserializing count?"); - if (MF.NumCurrentDeserializingEntities == 1) { - MF.finishPendingActions(); - } - - --MF.NumCurrentDeserializingEntities; - } - }; - friend class DeserializingEntityRAII; - - /// Picks a specific ModuleFile instance to serve as the "delayer" for the - /// entire module. - /// - /// This is usually \c this, but when there are partial swiftmodules all - /// loaded for the same module it may be different. - ModuleFile &getModuleFileForDelayedActions(); - - /// Finish any pending actions that were waiting for the topmost entity to - /// be deserialized. - void finishPendingActions(); - public: /// Represents another module that has been imported as a dependency. class Dependency { diff --git a/lib/Serialization/Deserialization.cpp b/lib/Serialization/Deserialization.cpp index 89172ded375..954de650c59 100644 --- a/lib/Serialization/Deserialization.cpp +++ b/lib/Serialization/Deserialization.cpp @@ -182,26 +182,6 @@ void ModuleFile::fatal(llvm::Error error) { abort(); } -ModuleFile &ModuleFile::getModuleFileForDelayedActions() { - assert(FileContext && "cannot delay actions before associating with a file"); - ModuleDecl *associatedModule = getAssociatedModule(); - - // Check for the common case. - if (associatedModule->getFiles().size() == 1) - return *this; - - for (FileUnit *file : associatedModule->getFiles()) - if (auto *serialized = dyn_cast(file)) - return serialized->File; - - llvm_unreachable("should always have FileContext in the list of files"); -} - -void ModuleFile::finishPendingActions() { - assert(&getModuleFileForDelayedActions() == this && - "wrong module used for delayed actions"); -} - static Optional getActualAccessorKind(uint8_t raw) { switch (serialization::AccessorKind(raw)) { @@ -883,7 +863,6 @@ GenericSignature *ModuleFile::getGenericSignature( // Read the generic signature. BCOffsetRAII restoreOffset(DeclTypeCursor); DeclTypeCursor.JumpToBit(sigOrOffset); - DeserializingEntityRAII deserializingEntity(*this); // Read the parameter types. SmallVector paramTypes; @@ -959,7 +938,6 @@ ModuleFile::getGenericSignatureOrEnvironment( // Read the generic environment. BCOffsetRAII restoreOffset(DeclTypeCursor); DeclTypeCursor.JumpToBit(bitOffset); - DeserializingEntityRAII deserializingEntity(*this); SmallVector paramTypes; using namespace decls_block; @@ -1067,7 +1045,6 @@ SubstitutionMap ModuleFile::getSubstitutionMap( // Read the substitution map. BCOffsetRAII restoreOffset(DeclTypeCursor); DeclTypeCursor.JumpToBit(substitutionsOrOffset); - DeserializingEntityRAII deserializingEntity(*this); // Read the substitution map. auto entry = DeclTypeCursor.advance(AF_DontPopBlockAtEnd); @@ -4007,7 +3984,6 @@ ModuleFile::getDeclChecked(DeclID DID) { BCOffsetRAII restoreOffset(DeclTypeCursor); DeclTypeCursor.JumpToBit(declOrOffset); - ModuleFile::DeserializingEntityRAII deserializingEntity(*this); Expected deserialized = DeclDeserializer(*this, declOrOffset).getDeclCheckedImpl(); if (!deserialized)