Index: src/full-codegen/mips/full-codegen-mips.cc |
diff --git a/src/full-codegen/mips/full-codegen-mips.cc b/src/full-codegen/mips/full-codegen-mips.cc |
index 8d780a24177b430e278cf444807899636d4cf595..917eb6f00e5009093b7a0adbede05aaae06412a5 100644 |
--- a/src/full-codegen/mips/full-codegen-mips.cc |
+++ b/src/full-codegen/mips/full-codegen-mips.cc |
@@ -755,13 +755,8 @@ void FullCodeGenerator::EmitDebugCheckDeclarationContext(Variable* variable) { |
void FullCodeGenerator::VisitVariableDeclaration( |
VariableDeclaration* declaration) { |
- // If it was not possible to allocate the variable at compile time, we |
- // need to "declare" it at runtime to make sure it actually exists in the |
- // local context. |
VariableProxy* proxy = declaration->proxy(); |
- VariableMode mode = declaration->mode(); |
Variable* variable = proxy->var(); |
- bool hole_init = mode == LET || mode == CONST; |
switch (variable->location()) { |
case VariableLocation::GLOBAL: |
case VariableLocation::UNALLOCATED: { |
@@ -774,7 +769,7 @@ void FullCodeGenerator::VisitVariableDeclaration( |
} |
case VariableLocation::PARAMETER: |
case VariableLocation::LOCAL: |
- if (hole_init) { |
+ if (variable->binding_needs_init()) { |
Comment cmnt(masm_, "[ VariableDeclaration"); |
__ LoadRoot(t0, Heap::kTheHoleValueRootIndex); |
__ sw(t0, StackOperand(variable)); |
@@ -782,7 +777,7 @@ void FullCodeGenerator::VisitVariableDeclaration( |
break; |
case VariableLocation::CONTEXT: |
- if (hole_init) { |
+ if (variable->binding_needs_init()) { |
Comment cmnt(masm_, "[ VariableDeclaration"); |
EmitDebugCheckDeclarationContext(variable); |
__ LoadRoot(at, Heap::kTheHoleValueRootIndex); |
@@ -794,8 +789,8 @@ void FullCodeGenerator::VisitVariableDeclaration( |
case VariableLocation::LOOKUP: { |
Comment cmnt(masm_, "[ VariableDeclaration"); |
- DCHECK_EQ(VAR, mode); |
- DCHECK(!hole_init); |
+ DCHECK_EQ(VAR, variable->mode()); |
+ DCHECK(!variable->binding_needs_init()); |
__ li(a2, Operand(variable->name())); |
__ Push(a2); |
__ CallRuntime(Runtime::kDeclareEvalVar); |
@@ -1265,15 +1260,16 @@ void FullCodeGenerator::EmitDynamicLookupFastCase(VariableProxy* proxy, |
} else if (var->mode() == DYNAMIC_LOCAL) { |
Variable* local = var->local_if_not_shadowed(); |
__ lw(v0, ContextSlotOperandCheckExtensions(local, slow)); |
- if (local->mode() == LET || local->mode() == CONST) { |
+ if (local->binding_needs_init()) { |
__ LoadRoot(at, Heap::kTheHoleValueRootIndex); |
__ subu(at, v0, at); // Sub as compare: at == 0 on eq. |
__ Branch(done, ne, at, Operand(zero_reg)); |
__ li(a0, Operand(var->name())); |
__ push(a0); |
__ CallRuntime(Runtime::kThrowReferenceError); |
+ } else { |
+ __ Branch(done); |
} |
- __ Branch(done); |
} |
} |
@@ -1316,20 +1312,17 @@ void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy, |
Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" |
: "[ Stack variable"); |
if (NeedsHoleCheckForLoad(proxy)) { |
- // Let and const need a read barrier. |
+ // Throw a reference error when using an uninitialized let/const |
+ // binding in harmony mode. |
+ Label done; |
GetVar(v0, var); |
__ LoadRoot(at, Heap::kTheHoleValueRootIndex); |
__ subu(at, v0, at); // Sub as compare: at == 0 on eq. |
- if (var->mode() == LET || var->mode() == CONST) { |
- // Throw a reference error when using an uninitialized let/const |
- // binding in harmony mode. |
- Label done; |
- __ Branch(&done, ne, at, Operand(zero_reg)); |
- __ li(a0, Operand(var->name())); |
- __ push(a0); |
- __ CallRuntime(Runtime::kThrowReferenceError); |
- __ bind(&done); |
- } |
+ __ Branch(&done, ne, at, Operand(zero_reg)); |
+ __ li(a0, Operand(var->name())); |
+ __ push(a0); |
+ __ CallRuntime(Runtime::kThrowReferenceError); |
+ __ bind(&done); |
context()->Plug(v0); |
break; |
} |
@@ -2169,37 +2162,26 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, |
EmitLoadStoreICSlot(slot); |
CallStoreIC(); |
- } else if (var->mode() == LET && op != Token::INIT) { |
- // Non-initializing assignment to let variable needs a write barrier. |
- DCHECK(!var->IsLookupSlot()); |
- DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
- Label assign; |
- MemOperand location = VarOperand(var, a1); |
- __ lw(a3, location); |
- __ LoadRoot(t0, Heap::kTheHoleValueRootIndex); |
- __ Branch(&assign, ne, a3, Operand(t0)); |
- __ li(a3, Operand(var->name())); |
- __ push(a3); |
- __ CallRuntime(Runtime::kThrowReferenceError); |
- // Perform the assignment. |
- __ bind(&assign); |
- EmitStoreToStackLocalOrContextSlot(var, location); |
- |
- } else if (var->mode() == CONST && op != Token::INIT) { |
- // Assignment to const variable needs a write barrier. |
+ } else if (IsLexicalVariableMode(var->mode()) && op != Token::INIT) { |
DCHECK(!var->IsLookupSlot()); |
DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
- Label const_error; |
MemOperand location = VarOperand(var, a1); |
- __ lw(a3, location); |
- __ LoadRoot(at, Heap::kTheHoleValueRootIndex); |
- __ Branch(&const_error, ne, a3, Operand(at)); |
- __ li(a3, Operand(var->name())); |
- __ push(a3); |
- __ CallRuntime(Runtime::kThrowReferenceError); |
- __ bind(&const_error); |
- __ CallRuntime(Runtime::kThrowConstAssignError); |
- |
+ // Perform an initialization check for lexically declared variables. |
+ if (var->binding_needs_init()) { |
+ Label assign; |
+ __ lw(a3, location); |
+ __ LoadRoot(t0, Heap::kTheHoleValueRootIndex); |
+ __ Branch(&assign, ne, a3, Operand(t0)); |
+ __ li(a3, Operand(var->name())); |
+ __ push(a3); |
+ __ CallRuntime(Runtime::kThrowReferenceError); |
+ __ bind(&assign); |
+ } |
+ if (var->mode() == CONST) { |
+ __ CallRuntime(Runtime::kThrowConstAssignError); |
+ } else { |
+ EmitStoreToStackLocalOrContextSlot(var, location); |
+ } |
} else if (var->is_this() && var->mode() == CONST && op == Token::INIT) { |
// Initializing assignment to const {this} needs a write barrier. |
DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |