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

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

Issue 2280063002: [asm.js] (Re)use temporaries in asm->wasm conversion. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: [asm.js] (Re)use temporaries in asm->wasm conversion. Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/wasm/encoder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/asmjs/asm-wasm-builder.cc
diff --git a/src/asmjs/asm-wasm-builder.cc b/src/asmjs/asm-wasm-builder.cc
index 6419459307be958b5d32e80a6471ec01fb56dc2a..dd17621d83c9df9efb30916145f2e1360b7c0efb 100644
--- a/src/asmjs/asm-wasm-builder.cc
+++ b/src/asmjs/asm-wasm-builder.cc
@@ -1099,11 +1099,11 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
}
case AsmTyper::kMathAbs: {
if (call_type == kAstI32) {
- uint32_t tmp = current_function_builder_->AddLocal(kAstI32);
+ WasmTemporary tmp(current_function_builder_, kAstI32);
// if set_local(tmp, x) < 0
Visit(call->arguments()->at(0));
- current_function_builder_->EmitSetLocal(tmp);
+ current_function_builder_->EmitSetLocal(tmp.index());
byte code[] = {WASM_I8(0)};
current_function_builder_->EmitCode(code, sizeof(code));
current_function_builder_->Emit(kExprI32LtS);
@@ -1111,12 +1111,12 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
// then (0 - tmp)
current_function_builder_->EmitCode(code, sizeof(code));
- current_function_builder_->EmitGetLocal(tmp);
+ current_function_builder_->EmitGetLocal(tmp.index());
current_function_builder_->Emit(kExprI32Sub);
// else tmp
current_function_builder_->Emit(kExprElse);
- current_function_builder_->EmitGetLocal(tmp);
+ current_function_builder_->EmitGetLocal(tmp.index());
// end
current_function_builder_->Emit(kExprEnd);
@@ -1134,25 +1134,25 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
case AsmTyper::kMathMin: {
// TODO(bradnelson): Change wasm to match Math.min in asm.js mode.
if (call_type == kAstI32) {
- uint32_t tmp_x = current_function_builder_->AddLocal(kAstI32);
- uint32_t tmp_y = current_function_builder_->AddLocal(kAstI32);
+ WasmTemporary tmp_x(current_function_builder_, kAstI32);
+ WasmTemporary tmp_y(current_function_builder_, kAstI32);
// if set_local(tmp_x, x) < set_local(tmp_y, y)
Visit(call->arguments()->at(0));
- current_function_builder_->EmitSetLocal(tmp_x);
+ current_function_builder_->EmitSetLocal(tmp_x.index());
Visit(call->arguments()->at(1));
- current_function_builder_->EmitSetLocal(tmp_y);
+ current_function_builder_->EmitSetLocal(tmp_y.index());
current_function_builder_->Emit(kExprI32LeS);
current_function_builder_->Emit(kExprIf);
// then tmp_x
- current_function_builder_->EmitGetLocal(tmp_x);
+ current_function_builder_->EmitGetLocal(tmp_x.index());
// else tmp_y
current_function_builder_->Emit(kExprElse);
- current_function_builder_->EmitGetLocal(tmp_y);
+ current_function_builder_->EmitGetLocal(tmp_y.index());
current_function_builder_->Emit(kExprEnd);
} else if (call_type == kAstF32) {
@@ -1169,26 +1169,26 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
case AsmTyper::kMathMax: {
// TODO(bradnelson): Change wasm to match Math.max in asm.js mode.
if (call_type == kAstI32) {
- uint32_t tmp_x = current_function_builder_->AddLocal(kAstI32);
- uint32_t tmp_y = current_function_builder_->AddLocal(kAstI32);
+ WasmTemporary tmp_x(current_function_builder_, kAstI32);
+ WasmTemporary tmp_y(current_function_builder_, kAstI32);
// if set_local(tmp_x, x) < set_local(tmp_y, y)
Visit(call->arguments()->at(0));
- current_function_builder_->EmitSetLocal(tmp_x);
+ current_function_builder_->EmitSetLocal(tmp_x.index());
Visit(call->arguments()->at(1));
- current_function_builder_->EmitSetLocal(tmp_y);
+ current_function_builder_->EmitSetLocal(tmp_y.index());
current_function_builder_->Emit(kExprI32LeS);
current_function_builder_->Emit(kExprIf);
// then tmp_y
- current_function_builder_->EmitGetLocal(tmp_y);
+ current_function_builder_->EmitGetLocal(tmp_y.index());
// else tmp_x
current_function_builder_->Emit(kExprElse);
- current_function_builder_->EmitGetLocal(tmp_x);
+ current_function_builder_->EmitGetLocal(tmp_x.index());
current_function_builder_->Emit(kExprEnd);
} else if (call_type == kAstF32) {
« no previous file with comments | « no previous file | src/wasm/encoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698