Chromium Code Reviews| 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 |