Commit 9693835a authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] [decoder] Minor interface change

The baseline compiler needs to know the depth in order to access the
parent block. This is a small CL, but anything that can land before the
big baseline CL reduced the complexity of the latter.

R=ahaas@chromium.org

Bug: v8:6600
Change-Id: I2e29cc974908438266adb4301026dfe5fbfb1990
Reviewed-on: https://chromium-review.googlesource.com/677301Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48112}
parent 70e0261a
...@@ -515,8 +515,8 @@ struct ControlWithNamedConstructors : public ControlBase<Value> { ...@@ -515,8 +515,8 @@ struct ControlWithNamedConstructors : public ControlBase<Value> {
F(Unreachable) \ F(Unreachable) \
F(Select, const Value& cond, const Value& fval, const Value& tval, \ F(Select, const Value& cond, const Value& fval, const Value& tval, \
Value* result) \ Value* result) \
F(BreakTo, Control* block) \ F(BreakTo, uint32_t depth) \
F(BrIf, const Value& cond, Control* block) \ F(BrIf, const Value& cond, uint32_t depth) \
F(BrTable, const BranchTableOperand<validate>& operand, const Value& key) \ F(BrTable, const BranchTableOperand<validate>& operand, const Value& key) \
F(Else, Control* if_block) \ F(Else, Control* if_block) \
F(LoadMem, ValueType type, MachineType mem_type, \ F(LoadMem, ValueType type, MachineType mem_type, \
...@@ -1375,7 +1375,7 @@ class WasmFullDecoder : public WasmDecoder<validate> { ...@@ -1375,7 +1375,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
BreakDepthOperand<validate> operand(this, this->pc_); BreakDepthOperand<validate> operand(this, this->pc_);
if (this->Validate(this->pc_, operand, control_.size()) && if (this->Validate(this->pc_, operand, control_.size()) &&
TypeCheckBreak(operand.depth)) { TypeCheckBreak(operand.depth)) {
interface_.BreakTo(this, control_at(operand.depth)); interface_.BreakTo(this, operand.depth);
} }
len = 1 + operand.length; len = 1 + operand.length;
EndControl(); EndControl();
...@@ -1386,7 +1386,7 @@ class WasmFullDecoder : public WasmDecoder<validate> { ...@@ -1386,7 +1386,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
auto cond = Pop(0, kWasmI32); auto cond = Pop(0, kWasmI32);
if (this->Validate(this->pc_, operand, control_.size()) && if (this->Validate(this->pc_, operand, control_.size()) &&
TypeCheckBreak(operand.depth)) { TypeCheckBreak(operand.depth)) {
interface_.BrIf(this, cond, control_at(operand.depth)); interface_.BrIf(this, cond, operand.depth);
} }
len = 1 + operand.length; len = 1 + operand.length;
break; break;
...@@ -1431,7 +1431,7 @@ class WasmFullDecoder : public WasmDecoder<validate> { ...@@ -1431,7 +1431,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
this->error(pos, "improper branch in br_table"); this->error(pos, "improper branch in br_table");
break; break;
} }
interface_.BreakTo(this, control_at(target)); interface_.BreakTo(this, target);
} }
len = 1 + iterator.length(); len = 1 + iterator.length();
EndControl(); EndControl();
......
...@@ -257,21 +257,22 @@ class WasmGraphBuildingInterface { ...@@ -257,21 +257,22 @@ class WasmGraphBuildingInterface {
ssa_env_->control = merge; ssa_env_->control = merge;
} }
void BreakTo(Decoder* decoder, Control* block) { void BreakTo(Decoder* decoder, uint32_t depth) {
if (block->is_loop()) { Control* target = decoder->control_at(depth);
Goto(decoder, ssa_env_, block->end_env); if (target->is_loop()) {
Goto(decoder, ssa_env_, target->end_env);
} else { } else {
MergeValuesInto(decoder, block); MergeValuesInto(decoder, target);
} }
} }
void BrIf(Decoder* decoder, const Value& cond, Control* block) { void BrIf(Decoder* decoder, const Value& cond, uint32_t depth) {
SsaEnv* fenv = ssa_env_; SsaEnv* fenv = ssa_env_;
SsaEnv* tenv = Split(decoder, fenv); SsaEnv* tenv = Split(decoder, fenv);
fenv->SetNotMerged(); fenv->SetNotMerged();
BUILD(BranchNoHint, cond.node, &tenv->control, &fenv->control); BUILD(BranchNoHint, cond.node, &tenv->control, &fenv->control);
ssa_env_ = tenv; ssa_env_ = tenv;
BreakTo(decoder, block); BreakTo(decoder, depth);
ssa_env_ = fenv; ssa_env_ = fenv;
} }
...@@ -290,7 +291,7 @@ class WasmGraphBuildingInterface { ...@@ -290,7 +291,7 @@ class WasmGraphBuildingInterface {
ssa_env_ = Split(decoder, copy); ssa_env_ = Split(decoder, copy);
ssa_env_->control = (i == operand.table_count) ? BUILD(IfDefault, sw) ssa_env_->control = (i == operand.table_count) ? BUILD(IfDefault, sw)
: BUILD(IfValue, i, sw); : BUILD(IfValue, i, sw);
BreakTo(decoder, decoder->control_at(target)); BreakTo(decoder, target);
} }
DCHECK(decoder->ok()); DCHECK(decoder->ok());
ssa_env_ = break_env; ssa_env_ = break_env;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment