Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Unified Diff: src/wasm/wasm-opcodes.h

Issue 1880493002: Move TrapReason messages over to messages.h (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@include-objects-in-messages
Patch Set: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/messages.h ('k') | src/wasm/wasm-opcodes.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « src/messages.h ('k') | src/wasm/wasm-opcodes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698