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

Unified Diff: src/wasm/ast-decoder.cc

Issue 2253543003: [wasm] Macro-ify checking of prototype flags. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: [wasm] Macro-ify checking of prototype flags. Created 4 years, 4 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 | « no previous file | test/unittests/wasm/ast-decoder-unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/ast-decoder.cc
diff --git a/src/wasm/ast-decoder.cc b/src/wasm/ast-decoder.cc
index edbdcfe1d96ed98076884d2d4f0667ae4ae74d05..740199c29817a5a6ab4cf4ffb6a37f1bd16ec3e1 100644
--- a/src/wasm/ast-decoder.cc
+++ b/src/wasm/ast-decoder.cc
@@ -31,6 +31,12 @@ namespace wasm {
#define TRACE(...)
#endif
+#define CHECK_PROTOTYPE_OPCODE(flag) \
+ if (!FLAG_##flag) { \
+ error("Invalid opcode (enable with --" #flag ")"); \
+ break; \
+ }
+
// An SsaEnv environment carries the current local variable renaming
// as well as the current effect and control dependency in the TF graph.
// It maintains a control state that tracks whether the environment
@@ -671,23 +677,14 @@ class WasmFullDecoder : public WasmDecoder {
break;
}
case kExprThrow: {
- if (!FLAG_wasm_eh_prototype) {
- error("Invalid opcode");
- return;
- }
-
- // TODO(jpp): validate the poped value.
- Pop();
+ CHECK_PROTOTYPE_OPCODE(wasm_eh_prototype);
+ Pop(0, kAstI32);
// TODO(jpp): start exception propagation.
break;
}
case kExprTryCatch: {
- if (!FLAG_wasm_eh_prototype) {
- error("Invalid opcode");
- return;
- }
-
+ CHECK_PROTOTYPE_OPCODE(wasm_eh_prototype);
SsaEnv* outer_env = ssa_env_;
SsaEnv* try_env = Steal(outer_env);
SsaEnv* catch_env = Split(try_env);
@@ -696,11 +693,7 @@ class WasmFullDecoder : public WasmDecoder {
break;
}
case kExprTryCatchFinally: {
- if (!FLAG_wasm_eh_prototype) {
- error("Invalid opcode");
- return;
- }
-
+ CHECK_PROTOTYPE_OPCODE(wasm_eh_prototype);
SsaEnv* outer_env = ssa_env_;
SsaEnv* try_env = Steal(outer_env);
SsaEnv* catch_env = Split(try_env);
@@ -710,11 +703,7 @@ class WasmFullDecoder : public WasmDecoder {
break;
}
case kExprTryFinally: {
- if (!FLAG_wasm_eh_prototype) {
- error("Invalid opcode");
- return;
- }
-
+ CHECK_PROTOTYPE_OPCODE(wasm_eh_prototype);
SsaEnv* outer_env = ssa_env_;
SsaEnv* try_env = Steal(outer_env);
SsaEnv* finally_env = Split(outer_env);
@@ -723,11 +712,7 @@ class WasmFullDecoder : public WasmDecoder {
break;
}
case kExprCatch: {
- if (!FLAG_wasm_eh_prototype) {
- error("Invalid opcode");
- return;
- }
-
+ CHECK_PROTOTYPE_OPCODE(wasm_eh_prototype);
LocalIndexOperand operand(this, pc_);
len = 1 + operand.length;
@@ -766,11 +751,7 @@ class WasmFullDecoder : public WasmDecoder {
break;
}
case kExprFinally: {
- if (!FLAG_wasm_eh_prototype) {
- error("Invalid opcode");
- return;
- }
-
+ CHECK_PROTOTYPE_OPCODE(wasm_eh_prototype);
if (control_.empty()) {
error(pc_, "finally does not match a any try");
break;
@@ -885,8 +866,6 @@ class WasmFullDecoder : public WasmDecoder {
name = "if_else:merge";
}
} else if (c->is_try()) {
- DCHECK(FLAG_wasm_eh_prototype);
-
name = "try:end";
// try blocks do not yield a value.
@@ -1201,10 +1180,7 @@ class WasmFullDecoder : public WasmDecoder {
break;
}
case kSimdPrefix: {
- if (!FLAG_wasm_simd_prototype) {
- error("Invalid opcode");
- return;
- }
+ CHECK_PROTOTYPE_OPCODE(wasm_simd_prototype);
len++;
byte simd_index = *(pc_ + 1);
opcode = static_cast<WasmOpcode>(opcode << 8 | simd_index);
« no previous file with comments | « no previous file | test/unittests/wasm/ast-decoder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698