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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/wasm/wasm-macro-gen.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/base/platform/elapsed-timer.h" 5 #include "src/base/platform/elapsed-timer.h"
6 #include "src/signature.h" 6 #include "src/signature.h"
7 7
8 #include "src/bit-vector.h" 8 #include "src/bit-vector.h"
9 #include "src/flags.h" 9 #include "src/flags.h"
10 #include "src/handles.h" 10 #include "src/handles.h"
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 } 991 }
992 break; 992 break;
993 } 993 }
994 case kExprBr: { 994 case kExprBr: {
995 BreakDepthOperand operand(this, p->pc()); 995 BreakDepthOperand operand(this, p->pc());
996 CHECK(Validate(p->pc(), operand, blocks_)); 996 CHECK(Validate(p->pc(), operand, blocks_));
997 ReduceBreakToExprBlock(p, operand.target); 997 ReduceBreakToExprBlock(p, operand.target);
998 break; 998 break;
999 } 999 }
1000 case kExprBrIf: { 1000 case kExprBrIf: {
1001 if (p->index == 1) { 1001 if (p->done()) {
1002 TypeCheckLast(p, kAstI32); 1002 TypeCheckLast(p, kAstI32);
1003 } else if (p->done()) {
1004 BreakDepthOperand operand(this, p->pc()); 1003 BreakDepthOperand operand(this, p->pc());
1005 CHECK(Validate(p->pc(), operand, blocks_)); 1004 CHECK(Validate(p->pc(), operand, blocks_));
1006 SsaEnv* fenv = ssa_env_; 1005 SsaEnv* fenv = ssa_env_;
1007 SsaEnv* tenv = Split(fenv); 1006 SsaEnv* tenv = Split(fenv);
1008 BUILD(Branch, p->tree->children[0]->node, &tenv->control, 1007 BUILD(Branch, p->tree->children[1]->node, &tenv->control,
1009 &fenv->control); 1008 &fenv->control);
1010 ssa_env_ = tenv; 1009 ssa_env_ = tenv;
1011 ReduceBreakToExprBlock(p, operand.target); 1010 ReduceBreakToExprBlock(p, operand.target, p->tree->children[0]);
1012 ssa_env_ = fenv; 1011 ssa_env_ = fenv;
1013 } 1012 }
1014 break; 1013 break;
1015 } 1014 }
1016 case kExprTableSwitch: { 1015 case kExprTableSwitch: {
1017 if (p->index == 1) { 1016 if (p->index == 1) {
1018 // Switch key finished. 1017 // Switch key finished.
1019 TypeCheckLast(p, kAstI32); 1018 TypeCheckLast(p, kAstI32);
1020 if (failed()) break; 1019 if (failed()) break;
1021 1020
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 p->tree->node = builder_->CallIndirect(operand.index, buffer); 1211 p->tree->node = builder_->CallIndirect(operand.index, buffer);
1213 } 1212 }
1214 break; 1213 break;
1215 } 1214 }
1216 default: 1215 default:
1217 break; 1216 break;
1218 } 1217 }
1219 } 1218 }
1220 1219
1221 void ReduceBreakToExprBlock(Production* p, Block* block) { 1220 void ReduceBreakToExprBlock(Production* p, Block* block) {
1221 ReduceBreakToExprBlock(p, block, p->tree->count > 0 ? p->last() : nullptr);
1222 }
1223
1224 void ReduceBreakToExprBlock(Production* p, Block* block, Tree* val) {
1222 if (block->stack_depth < 0) { 1225 if (block->stack_depth < 0) {
1223 // This is the inner loop block, which does not have a value. 1226 // This is the inner loop block, which does not have a value.
1224 Goto(ssa_env_, block->ssa_env); 1227 Goto(ssa_env_, block->ssa_env);
1225 } else { 1228 } else {
1226 // Merge the value into the production for the block. 1229 // Merge the value into the production for the block.
1227 Production* bp = &stack_[block->stack_depth]; 1230 Production* bp = &stack_[block->stack_depth];
1228 MergeIntoProduction(bp, block->ssa_env, p->last()); 1231 MergeIntoProduction(bp, block->ssa_env, val);
1229 } 1232 }
1230 } 1233 }
1231 1234
1232 void MergeIntoProduction(Production* p, SsaEnv* target, Tree* expr) { 1235 void MergeIntoProduction(Production* p, SsaEnv* target, Tree* expr) {
1233 if (!ssa_env_->go()) return; 1236 if (!ssa_env_->go()) return;
1234 1237
1235 bool first = target->state == SsaEnv::kUnreachable; 1238 bool first = target->state == SsaEnv::kUnreachable;
1236 Goto(ssa_env_, target); 1239 Goto(ssa_env_, target);
1237 if (expr->type == kAstEnd) return; 1240 if (expr == nullptr || expr->type == kAstEnd) return;
1238 1241
1239 if (first) { 1242 if (first) {
1240 // first merge to this environment; set the type and the node. 1243 // first merge to this environment; set the type and the node.
1241 p->tree->type = expr->type; 1244 p->tree->type = expr->type;
1242 p->tree->node = expr->node; 1245 p->tree->node = expr->node;
1243 } else { 1246 } else {
1244 // merge with the existing value for this block. 1247 // merge with the existing value for this block.
1245 LocalType type = p->tree->type; 1248 LocalType type = p->tree->type;
1246 if (expr->type != type) { 1249 if (expr->type != type) {
1247 type = kAstStmt; 1250 type = kAstStmt;
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
1654 1657
1655 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, FunctionEnv* env, 1658 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, FunctionEnv* env,
1656 const byte* start, const byte* end) { 1659 const byte* start, const byte* end) {
1657 LoopAssignmentAnalyzer analyzer(zone, env); 1660 LoopAssignmentAnalyzer analyzer(zone, env);
1658 return analyzer.Analyze(start, end); 1661 return analyzer.Analyze(start, end);
1659 } 1662 }
1660 1663
1661 } // namespace wasm 1664 } // namespace wasm
1662 } // namespace internal 1665 } // namespace internal
1663 } // namespace v8 1666 } // namespace v8
OLDNEW
« 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