Index: src/wasm/wasm-opcodes.cc |
diff --git a/src/wasm/wasm-opcodes.cc b/src/wasm/wasm-opcodes.cc |
index 736c4d960926bdedd1ef144b2d9b77660d484b19..8336e2dea083f0858640b8ad69c9757d12a7ffec 100644 |
--- a/src/wasm/wasm-opcodes.cc |
+++ b/src/wasm/wasm-opcodes.cc |
@@ -3,6 +3,7 @@ |
// found in the LICENSE file. |
#include "src/wasm/wasm-opcodes.h" |
+#include "src/messages.h" |
#include "src/signature.h" |
namespace v8 { |
@@ -145,6 +146,22 @@ bool WasmOpcodes::IsSupported(WasmOpcode opcode) { |
return true; |
#endif |
} |
+ |
+int WasmOpcodes::TrapReasonToMessageId(TrapReason reason) { |
+ switch (reason) { |
+#define TRAPREASON_TO_MESSAGE(name) \ |
+ case k##name: \ |
+ return MessageTemplate::kWasm##name; |
+ FOREACH_WASM_TRAPREASON(TRAPREASON_TO_MESSAGE) |
+#undef TRAPREASON_TO_MESSAGE |
+ default: |
+ return MessageTemplate::kNone; |
+ } |
+} |
+ |
+const char* WasmOpcodes::TrapReasonMessage(TrapReason reason) { |
+ return MessageTemplate::TemplateString(TrapReasonToMessageId(reason)); |
+} |
} // namespace wasm |
} // namespace internal |
} // namespace v8 |