Skip to content

Commit e1d218f

Browse files
authored
wasm2js: use OverriddenVisitor, so we show a clear error on unsupported instructions (#2199)
1 parent 2a138fa commit e1d218f

File tree

1 file changed

+62
-2
lines changed

1 file changed

+62
-2
lines changed

src/wasm2js.h

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,8 @@ Ref Wasm2JSBuilder::processFunctionBody(Module* m,
831831
}
832832
};
833833

834-
struct ExpressionProcessor : public Visitor<ExpressionProcessor, Ref> {
834+
struct ExpressionProcessor
835+
: public OverriddenVisitor<ExpressionProcessor, Ref> {
835836
Wasm2JSBuilder* parent;
836837
IString result; // TODO: remove
837838
Function* func;
@@ -890,7 +891,7 @@ Ref Wasm2JSBuilder::processFunctionBody(Module* m,
890891
Ref visit(Expression* curr, IString nextResult) {
891892
IString old = result;
892893
result = nextResult;
893-
Ref ret = Visitor::visit(curr);
894+
Ref ret = OverriddenVisitor::visit(curr);
894895
// keep it consistent for the rest of this frame, which may call visit on
895896
// multiple children
896897
result = old;
@@ -1803,6 +1804,61 @@ Ref Wasm2JSBuilder::processFunctionBody(Module* m,
18031804
return ValueBuilder::makeCall(ABORT_FUNC);
18041805
}
18051806

1807+
// TODO's
1808+
1809+
Ref visitAtomicRMW(AtomicRMW* curr) {
1810+
unimplemented(curr);
1811+
WASM_UNREACHABLE();
1812+
}
1813+
Ref visitAtomicCmpxchg(AtomicCmpxchg* curr) {
1814+
unimplemented(curr);
1815+
WASM_UNREACHABLE();
1816+
}
1817+
Ref visitAtomicWait(AtomicWait* curr) {
1818+
unimplemented(curr);
1819+
WASM_UNREACHABLE();
1820+
}
1821+
Ref visitAtomicNotify(AtomicNotify* curr) {
1822+
unimplemented(curr);
1823+
WASM_UNREACHABLE();
1824+
}
1825+
Ref visitSIMDExtract(SIMDExtract* curr) {
1826+
unimplemented(curr);
1827+
WASM_UNREACHABLE();
1828+
}
1829+
Ref visitSIMDReplace(SIMDReplace* curr) {
1830+
unimplemented(curr);
1831+
WASM_UNREACHABLE();
1832+
}
1833+
Ref visitSIMDShuffle(SIMDShuffle* curr) {
1834+
unimplemented(curr);
1835+
WASM_UNREACHABLE();
1836+
}
1837+
Ref visitSIMDBitselect(SIMDBitselect* curr) {
1838+
unimplemented(curr);
1839+
WASM_UNREACHABLE();
1840+
}
1841+
Ref visitSIMDShift(SIMDShift* curr) {
1842+
unimplemented(curr);
1843+
WASM_UNREACHABLE();
1844+
}
1845+
Ref visitMemoryInit(MemoryInit* curr) {
1846+
unimplemented(curr);
1847+
WASM_UNREACHABLE();
1848+
}
1849+
Ref visitDataDrop(DataDrop* curr) {
1850+
unimplemented(curr);
1851+
WASM_UNREACHABLE();
1852+
}
1853+
Ref visitMemoryCopy(MemoryCopy* curr) {
1854+
unimplemented(curr);
1855+
WASM_UNREACHABLE();
1856+
}
1857+
Ref visitMemoryFill(MemoryFill* curr) {
1858+
unimplemented(curr);
1859+
WASM_UNREACHABLE();
1860+
}
1861+
18061862
private:
18071863
Ref makePointer(Expression* ptr, Address offset) {
18081864
auto ret = visit(ptr, EXPRESSION_RESULT);
@@ -1813,6 +1869,10 @@ Ref Wasm2JSBuilder::processFunctionBody(Module* m,
18131869
}
18141870
return ret;
18151871
}
1872+
1873+
void unimplemented(Expression* curr) {
1874+
Fatal() << "wasm2js cannot convert " << getExpressionName(curr);
1875+
}
18161876
};
18171877

18181878
return ExpressionProcessor(this, m, func, standaloneFunction).process();

0 commit comments

Comments
 (0)