Skip to content

Commit e8b1fc0

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-rebranch
2 parents 3f4499c + e51086b commit e8b1fc0

File tree

2 files changed

+7
-71
lines changed

2 files changed

+7
-71
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: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ StringRef swift::getNameOfModule(const ModuleFile *MF) {
5757
}
5858

5959
namespace {
60-
struct OffsetAndKind {
60+
struct DeclAndOffset {
6161
const Decl *D;
6262
uint64_t offset;
6363
};
6464

65-
static raw_ostream &operator<<(raw_ostream &os, OffsetAndKind &&pair) {
65+
static raw_ostream &operator<<(raw_ostream &os, DeclAndOffset &&pair) {
6666
return os << Decl::getKindName(pair.D->getKind())
6767
<< "Decl @ " << pair.offset;
6868
}
@@ -97,13 +97,13 @@ namespace {
9797
os << "While deserializing ";
9898

9999
if (auto VD = dyn_cast<ValueDecl>(DeclOrOffset.get())) {
100-
os << "'" << VD->getBaseName() << "' (" << OffsetAndKind{VD, offset}
100+
os << "'" << VD->getBaseName() << "' (" << DeclAndOffset{VD, offset}
101101
<< ")";
102102
} else if (auto ED = dyn_cast<ExtensionDecl>(DeclOrOffset.get())) {
103103
os << "extension of '" << ED->getExtendedType() << "' ("
104-
<< OffsetAndKind{ED, offset} << ")";
104+
<< DeclAndOffset{ED, offset} << ")";
105105
} else {
106-
os << OffsetAndKind{DeclOrOffset.get(), offset};
106+
os << DeclAndOffset{DeclOrOffset.get(), offset};
107107
}
108108
}
109109
os << " in '" << getNameOfModule(MF) << "'\n";
@@ -143,14 +143,9 @@ static void skipRecord(llvm::BitstreamCursor &cursor, unsigned recordKind) {
143143
auto next = cursor.advance(AF_DontPopBlockAtEnd);
144144
assert(next.Kind == llvm::BitstreamEntry::Record);
145145

146-
#if NDEBUG
147-
cursor.skipRecord(next.ID);
148-
#else
149-
SmallVector<uint64_t, 64> scratch;
150-
StringRef blobData;
151-
unsigned kind = cursor.readRecord(next.ID, scratch, &blobData);
146+
unsigned kind = cursor.skipRecord(next.ID);
152147
assert(kind == recordKind);
153-
#endif
148+
(void)kind;
154149
}
155150

156151
void ModuleFile::fatal(llvm::Error error) {
@@ -182,26 +177,6 @@ void ModuleFile::fatal(llvm::Error error) {
182177
abort();
183178
}
184179

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-
205180
static Optional<swift::AccessorKind>
206181
getActualAccessorKind(uint8_t raw) {
207182
switch (serialization::AccessorKind(raw)) {
@@ -883,7 +858,6 @@ GenericSignature *ModuleFile::getGenericSignature(
883858
// Read the generic signature.
884859
BCOffsetRAII restoreOffset(DeclTypeCursor);
885860
DeclTypeCursor.JumpToBit(sigOrOffset);
886-
DeserializingEntityRAII deserializingEntity(*this);
887861

888862
// Read the parameter types.
889863
SmallVector<GenericTypeParamType *, 4> paramTypes;
@@ -959,7 +933,6 @@ ModuleFile::getGenericSignatureOrEnvironment(
959933
// Read the generic environment.
960934
BCOffsetRAII restoreOffset(DeclTypeCursor);
961935
DeclTypeCursor.JumpToBit(bitOffset);
962-
DeserializingEntityRAII deserializingEntity(*this);
963936

964937
SmallVector<GenericTypeParamType *, 4> paramTypes;
965938
using namespace decls_block;
@@ -1067,7 +1040,6 @@ SubstitutionMap ModuleFile::getSubstitutionMap(
10671040
// Read the substitution map.
10681041
BCOffsetRAII restoreOffset(DeclTypeCursor);
10691042
DeclTypeCursor.JumpToBit(substitutionsOrOffset);
1070-
DeserializingEntityRAII deserializingEntity(*this);
10711043

10721044
// Read the substitution map.
10731045
auto entry = DeclTypeCursor.advance(AF_DontPopBlockAtEnd);
@@ -4007,7 +3979,6 @@ ModuleFile::getDeclChecked(DeclID DID) {
40073979
BCOffsetRAII restoreOffset(DeclTypeCursor);
40083980
DeclTypeCursor.JumpToBit(declOrOffset);
40093981

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

0 commit comments

Comments
 (0)