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

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

Issue 1862633002: [wasm] Factor trap codes out of wasm-compiler.cc (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
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/compiler/wasm-compiler.cc ('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 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
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698