| Index: src/wasm/wasm-opcodes.h
|
| diff --git a/src/wasm/wasm-opcodes.h b/src/wasm/wasm-opcodes.h
|
| index 52f85aab0a61c367225a4e5bde1cffeab14bf540..1a3aa9cf2a3610b69ed358c957e14a2dabece652 100644
|
| --- a/src/wasm/wasm-opcodes.h
|
| +++ b/src/wasm/wasm-opcodes.h
|
| @@ -330,16 +330,21 @@ enum WasmOpcode {
|
| };
|
|
|
| // The reason for a trap.
|
| +#define FOREACH_WASM_TRAPREASON(V) \
|
| + V(TrapUnreachable) \
|
| + V(TrapMemOutOfBounds) \
|
| + V(TrapDivByZero) \
|
| + V(TrapDivUnrepresentable) \
|
| + V(TrapRemByZero) \
|
| + V(TrapFloatUnrepresentable) \
|
| + V(TrapFuncInvalid) \
|
| + V(TrapFuncSigMismatch)
|
| +
|
| enum TrapReason {
|
| - kTrapUnreachable,
|
| - kTrapMemOutOfBounds,
|
| - kTrapDivByZero,
|
| - kTrapDivUnrepresentable,
|
| - kTrapRemByZero,
|
| - kTrapFloatUnrepresentable,
|
| - kTrapFuncInvalid,
|
| - kTrapFuncSigMismatch,
|
| +#define DECLARE_ENUM(name) k##name,
|
| + FOREACH_WASM_TRAPREASON(DECLARE_ENUM)
|
| kTrapCount
|
| +#undef DECLARE_ENUM
|
| };
|
|
|
| // A collection of opcode-related static methods.
|
| @@ -349,6 +354,9 @@ class WasmOpcodes {
|
| static const char* OpcodeName(WasmOpcode opcode);
|
| static FunctionSig* Signature(WasmOpcode opcode);
|
|
|
| + static int TrapReasonToMessageId(TrapReason reason);
|
| + static const char* TrapReasonMessage(TrapReason reason);
|
| +
|
| static byte MemSize(MachineType type) {
|
| return 1 << ElementSizeLog2Of(type.representation());
|
| }
|
| @@ -508,29 +516,6 @@ class WasmOpcodes {
|
| return "<unknown>";
|
| }
|
| }
|
| -
|
| - static const char* TrapReasonName(TrapReason reason) {
|
| - switch (reason) {
|
| - case kTrapUnreachable:
|
| - return "unreachable";
|
| - case kTrapMemOutOfBounds:
|
| - return "memory access out of bounds";
|
| - case kTrapDivByZero:
|
| - return "divide by zero";
|
| - case kTrapDivUnrepresentable:
|
| - return "divide result unrepresentable";
|
| - case kTrapRemByZero:
|
| - return "remainder by zero";
|
| - case kTrapFloatUnrepresentable:
|
| - return "integer result unrepresentable";
|
| - case kTrapFuncInvalid:
|
| - return "invalid function";
|
| - case kTrapFuncSigMismatch:
|
| - return "function signature mismatch";
|
| - default:
|
| - return "<?>";
|
| - }
|
| - }
|
| };
|
| } // namespace wasm
|
| } // namespace internal
|
|
|