Skip to content

Commit 57b1ea8

Browse files
committed
[Serialization] Remove "delayed actions" support
Previously, cycle-breaking logic would delay certain actions until all re-entrant deserialization was complete for a particular module. That hasn't been used in a while, though, now that the AST itself supports more laziness, so let's take it out. No functionality change; this really was unused.
1 parent 6562fa4 commit 57b1ea8

File tree

2 files changed

+0
-59
lines changed

2 files changed

+0
-59
lines changed

include/swift/Serialization/ModuleFile.h

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -87,46 +87,11 @@ class ModuleFile
8787
/// A callback to be invoked every time a type was deserialized.
8888
std::function<void(Type)> DeserializedTypeCallback;
8989

90-
/// The number of entities that are currently being deserialized.
91-
unsigned NumCurrentDeserializingEntities = 0;
92-
9390
/// Is this module file actually a .sib file? .sib files are serialized SIL at
9491
/// arbitrary granularity and arbitrary stage; unlike serialized Swift
9592
/// modules, which are assumed to contain canonical SIL for an entire module.
9693
bool IsSIB = false;
9794

98-
/// RAII class to be used when deserializing an entity.
99-
class DeserializingEntityRAII {
100-
ModuleFile &MF;
101-
102-
public:
103-
DeserializingEntityRAII(ModuleFile &mf)
104-
: MF(mf.getModuleFileForDelayedActions()) {
105-
++MF.NumCurrentDeserializingEntities;
106-
}
107-
~DeserializingEntityRAII() {
108-
assert(MF.NumCurrentDeserializingEntities > 0 &&
109-
"Imbalanced currently-deserializing count?");
110-
if (MF.NumCurrentDeserializingEntities == 1) {
111-
MF.finishPendingActions();
112-
}
113-
114-
--MF.NumCurrentDeserializingEntities;
115-
}
116-
};
117-
friend class DeserializingEntityRAII;
118-
119-
/// Picks a specific ModuleFile instance to serve as the "delayer" for the
120-
/// entire module.
121-
///
122-
/// This is usually \c this, but when there are partial swiftmodules all
123-
/// loaded for the same module it may be different.
124-
ModuleFile &getModuleFileForDelayedActions();
125-
126-
/// Finish any pending actions that were waiting for the topmost entity to
127-
/// be deserialized.
128-
void finishPendingActions();
129-
13095
public:
13196
/// Represents another module that has been imported as a dependency.
13297
class Dependency {

lib/Serialization/Deserialization.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -182,26 +182,6 @@ void ModuleFile::fatal(llvm::Error error) {
182182
abort();
183183
}
184184

185-
ModuleFile &ModuleFile::getModuleFileForDelayedActions() {
186-
assert(FileContext && "cannot delay actions before associating with a file");
187-
ModuleDecl *associatedModule = getAssociatedModule();
188-
189-
// Check for the common case.
190-
if (associatedModule->getFiles().size() == 1)
191-
return *this;
192-
193-
for (FileUnit *file : associatedModule->getFiles())
194-
if (auto *serialized = dyn_cast<SerializedASTFile>(file))
195-
return serialized->File;
196-
197-
llvm_unreachable("should always have FileContext in the list of files");
198-
}
199-
200-
void ModuleFile::finishPendingActions() {
201-
assert(&getModuleFileForDelayedActions() == this &&
202-
"wrong module used for delayed actions");
203-
}
204-
205185
static Optional<swift::AccessorKind>
206186
getActualAccessorKind(uint8_t raw) {
207187
switch (serialization::AccessorKind(raw)) {
@@ -883,7 +863,6 @@ GenericSignature *ModuleFile::getGenericSignature(
883863
// Read the generic signature.
884864
BCOffsetRAII restoreOffset(DeclTypeCursor);
885865
DeclTypeCursor.JumpToBit(sigOrOffset);
886-
DeserializingEntityRAII deserializingEntity(*this);
887866

888867
// Read the parameter types.
889868
SmallVector<GenericTypeParamType *, 4> paramTypes;
@@ -959,7 +938,6 @@ ModuleFile::getGenericSignatureOrEnvironment(
959938
// Read the generic environment.
960939
BCOffsetRAII restoreOffset(DeclTypeCursor);
961940
DeclTypeCursor.JumpToBit(bitOffset);
962-
DeserializingEntityRAII deserializingEntity(*this);
963941

964942
SmallVector<GenericTypeParamType *, 4> paramTypes;
965943
using namespace decls_block;
@@ -1067,7 +1045,6 @@ SubstitutionMap ModuleFile::getSubstitutionMap(
10671045
// Read the substitution map.
10681046
BCOffsetRAII restoreOffset(DeclTypeCursor);
10691047
DeclTypeCursor.JumpToBit(substitutionsOrOffset);
1070-
DeserializingEntityRAII deserializingEntity(*this);
10711048

10721049
// Read the substitution map.
10731050
auto entry = DeclTypeCursor.advance(AF_DontPopBlockAtEnd);
@@ -4007,7 +3984,6 @@ ModuleFile::getDeclChecked(DeclID DID) {
40073984
BCOffsetRAII restoreOffset(DeclTypeCursor);
40083985
DeclTypeCursor.JumpToBit(declOrOffset);
40093986

4010-
ModuleFile::DeserializingEntityRAII deserializingEntity(*this);
40113987
Expected<Decl *> deserialized =
40123988
DeclDeserializer(*this, declOrOffset).getDeclCheckedImpl();
40133989
if (!deserialized)

0 commit comments

Comments
 (0)