From 029ca8ca6b6efaf16ae10352e5fafdc9591f0e4e Mon Sep 17 00:00:00 2001 From: "chunyang.dai" Date: Tue, 28 Jul 2015 01:37:21 -0700 Subject: [PATCH] X87: [stubs] Don't pass name to Load/StoreGlobalViaContext stubs. port 5dff4bdff06c0463db1e876af7541af2b715392c (r29886). original commit message: No need to pass the name explicitly to the stubs; the runtime can extract the name from the ScopeInfo (the extension of the ScriptContext) on-demand easily without any performance impact. BUG= Review URL: https://codereview.chromium.org/1259063004 Cr-Commit-Position: refs/heads/master@{#29892} --- src/full-codegen/x87/full-codegen-x87.cc | 8 ++------ src/x87/code-stubs-x87.cc | 16 +++++----------- src/x87/interface-descriptors-x87.cc | 2 -- src/x87/lithium-codegen-x87.cc | 12 ++++-------- src/x87/lithium-x87.cc | 7 ++----- src/x87/lithium-x87.h | 2 -- 6 files changed, 13 insertions(+), 34 deletions(-) diff --git a/src/full-codegen/x87/full-codegen-x87.cc b/src/full-codegen/x87/full-codegen-x87.cc index 8f40e05..40b7836 100644 --- a/src/full-codegen/x87/full-codegen-x87.cc +++ b/src/full-codegen/x87/full-codegen-x87.cc @@ -1337,13 +1337,11 @@ void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, int const depth = scope()->ContextChainLength(var->scope()); if (depth <= LoadGlobalViaContextStub::kMaximumDepth) { __ Move(LoadGlobalViaContextDescriptor::SlotRegister(), Immediate(slot)); - __ mov(LoadGlobalViaContextDescriptor::NameRegister(), var->name()); LoadGlobalViaContextStub stub(isolate(), depth); __ CallStub(&stub); } else { __ Push(Smi::FromInt(slot)); - __ Push(var->name()); - __ CallRuntime(Runtime::kLoadGlobalViaContext, 2); + __ CallRuntime(Runtime::kLoadGlobalViaContext, 1); } } else { @@ -2616,18 +2614,16 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, int const depth = scope()->ContextChainLength(var->scope()); if (depth <= StoreGlobalViaContextStub::kMaximumDepth) { __ Move(StoreGlobalViaContextDescriptor::SlotRegister(), Immediate(slot)); - __ mov(StoreGlobalViaContextDescriptor::NameRegister(), var->name()); DCHECK(StoreGlobalViaContextDescriptor::ValueRegister().is(eax)); StoreGlobalViaContextStub stub(isolate(), depth, language_mode()); __ CallStub(&stub); } else { __ Push(Smi::FromInt(slot)); - __ Push(var->name()); __ Push(eax); __ CallRuntime(is_strict(language_mode()) ? Runtime::kStoreGlobalViaContext_Strict : Runtime::kStoreGlobalViaContext_Sloppy, - 3); + 2); } } else if (var->mode() == LET && op != Token::INIT_LET) { diff --git a/src/x87/code-stubs-x87.cc b/src/x87/code-stubs-x87.cc index 8b11e02..e70f9c8 100644 --- a/src/x87/code-stubs-x87.cc +++ b/src/x87/code-stubs-x87.cc @@ -4799,7 +4799,6 @@ void InternalArrayConstructorStub::Generate(MacroAssembler* masm) { void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { Register context_reg = esi; Register slot_reg = ebx; - Register name_reg = ecx; Register result_reg = eax; Label slow_case; @@ -4823,25 +4822,23 @@ void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { __ SmiTag(slot_reg); __ Pop(result_reg); // Pop return address. __ Push(slot_reg); - __ Push(name_reg); __ Push(result_reg); // Push return address. - __ TailCallRuntime(Runtime::kLoadGlobalViaContext, 2, 1); + __ TailCallRuntime(Runtime::kLoadGlobalViaContext, 1, 1); } void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { Register context_reg = esi; Register slot_reg = ebx; - Register name_reg = ecx; Register value_reg = eax; Register cell_reg = edi; Register cell_details_reg = edx; + Register cell_value_reg = ecx; Label fast_heapobject_case, fast_smi_case, slow_case; if (FLAG_debug_code) { __ CompareRoot(value_reg, Heap::kTheHoleValueRootIndex); __ Check(not_equal, kUnexpectedValue); - __ AssertName(name_reg); } // Go up context chain to the script context. @@ -4883,7 +4880,8 @@ void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { // Check if PropertyCell value matches the new value (relevant for Constant, // ConstantType and Undefined cells). Label not_same_value; - __ cmp(value_reg, FieldOperand(cell_reg, PropertyCell::kValueOffset)); + __ mov(cell_value_reg, FieldOperand(cell_reg, PropertyCell::kValueOffset)); + __ cmp(cell_value_reg, value_reg); __ j(not_equal, ¬_same_value, FLAG_debug_code ? Label::kFar : Label::kNear); // Make sure the PropertyCell is not marked READ_ONLY. @@ -4925,9 +4923,6 @@ void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { // Now either both old and new values must be SMIs or both must be heap // objects with same map. Label value_is_heap_object; - // TODO(bmeurer): use ecx (name_reg) when name parameter is removed. - Register cell_value_reg = cell_details_reg; - __ mov(cell_value_reg, FieldOperand(cell_reg, PropertyCell::kValueOffset)); __ JumpIfNotSmi(value_reg, &value_is_heap_object, Label::kNear); __ JumpIfNotSmi(cell_value_reg, &slow_case, Label::kNear); // Old and new values are SMIs, no need for a write barrier here. @@ -4947,13 +4942,12 @@ void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { __ SmiTag(slot_reg); __ Pop(cell_reg); // Pop return address. __ Push(slot_reg); - __ Push(name_reg); __ Push(value_reg); __ Push(cell_reg); // Push return address. __ TailCallRuntime(is_strict(language_mode()) ? Runtime::kStoreGlobalViaContext_Strict : Runtime::kStoreGlobalViaContext_Sloppy, - 3, 1); + 2, 1); } diff --git a/src/x87/interface-descriptors-x87.cc b/src/x87/interface-descriptors-x87.cc index 0cbec94..dacbf10 100644 --- a/src/x87/interface-descriptors-x87.cc +++ b/src/x87/interface-descriptors-x87.cc @@ -38,11 +38,9 @@ const Register StoreTransitionDescriptor::MapRegister() { const Register LoadGlobalViaContextDescriptor::SlotRegister() { return ebx; } -const Register LoadGlobalViaContextDescriptor::NameRegister() { return ecx; } const Register StoreGlobalViaContextDescriptor::SlotRegister() { return ebx; } -const Register StoreGlobalViaContextDescriptor::NameRegister() { return ecx; } const Register StoreGlobalViaContextDescriptor::ValueRegister() { return eax; } diff --git a/src/x87/lithium-codegen-x87.cc b/src/x87/lithium-codegen-x87.cc index ee96cf6..bfb72b9 100644 --- a/src/x87/lithium-codegen-x87.cc +++ b/src/x87/lithium-codegen-x87.cc @@ -3153,15 +3153,13 @@ void LCodeGen::DoLoadGlobalViaContext(LLoadGlobalViaContext* instr) { int const slot = instr->slot_index(); int const depth = instr->depth(); if (depth <= LoadGlobalViaContextStub::kMaximumDepth) { - __ mov(LoadGlobalViaContextDescriptor::SlotRegister(), slot); - __ mov(LoadGlobalViaContextDescriptor::NameRegister(), instr->name()); + __ mov(LoadGlobalViaContextDescriptor::SlotRegister(), Immediate(slot)); Handle stub = CodeFactory::LoadGlobalViaContext(isolate(), depth).code(); CallCode(stub, RelocInfo::CODE_TARGET, instr); } else { __ Push(Smi::FromInt(slot)); - __ Push(instr->name()); - __ CallRuntime(Runtime::kLoadGlobalViaContext, 2); + __ CallRuntime(Runtime::kLoadGlobalViaContext, 1); } } @@ -4553,20 +4551,18 @@ void LCodeGen::DoStoreGlobalViaContext(LStoreGlobalViaContext* instr) { int const slot = instr->slot_index(); int const depth = instr->depth(); if (depth <= StoreGlobalViaContextStub::kMaximumDepth) { - __ mov(StoreGlobalViaContextDescriptor::SlotRegister(), slot); - __ mov(StoreGlobalViaContextDescriptor::NameRegister(), instr->name()); + __ mov(StoreGlobalViaContextDescriptor::SlotRegister(), Immediate(slot)); Handle stub = CodeFactory::StoreGlobalViaContext( isolate(), depth, instr->language_mode()) .code(); CallCode(stub, RelocInfo::CODE_TARGET, instr); } else { __ Push(Smi::FromInt(slot)); - __ Push(instr->name()); __ Push(StoreGlobalViaContextDescriptor::ValueRegister()); __ CallRuntime(is_strict(instr->language_mode()) ? Runtime::kStoreGlobalViaContext_Strict : Runtime::kStoreGlobalViaContext_Sloppy, - 3); + 2); } } diff --git a/src/x87/lithium-x87.cc b/src/x87/lithium-x87.cc index 2f5f15f..7a31cf6 100644 --- a/src/x87/lithium-x87.cc +++ b/src/x87/lithium-x87.cc @@ -391,8 +391,7 @@ LOperand* LPlatformChunk::GetNextSpillSlot(RegisterKind kind) { void LLoadGlobalViaContext::PrintDataTo(StringStream* stream) { - stream->Add(String::cast(*name())->ToCString().get()); - stream->Add(" depth:%d slot:%d", depth(), slot_index()); + stream->Add("depth:%d slot:%d", depth(), slot_index()); } @@ -415,10 +414,8 @@ void LStoreNamedGeneric::PrintDataTo(StringStream* stream) { void LStoreGlobalViaContext::PrintDataTo(StringStream* stream) { - stream->Add(String::cast(*name())->ToCString().get()); - stream->Add(" <- "); + stream->Add("depth:%d slot:%d <- ", depth(), slot_index()); value()->PrintTo(stream); - stream->Add(" depth:%d slot:%d", depth(), slot_index()); } diff --git a/src/x87/lithium-x87.h b/src/x87/lithium-x87.h index b8f881d..020ec53 100644 --- a/src/x87/lithium-x87.h +++ b/src/x87/lithium-x87.h @@ -1738,7 +1738,6 @@ class LLoadGlobalViaContext final : public LTemplateInstruction<1, 1, 1> { LOperand* context() { return inputs_[0]; } - Handle name() const { return hydrogen()->name(); } int depth() const { return hydrogen()->depth(); } int slot_index() const { return hydrogen()->slot_index(); } }; @@ -2248,7 +2247,6 @@ class LStoreGlobalViaContext final : public LTemplateInstruction<0, 2, 0> { void PrintDataTo(StringStream* stream) override; - Handle name() const { return hydrogen()->name(); } int depth() { return hydrogen()->depth(); } int slot_index() { return hydrogen()->slot_index(); } LanguageMode language_mode() { return hydrogen()->language_mode(); } -- 2.7.4