Index: src/wasm/ast-decoder.cc |
diff --git a/src/wasm/ast-decoder.cc b/src/wasm/ast-decoder.cc |
index b1d29d8654099c5958965094bf70d681eb8ca7a6..923b1018e4702689d97ab529889ab41956b4198b 100644 |
--- a/src/wasm/ast-decoder.cc |
+++ b/src/wasm/ast-decoder.cc |
@@ -335,12 +335,18 @@ class WasmDecoder : public Decoder { |
BranchTableOperand operand(this, pc); |
return 1 + operand.length; |
} |
+ case kExprI32Const: { |
binji
2016/03/11 18:10:03
oops, sorry about this. Didn't notice!
|
+ ImmI32Operand operand(this, pc); |
+ return 1 + operand.length; |
+ } |
+ case kExprI64Const: { |
+ ImmI64Operand operand(this, pc); |
+ return 1 + operand.length; |
+ } |
case kExprI8Const: |
return 2; |
- case kExprI32Const: |
case kExprF32Const: |
return 5; |
- case kExprI64Const: |
case kExprF64Const: |
return 9; |
@@ -664,7 +670,7 @@ class SR_WasmDecoder : public WasmDecoder { |
PushBlock(break_env); |
SsaEnv* cont_env = Steal(break_env); |
// The continue environment is the inner environment. |
- PrepareForLoop(cont_env); |
+ PrepareForLoop(pc_, cont_env); |
SetEnv("loop:start", Split(cont_env)); |
if (ssa_env_->go()) ssa_env_->state = SsaEnv::kReached; |
PushBlock(cont_env); |
@@ -1463,28 +1469,18 @@ class SR_WasmDecoder : public WasmDecoder { |
return tnode; |
} |
- void BuildInfiniteLoop() { |
- if (ssa_env_->go()) { |
- PrepareForLoop(ssa_env_); |
- SsaEnv* cont_env = ssa_env_; |
- ssa_env_ = Split(ssa_env_); |
- ssa_env_->state = SsaEnv::kReached; |
- Goto(ssa_env_, cont_env); |
- } |
- } |
- |
- void PrepareForLoop(SsaEnv* env) { |
- if (env->go()) { |
- env->state = SsaEnv::kMerged; |
- if (builder_) { |
- env->control = builder_->Loop(env->control); |
- env->effect = builder_->EffectPhi(1, &env->effect, env->control); |
- builder_->Terminate(env->effect, env->control); |
- for (int i = EnvironmentCount() - 1; i >= 0; i--) { |
- env->locals[i] = builder_->Phi(local_type_vec_[i], 1, &env->locals[i], |
- env->control); |
- } |
- } |
+ void PrepareForLoop(const byte* pc, SsaEnv* env) { |
Mircea Trofin
2016/03/11 17:15:41
Looks like the change below is aesthetic only. Wha
titzer
2016/03/11 17:17:35
Ah, an artifact of splitting this CL off. The next
|
+ if (!env->go()) return; |
+ env->state = SsaEnv::kMerged; |
+ if (!builder_) return; |
+ |
+ env->control = builder_->Loop(env->control); |
+ env->effect = builder_->EffectPhi(1, &env->effect, env->control); |
+ builder_->Terminate(env->effect, env->control); |
+ // Conservatively introduce phis for all local variables. |
+ for (int i = EnvironmentCount() - 1; i >= 0; i--) { |
+ env->locals[i] = |
+ builder_->Phi(local_type_vec_[i], 1, &env->locals[i], env->control); |
} |
} |
@@ -1603,6 +1599,9 @@ class SR_WasmDecoder : public WasmDecoder { |
length = OpcodeLength(pc); |
} |
+ TRACE("loop-assign module+%-6d %s func+%d: 0x%02x %s (len=%d)\n", |
+ baserel(pc), indentation(), startrel(pc), opcode, |
+ WasmOpcodes::OpcodeName(opcode), length); |
pc += length; |
arity_stack.push_back(arity); |
while (arity_stack.back() == 0) { |