Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 0 additions & 58 deletions src/passes/StringLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,6 @@ struct StringLowering : public StringGathering {
// Replace string.* etc. operations with imported ones.
replaceInstructions(module);

// Replace ref.null types as needed.
replaceNulls(module);

// ReFinalize to apply all the above changes.
ReFinalize().run(getPassRunner(), module);

Expand Down Expand Up @@ -495,61 +492,6 @@ struct StringLowering : public StringGathering {
replacer.run(getPassRunner(), module);
replacer.walkModuleCode(module);
}

// A ref.null of none needs to be noext if it is going to a location of type
// stringref.
void replaceNulls(Module* module) {
// Use SubtypingDiscoverer to find when a ref.null of none flows into a
// place that has been changed from stringref to externref.
struct NullFixer
: public WalkerPass<
ControlFlowWalker<NullFixer, SubtypingDiscoverer<NullFixer>>> {
// Hooks for SubtypingDiscoverer.
void noteSubtype(Type, Type) {
// Nothing to do for pure types.
}
void noteSubtype(HeapType, HeapType) {
// Nothing to do for pure types.
}
void noteSubtype(Type, Expression*) {
// Nothing to do for a subtype of an expression.
}
void noteSubtype(Expression* a, Type b) {
// This is the case we care about: if |a| is a null that must be a
// subtype of ext then we fix that up.
if (!b.isRef()) {
return;
}
HeapType top = b.getHeapType().getTop();
if (top.isMaybeShared(HeapType::ext)) {
if (auto* null = a->dynCast<RefNull>()) {
null->finalize(HeapTypes::noext.getBasic(top.getShared()));
}
}
}
void noteSubtype(Expression* a, Expression* b) {
// Only the type matters of the place we assign to.
noteSubtype(a, b->type);
}
void noteNonFlowSubtype(Expression* a, Type b) {
// Flow or non-flow is the same for us.
noteSubtype(a, b);
}
void noteCast(HeapType, HeapType) {
// Casts do not concern us.
}
void noteCast(Expression*, Type) {
// Casts do not concern us.
}
void noteCast(Expression*, Expression*) {
// Casts do not concern us.
}
};

NullFixer fixer;
fixer.run(getPassRunner(), module);
fixer.walkModuleCode(module);
}
};

Pass* createStringGatheringPass() { return new StringGathering(); }
Expand Down
Loading