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

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

Issue 1895013002: [wasm] Introduce Encoder::GetLocal and Encoder::SetLocal utilities. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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/wasm/asm-wasm-builder.cc
diff --git a/src/wasm/asm-wasm-builder.cc b/src/wasm/asm-wasm-builder.cc
index f7b7998e54c77636bab9cd6c049d4ba8e2fd850c..7d166f0f3e40521220ad60f4b6ac98bcdbf0514b 100644
--- a/src/wasm/asm-wasm-builder.cc
+++ b/src/wasm/asm-wasm-builder.cc
@@ -510,30 +510,28 @@ class AsmWasmBuilderImpl : public AstVisitor {
void VisitVariableProxy(VariableProxy* expr) {
if (in_function_) {
Variable* var = expr->var();
+ LocalType var_type = TypeOf(expr);
if (is_set_op_) {
+ is_set_op_ = false;
if (var->IsContextSlot()) {
- current_function_builder_->Emit(kExprStoreGlobal);
+ return current_function_builder_->EmitWithVarInt(
+ kExprStoreGlobal, LookupOrInsertGlobal(var, var_type));
} else {
- current_function_builder_->Emit(kExprSetLocal);
+ return current_function_builder_->EmitSetLocal(
+ LookupOrInsertLocal(var, var_type));
}
- is_set_op_ = false;
} else {
if (VisitStdlibConstant(var)) {
return;
}
if (var->IsContextSlot()) {
- current_function_builder_->Emit(kExprLoadGlobal);
+ return current_function_builder_->EmitWithVarInt(
+ kExprLoadGlobal, LookupOrInsertGlobal(var, var_type));
} else {
- current_function_builder_->Emit(kExprGetLocal);
+ return current_function_builder_->EmitGetLocal(
+ LookupOrInsertLocal(var, var_type));
}
}
- LocalType var_type = TypeOf(expr);
- DCHECK_NE(kAstStmt, var_type);
- if (var->IsContextSlot()) {
- AddLeb128(LookupOrInsertGlobal(var, var_type), false);
- } else {
- AddLeb128(LookupOrInsertLocal(var, var_type), true);
- }
}
}
@@ -1387,19 +1385,6 @@ class AsmWasmBuilderImpl : public AstVisitor {
}
}
- void AddLeb128(uint32_t index, bool is_local) {
- std::vector<uint8_t> index_vec = UnsignedLEB128From(index);
- if (is_local) {
- uint32_t pos_of_index[1] = {0};
- current_function_builder_->EmitCode(
- &index_vec[0], static_cast<uint32_t>(index_vec.size()), pos_of_index,
- 1);
- } else {
- current_function_builder_->EmitCode(
- &index_vec[0], static_cast<uint32_t>(index_vec.size()));
- }
- }
-
void VisitCompareOperation(CompareOperation* expr) {
switch (expr->op()) {
BINOP_CASE(Token::EQ, Eq, NON_SIGNED_BINOP, false);
« 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