diff options
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/asm2wasm.cpp | 2 | ||||
-rw-r--r-- | src/tools/fuzzing.h | 635 | ||||
-rw-r--r-- | src/tools/js-wrapper.h | 2 | ||||
-rw-r--r-- | src/tools/spec-wrapper.h | 22 | ||||
-rw-r--r-- | src/tools/wasm-reduce.cpp | 120 | ||||
-rw-r--r-- | src/tools/wasm2js.cpp | 20 |
6 files changed, 404 insertions, 397 deletions
diff --git a/src/tools/asm2wasm.cpp b/src/tools/asm2wasm.cpp index b54dd8cd8..6b20d1bcb 100644 --- a/src/tools/asm2wasm.cpp +++ b/src/tools/asm2wasm.cpp @@ -227,7 +227,7 @@ int main(int argc, const char* argv[]) { Expression* init; const auto& memBase = options.extra.find("mem base"); if (memBase == options.extra.end()) { - init = Builder(wasm).makeGlobalGet(MEMORY_BASE, i32); + init = Builder(wasm).makeGlobalGet(MEMORY_BASE, Type::i32); } else { init = Builder(wasm).makeConst( Literal(int32_t(atoi(memBase->second.c_str())))); diff --git a/src/tools/fuzzing.h b/src/tools/fuzzing.h index af5773e80..81bd87581 100644 --- a/src/tools/fuzzing.h +++ b/src/tools/fuzzing.h @@ -378,16 +378,20 @@ private: builder.makeBinary( AddInt32, builder.makeBinary(ShlInt32, - builder.makeLocalGet(0, i32), + builder.makeLocalGet(0, Type::i32), builder.makeConst(Literal(uint32_t(5)))), - builder.makeLocalGet(0, i32)), - builder.makeLoad( - 1, false, i, 1, builder.makeConst(Literal(uint32_t(0))), i32)))); - } - contents.push_back(builder.makeLocalGet(0, i32)); + builder.makeLocalGet(0, Type::i32)), + builder.makeLoad(1, + false, + i, + 1, + builder.makeConst(Literal(uint32_t(0))), + Type::i32)))); + } + contents.push_back(builder.makeLocalGet(0, Type::i32)); auto* body = builder.makeBlock(contents); auto* hasher = wasm.addFunction(builder.makeFunction( - "hashMemory", Signature(Type::none, Type::i32), {i32}, body)); + "hashMemory", Signature(Type::none, Type::i32), {Type::i32}, body)); wasm.addExport( builder.makeExport(hasher->name, hasher->name, ExternalKind::Function)); // Export memory so JS fuzzing can use it @@ -446,7 +450,7 @@ private: void addHangLimitSupport() { auto* glob = builder.makeGlobal(HANG_LIMIT_GLOBAL, - i32, + Type::i32, builder.makeConst(Literal(int32_t(HANG_LIMIT))), Builder::Mutable); wasm.addGlobal(glob); @@ -481,12 +485,12 @@ private: return builder.makeSequence( builder.makeIf( builder.makeUnary(UnaryOp::EqZInt32, - builder.makeGlobalGet(HANG_LIMIT_GLOBAL, i32)), - makeTrivial(unreachable)), + builder.makeGlobalGet(HANG_LIMIT_GLOBAL, Type::i32)), + makeTrivial(Type::unreachable)), builder.makeGlobalSet( HANG_LIMIT_GLOBAL, builder.makeBinary(BinaryOp::SubInt32, - builder.makeGlobalGet(HANG_LIMIT_GLOBAL, i32), + builder.makeGlobalGet(HANG_LIMIT_GLOBAL, Type::i32), builder.makeConst(Literal(int32_t(1)))))); } @@ -502,18 +506,18 @@ private: builder.makeConst(literal)); wasm.addFunction(func); }; - add("deNan32", f32, Literal(float(0)), EqFloat32); - add("deNan64", f64, Literal(double(0)), EqFloat64); + add("deNan32", Type::f32, Literal(float(0)), EqFloat32); + add("deNan64", Type::f64, Literal(double(0)), EqFloat64); } Expression* makeDeNanOp(Expression* expr) { if (allowNaNs) { return expr; } - if (expr->type == f32) { - return builder.makeCall("deNan32", {expr}, f32); - } else if (expr->type == f64) { - return builder.makeCall("deNan64", {expr}, f64); + if (expr->type == Type::f32) { + return builder.makeCall("deNan32", {expr}, Type::f32); + } else if (expr->type == Type::f64) { + return builder.makeCall("deNan64", {expr}, Type::f64); } return expr; // unreachable etc. is fine } @@ -558,7 +562,7 @@ private: // with small chance, make the body unreachable auto bodyType = func->sig.results; if (oneIn(10)) { - bodyType = unreachable; + bodyType = Type::unreachable; } // with reasonable chance make the body a block if (oneIn(2)) { @@ -844,34 +848,34 @@ private: } else { return makeLocalGet(type); } - } else if (type == none) { + } else if (type == Type::none) { if (oneIn(2)) { return makeNop(type); } else { return makeLocalSet(type); } } - assert(type == unreachable); + assert(type == Type::unreachable); return makeTrivial(type); } nesting++; Expression* ret = nullptr; switch (type) { - case i32: - case i64: - case f32: - case f64: - case v128: - case funcref: - case anyref: - case nullref: - case exnref: + case Type::i32: + case Type::i64: + case Type::f32: + case Type::f64: + case Type::v128: + case Type::funcref: + case Type::anyref: + case Type::nullref: + case Type::exnref: ret = _makeConcrete(type); break; - case none: + case Type::none: ret = _makenone(); break; - case unreachable: + case Type::unreachable: ret = _makeunreachable(); break; } @@ -942,19 +946,19 @@ private: } choice = upTo(100); if (choice < 50) { - return makeLocalSet(none); + return makeLocalSet(Type::none); } if (choice < 60) { - return makeBlock(none); + return makeBlock(Type::none); } if (choice < 70) { - return makeIf(none); + return makeIf(Type::none); } if (choice < 80) { - return makeLoop(none); + return makeLoop(Type::none); } if (choice < 90) { - return makeBreak(none); + return makeBreak(Type::none); } using Self = TranslateToFuzzReader; auto options = FeatureOptions<Expression* (Self::*)(Type)>() @@ -972,41 +976,41 @@ private: &Self::makeGlobalSet) .add(FeatureSet::BulkMemory, &Self::makeBulkMemory) .add(FeatureSet::Atomics, &Self::makeAtomic); - return (this->*pick(options))(none); + return (this->*pick(options))(Type::none); } Expression* _makeunreachable() { switch (upTo(15)) { case 0: - return makeBlock(unreachable); + return makeBlock(Type::unreachable); case 1: - return makeIf(unreachable); + return makeIf(Type::Type::unreachable); case 2: - return makeLoop(unreachable); + return makeLoop(Type::unreachable); case 3: - return makeBreak(unreachable); + return makeBreak(Type::unreachable); case 4: - return makeCall(unreachable); + return makeCall(Type::unreachable); case 5: - return makeCallIndirect(unreachable); + return makeCallIndirect(Type::unreachable); case 6: - return makeLocalSet(unreachable); + return makeLocalSet(Type::unreachable); case 7: - return makeStore(unreachable); + return makeStore(Type::unreachable); case 8: - return makeUnary(unreachable); + return makeUnary(Type::unreachable); case 9: - return makeBinary(unreachable); + return makeBinary(Type::unreachable); case 10: - return makeSelect(unreachable); + return makeSelect(Type::unreachable); case 11: - return makeSwitch(unreachable); + return makeSwitch(Type::unreachable); case 12: - return makeDrop(unreachable); + return makeDrop(Type::unreachable); case 13: - return makeReturn(unreachable); + return makeReturn(Type::unreachable); case 14: - return makeUnreachable(unreachable); + return makeUnreachable(Type::unreachable); } WASM_UNREACHABLE("unexpected value"); } @@ -1019,10 +1023,10 @@ private: } else { return makeConst(type); } - } else if (type == none) { + } else if (type == Type::none) { return makeNop(type); } - assert(type == unreachable); + assert(type == Type::unreachable); Expression* ret = nullptr; if (func->sig.results.isConcrete()) { ret = makeTrivial(func->sig.results); @@ -1051,13 +1055,13 @@ private: num++; } while (num > 0 && !finishedInput) { - ret->list.push_back(make(none)); + ret->list.push_back(make(Type::none)); num--; } // give a chance to make the final element an unreachable break, instead // of concrete - a common pattern (branch to the top of a loop etc.) if (!finishedInput && type.isConcrete() && oneIn(2)) { - ret->list.push_back(makeBreak(unreachable)); + ret->list.push_back(makeBreak(Type::unreachable)); } else { ret->list.push_back(make(type)); } @@ -1069,8 +1073,8 @@ private: } if (ret->type != type) { // e.g. we might want an unreachable block, but a child breaks to it - assert(type == unreachable && ret->type == none); - return builder.makeSequence(ret, make(unreachable)); + assert(type == Type::unreachable && ret->type == Type::none); + return builder.makeSequence(ret, make(Type::unreachable)); } return ret; } @@ -1087,7 +1091,7 @@ private: } else { // ensure a branch back. also optionally create some loop vars std::vector<Expression*> list; - list.push_back(makeMaybeBlock(none)); // primary contents + list.push_back(makeMaybeBlock(Type::none)); // primary contents // possible branch back list.push_back(builder.makeBreak(ret->name, nullptr, makeCondition())); list.push_back(make(type)); // final element, so we have the right type @@ -1103,7 +1107,7 @@ private: // we want a 50-50 chance for the condition to be taken, for interesting // execution paths. by itself, there is bias (e.g. most consts are "yes") // so even that out with noise - auto* ret = make(i32); + auto* ret = make(Type::i32); if (oneIn(2)) { ret = builder.makeUnary(UnaryOp::EqZInt32, ret); } @@ -1138,7 +1142,7 @@ private: return makeTrivial(type); } Expression* condition = nullptr; - if (type != unreachable) { + if (type != Type::unreachable) { hangStack.push_back(nullptr); condition = makeCondition(); } @@ -1157,8 +1161,8 @@ private: auto* ret = builder.makeBreak(name, make(type), condition); hangStack.pop_back(); return ret; - } else if (type == none) { - if (valueType != none) { + } else if (type == Type::none) { + if (valueType != Type::Type::none) { // we need to break to a proper place continue; } @@ -1166,8 +1170,8 @@ private: hangStack.pop_back(); return ret; } else { - assert(type == unreachable); - if (valueType != none) { + assert(type == Type::unreachable); + if (valueType != Type::Type::none) { // we need to break to a proper place continue; } @@ -1210,7 +1214,7 @@ private: } } // we failed to find something - if (type != unreachable) { + if (type != Type::unreachable) { hangStack.pop_back(); } return makeTrivial(type); @@ -1254,7 +1258,7 @@ private: while (1) { // TODO: handle unreachable targetFn = wasm.getFunction(data[i]); - isReturn = type == unreachable && wasm.features.hasTailCall() && + isReturn = type == Type::unreachable && wasm.features.hasTailCall() && func->sig.results == targetFn->sig.results; if (targetFn->sig.results == type || isReturn) { break; @@ -1273,7 +1277,7 @@ private: if (!allowOOB || !oneIn(10)) { target = builder.makeConst(Literal(int32_t(i))); } else { - target = make(i32); + target = make(Type::i32); } std::vector<Expression*> args; for (auto type : targetFn->sig.params.expand()) { @@ -1291,7 +1295,7 @@ private: } Expression* makeLocalSet(Type type) { - bool tee = type != none; + bool tee = type != Type::none; Type valueType; if (tee) { valueType = type; @@ -1319,18 +1323,18 @@ private: } Expression* makeGlobalSet(Type type) { - assert(type == none); + assert(type == Type::none); type = getConcreteType(); auto& globals = globalsByType[type]; if (globals.empty()) { - return makeTrivial(none); + return makeTrivial(Type::Type::none); } auto* value = make(type); return builder.makeGlobalSet(pick(globals), value); } Expression* makePointer() { - auto* ret = make(i32); + auto* ret = make(Type::i32); // with high probability, mask the pointer so it's in a reasonable // range. otherwise, most pointers are going to be out of range and // most memory ops will just trap @@ -1345,7 +1349,7 @@ private: auto offset = logify(get()); auto ptr = makePointer(); switch (type) { - case i32: { + case Type::i32: { bool signed_ = get() & 1; switch (upTo(3)) { case 0: @@ -1358,7 +1362,7 @@ private: } WASM_UNREACHABLE("unexpected value"); } - case i64: { + case Type::i64: { bool signed_ = get() & 1; switch (upTo(4)) { case 0: @@ -1374,25 +1378,25 @@ private: } WASM_UNREACHABLE("unexpected value"); } - case f32: { + case Type::f32: { return builder.makeLoad(4, false, offset, pick(1, 2, 4), ptr, type); } - case f64: { + case Type::f64: { return builder.makeLoad(8, false, offset, pick(1, 2, 4, 8), ptr, type); } - case v128: { + case Type::v128: { if (!wasm.features.hasSIMD()) { return makeTrivial(type); } return builder.makeLoad( 16, false, offset, pick(1, 2, 4, 8, 16), ptr, type); } - case funcref: - case anyref: - case nullref: - case exnref: - case none: - case unreachable: + case Type::funcref: + case Type::anyref: + case Type::nullref: + case Type::exnref: + case Type::none: + case Type::unreachable: WASM_UNREACHABLE("invalid type"); } WASM_UNREACHABLE("invalid type"); @@ -1404,7 +1408,7 @@ private: return makeTrivial(type); } auto* ret = makeNonAtomicLoad(type); - if (type != i32 && type != i64) { + if (type != Type::i32 && type != Type::i64) { return ret; } if (!wasm.features.hasAtomics() || oneIn(2)) { @@ -1420,7 +1424,7 @@ private: } Expression* makeNonAtomicStore(Type type) { - if (type == unreachable) { + if (type == Type::unreachable) { // make a normal store, then make it unreachable auto* ret = makeNonAtomicStore(getStorableType()); auto* store = ret->dynCast<Store>(); @@ -1429,14 +1433,14 @@ private: } switch (upTo(3)) { case 0: - store->ptr = make(unreachable); + store->ptr = make(Type::unreachable); break; case 1: - store->value = make(unreachable); + store->value = make(Type::unreachable); break; case 2: - store->ptr = make(unreachable); - store->value = make(unreachable); + store->ptr = make(Type::unreachable); + store->value = make(Type::unreachable); break; } store->finalize(); @@ -1444,14 +1448,14 @@ private: } // the type is none or unreachable. we also need to pick the value // type. - if (type == none) { + if (type == Type::none) { type = getStorableType(); } auto offset = logify(get()); auto ptr = makePointer(); auto value = make(type); switch (type) { - case i32: { + case Type::i32: { switch (upTo(3)) { case 0: return builder.makeStore(1, offset, 1, ptr, value, type); @@ -1463,7 +1467,7 @@ private: } WASM_UNREACHABLE("invalid value"); } - case i64: { + case Type::i64: { switch (upTo(4)) { case 0: return builder.makeStore(1, offset, 1, ptr, value, type); @@ -1478,25 +1482,25 @@ private: } WASM_UNREACHABLE("invalid value"); } - case f32: { + case Type::f32: { return builder.makeStore(4, offset, pick(1, 2, 4), ptr, value, type); } - case f64: { + case Type::f64: { return builder.makeStore(8, offset, pick(1, 2, 4, 8), ptr, value, type); } - case v128: { + case Type::v128: { if (!wasm.features.hasSIMD()) { return makeTrivial(type); } return builder.makeStore( 16, offset, pick(1, 2, 4, 8, 16), ptr, value, type); } - case funcref: - case anyref: - case nullref: - case exnref: - case none: - case unreachable: + case Type::funcref: + case Type::anyref: + case Type::nullref: + case Type::exnref: + case Type::none: + case Type::unreachable: WASM_UNREACHABLE("invalid type"); } WASM_UNREACHABLE("invalid type"); @@ -1511,7 +1515,7 @@ private: if (!store) { return ret; } - if (store->value->type != i32 && store->value->type != i64) { + if (store->value->type != Type::i32 && store->value->type != Type::i64) { return store; } if (!wasm.features.hasAtomics() || oneIn(2)) { @@ -1525,51 +1529,51 @@ private: } Literal makeArbitraryLiteral(Type type) { - if (type == v128) { + if (type == Type::v128) { // generate each lane individually for random lane interpretation switch (upTo(6)) { case 0: - return Literal(std::array<Literal, 16>{{makeLiteral(i32), - makeLiteral(i32), - makeLiteral(i32), - makeLiteral(i32), - makeLiteral(i32), - makeLiteral(i32), - makeLiteral(i32), - makeLiteral(i32), - makeLiteral(i32), - makeLiteral(i32), - makeLiteral(i32), - makeLiteral(i32), - makeLiteral(i32), - makeLiteral(i32), - makeLiteral(i32), - makeLiteral(i32)}}); + return Literal(std::array<Literal, 16>{{makeLiteral(Type::i32), + makeLiteral(Type::i32), + makeLiteral(Type::i32), + makeLiteral(Type::i32), + makeLiteral(Type::i32), + makeLiteral(Type::i32), + makeLiteral(Type::i32), + makeLiteral(Type::i32), + makeLiteral(Type::i32), + makeLiteral(Type::i32), + makeLiteral(Type::i32), + makeLiteral(Type::i32), + makeLiteral(Type::i32), + makeLiteral(Type::i32), + makeLiteral(Type::i32), + makeLiteral(Type::i32)}}); case 1: - return Literal(std::array<Literal, 8>{{makeLiteral(i32), - makeLiteral(i32), - makeLiteral(i32), - makeLiteral(i32), - makeLiteral(i32), - makeLiteral(i32), - makeLiteral(i32), - makeLiteral(i32)}}); + return Literal(std::array<Literal, 8>{{makeLiteral(Type::i32), + makeLiteral(Type::i32), + makeLiteral(Type::i32), + makeLiteral(Type::i32), + makeLiteral(Type::i32), + makeLiteral(Type::i32), + makeLiteral(Type::i32), + makeLiteral(Type::i32)}}); case 2: - return Literal(std::array<Literal, 4>{{makeLiteral(i32), - makeLiteral(i32), - makeLiteral(i32), - makeLiteral(i32)}}); + return Literal(std::array<Literal, 4>{{makeLiteral(Type::i32), + makeLiteral(Type::i32), + makeLiteral(Type::i32), + makeLiteral(Type::i32)}}); case 3: - return Literal( - std::array<Literal, 2>{{makeLiteral(i64), makeLiteral(i64)}}); + return Literal(std::array<Literal, 2>{ + {makeLiteral(Type::i64), makeLiteral(Type::i64)}}); case 4: - return Literal(std::array<Literal, 4>{{makeLiteral(f32), - makeLiteral(f32), - makeLiteral(f32), - makeLiteral(f32)}}); + return Literal(std::array<Literal, 4>{{makeLiteral(Type::f32), + makeLiteral(Type::f32), + makeLiteral(Type::f32), + makeLiteral(Type::f32)}}); case 5: - return Literal( - std::array<Literal, 2>{{makeLiteral(f64), makeLiteral(f64)}}); + return Literal(std::array<Literal, 2>{ + {makeLiteral(Type::f64), makeLiteral(Type::f64)}}); default: WASM_UNREACHABLE("unexpected value"); } @@ -1579,21 +1583,21 @@ private: case 0: { // totally random, entire range switch (type) { - case i32: + case Type::i32: return Literal(get32()); - case i64: + case Type::i64: return Literal(get64()); - case f32: + case Type::f32: return Literal(getFloat()); - case f64: + case Type::f64: return Literal(getDouble()); - case v128: - case funcref: - case anyref: - case nullref: - case exnref: - case none: - case unreachable: + case Type::v128: + case Type::funcref: + case Type::anyref: + case Type::nullref: + case Type::exnref: + case Type::none: + case Type::unreachable: WASM_UNREACHABLE("invalid type"); } break; @@ -1624,21 +1628,21 @@ private: WASM_UNREACHABLE("invalid value"); } switch (type) { - case i32: + case Type::i32: return Literal(int32_t(small)); - case i64: + case Type::i64: return Literal(int64_t(small)); - case f32: + case Type::f32: return Literal(float(small)); - case f64: + case Type::f64: return Literal(double(small)); - case v128: - case funcref: - case anyref: - case nullref: - case exnref: - case none: - case unreachable: + case Type::v128: + case Type::funcref: + case Type::anyref: + case Type::nullref: + case Type::exnref: + case Type::none: + case Type::unreachable: WASM_UNREACHABLE("unexpected type"); } break; @@ -1647,7 +1651,7 @@ private: // special values Literal value; switch (type) { - case i32: + case Type::i32: value = Literal(pick<int32_t>(0, std::numeric_limits<int8_t>::min(), @@ -1660,7 +1664,7 @@ private: std::numeric_limits<uint16_t>::max(), std::numeric_limits<uint32_t>::max())); break; - case i64: + case Type::i64: value = Literal(pick<int64_t>(0, std::numeric_limits<int8_t>::min(), @@ -1676,7 +1680,7 @@ private: std::numeric_limits<uint32_t>::max(), std::numeric_limits<uint64_t>::max())); break; - case f32: + case Type::f32: value = Literal(pick<float>(0, std::numeric_limits<float>::min(), std::numeric_limits<float>::max(), @@ -1687,7 +1691,7 @@ private: std::numeric_limits<uint32_t>::max(), std::numeric_limits<uint64_t>::max())); break; - case f64: + case Type::f64: value = Literal(pick<double>(0, std::numeric_limits<float>::min(), std::numeric_limits<float>::max(), @@ -1700,13 +1704,13 @@ private: std::numeric_limits<uint32_t>::max(), std::numeric_limits<uint64_t>::max())); break; - case v128: - case funcref: - case anyref: - case nullref: - case exnref: - case none: - case unreachable: + case Type::v128: + case Type::funcref: + case Type::anyref: + case Type::nullref: + case Type::exnref: + case Type::none: + case Type::unreachable: WASM_UNREACHABLE("unexpected type"); } // tweak around special values @@ -1722,25 +1726,25 @@ private: // powers of 2 Literal value; switch (type) { - case i32: + case Type::i32: value = Literal(int32_t(1) << upTo(32)); break; - case i64: + case Type::i64: value = Literal(int64_t(1) << upTo(64)); break; - case f32: + case Type::f32: value = Literal(float(int64_t(1) << upTo(64))); break; - case f64: + case Type::f64: value = Literal(double(int64_t(1) << upTo(64))); break; - case v128: - case funcref: - case anyref: - case nullref: - case exnref: - case none: - case unreachable: + case Type::v128: + case Type::funcref: + case Type::anyref: + case Type::nullref: + case Type::exnref: + case Type::none: + case Type::unreachable: WASM_UNREACHABLE("unexpected type"); } // maybe negative @@ -1790,9 +1794,10 @@ private: } Expression* makeUnary(Type type) { - if (type == unreachable) { + if (type == Type::unreachable) { if (auto* unary = makeUnary(getConcreteType())->dynCast<Unary>()) { - return makeDeNanOp(builder.makeUnary(unary->op, make(unreachable))); + return makeDeNanOp( + builder.makeUnary(unary->op, make(Type::unreachable))); } // give up return makeTrivial(type); @@ -1803,18 +1808,18 @@ private: } switch (type) { - case i32: { + case Type::i32: { switch (getConcreteType()) { - case i32: { + case Type::i32: { auto op = pick( FeatureOptions<UnaryOp>() .add(FeatureSet::MVP, EqZInt32, ClzInt32, CtzInt32, PopcntInt32) .add(FeatureSet::SignExt, ExtendS8Int32, ExtendS16Int32)); - return buildUnary({op, make(i32)}); + return buildUnary({op, make(Type::i32)}); } - case i64: - return buildUnary({pick(EqZInt64, WrapInt64), make(i64)}); - case f32: { + case Type::i64: + return buildUnary({pick(EqZInt64, WrapInt64), make(Type::i64)}); + case Type::f32: { auto op = pick(FeatureOptions<UnaryOp>() .add(FeatureSet::MVP, TruncSFloat32ToInt32, @@ -1823,9 +1828,9 @@ private: .add(FeatureSet::TruncSat, TruncSatSFloat32ToInt32, TruncSatUFloat32ToInt32)); - return buildUnary({op, make(f32)}); + return buildUnary({op, make(Type::f32)}); } - case f64: { + case Type::f64: { auto op = pick(FeatureOptions<UnaryOp>() .add(FeatureSet::MVP, TruncSFloat64ToInt32, @@ -1833,9 +1838,9 @@ private: .add(FeatureSet::TruncSat, TruncSatSFloat64ToInt32, TruncSatUFloat64ToInt32)); - return buildUnary({op, make(f64)}); + return buildUnary({op, make(Type::f64)}); } - case v128: { + case Type::v128: { assert(wasm.features.hasSIMD()); return buildUnary({pick(AnyTrueVecI8x16, AllTrueVecI8x16, @@ -1845,20 +1850,20 @@ private: AllTrueVecI32x4, AnyTrueVecI64x2, AllTrueVecI64x2), - make(v128)}); + make(Type::v128)}); } - case funcref: - case anyref: - case nullref: - case exnref: + case Type::funcref: + case Type::anyref: + case Type::nullref: + case Type::exnref: return makeTrivial(type); - case none: - case unreachable: + case Type::none: + case Type::unreachable: WASM_UNREACHABLE("unexpected type"); } WASM_UNREACHABLE("invalid type"); } - case i64: { + case Type::i64: { switch (upTo(4)) { case 0: { auto op = @@ -1868,10 +1873,11 @@ private: ExtendS8Int64, ExtendS16Int64, ExtendS32Int64)); - return buildUnary({op, make(i64)}); + return buildUnary({op, make(Type::i64)}); } case 1: - return buildUnary({pick(ExtendSInt32, ExtendUInt32), make(i32)}); + return buildUnary( + {pick(ExtendSInt32, ExtendUInt32), make(Type::i32)}); case 2: { auto op = pick(FeatureOptions<UnaryOp>() .add(FeatureSet::MVP, @@ -1880,7 +1886,7 @@ private: .add(FeatureSet::TruncSat, TruncSatSFloat32ToInt64, TruncSatUFloat32ToInt64)); - return buildUnary({op, make(f32)}); + return buildUnary({op, make(Type::f32)}); } case 3: { auto op = pick(FeatureOptions<UnaryOp>() @@ -1891,12 +1897,12 @@ private: .add(FeatureSet::TruncSat, TruncSatSFloat64ToInt64, TruncSatUFloat64ToInt64)); - return buildUnary({op, make(f64)}); + return buildUnary({op, make(Type::f64)}); } } WASM_UNREACHABLE("invalid value"); } - case f32: { + case Type::f32: { switch (upTo(4)) { case 0: return makeDeNanOp(buildUnary({pick(NegFloat32, @@ -1906,22 +1912,22 @@ private: TruncFloat32, NearestFloat32, SqrtFloat32), - make(f32)})); + make(Type::f32)})); case 1: return makeDeNanOp(buildUnary({pick(ConvertUInt32ToFloat32, ConvertSInt32ToFloat32, ReinterpretInt32), - make(i32)})); + make(Type::i32)})); case 2: return makeDeNanOp( buildUnary({pick(ConvertUInt64ToFloat32, ConvertSInt64ToFloat32), - make(i64)})); + make(Type::i64)})); case 3: - return makeDeNanOp(buildUnary({DemoteFloat64, make(f64)})); + return makeDeNanOp(buildUnary({DemoteFloat64, make(Type::f64)})); } WASM_UNREACHABLE("invalid value"); } - case f64: { + case Type::f64: { switch (upTo(4)) { case 0: return makeDeNanOp(buildUnary({pick(NegFloat64, @@ -1931,33 +1937,34 @@ private: TruncFloat64, NearestFloat64, SqrtFloat64), - make(f64)})); + make(Type::f64)})); case 1: return makeDeNanOp( buildUnary({pick(ConvertUInt32ToFloat64, ConvertSInt32ToFloat64), - make(i32)})); + make(Type::i32)})); case 2: return makeDeNanOp(buildUnary({pick(ConvertUInt64ToFloat64, ConvertSInt64ToFloat64, ReinterpretInt64), - make(i64)})); + make(Type::i64)})); case 3: - return makeDeNanOp(buildUnary({PromoteFloat32, make(f32)})); + return makeDeNanOp(buildUnary({PromoteFloat32, make(Type::f32)})); } WASM_UNREACHABLE("invalid value"); } - case v128: { + case Type::v128: { assert(wasm.features.hasSIMD()); switch (upTo(5)) { case 0: return buildUnary( - {pick(SplatVecI8x16, SplatVecI16x8, SplatVecI32x4), make(i32)}); + {pick(SplatVecI8x16, SplatVecI16x8, SplatVecI32x4), + make(Type::i32)}); case 1: - return buildUnary({SplatVecI64x2, make(i64)}); + return buildUnary({SplatVecI64x2, make(Type::i64)}); case 2: - return buildUnary({SplatVecF32x4, make(f32)}); + return buildUnary({SplatVecF32x4, make(Type::f32)}); case 3: - return buildUnary({SplatVecF64x2, make(f64)}); + return buildUnary({SplatVecF64x2, make(Type::f64)}); case 4: return buildUnary({pick(NotVec128, NegVecI8x16, @@ -1986,16 +1993,16 @@ private: WidenHighSVecI16x8ToVecI32x4, WidenLowUVecI16x8ToVecI32x4, WidenHighUVecI16x8ToVecI32x4), - make(v128)}); + make(Type::v128)}); } WASM_UNREACHABLE("invalid value"); } - case funcref: - case anyref: - case nullref: - case exnref: - case none: - case unreachable: + case Type::funcref: + case Type::anyref: + case Type::nullref: + case Type::exnref: + case Type::none: + case Type::unreachable: WASM_UNREACHABLE("unexpected type"); } WASM_UNREACHABLE("invalid type"); @@ -2006,10 +2013,10 @@ private: } Expression* makeBinary(Type type) { - if (type == unreachable) { + if (type == Type::unreachable) { if (auto* binary = makeBinary(getConcreteType())->dynCast<Binary>()) { - return makeDeNanOp( - buildBinary({binary->op, make(unreachable), make(unreachable)})); + return makeDeNanOp(buildBinary( + {binary->op, make(Type::unreachable), make(Type::unreachable)})); } // give up return makeTrivial(type); @@ -2020,7 +2027,7 @@ private: } switch (type) { - case i32: { + case Type::i32: { switch (upTo(4)) { case 0: return buildBinary({pick(AddInt32, @@ -2048,8 +2055,8 @@ private: GtUInt32, GeSInt32, GeUInt32), - make(i32), - make(i32)}); + make(Type::i32), + make(Type::i32)}); case 1: return buildBinary({pick(EqInt64, NeInt64, @@ -2061,8 +2068,8 @@ private: GtUInt64, GeSInt64, GeUInt64), - make(i64), - make(i64)}); + make(Type::i64), + make(Type::i64)}); case 2: return buildBinary({pick(EqFloat32, NeFloat32, @@ -2070,8 +2077,8 @@ private: LeFloat32, GtFloat32, GeFloat32), - make(f32), - make(f32)}); + make(Type::f32), + make(Type::f32)}); case 3: return buildBinary({pick(EqFloat64, NeFloat64, @@ -2079,12 +2086,12 @@ private: LeFloat64, GtFloat64, GeFloat64), - make(f64), - make(f64)}); + make(Type::f64), + make(Type::f64)}); } WASM_UNREACHABLE("invalid value"); } - case i64: { + case Type::i64: { return buildBinary({pick(AddInt64, SubInt64, MulInt64, @@ -2100,10 +2107,10 @@ private: ShrSInt64, RotLInt64, RotRInt64), - make(i64), - make(i64)}); + make(Type::i64), + make(Type::i64)}); } - case f32: { + case Type::f32: { return makeDeNanOp(buildBinary({pick(AddFloat32, SubFloat32, MulFloat32, @@ -2111,10 +2118,10 @@ private: CopySignFloat32, MinFloat32, MaxFloat32), - make(f32), - make(f32)})); + make(Type::f32), + make(Type::f32)})); } - case f64: { + case Type::f64: { return makeDeNanOp(buildBinary({pick(AddFloat64, SubFloat64, MulFloat64, @@ -2122,10 +2129,10 @@ private: CopySignFloat64, MinFloat64, MaxFloat64), - make(f64), - make(f64)})); + make(Type::f64), + make(Type::f64)})); } - case v128: { + case Type::v128: { assert(wasm.features.hasSIMD()); return buildBinary({pick(EqVecI8x16, NeVecI8x16, @@ -2222,15 +2229,15 @@ private: NarrowSVecI32x4ToVecI16x8, NarrowUVecI32x4ToVecI16x8, SwizzleVec8x16), - make(v128), - make(v128)}); - } - case funcref: - case anyref: - case nullref: - case exnref: - case none: - case unreachable: + make(Type::v128), + make(Type::v128)}); + } + case Type::funcref: + case Type::anyref: + case Type::nullref: + case Type::exnref: + case Type::none: + case Type::unreachable: WASM_UNREACHABLE("unexpected type"); } WASM_UNREACHABLE("invalid type"); @@ -2244,18 +2251,18 @@ private: Type subType1 = pick(getSubTypes(type)); Type subType2 = pick(getSubTypes(type)); return makeDeNanOp( - buildSelect({make(i32), make(subType1), make(subType2)}, type)); + buildSelect({make(Type::i32), make(subType1), make(subType2)}, type)); } Expression* makeSwitch(Type type) { - assert(type == unreachable); + assert(type == Type::unreachable); if (breakableStack.empty()) { return make(type); } // we need to find proper targets to break to; try a bunch int tries = TRIES; std::vector<Name> names; - Type valueType = unreachable; + Type valueType = Type::Type::unreachable; while (tries-- > 0) { auto* target = pick(breakableStack); auto name = getTargetName(target); @@ -2275,14 +2282,14 @@ private: } auto default_ = names.back(); names.pop_back(); - auto temp1 = make(i32), + auto temp1 = make(Type::i32), temp2 = valueType.isConcrete() ? make(valueType) : nullptr; return builder.makeSwitch(names, default_, temp1, temp2); } Expression* makeDrop(Type type) { return builder.makeDrop( - make(type == unreachable ? type : getConcreteType())); + make(type == Type::unreachable ? type : getConcreteType())); } Expression* makeReturn(Type type) { @@ -2291,12 +2298,12 @@ private: } Expression* makeNop(Type type) { - assert(type == none); + assert(type == Type::none); return builder.makeNop(); } Expression* makeUnreachable(Type type) { - assert(type == unreachable); + assert(type == Type::unreachable); return builder.makeUnreachable(); } @@ -2306,26 +2313,26 @@ private: return makeTrivial(type); } wasm.memory.shared = true; - if (type == none) { + if (type == Type::none) { return builder.makeAtomicFence(); } - if (type == i32 && oneIn(2)) { + if (type == Type::i32 && oneIn(2)) { if (ATOMIC_WAITS && oneIn(2)) { auto* ptr = makePointer(); - auto expectedType = pick(i32, i64); + auto expectedType = pick(Type::i32, Type::i64); auto* expected = make(expectedType); - auto* timeout = make(i64); + auto* timeout = make(Type::i64); return builder.makeAtomicWait( ptr, expected, timeout, expectedType, logify(get())); } else { auto* ptr = makePointer(); - auto* count = make(i32); + auto* count = make(Type::i32); return builder.makeAtomicNotify(ptr, count, logify(get())); } } Index bytes; switch (type) { - case i32: { + case Type::i32: { switch (upTo(3)) { case 0: bytes = 1; @@ -2341,7 +2348,7 @@ private: } break; } - case i64: { + case Type::i64: { switch (upTo(4)) { case 0: bytes = 1; @@ -2391,14 +2398,14 @@ private: if (type.isRef()) { return makeTrivial(type); } - if (type != v128) { + if (type != Type::v128) { return makeSIMDExtract(type); } switch (upTo(7)) { case 0: - return makeUnary(v128); + return makeUnary(Type::v128); case 1: - return makeBinary(v128); + return makeBinary(Type::v128); case 2: return makeSIMDReplace(); case 3: @@ -2416,32 +2423,32 @@ private: Expression* makeSIMDExtract(Type type) { auto op = static_cast<SIMDExtractOp>(0); switch (type) { - case i32: + case Type::i32: op = pick(ExtractLaneSVecI8x16, ExtractLaneUVecI8x16, ExtractLaneSVecI16x8, ExtractLaneUVecI16x8, ExtractLaneVecI32x4); break; - case i64: + case Type::i64: op = ExtractLaneVecI64x2; break; - case f32: + case Type::f32: op = ExtractLaneVecF32x4; break; - case f64: + case Type::f64: op = ExtractLaneVecF64x2; break; - case v128: - case funcref: - case anyref: - case nullref: - case exnref: - case none: - case unreachable: + case Type::v128: + case Type::funcref: + case Type::anyref: + case Type::nullref: + case Type::exnref: + case Type::none: + case Type::unreachable: WASM_UNREACHABLE("unexpected type"); } - Expression* vec = make(v128); + Expression* vec = make(Type::v128); uint8_t index = 0; switch (op) { case ExtractLaneSVecI8x16: @@ -2471,33 +2478,33 @@ private: ReplaceLaneVecI64x2, ReplaceLaneVecF32x4, ReplaceLaneVecF64x2); - Expression* vec = make(v128); + Expression* vec = make(Type::v128); uint8_t index; Type lane_t; switch (op) { case ReplaceLaneVecI8x16: index = upTo(16); - lane_t = i32; + lane_t = Type::i32; break; case ReplaceLaneVecI16x8: index = upTo(8); - lane_t = i32; + lane_t = Type::i32; break; case ReplaceLaneVecI32x4: index = upTo(4); - lane_t = i32; + lane_t = Type::i32; break; case ReplaceLaneVecI64x2: index = upTo(2); - lane_t = i64; + lane_t = Type::i64; break; case ReplaceLaneVecF32x4: index = upTo(4); - lane_t = f32; + lane_t = Type::f32; break; case ReplaceLaneVecF64x2: index = upTo(2); - lane_t = f64; + lane_t = Type::f64; break; default: WASM_UNREACHABLE("unexpected op"); @@ -2507,8 +2514,8 @@ private: } Expression* makeSIMDShuffle() { - Expression* left = make(v128); - Expression* right = make(v128); + Expression* left = make(Type::v128); + Expression* right = make(Type::v128); std::array<uint8_t, 16> mask; for (size_t i = 0; i < 16; ++i) { mask[i] = upTo(32); @@ -2524,9 +2531,9 @@ private: // QFMAF64x2, // QFMSF64x2); SIMDTernaryOp op = Bitselect; - Expression* a = make(v128); - Expression* b = make(v128); - Expression* c = make(v128); + Expression* a = make(Type::v128); + Expression* b = make(Type::v128); + Expression* c = make(Type::v128); return builder.makeSIMDTernary(op, a, b, c); } @@ -2543,8 +2550,8 @@ private: ShlVecI64x2, ShrSVecI64x2, ShrUVecI64x2); - Expression* vec = make(v128); - Expression* shift = make(i32); + Expression* vec = make(Type::v128); + Expression* shift = make(Type::Type::i32); return builder.makeSIMDShift(op, vec, shift); } @@ -2590,7 +2597,7 @@ private: return makeTrivial(type); } assert(wasm.features.hasBulkMemory()); - assert(type == none); + assert(type == Type::none); switch (upTo(4)) { case 0: return makeMemoryInit(); @@ -2618,7 +2625,7 @@ private: Expression* makeMemoryInit() { if (!allowMemory) { - return makeTrivial(none); + return makeTrivial(Type::none); } uint32_t segment = upTo(wasm.memory.segments.size()); size_t totalSize = wasm.memory.segments[segment].data.size(); @@ -2632,28 +2639,28 @@ private: Expression* makeDataDrop() { if (!allowMemory) { - return makeTrivial(none); + return makeTrivial(Type::none); } return builder.makeDataDrop(upTo(wasm.memory.segments.size())); } Expression* makeMemoryCopy() { if (!allowMemory) { - return makeTrivial(none); + return makeTrivial(Type::none); } Expression* dest = makePointer(); Expression* source = makePointer(); - Expression* size = make(i32); + Expression* size = make(Type::i32); return builder.makeMemoryCopy(dest, source, size); } Expression* makeMemoryFill() { if (!allowMemory) { - return makeTrivial(none); + return makeTrivial(Type::none); } Expression* dest = makePointer(); Expression* value = makePointer(); - Expression* size = make(i32); + Expression* size = make(Type::i32); return builder.makeMemoryFill(dest, value, size); } @@ -2662,12 +2669,12 @@ private: Expression* makeLogging() { auto type = getLoggableType(); return builder.makeCall( - std::string("log-") + type.toString(), {make(type)}, none); + std::string("log-") + type.toString(), {make(type)}, Type::none); } Expression* makeMemoryHashLogging() { - auto* hash = builder.makeCall(std::string("hashMemory"), {}, i32); - return builder.makeCall(std::string("log-i32"), {hash}, none); + auto* hash = builder.makeCall(std::string("hashMemory"), {}, Type::i32); + return builder.makeCall(std::string("log-i32"), {hash}, Type::none); } // special getters @@ -2850,7 +2857,7 @@ private: if (auto* block = target->dynCast<Block>()) { return block->type; } else if (target->is<Loop>()) { - return none; + return Type::none; } WASM_UNREACHABLE("unexpected expr type"); } diff --git a/src/tools/js-wrapper.h b/src/tools/js-wrapper.h index a2d481f42..a787d4d2c 100644 --- a/src/tools/js-wrapper.h +++ b/src/tools/js-wrapper.h @@ -107,7 +107,7 @@ static std::string generateJSWrapper(Module& wasm) { ret += ", "; } ret += "0"; - if (param == i64) { + if (param == Type::i64) { ret += ", 0"; } } diff --git a/src/tools/spec-wrapper.h b/src/tools/spec-wrapper.h index f59291e55..2bad602f2 100644 --- a/src/tools/spec-wrapper.h +++ b/src/tools/spec-wrapper.h @@ -33,29 +33,29 @@ static std::string generateSpecWrapper(Module& wasm) { for (Type param : func->sig.params.expand()) { // zeros in arguments TODO more? switch (param) { - case i32: + case Type::i32: ret += "(i32.const 0)"; break; - case i64: + case Type::i64: ret += "(i64.const 0)"; break; - case f32: + case Type::f32: ret += "(f32.const 0)"; break; - case f64: + case Type::f64: ret += "(f64.const 0)"; break; - case v128: + case Type::v128: ret += "(v128.const i32x4 0 0 0 0)"; break; - case funcref: - case anyref: - case nullref: - case exnref: + case Type::funcref: + case Type::anyref: + case Type::nullref: + case Type::exnref: ret += "(ref.null)"; break; - case none: - case unreachable: + case Type::none: + case Type::unreachable: WASM_UNREACHABLE("unexpected type"); } ret += " "; diff --git a/src/tools/wasm-reduce.cpp b/src/tools/wasm-reduce.cpp index 6adb1e174..5a05fc7d2 100644 --- a/src/tools/wasm-reduce.cpp +++ b/src/tools/wasm-reduce.cpp @@ -462,7 +462,7 @@ struct Reducer void visitExpression(Expression* curr) { // type-based reductions - if (curr->type == none) { + if (curr->type == Type::none) { if (tryToReduceCurrentToNop()) { return; } @@ -471,14 +471,14 @@ struct Reducer return; } } else { - assert(curr->type == unreachable); + assert(curr->type == Type::unreachable); if (tryToReduceCurrentToUnreachable()) { return; } } // specific reductions if (auto* iff = curr->dynCast<If>()) { - if (iff->type == none) { + if (iff->type == Type::none) { // perhaps we need just the condition? if (tryToReplaceCurrent(builder->makeDrop(iff->condition))) { return; @@ -556,7 +556,7 @@ struct Reducer } // Finally, try to replace with a child. for (auto* child : ChildIterator(curr)) { - if (child->type.isConcrete() && curr->type == none) { + if (child->type.isConcrete() && curr->type == Type::none) { if (tryToReplaceCurrent(builder->makeDrop(child))) { return; } @@ -578,114 +578,114 @@ struct Reducer } Expression* fixed = nullptr; switch (curr->type) { - case i32: { + case Type::i32: { switch (child->type) { - case i32: + case Type::i32: WASM_UNREACHABLE("invalid type"); - case i64: + case Type::i64: fixed = builder->makeUnary(WrapInt64, child); break; - case f32: + case Type::f32: fixed = builder->makeUnary(TruncSFloat32ToInt32, child); break; - case f64: + case Type::f64: fixed = builder->makeUnary(TruncSFloat64ToInt32, child); break; - case v128: - case funcref: - case anyref: - case nullref: - case exnref: + case Type::v128: + case Type::funcref: + case Type::anyref: + case Type::nullref: + case Type::exnref: continue; // not implemented yet - case none: - case unreachable: + case Type::none: + case Type::unreachable: WASM_UNREACHABLE("unexpected type"); } break; } - case i64: { + case Type::i64: { switch (child->type) { - case i32: + case Type::i32: fixed = builder->makeUnary(ExtendSInt32, child); break; - case i64: + case Type::i64: WASM_UNREACHABLE("invalid type"); - case f32: + case Type::f32: fixed = builder->makeUnary(TruncSFloat32ToInt64, child); break; - case f64: + case Type::f64: fixed = builder->makeUnary(TruncSFloat64ToInt64, child); break; - case v128: - case funcref: - case anyref: - case nullref: - case exnref: + case Type::v128: + case Type::funcref: + case Type::anyref: + case Type::nullref: + case Type::exnref: continue; // not implemented yet - case none: - case unreachable: + case Type::none: + case Type::unreachable: WASM_UNREACHABLE("unexpected type"); } break; } - case f32: { + case Type::f32: { switch (child->type) { - case i32: + case Type::i32: fixed = builder->makeUnary(ConvertSInt32ToFloat32, child); break; - case i64: + case Type::i64: fixed = builder->makeUnary(ConvertSInt64ToFloat32, child); break; - case f32: + case Type::f32: WASM_UNREACHABLE("unexpected type"); - case f64: + case Type::f64: fixed = builder->makeUnary(DemoteFloat64, child); break; - case v128: - case funcref: - case anyref: - case nullref: - case exnref: + case Type::v128: + case Type::funcref: + case Type::anyref: + case Type::nullref: + case Type::exnref: continue; // not implemented yet - case none: - case unreachable: + case Type::none: + case Type::unreachable: WASM_UNREACHABLE("unexpected type"); } break; } - case f64: { + case Type::f64: { switch (child->type) { - case i32: + case Type::i32: fixed = builder->makeUnary(ConvertSInt32ToFloat64, child); break; - case i64: + case Type::i64: fixed = builder->makeUnary(ConvertSInt64ToFloat64, child); break; - case f32: + case Type::f32: fixed = builder->makeUnary(PromoteFloat32, child); break; - case f64: + case Type::f64: WASM_UNREACHABLE("unexpected type"); - case v128: - case funcref: - case anyref: - case nullref: - case exnref: + case Type::v128: + case Type::funcref: + case Type::anyref: + case Type::nullref: + case Type::exnref: continue; // not implemented yet - case none: - case unreachable: + case Type::none: + case Type::unreachable: WASM_UNREACHABLE("unexpected type"); } break; } - case v128: - case funcref: - case anyref: - case nullref: - case exnref: + case Type::v128: + case Type::funcref: + case Type::anyref: + case Type::nullref: + case Type::exnref: continue; // not implemented yet - case none: - case unreachable: + case Type::none: + case Type::unreachable: WASM_UNREACHABLE("unexpected type"); } assert(fixed->type == curr->type); @@ -879,7 +879,7 @@ struct Reducer auto funcSig = func->sig; auto* funcBody = func->body; for (auto* child : ChildIterator(func->body)) { - if (!(child->type.isConcrete() || child->type == none)) { + if (!(child->type.isConcrete() || child->type == Type::none)) { continue; // not something a function can return } // Try to replace the body with the child, fixing up the function diff --git a/src/tools/wasm2js.cpp b/src/tools/wasm2js.cpp index 7fa56c810..fabcf5522 100644 --- a/src/tools/wasm2js.cpp +++ b/src/tools/wasm2js.cpp @@ -565,7 +565,7 @@ Ref AssertionEmitter::emitAssertReturnFunc(Builder& wasmBuilder, Expression* actual = sexpBuilder.parseExpression(e[1]); Expression* body = nullptr; if (e.size() == 2) { - if (actual->type == none) { + if (actual->type == Type::none) { body = wasmBuilder.blockify(actual, wasmBuilder.makeConst(Literal(uint32_t(1)))); } else { @@ -576,25 +576,25 @@ Ref AssertionEmitter::emitAssertReturnFunc(Builder& wasmBuilder, Type resType = expected->type; actual->type = resType; switch (resType) { - case i32: + case Type::i32: body = wasmBuilder.makeBinary(EqInt32, actual, expected); break; - case i64: + case Type::i64: body = wasmBuilder.makeCall( "i64Equal", {actual, - wasmBuilder.makeCall(WASM_FETCH_HIGH_BITS, {}, i32), + wasmBuilder.makeCall(WASM_FETCH_HIGH_BITS, {}, Type::i32), expected}, - i32); + Type::i32); break; - case f32: { - body = wasmBuilder.makeCall("f32Equal", {actual, expected}, i32); + case Type::f32: { + body = wasmBuilder.makeCall("f32Equal", {actual, expected}, Type::i32); break; } - case f64: { - body = wasmBuilder.makeCall("f64Equal", {actual, expected}, i32); + case Type::f64: { + body = wasmBuilder.makeCall("f64Equal", {actual, expected}, Type::i32); break; } @@ -623,7 +623,7 @@ Ref AssertionEmitter::emitAssertReturnNanFunc(Builder& wasmBuilder, Name testFuncName, Name asmModule) { Expression* actual = sexpBuilder.parseExpression(e[1]); - Expression* body = wasmBuilder.makeCall("isNaN", {actual}, i32); + Expression* body = wasmBuilder.makeCall("isNaN", {actual}, Type::i32); std::unique_ptr<Function> testFunc( wasmBuilder.makeFunction(testFuncName, std::vector<NameType>{}, |