From 23887bf978b8298be203bc720971be364de85823 Mon Sep 17 00:00:00 2001 From: "weiliang.lin@intel.com" Date: Tue, 15 Jul 2014 08:37:37 +0000 Subject: [PATCH] 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 . git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22395 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/x87/full-codegen-x87.cc | 52 +++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/src/x87/full-codegen-x87.cc b/src/x87/full-codegen-x87.cc index 2efe36c..debff6d 100644 --- a/src/x87/full-codegen-x87.cc +++ b/src/x87/full-codegen-x87.cc @@ -801,7 +801,7 @@ void FullCodeGenerator::VisitVariableDeclaration( } else { __ push(Immediate(Smi::FromInt(0))); // Indicates no initial value. } - __ CallRuntime(Runtime::kDeclareContextSlot, 4); + __ CallRuntime(Runtime::kDeclareLookupSlot, 4); break; } } @@ -853,7 +853,7 @@ void FullCodeGenerator::VisitFunctionDeclaration( __ push(Immediate(variable->name())); __ push(Immediate(Smi::FromInt(NONE))); VisitForStackValue(declaration->fun()); - __ CallRuntime(Runtime::kDeclareContextSlot, 4); + __ CallRuntime(Runtime::kDeclareLookupSlot, 4); break; } } @@ -2379,16 +2379,6 @@ void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot( } -void FullCodeGenerator::EmitCallStoreContextSlot( - Handle 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, Token::Value op) { if (var->IsUnallocated()) { @@ -2404,7 +2394,7 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, __ push(eax); __ push(esi); __ push(Immediate(var->name())); - __ CallRuntime(Runtime::kInitializeConstContextSlot, 3); + __ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot, 3); } else { ASSERT(var->IsStackLocal() || var->IsContextSlot()); Label skip; @@ -2418,27 +2408,29 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, } else if (var->mode() == LET && op != Token::INIT_LET) { // Non-initializing assignment to let variable needs a write barrier. - if (var->IsLookupSlot()) { - EmitCallStoreContextSlot(var->name(), strict_mode()); - } else { - ASSERT(var->IsStackAllocated() || var->IsContextSlot()); - Label assign; - MemOperand location = VarOperand(var, ecx); - __ mov(edx, location); - __ cmp(edx, isolate()->factory()->the_hole_value()); - __ j(not_equal, &assign, Label::kNear); - __ push(Immediate(var->name())); - __ CallRuntime(Runtime::kThrowReferenceError, 1); - __ bind(&assign); - EmitStoreToStackLocalOrContextSlot(var, location); - } + ASSERT(!var->IsLookupSlot()); + ASSERT(var->IsStackAllocated() || var->IsContextSlot()); + Label assign; + MemOperand location = VarOperand(var, ecx); + __ mov(edx, location); + __ cmp(edx, isolate()->factory()->the_hole_value()); + __ j(not_equal, &assign, Label::kNear); + __ push(Immediate(var->name())); + __ CallRuntime(Runtime::kThrowReferenceError, 1); + __ bind(&assign); + EmitStoreToStackLocalOrContextSlot(var, location); } 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()) { - 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 { + // Assignment to var or initializing assignment to let/const in harmony + // mode. ASSERT(var->IsStackAllocated() || var->IsContextSlot()); MemOperand location = VarOperand(var, ecx); if (generate_debug_code_ && op == Token::INIT_LET) { -- 2.7.4