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

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

Issue 1682443002: [wasm] Put the condition last in kExprBrIf. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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 | src/wasm/wasm-macro-gen.h » ('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 968a45696471598fe04fd58aefc05302efbf3246..5b23babd6ef7feaeabd6d22a8e66676e4b2e2205 100644
--- a/src/wasm/ast-decoder.cc
+++ b/src/wasm/ast-decoder.cc
@@ -998,17 +998,16 @@ class LR_WasmDecoder : public WasmDecoder {
break;
}
case kExprBrIf: {
- if (p->index == 1) {
+ if (p->done()) {
TypeCheckLast(p, kAstI32);
- } else if (p->done()) {
BreakDepthOperand operand(this, p->pc());
CHECK(Validate(p->pc(), operand, blocks_));
SsaEnv* fenv = ssa_env_;
SsaEnv* tenv = Split(fenv);
- BUILD(Branch, p->tree->children[0]->node, &tenv->control,
+ BUILD(Branch, p->tree->children[1]->node, &tenv->control,
&fenv->control);
ssa_env_ = tenv;
- ReduceBreakToExprBlock(p, operand.target);
+ ReduceBreakToExprBlock(p, operand.target, p->tree->children[0]);
ssa_env_ = fenv;
}
break;
@@ -1219,13 +1218,17 @@ class LR_WasmDecoder : public WasmDecoder {
}
void ReduceBreakToExprBlock(Production* p, Block* block) {
+ ReduceBreakToExprBlock(p, block, p->tree->count > 0 ? p->last() : nullptr);
+ }
+
+ void ReduceBreakToExprBlock(Production* p, Block* block, Tree* val) {
if (block->stack_depth < 0) {
// This is the inner loop block, which does not have a value.
Goto(ssa_env_, block->ssa_env);
} else {
// Merge the value into the production for the block.
Production* bp = &stack_[block->stack_depth];
- MergeIntoProduction(bp, block->ssa_env, p->last());
+ MergeIntoProduction(bp, block->ssa_env, val);
}
}
@@ -1234,7 +1237,7 @@ class LR_WasmDecoder : public WasmDecoder {
bool first = target->state == SsaEnv::kUnreachable;
Goto(ssa_env_, target);
- if (expr->type == kAstEnd) return;
+ if (expr == nullptr || expr->type == kAstEnd) return;
if (first) {
// first merge to this environment; set the type and the node.
« no previous file with comments | « no previous file | src/wasm/wasm-macro-gen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698