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

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: 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') | no next file » | 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..ea6fd0c69c95a0d812d42e507691643cbc904682 100644
--- a/src/wasm/wasm-opcodes.h
+++ b/src/wasm/wasm-opcodes.h
@@ -6,6 +6,7 @@
#define V8_WASM_OPCODES_H_
#include "src/machine-type.h"
+#include "src/messages.h"
Michael Starzinger 2016/04/11 14:05:24 nit: Not sure about the header inclusion policy in
#include "src/signature.h"
namespace v8 {
@@ -330,16 +331,21 @@ enum WasmOpcode {
};
// The reason for a trap.
+#define FOREACH_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_TRAPREASON(DECLARE_ENUM)
kTrapCount
+#undef DECLARE_ENUM
};
// A collection of opcode-related static methods.
@@ -509,28 +515,21 @@ class WasmOpcodes {
}
}
- static const char* TrapReasonName(TrapReason reason) {
+ static int TrapReasonToMessageId(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";
+#define TRAPREASON_TO_MESSAGE(name) \
+ case k##name: \
+ return MessageTemplate::kWasm##name;
+ FOREACH_TRAPREASON(TRAPREASON_TO_MESSAGE)
+#undef TRAPREASON_TO_MESSAGE
default:
- return "<?>";
+ return MessageTemplate::kNone;
}
}
+
+ static const char* TrapReasonName(TrapReason reason) {
Michael Starzinger 2016/04/11 14:05:24 nit/suggestion: Calling this "TrapReasonMessage" w
+ return MessageTemplate::TemplateString(TrapReasonToMessageId(reason));
+ }
};
} // namespace wasm
} // namespace internal
« no previous file with comments | « src/messages.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698