Index: src/wasm/asm-wasm-builder.cc |
diff --git a/src/wasm/asm-wasm-builder.cc b/src/wasm/asm-wasm-builder.cc |
index 88049b8520bc7f07a32dc3761ebbd1ce054d94a3..a0cabb24d3b4fe24c536ab5251aa8805268dc716 100644 |
--- a/src/wasm/asm-wasm-builder.cc |
+++ b/src/wasm/asm-wasm-builder.cc |
@@ -226,16 +226,39 @@ class AsmWasmBuilderImpl : public AstVisitor { |
} |
void VisitForStatement(ForStatement* stmt) { |
+ DCHECK(in_function_); |
if (stmt->init() != NULL) { |
+ block_size_++; |
RECURSE(Visit(stmt->init())); |
} |
+ current_function_builder_->Emit(kExprLoop); |
+ uint32_t index = current_function_builder_->EmitEditableImmediate(0); |
+ int prev_block_size = block_size_; |
+ block_size_ = 0; |
+ breakable_blocks_.push_back( |
+ std::make_pair(stmt->AsBreakableStatement(), true)); |
if (stmt->cond() != NULL) { |
+ block_size_++; |
+ current_function_builder_->Emit(kExprIf); |
+ current_function_builder_->Emit(kExprBoolNot); |
RECURSE(Visit(stmt->cond())); |
+ current_function_builder_->EmitWithU8(kExprBr, 1); |
+ current_function_builder_->Emit(kExprNop); |
+ } |
+ if (stmt->body() != NULL) { |
+ block_size_++; |
+ RECURSE(Visit(stmt->body())); |
} |
if (stmt->next() != NULL) { |
+ block_size_++; |
RECURSE(Visit(stmt->next())); |
} |
- RECURSE(Visit(stmt->body())); |
+ block_size_++; |
+ current_function_builder_->EmitWithU8(kExprBr, 0); |
+ current_function_builder_->Emit(kExprNop); |
+ current_function_builder_->EditImmediate(index, block_size_); |
+ block_size_ = prev_block_size; |
+ breakable_blocks_.pop_back(); |
} |
void VisitForInStatement(ForInStatement* stmt) { |
bradnelson
2015/12/15 03:07:04
Unrelated to this CL, but since for..in, for..of,
|