diff options
author | Sam Clegg <sbc@chromium.org> | 2019-12-05 13:09:21 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-05 13:09:21 -0600 |
commit | a28343a33ed28b4d5c83c37e350aceaf09b5246f (patch) | |
tree | 084a487cdf79e8025246d2a85d5578c113c9ad51 /src/wasm | |
parent | cbf121df96cfce5038f52ed04f9780e19ed3b762 (diff) | |
download | binaryen-a28343a33ed28b4d5c83c37e350aceaf09b5246f.tar.gz binaryen-a28343a33ed28b4d5c83c37e350aceaf09b5246f.tar.bz2 binaryen-a28343a33ed28b4d5c83c37e350aceaf09b5246f.zip |
Add string parameter to WASM_UNREACHABLE (#2499)
This works more like llvm's unreachable handler in that is preserves
information even in release builds.
Diffstat (limited to 'src/wasm')
-rw-r--r-- | src/wasm/literal.cpp | 138 | ||||
-rw-r--r-- | src/wasm/wasm-binary.cpp | 15 | ||||
-rw-r--r-- | src/wasm/wasm-emscripten.cpp | 2 | ||||
-rw-r--r-- | src/wasm/wasm-stack.cpp | 46 | ||||
-rw-r--r-- | src/wasm/wasm-type.cpp | 10 | ||||
-rw-r--r-- | src/wasm/wasm-validator.cpp | 10 | ||||
-rw-r--r-- | src/wasm/wasm.cpp | 14 |
7 files changed, 118 insertions, 117 deletions
diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp index 3b2930c67..4183d8a23 100644 --- a/src/wasm/literal.cpp +++ b/src/wasm/literal.cpp @@ -141,7 +141,7 @@ void Literal::getBits(uint8_t (&buf)[16]) const { case Type::exnref: // exnref type is opaque case Type::none: case Type::unreachable: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid type"); } } @@ -276,7 +276,7 @@ std::ostream& operator<<(std::ostream& o, Literal literal) { case Type::anyref: // anyref type is opaque case Type::exnref: // exnref type is opaque case Type::unreachable: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid type"); } restoreNormalColor(o); return o; @@ -289,7 +289,7 @@ Literal Literal::countLeadingZeroes() const { if (type == Type::i64) { return Literal((int64_t)CountLeadingZeroes(i64)); } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid type"); } Literal Literal::countTrailingZeroes() const { @@ -299,7 +299,7 @@ Literal Literal::countTrailingZeroes() const { if (type == Type::i64) { return Literal((int64_t)CountTrailingZeroes(i64)); } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid type"); } Literal Literal::popCount() const { @@ -309,7 +309,7 @@ Literal Literal::popCount() const { if (type == Type::i64) { return Literal((int64_t)PopCount(i64)); } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid type"); } Literal Literal::extendToSI64() const { @@ -334,7 +334,7 @@ Literal Literal::extendS8() const { if (type == Type::i64) { return Literal(int64_t(int8_t(geti64() & 0xFF))); } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid type"); } Literal Literal::extendS16() const { @@ -344,14 +344,14 @@ Literal Literal::extendS16() const { if (type == Type::i64) { return Literal(int64_t(int16_t(geti64() & 0xFFFF))); } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid type"); } Literal Literal::extendS32() const { if (type == Type::i64) { return Literal(int64_t(int32_t(geti64() & 0xFFFFFFFF))); } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid type"); } Literal Literal::wrapToI32() const { @@ -366,7 +366,7 @@ Literal Literal::convertSIToF32() const { if (type == Type::i64) { return Literal(float(i64)); } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid type"); } Literal Literal::convertUIToF32() const { @@ -376,7 +376,7 @@ Literal Literal::convertUIToF32() const { if (type == Type::i64) { return Literal(float(uint64_t(i64))); } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid type"); } Literal Literal::convertSIToF64() const { @@ -386,7 +386,7 @@ Literal Literal::convertSIToF64() const { if (type == Type::i64) { return Literal(double(i64)); } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid type"); } Literal Literal::convertUIToF64() const { @@ -396,7 +396,7 @@ Literal Literal::convertUIToF64() const { if (type == Type::i64) { return Literal(double(uint64_t(i64))); } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid type"); } template<typename F> struct AsInt { using type = void; }; @@ -427,7 +427,7 @@ Literal Literal::truncSatToSI32() const { return saturating_trunc<double, int32_t, isInRangeI32TruncS>( Literal(*this).castToI64().geti64()); } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid type"); } Literal Literal::truncSatToSI64() const { @@ -439,7 +439,7 @@ Literal Literal::truncSatToSI64() const { return saturating_trunc<double, int64_t, isInRangeI64TruncS>( Literal(*this).castToI64().geti64()); } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid type"); } Literal Literal::truncSatToUI32() const { @@ -451,7 +451,7 @@ Literal Literal::truncSatToUI32() const { return saturating_trunc<double, uint32_t, isInRangeI32TruncU>( Literal(*this).castToI64().geti64()); } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid type"); } Literal Literal::truncSatToUI64() const { @@ -463,7 +463,7 @@ Literal Literal::truncSatToUI64() const { return saturating_trunc<double, uint64_t, isInRangeI64TruncU>( Literal(*this).castToI64().geti64()); } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid type"); } Literal Literal::eqz() const { @@ -481,9 +481,9 @@ Literal Literal::eqz() const { case Type::exnref: case Type::none: case Type::unreachable: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid type"); } Literal Literal::neg() const { @@ -501,9 +501,9 @@ Literal Literal::neg() const { case Type::exnref: case Type::none: case Type::unreachable: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid type"); } Literal Literal::abs() const { @@ -521,9 +521,9 @@ Literal Literal::abs() const { case Type::exnref: case Type::none: case Type::unreachable: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } Literal Literal::ceil() const { @@ -533,7 +533,7 @@ Literal Literal::ceil() const { case Type::f64: return Literal(std::ceil(getf64())); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -544,7 +544,7 @@ Literal Literal::floor() const { case Type::f64: return Literal(std::floor(getf64())); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -555,7 +555,7 @@ Literal Literal::trunc() const { case Type::f64: return Literal(std::trunc(getf64())); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -566,7 +566,7 @@ Literal Literal::nearbyint() const { case Type::f64: return Literal(std::nearbyint(getf64())); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -577,7 +577,7 @@ Literal Literal::sqrt() const { case Type::f64: return Literal(std::sqrt(getf64())); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -624,9 +624,9 @@ Literal Literal::add(const Literal& other) const { case Type::exnref: case Type::none: case Type::unreachable: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } Literal Literal::sub(const Literal& other) const { @@ -644,9 +644,9 @@ Literal Literal::sub(const Literal& other) const { case Type::exnref: case Type::none: case Type::unreachable: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } template<typename T> static T add_sat_s(T a, T b) { @@ -735,9 +735,9 @@ Literal Literal::mul(const Literal& other) const { case Type::exnref: case Type::none: case Type::unreachable: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } Literal Literal::div(const Literal& other) const { @@ -759,7 +759,7 @@ Literal Literal::div(const Literal& other) const { return Literal( std::copysign(std::numeric_limits<float>::infinity(), sign)); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid fp classification"); } case FP_NAN: // fallthrough case FP_INFINITE: // fallthrough @@ -767,7 +767,7 @@ Literal Literal::div(const Literal& other) const { case FP_SUBNORMAL: return Literal(lhs / rhs); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid fp classification"); } } case Type::f64: { @@ -787,7 +787,7 @@ Literal Literal::div(const Literal& other) const { return Literal( std::copysign(std::numeric_limits<double>::infinity(), sign)); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid fp classification"); } case FP_NAN: // fallthrough case FP_INFINITE: // fallthrough @@ -795,11 +795,11 @@ Literal Literal::div(const Literal& other) const { case FP_SUBNORMAL: return Literal(lhs / rhs); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid fp classification"); } } default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -810,7 +810,7 @@ Literal Literal::divS(const Literal& other) const { case Type::i64: return Literal(i64 / other.i64); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -821,7 +821,7 @@ Literal Literal::divU(const Literal& other) const { case Type::i64: return Literal(uint64_t(i64) / uint64_t(other.i64)); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -832,7 +832,7 @@ Literal Literal::remS(const Literal& other) const { case Type::i64: return Literal(i64 % other.i64); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -843,7 +843,7 @@ Literal Literal::remU(const Literal& other) const { case Type::i64: return Literal(uint64_t(i64) % uint64_t(other.i64)); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -867,7 +867,7 @@ Literal Literal::and_(const Literal& other) const { case Type::i64: return Literal(i64 & other.i64); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -878,7 +878,7 @@ Literal Literal::or_(const Literal& other) const { case Type::i64: return Literal(i64 | other.i64); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -889,7 +889,7 @@ Literal Literal::xor_(const Literal& other) const { case Type::i64: return Literal(i64 ^ other.i64); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -902,7 +902,7 @@ Literal Literal::shl(const Literal& other) const { return Literal(uint64_t(i64) << Bits::getEffectiveShifts(other.i64, Type::i64)); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -913,7 +913,7 @@ Literal Literal::shrS(const Literal& other) const { case Type::i64: return Literal(i64 >> Bits::getEffectiveShifts(other.i64, Type::i64)); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -926,7 +926,7 @@ Literal Literal::shrU(const Literal& other) const { return Literal(uint64_t(i64) >> Bits::getEffectiveShifts(other.i64, Type::i64)); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -937,7 +937,7 @@ Literal Literal::rotL(const Literal& other) const { case Type::i64: return Literal(RotateLeft(uint64_t(i64), uint64_t(other.i64))); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -948,7 +948,7 @@ Literal Literal::rotR(const Literal& other) const { case Type::i64: return Literal(RotateRight(uint64_t(i64), uint64_t(other.i64))); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -967,9 +967,9 @@ Literal Literal::eq(const Literal& other) const { case Type::exnref: case Type::none: case Type::unreachable: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } Literal Literal::ne(const Literal& other) const { @@ -987,9 +987,9 @@ Literal Literal::ne(const Literal& other) const { case Type::exnref: case Type::none: case Type::unreachable: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } Literal Literal::ltS(const Literal& other) const { @@ -999,7 +999,7 @@ Literal Literal::ltS(const Literal& other) const { case Type::i64: return Literal(i64 < other.i64); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -1010,7 +1010,7 @@ Literal Literal::ltU(const Literal& other) const { case Type::i64: return Literal(uint64_t(i64) < uint64_t(other.i64)); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -1021,7 +1021,7 @@ Literal Literal::lt(const Literal& other) const { case Type::f64: return Literal(getf64() < other.getf64()); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -1032,7 +1032,7 @@ Literal Literal::leS(const Literal& other) const { case Type::i64: return Literal(i64 <= other.i64); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -1043,7 +1043,7 @@ Literal Literal::leU(const Literal& other) const { case Type::i64: return Literal(uint64_t(i64) <= uint64_t(other.i64)); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -1054,7 +1054,7 @@ Literal Literal::le(const Literal& other) const { case Type::f64: return Literal(getf64() <= other.getf64()); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -1065,7 +1065,7 @@ Literal Literal::gtS(const Literal& other) const { case Type::i64: return Literal(i64 > other.i64); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -1076,7 +1076,7 @@ Literal Literal::gtU(const Literal& other) const { case Type::i64: return Literal(uint64_t(i64) > uint64_t(other.i64)); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -1087,7 +1087,7 @@ Literal Literal::gt(const Literal& other) const { case Type::f64: return Literal(getf64() > other.getf64()); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -1098,7 +1098,7 @@ Literal Literal::geS(const Literal& other) const { case Type::i64: return Literal(i64 >= other.i64); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -1109,7 +1109,7 @@ Literal Literal::geU(const Literal& other) const { case Type::i64: return Literal(uint64_t(i64) >= uint64_t(other.i64)); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -1120,7 +1120,7 @@ Literal Literal::ge(const Literal& other) const { case Type::f64: return Literal(getf64() >= other.getf64()); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -1163,7 +1163,7 @@ Literal Literal::min(const Literal& other) const { .castToF64(); } default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -1206,7 +1206,7 @@ Literal Literal::max(const Literal& other) const { .castToF64(); } default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -1222,7 +1222,7 @@ Literal Literal::copysign(const Literal& other) const { .castToF64(); break; default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index bb8b96aa4..b8b001927 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -398,7 +398,7 @@ void WasmBinaryWriter::writeExports() { o << U32LEB(getEventIndex(curr->value)); break; default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected extern kind"); } } finishSection(start); @@ -669,7 +669,7 @@ void WasmBinaryWriter::writeFeaturesSection() { case FeatureSet::ReferenceTypes: return BinaryConsts::UserSections::ReferenceTypesFeature; default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected feature flag"); } }; @@ -1023,9 +1023,10 @@ Type WasmBinaryBuilder::getType() { return anyref; case BinaryConsts::EncodedType::exnref: return exnref; - default: { throwError("invalid wasm type: " + std::to_string(type)); } + default: + throwError("invalid wasm type: " + std::to_string(type)); } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpeced type"); } Type WasmBinaryBuilder::getConcreteType() { @@ -2848,7 +2849,7 @@ bool WasmBinaryBuilder::maybeVisitAtomicRMW(Expression*& out, uint8_t code) { SET_FOR_OP(Xor); SET_FOR_OP(Xchg); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected opcode"); } #undef SET_FOR_OP #undef SET @@ -2902,7 +2903,7 @@ bool WasmBinaryBuilder::maybeVisitAtomicCmpxchg(Expression*& out, SET(i64, 4); break; default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected opcode"); } BYN_TRACE("zz node: AtomicCmpxchg\n"); @@ -2934,7 +2935,7 @@ bool WasmBinaryBuilder::maybeVisitAtomicWait(Expression*& out, uint8_t code) { curr->expectedType = i64; break; default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected opcode"); } curr->type = i32; BYN_TRACE("zz node: AtomicWait\n"); diff --git a/src/wasm/wasm-emscripten.cpp b/src/wasm/wasm-emscripten.cpp index 3f64bafe8..dae125096 100644 --- a/src/wasm/wasm-emscripten.cpp +++ b/src/wasm/wasm-emscripten.cpp @@ -678,7 +678,7 @@ std::string proxyingSuffix(Proxying proxy) { case Proxying::Async: return "async_on_main_thread_"; } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid prozy type"); } struct AsmConstWalker : public LinearExecutionWalker<AsmConstWalker> { diff --git a/src/wasm/wasm-stack.cpp b/src/wasm/wasm-stack.cpp index f1aaff93e..0f12a2f2b 100644 --- a/src/wasm/wasm-stack.cpp +++ b/src/wasm/wasm-stack.cpp @@ -152,7 +152,7 @@ void BinaryInstWriter::visitLoad(Load* curr) { case anyref: // anyref cannot be loaded from memory case exnref: // exnref cannot be loaded from memory case none: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } else { o << int8_t(BinaryConsts::AtomicPrefix); @@ -169,7 +169,7 @@ void BinaryInstWriter::visitLoad(Load* curr) { o << int8_t(BinaryConsts::I32AtomicLoad); break; default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid load size"); } break; } @@ -188,14 +188,14 @@ void BinaryInstWriter::visitLoad(Load* curr) { o << int8_t(BinaryConsts::I64AtomicLoad); break; default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid load size"); } break; } case unreachable: return; default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } emitMemoryAccess(curr->align, curr->bytes, curr->offset); @@ -253,7 +253,7 @@ void BinaryInstWriter::visitStore(Store* curr) { case exnref: // exnref cannot be stored in memory case none: case unreachable: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } else { o << int8_t(BinaryConsts::AtomicPrefix); @@ -270,7 +270,7 @@ void BinaryInstWriter::visitStore(Store* curr) { o << int8_t(BinaryConsts::I32AtomicStore); break; default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid store size"); } break; } @@ -289,12 +289,12 @@ void BinaryInstWriter::visitStore(Store* curr) { o << int8_t(BinaryConsts::I64AtomicStore); break; default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid store size"); } break; } default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } emitMemoryAccess(curr->align, curr->bytes, curr->offset); @@ -318,7 +318,7 @@ void BinaryInstWriter::visitAtomicRMW(AtomicRMW* curr) { o << int8_t(BinaryConsts::I32AtomicRMW##Op); \ break; \ default: \ - WASM_UNREACHABLE(); \ + WASM_UNREACHABLE("invalid rmw size"); \ } \ break; \ case i64: \ @@ -336,11 +336,11 @@ void BinaryInstWriter::visitAtomicRMW(AtomicRMW* curr) { o << int8_t(BinaryConsts::I64AtomicRMW##Op); \ break; \ default: \ - WASM_UNREACHABLE(); \ + WASM_UNREACHABLE("invalid rmw size"); \ } \ break; \ default: \ - WASM_UNREACHABLE(); \ + WASM_UNREACHABLE("unexpected type"); \ } \ break @@ -352,7 +352,7 @@ void BinaryInstWriter::visitAtomicRMW(AtomicRMW* curr) { CASE_FOR_OP(Xor); CASE_FOR_OP(Xchg); default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected op"); } #undef CASE_FOR_OP @@ -374,7 +374,7 @@ void BinaryInstWriter::visitAtomicCmpxchg(AtomicCmpxchg* curr) { o << int8_t(BinaryConsts::I32AtomicCmpxchg); break; default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid size"); } break; case i64: @@ -392,11 +392,11 @@ void BinaryInstWriter::visitAtomicCmpxchg(AtomicCmpxchg* curr) { o << int8_t(BinaryConsts::I64AtomicCmpxchg); break; default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid size"); } break; default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } emitMemoryAccess(curr->bytes, curr->bytes, curr->offset); } @@ -415,7 +415,7 @@ void BinaryInstWriter::visitAtomicWait(AtomicWait* curr) { break; } default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -648,7 +648,7 @@ void BinaryInstWriter::visitConst(Const* curr) { case exnref: // there's no exnref.const case none: case unreachable: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } } @@ -990,7 +990,7 @@ void BinaryInstWriter::visitUnary(Unary* curr) { << U32LEB(BinaryConsts::I32x4WidenHighUI16x8); break; case InvalidUnary: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid unary op"); } } @@ -1532,7 +1532,7 @@ void BinaryInstWriter::visitBinary(Binary* curr) { break; case InvalidBinary: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid binary op"); } } @@ -1664,7 +1664,7 @@ void BinaryInstWriter::mapLocalsAndEmitHeader() { mappedLocals[i] = index + currLocalsByType[exnref] - 1; continue; } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); } // Emit them. o << U32LEB((numLocalsByType[i32] ? 1 : 0) + (numLocalsByType[i64] ? 1 : 0) + @@ -1708,7 +1708,7 @@ int32_t BinaryInstWriter::getBreakIndex(Name name) { // -1 if not found return breakStack.size() - 1 - i; } } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("break index not found"); } void StackIRGenerator::emit(Expression* curr) { @@ -1738,7 +1738,7 @@ void StackIRGenerator::emitScopeEnd(Expression* curr) { } else if (curr->is<Try>()) { stackInst = makeStackInst(StackInst::TryEnd, curr); } else { - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected expr type"); } stackIR.push_back(stackInst); } @@ -1796,7 +1796,7 @@ void StackIRToBinaryWriter::write() { break; } default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected op"); } } writer.emitFunctionEnd(); diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp index 50ddc82f8..d5a3668fb 100644 --- a/src/wasm/wasm-type.cpp +++ b/src/wasm/wasm-type.cpp @@ -248,9 +248,9 @@ unsigned getTypeSize(Type type) { case Type::exnref: // exnref type is opaque case Type::none: case Type::unreachable: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid type"); } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid type"); } FeatureSet getFeatures(Type type) { @@ -279,7 +279,7 @@ Type getType(unsigned size, bool float_) { if (size == 16) { return Type::v128; } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid size"); } Type reinterpretType(Type type) { @@ -297,9 +297,9 @@ Type reinterpretType(Type type) { case Type::exnref: case Type::none: case Type::unreachable: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid type"); } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid type"); } } // namespace wasm diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index d3f03b76c..75121d4f4 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -1183,7 +1183,7 @@ void FunctionValidator::validateMemBytes(uint8_t bytes, case anyref: // anyref cannot be stored in memory case exnref: // exnref cannot be stored in memory case none: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected type"); case unreachable: break; } @@ -1387,7 +1387,7 @@ void FunctionValidator::visitBinary(Binary* curr) { break; } case InvalidBinary: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invliad binary op"); } shouldBeTrue(Features::get(curr->op) <= getModule()->features, curr, @@ -1601,7 +1601,7 @@ void FunctionValidator::visitUnary(Unary* curr) { shouldBeEqual(curr->value->type, v128, curr, "expected v128 operand"); break; case InvalidUnary: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid unary op"); } shouldBeTrue(Features::get(curr->op) <= getModule()->features, curr, @@ -1866,7 +1866,7 @@ void FunctionValidator::validateAlignment( case anyref: // anyref cannot be stored in memory case exnref: // exnref cannot be stored in memory case none: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid type"); } } @@ -1995,7 +1995,7 @@ static void validateExports(Module& module, ValidationInfo& info) { name, "module event exports must be found"); } else { - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid ExternalKind"); } Name exportName = exp->name; info.shouldBeFalse(exportNames.count(exportName) > 0, diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp index f0c853172..5a722e600 100644 --- a/src/wasm/wasm.cpp +++ b/src/wasm/wasm.cpp @@ -94,7 +94,7 @@ Name ATTR("attr"); const char* getExpressionName(Expression* curr) { switch (curr->_id) { case Expression::Id::InvalidId: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid expr id"); case Expression::Id::BlockId: return "block"; case Expression::Id::IfId: @@ -182,9 +182,9 @@ const char* getExpressionName(Expression* curr) { case Expression::BrOnExnId: return "br_on_exn"; case Expression::Id::NumExpressionIds: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid expr id"); } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid expr id"); } // core AST type checking @@ -559,7 +559,7 @@ void SIMDExtract::finalize() { type = f64; break; default: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected op"); } if (vec->type == unreachable) { type = unreachable; @@ -653,7 +653,7 @@ Index SIMDLoad::getMemBytes() { case LoadExtUVec32x2ToVecI64x2: return 8; } - WASM_UNREACHABLE(); + WASM_UNREACHABLE("unexpected op"); } Const* Const::set(Literal value_) { @@ -801,7 +801,7 @@ void Unary::finalize() { break; case InvalidUnary: - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid unary op"); } } @@ -981,7 +981,7 @@ Type Function::getLocalType(Index index) { } else if (isVar(index)) { return vars[index - getVarIndexBase()]; } else { - WASM_UNREACHABLE(); + WASM_UNREACHABLE("invalid local index"); } } |