X87: Clean up and update const / var

port r22379

original commit message:
This CL simplifies var / const by ensuring the behavior is consistent in itself,
and with regular JS semantics; between regular var/const and eval-ed var/const.

Legacy const is changed so that a declaration declares a configurable, but non-writable, slot,
 and the initializer reconfigures it (when possible) to non-configurable non-writable. This
 avoids the need for "the hole" as marker value in JSContextExtensionObjects and GlobalObjects.
Undefined is used instead.

BUG=
R=weiliang.lin@intel.com

Review URL: https://codereview.chromium.org/397573002

Patch from Chunyang Dai <chunyang.dai@intel.com>.

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22395 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 9180b1a3
...@@ -801,7 +801,7 @@ void FullCodeGenerator::VisitVariableDeclaration( ...@@ -801,7 +801,7 @@ void FullCodeGenerator::VisitVariableDeclaration(
} else { } else {
__ push(Immediate(Smi::FromInt(0))); // Indicates no initial value. __ push(Immediate(Smi::FromInt(0))); // Indicates no initial value.
} }
__ CallRuntime(Runtime::kDeclareContextSlot, 4); __ CallRuntime(Runtime::kDeclareLookupSlot, 4);
break; break;
} }
} }
...@@ -853,7 +853,7 @@ void FullCodeGenerator::VisitFunctionDeclaration( ...@@ -853,7 +853,7 @@ void FullCodeGenerator::VisitFunctionDeclaration(
__ push(Immediate(variable->name())); __ push(Immediate(variable->name()));
__ push(Immediate(Smi::FromInt(NONE))); __ push(Immediate(Smi::FromInt(NONE)));
VisitForStackValue(declaration->fun()); VisitForStackValue(declaration->fun());
__ CallRuntime(Runtime::kDeclareContextSlot, 4); __ CallRuntime(Runtime::kDeclareLookupSlot, 4);
break; break;
} }
} }
...@@ -2379,16 +2379,6 @@ void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot( ...@@ -2379,16 +2379,6 @@ void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot(
} }
void FullCodeGenerator::EmitCallStoreContextSlot(
Handle<String> name, StrictMode strict_mode) {
__ push(eax); // Value.
__ push(esi); // Context.
__ push(Immediate(name));
__ push(Immediate(Smi::FromInt(strict_mode)));
__ CallRuntime(Runtime::kStoreContextSlot, 4);
}
void FullCodeGenerator::EmitVariableAssignment(Variable* var, void FullCodeGenerator::EmitVariableAssignment(Variable* var,
Token::Value op) { Token::Value op) {
if (var->IsUnallocated()) { if (var->IsUnallocated()) {
...@@ -2404,7 +2394,7 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, ...@@ -2404,7 +2394,7 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var,
__ push(eax); __ push(eax);
__ push(esi); __ push(esi);
__ push(Immediate(var->name())); __ push(Immediate(var->name()));
__ CallRuntime(Runtime::kInitializeConstContextSlot, 3); __ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot, 3);
} else { } else {
ASSERT(var->IsStackLocal() || var->IsContextSlot()); ASSERT(var->IsStackLocal() || var->IsContextSlot());
Label skip; Label skip;
...@@ -2418,9 +2408,7 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, ...@@ -2418,9 +2408,7 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var,
} else if (var->mode() == LET && op != Token::INIT_LET) { } else if (var->mode() == LET && op != Token::INIT_LET) {
// Non-initializing assignment to let variable needs a write barrier. // Non-initializing assignment to let variable needs a write barrier.
if (var->IsLookupSlot()) { ASSERT(!var->IsLookupSlot());
EmitCallStoreContextSlot(var->name(), strict_mode());
} else {
ASSERT(var->IsStackAllocated() || var->IsContextSlot()); ASSERT(var->IsStackAllocated() || var->IsContextSlot());
Label assign; Label assign;
MemOperand location = VarOperand(var, ecx); MemOperand location = VarOperand(var, ecx);
...@@ -2431,14 +2419,18 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, ...@@ -2431,14 +2419,18 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var,
__ CallRuntime(Runtime::kThrowReferenceError, 1); __ CallRuntime(Runtime::kThrowReferenceError, 1);
__ bind(&assign); __ bind(&assign);
EmitStoreToStackLocalOrContextSlot(var, location); EmitStoreToStackLocalOrContextSlot(var, location);
}
} else if (!var->is_const_mode() || op == Token::INIT_CONST) { } else if (!var->is_const_mode() || op == Token::INIT_CONST) {
// Assignment to var or initializing assignment to let/const
// in harmony mode.
if (var->IsLookupSlot()) { if (var->IsLookupSlot()) {
EmitCallStoreContextSlot(var->name(), strict_mode()); // Assignment to var.
__ push(eax); // Value.
__ push(esi); // Context.
__ push(Immediate(var->name()));
__ push(Immediate(Smi::FromInt(strict_mode())));
__ CallRuntime(Runtime::kStoreLookupSlot, 4);
} else { } else {
// Assignment to var or initializing assignment to let/const in harmony
// mode.
ASSERT(var->IsStackAllocated() || var->IsContextSlot()); ASSERT(var->IsStackAllocated() || var->IsContextSlot());
MemOperand location = VarOperand(var, ecx); MemOperand location = VarOperand(var, ecx);
if (generate_debug_code_ && op == Token::INIT_LET) { if (generate_debug_code_ && op == Token::INIT_LET) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment