[deserialization] Do not allow SILModule to attempt to deserialize a witness table lazily while we are already deserializing.

When deserializing, the serialized sil loader attempts to first lookup
from its SILModule the witness table to attempt to grab a witness table
declaration. Before this patch if the SILModule could not find it, it
would attempt to deserialize it. In certain edge cases this would cause
us to attempt to deserialize a function definition which violates the
invariant that that should never happen.

This patch adds an argument to SILModule::lookUpWitnessTable that
enables you to turn off the lazy deserialization behavior. The default
argument gives the current behavior which should be used everywhere
except for the deserializer.

Swift SVN r16740
This commit is contained in:
Michael Gottesman
2014-04-24 03:37:33 +00:00
parent c7566510f3
commit afa464f980
3 changed files with 15 additions and 7 deletions

View File

@@ -136,7 +136,8 @@ SILModule::createWitnessTableDeclaration(ProtocolConformance *C) {
}
std::pair<SILWitnessTable *, ArrayRef<Substitution>>
SILModule::lookUpWitnessTable(const ProtocolConformance *C) {
SILModule::
lookUpWitnessTable(const ProtocolConformance *C, bool deserializeLazily) {
// Walk down to the base NormalProtocolConformance.
const ProtocolConformance *ParentC = C;
ArrayRef<Substitution> Subs;
@@ -201,8 +202,9 @@ SILModule::lookUpWitnessTable(const ProtocolConformance *C) {
//
// *NOTE* In practice, wT will be deserializedTable, but I do not want to rely
// on that behavior for now.
if (auto deserializedTable = getSILLoader()->lookupWitnessTable(wT))
return {deserializedTable, Subs};
if (deserializeLazily)
if (auto deserializedTable = getSILLoader()->lookupWitnessTable(wT))
return {deserializedTable, Subs};
// If we fail, just return the declaration.
return {wT, Subs};