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

Unified Diff: src/wasm/asm-wasm-builder.cc

Issue 1523843003: Add for loop to asm-to-wasm (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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 | test/mjsunit/wasm/asm-wasm.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « no previous file | test/mjsunit/wasm/asm-wasm.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698