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); |