Index: src/wasm/wasm-opcodes.h |
diff --git a/src/wasm/wasm-opcodes.h b/src/wasm/wasm-opcodes.h |
index 83c7be1c514b20100b08eb78632ffe3739b6a006..52f85aab0a61c367225a4e5bde1cffeab14bf540 100644 |
--- a/src/wasm/wasm-opcodes.h |
+++ b/src/wasm/wasm-opcodes.h |
@@ -329,6 +329,19 @@ enum WasmOpcode { |
#undef DECLARE_NAMED_ENUM |
}; |
+// The reason for a trap. |
+enum TrapReason { |
+ kTrapUnreachable, |
+ kTrapMemOutOfBounds, |
+ kTrapDivByZero, |
+ kTrapDivUnrepresentable, |
+ kTrapRemByZero, |
+ kTrapFloatUnrepresentable, |
+ kTrapFuncInvalid, |
+ kTrapFuncSigMismatch, |
+ kTrapCount |
+}; |
+ |
// A collection of opcode-related static methods. |
class WasmOpcodes { |
public: |
@@ -495,6 +508,29 @@ 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 |