summaryrefslogtreecommitdiff
path: root/src/passes
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes')
-rw-r--r--src/passes/MemoryPacking.cpp24
-rw-r--r--src/passes/Print.cpp45
-rw-r--r--src/passes/RemoveUnusedModuleElements.cpp33
-rw-r--r--src/passes/TypeSSA.cpp7
4 files changed, 47 insertions, 62 deletions
diff --git a/src/passes/MemoryPacking.cpp b/src/passes/MemoryPacking.cpp
index b2798f4b6..08d1407f4 100644
--- a/src/passes/MemoryPacking.cpp
+++ b/src/passes/MemoryPacking.cpp
@@ -278,7 +278,7 @@ bool MemoryPacking::canSplit(const std::unique_ptr<DataSegment>& segment,
return false;
}
}
- } else if (referrer->is<ArrayNewSeg>() || referrer->is<ArrayInit>()) {
+ } else if (referrer->is<ArrayNewData>() || referrer->is<ArrayInitData>()) {
// TODO: Split segments referenced by GC instructions.
return false;
}
@@ -474,15 +474,11 @@ void MemoryPacking::getSegmentReferrers(Module* module,
void visitDataDrop(DataDrop* curr) {
referrers[curr->segment].push_back(curr);
}
- void visitArrayNewSeg(ArrayNewSeg* curr) {
- if (curr->op == NewData) {
- referrers[curr->segment].push_back(curr);
- }
+ void visitArrayNewData(ArrayNewData* curr) {
+ referrers[curr->segment].push_back(curr);
}
- void visitArrayInit(ArrayInit* curr) {
- if (curr->op == InitData) {
- referrers[curr->segment].push_back(curr);
- }
+ void visitArrayInitData(ArrayInitData* curr) {
+ referrers[curr->segment].push_back(curr);
}
} collector(referrers);
collector.walkFunctionInModule(func, module);
@@ -808,12 +804,10 @@ void MemoryPacking::replaceSegmentOps(Module* module,
}
}
- void visitArrayNewSeg(ArrayNewSeg* curr) {
- if (curr->op == NewData) {
- if (auto replacement = replacements.find(curr);
- replacement != replacements.end()) {
- replaceCurrent(replacement->second(getFunction()));
- }
+ void visitArrayNewData(ArrayNewData* curr) {
+ if (auto replacement = replacements.find(curr);
+ replacement != replacements.end()) {
+ replaceCurrent(replacement->second(getFunction()));
}
}
} replacer(replacements);
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index 650a17203..76fd53759 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -2265,21 +2265,20 @@ struct PrintExpressionContents
o << ' ';
TypeNamePrinter(o, wasm).print(curr->type.getHeapType());
}
- void visitArrayNewSeg(ArrayNewSeg* curr) {
+ void visitArrayNewData(ArrayNewData* curr) {
if (printUnreachableReplacement(curr)) {
return;
}
- printMedium(o, "array.new_");
- switch (curr->op) {
- case NewData:
- printMedium(o, "data");
- break;
- case NewElem:
- printMedium(o, "elem");
- break;
- default:
- WASM_UNREACHABLE("unexpected op");
+ printMedium(o, "array.new_data");
+ o << ' ';
+ TypeNamePrinter(o, wasm).print(curr->type.getHeapType());
+ o << " $" << curr->segment;
+ }
+ void visitArrayNewElem(ArrayNewElem* curr) {
+ if (printUnreachableReplacement(curr)) {
+ return;
}
+ printMedium(o, "array.new_elem");
o << ' ';
TypeNamePrinter(o, wasm).print(curr->type.getHeapType());
o << " $" << curr->segment;
@@ -2333,20 +2332,19 @@ struct PrintExpressionContents
printMedium(o, "array.fill ");
TypeNamePrinter(o, wasm).print(curr->ref->type.getHeapType());
}
- void visitArrayInit(ArrayInit* curr) {
+ void visitArrayInitData(ArrayInitData* curr) {
if (printUnreachableOrNullReplacement(curr->ref)) {
return;
}
- switch (curr->op) {
- case InitData:
- printMedium(o, "array.init_data ");
- break;
- case InitElem:
- printMedium(o, "array.init_elem ");
- break;
- default:
- WASM_UNREACHABLE("unexpected op");
+ printMedium(o, "array.init_data ");
+ TypeNamePrinter(o, wasm).print(curr->ref->type.getHeapType());
+ o << " $" << curr->segment;
+ }
+ void visitArrayInitElem(ArrayInitElem* curr) {
+ if (printUnreachableOrNullReplacement(curr->ref)) {
+ return;
}
+ printMedium(o, "array.init_elem ");
TypeNamePrinter(o, wasm).print(curr->ref->type.getHeapType());
o << " $" << curr->segment;
}
@@ -2915,7 +2913,10 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> {
void visitArrayNew(ArrayNew* curr) {
maybePrintUnreachableReplacement(curr, curr->type);
}
- void visitArrayNewSeg(ArrayNewSeg* curr) {
+ void visitArrayNewData(ArrayNewData* curr) {
+ maybePrintUnreachableReplacement(curr, curr->type);
+ }
+ void visitArrayNewElem(ArrayNewElem* curr) {
maybePrintUnreachableReplacement(curr, curr->type);
}
void visitArrayNewFixed(ArrayNewFixed* curr) {
diff --git a/src/passes/RemoveUnusedModuleElements.cpp b/src/passes/RemoveUnusedModuleElements.cpp
index 6842c852e..725e292b2 100644
--- a/src/passes/RemoveUnusedModuleElements.cpp
+++ b/src/passes/RemoveUnusedModuleElements.cpp
@@ -203,28 +203,17 @@ struct ReferenceFinder : public PostWalker<ReferenceFinder> {
auto type = curr->ref->type.getHeapType();
note(StructField{type, curr->index});
}
- void visitArrayNewSeg(ArrayNewSeg* curr) {
- switch (curr->op) {
- case NewData: {
- note({ModuleElementKind::DataSegment, curr->segment});
- return;
- case NewElem:
- note({ModuleElementKind::ElementSegment, curr->segment});
- return;
- }
- }
- WASM_UNREACHABLE("unexpected op");
- }
- void visitArrayInit(ArrayInit* curr) {
- switch (curr->op) {
- case InitData:
- note({ModuleElementKind::DataSegment, curr->segment});
- return;
- case InitElem:
- note({ModuleElementKind::ElementSegment, curr->segment});
- return;
- }
- WASM_UNREACHABLE("unexpected op");
+ void visitArrayNewData(ArrayNewData* curr) {
+ note({ModuleElementKind::DataSegment, curr->segment});
+ }
+ void visitArrayNewElem(ArrayNewElem* curr) {
+ note({ModuleElementKind::ElementSegment, curr->segment});
+ }
+ void visitArrayInitData(ArrayInitData* curr) {
+ note({ModuleElementKind::DataSegment, curr->segment});
+ }
+ void visitArrayInitElem(ArrayInitElem* curr) {
+ note({ModuleElementKind::ElementSegment, curr->segment});
}
};
diff --git a/src/passes/TypeSSA.cpp b/src/passes/TypeSSA.cpp
index 9e3a57815..666eda942 100644
--- a/src/passes/TypeSSA.cpp
+++ b/src/passes/TypeSSA.cpp
@@ -67,7 +67,8 @@ struct NewFinder : public PostWalker<NewFinder> {
void visitStructNew(StructNew* curr) { news.push_back(curr); }
void visitArrayNew(ArrayNew* curr) { news.push_back(curr); }
- void visitArrayNewSeg(ArrayNewSeg* curr) { news.push_back(curr); }
+ void visitArrayNewData(ArrayNewData* curr) { news.push_back(curr); }
+ void visitArrayNewElem(ArrayNewElem* curr) { news.push_back(curr); }
void visitArrayNewFixed(ArrayNewFixed* curr) { news.push_back(curr); }
};
@@ -286,8 +287,8 @@ struct TypeSSA : public Pass {
if (isInterestingRelevantTo(arrayNew->init, element.type)) {
return true;
}
- } else if (curr->is<ArrayNewSeg>()) {
- // TODO: If the element segment is immutable perhaps we could inspect it.
+ } else if (curr->is<ArrayNewData>() || curr->is<ArrayNewElem>()) {
+ // TODO: If the segment is immutable perhaps we could inspect it.
return true;
} else if (auto* arrayInit = curr->dynCast<ArrayNewFixed>()) {
// All the items must be interesting for us to consider this interesting,