From: bmeurer Date: Tue, 28 Jul 2015 06:04:04 +0000 (-0700) Subject: [stubs] Don't pass name to Load/StoreGlobalViaContext stubs. X-Git-Tag: upstream/4.7.83~1154 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5dff4bdff06c0463db1e876af7541af2b715392c;p=platform%2Fupstream%2Fv8.git [stubs] Don't pass name to Load/StoreGlobalViaContext stubs. 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. Review URL: https://codereview.chromium.org/1259963002 Cr-Commit-Position: refs/heads/master@{#29886} --- diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc index e201134..cc090d5 100644 --- a/src/arm/code-stubs-arm.cc +++ b/src/arm/code-stubs-arm.cc @@ -5061,8 +5061,6 @@ void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { Register context = cp; Register result = r0; Register slot = r2; - Register name = r3; - Label slow_case; // Go up the context chain to the script context. for (int i = 0; i < depth(); ++i) { @@ -5080,18 +5078,15 @@ void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { __ Ret(ne); // Fallback to runtime. - __ bind(&slow_case); __ SmiTag(slot); __ push(slot); - __ push(name); - __ TailCallRuntime(Runtime::kLoadGlobalViaContext, 2, 1); + __ TailCallRuntime(Runtime::kLoadGlobalViaContext, 1, 1); } void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { Register value = r0; Register slot = r2; - Register name = r3; Register cell = r1; Register cell_details = r4; @@ -5107,7 +5102,6 @@ void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { if (FLAG_debug_code) { __ CompareRoot(value, Heap::kTheHoleValueRootIndex); __ Check(ne, kUnexpectedValue); - __ AssertName(name); } // Go up the context chain to the script context. @@ -5207,13 +5201,11 @@ void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { // Fallback to runtime. __ bind(&slow_case); __ SmiTag(slot); - __ push(slot); - __ push(name); - __ push(value); + __ Push(slot, value); __ TailCallRuntime(is_strict(language_mode()) ? Runtime::kStoreGlobalViaContext_Strict : Runtime::kStoreGlobalViaContext_Sloppy, - 3, 1); + 2, 1); } diff --git a/src/arm/interface-descriptors-arm.cc b/src/arm/interface-descriptors-arm.cc index 5e98b98..e54dd5c 100644 --- a/src/arm/interface-descriptors-arm.cc +++ b/src/arm/interface-descriptors-arm.cc @@ -37,11 +37,9 @@ const Register StoreTransitionDescriptor::MapRegister() { return r3; } const Register LoadGlobalViaContextDescriptor::SlotRegister() { return r2; } -const Register LoadGlobalViaContextDescriptor::NameRegister() { return r3; } const Register StoreGlobalViaContextDescriptor::SlotRegister() { return r2; } -const Register StoreGlobalViaContextDescriptor::NameRegister() { return r3; } const Register StoreGlobalViaContextDescriptor::ValueRegister() { return r0; } diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc index ad34013..946efed 100644 --- a/src/arm/lithium-arm.cc +++ b/src/arm/lithium-arm.cc @@ -331,8 +331,7 @@ void LAccessArgumentsAt::PrintDataTo(StringStream* stream) { 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()); } @@ -355,10 +354,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/arm/lithium-arm.h b/src/arm/lithium-arm.h index 4eeca33..0f999c5 100644 --- a/src/arm/lithium-arm.h +++ b/src/arm/lithium-arm.h @@ -1717,7 +1717,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(); } }; @@ -2240,7 +2239,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(); } diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index 97881ba..39df587 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -2991,15 +2991,12 @@ void LCodeGen::DoLoadGlobalViaContext(LLoadGlobalViaContext* instr) { int const depth = instr->depth(); if (depth <= LoadGlobalViaContextStub::kMaximumDepth) { __ mov(LoadGlobalViaContextDescriptor::SlotRegister(), Operand(slot)); - __ mov(LoadGlobalViaContextDescriptor::NameRegister(), - Operand(instr->name())); 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); } } @@ -4257,20 +4254,17 @@ void LCodeGen::DoStoreGlobalViaContext(LStoreGlobalViaContext* instr) { int const depth = instr->depth(); if (depth <= StoreGlobalViaContextStub::kMaximumDepth) { __ mov(StoreGlobalViaContextDescriptor::SlotRegister(), Operand(slot)); - __ mov(StoreGlobalViaContextDescriptor::NameRegister(), - Operand(instr->name())); 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/arm64/code-stubs-arm64.cc b/src/arm64/code-stubs-arm64.cc index d8b1532..d349383 100644 --- a/src/arm64/code-stubs-arm64.cc +++ b/src/arm64/code-stubs-arm64.cc @@ -5498,7 +5498,6 @@ void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { Register context = cp; Register result = x0; Register slot = x2; - Register name = x3; Label slow_case; // Go up the context chain to the script context. @@ -5519,8 +5518,8 @@ void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { // Fallback to runtime. __ Bind(&slow_case); __ SmiTag(slot); - __ Push(slot, name); - __ TailCallRuntime(Runtime::kLoadGlobalViaContext, 2, 1); + __ Push(slot); + __ TailCallRuntime(Runtime::kLoadGlobalViaContext, 1, 1); } @@ -5528,7 +5527,6 @@ void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { Register context = cp; Register value = x0; Register slot = x2; - Register name = x3; Register context_temp = x10; Register cell = x10; Register cell_details = x11; @@ -5540,7 +5538,6 @@ void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { if (FLAG_debug_code) { __ CompareRoot(value, Heap::kTheHoleValueRootIndex); __ Check(ne, kUnexpectedValue); - __ AssertName(name); } // Go up the context chain to the script context. @@ -5639,11 +5636,11 @@ void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { // Fall back to the runtime. __ Bind(&slow_case); __ SmiTag(slot); - __ Push(slot, name, value); + __ Push(slot, value); __ TailCallRuntime(is_strict(language_mode()) ? Runtime::kStoreGlobalViaContext_Strict : Runtime::kStoreGlobalViaContext_Sloppy, - 3, 1); + 2, 1); } diff --git a/src/arm64/interface-descriptors-arm64.cc b/src/arm64/interface-descriptors-arm64.cc index a3366cd..d344783 100644 --- a/src/arm64/interface-descriptors-arm64.cc +++ b/src/arm64/interface-descriptors-arm64.cc @@ -37,11 +37,9 @@ const Register StoreTransitionDescriptor::MapRegister() { return x3; } const Register LoadGlobalViaContextDescriptor::SlotRegister() { return x2; } -const Register LoadGlobalViaContextDescriptor::NameRegister() { return x3; } const Register StoreGlobalViaContextDescriptor::SlotRegister() { return x2; } -const Register StoreGlobalViaContextDescriptor::NameRegister() { return x3; } const Register StoreGlobalViaContextDescriptor::ValueRegister() { return x0; } diff --git a/src/arm64/lithium-arm64.cc b/src/arm64/lithium-arm64.cc index e1119c2..c432f24 100644 --- a/src/arm64/lithium-arm64.cc +++ b/src/arm64/lithium-arm64.cc @@ -297,8 +297,7 @@ void LStoreKeyedGeneric::PrintDataTo(StringStream* stream) { 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()); } @@ -322,10 +321,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/arm64/lithium-arm64.h b/src/arm64/lithium-arm64.h index 6ab7ebf..7033777 100644 --- a/src/arm64/lithium-arm64.h +++ b/src/arm64/lithium-arm64.h @@ -1686,7 +1686,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(); } }; @@ -2490,7 +2489,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(); } diff --git a/src/arm64/lithium-codegen-arm64.cc b/src/arm64/lithium-codegen-arm64.cc index cac7f92..47dd999 100644 --- a/src/arm64/lithium-codegen-arm64.cc +++ b/src/arm64/lithium-codegen-arm64.cc @@ -3388,15 +3388,12 @@ void LCodeGen::DoLoadGlobalViaContext(LLoadGlobalViaContext* instr) { int const depth = instr->depth(); if (depth <= LoadGlobalViaContextStub::kMaximumDepth) { __ Mov(LoadGlobalViaContextDescriptor::SlotRegister(), Operand(slot)); - __ Mov(LoadGlobalViaContextDescriptor::NameRegister(), - Operand(instr->name())); 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); } } @@ -5548,20 +5545,17 @@ void LCodeGen::DoStoreGlobalViaContext(LStoreGlobalViaContext* instr) { int const depth = instr->depth(); if (depth <= StoreGlobalViaContextStub::kMaximumDepth) { __ Mov(StoreGlobalViaContextDescriptor::SlotRegister(), Operand(slot)); - __ Mov(StoreGlobalViaContextDescriptor::NameRegister(), - Operand(instr->name())); 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/compiler/js-generic-lowering.cc b/src/compiler/js-generic-lowering.cc index 29a2a4a..e823b35 100644 --- a/src/compiler/js-generic-lowering.cc +++ b/src/compiler/js-generic-lowering.cc @@ -339,9 +339,9 @@ void JSGenericLowering::LowerJSLoadGlobal(Node* node) { Callable callable = CodeFactory::LoadGlobalViaContext(isolate(), 0); Node* script_context = node->InputAt(0); node->ReplaceInput(0, jsgraph()->Int32Constant(p.slot_index())); - node->ReplaceInput(1, jsgraph()->HeapConstant(p.name())); - node->ReplaceInput(2, script_context); // Set new context... - node->RemoveInput(3); // ...instead of old one. + node->ReplaceInput(1, script_context); // Set new context... + node->RemoveInput(2); + node->RemoveInput(2); // ...instead of old one. ReplaceWithStubCall(node, callable, flags); } else { @@ -402,10 +402,10 @@ void JSGenericLowering::LowerJSStoreGlobal(Node* node) { Node* script_context = node->InputAt(0); Node* value = node->InputAt(2); node->ReplaceInput(0, jsgraph()->Int32Constant(p.slot_index())); - node->ReplaceInput(1, jsgraph()->HeapConstant(p.name())); - node->ReplaceInput(2, value); - node->ReplaceInput(3, script_context); // Set new context... - node->RemoveInput(4); // ...instead of old one. + node->ReplaceInput(1, value); + node->ReplaceInput(2, script_context); // Set new context... + node->RemoveInput(3); + node->RemoveInput(3); // ...instead of old one. ReplaceWithStubCall(node, callable, flags); } else { diff --git a/src/full-codegen/arm/full-codegen-arm.cc b/src/full-codegen/arm/full-codegen-arm.cc index 047ffb5..705e2b7 100644 --- a/src/full-codegen/arm/full-codegen-arm.cc +++ b/src/full-codegen/arm/full-codegen-arm.cc @@ -1419,14 +1419,11 @@ void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, const int depth = scope()->ContextChainLength(var->scope()); if (depth <= LoadGlobalViaContextStub::kMaximumDepth) { __ mov(LoadGlobalViaContextDescriptor::SlotRegister(), Operand(slot)); - __ mov(LoadGlobalViaContextDescriptor::NameRegister(), - Operand(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 { __ ldr(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); @@ -2721,19 +2718,16 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, const int depth = scope()->ContextChainLength(var->scope()); if (depth <= StoreGlobalViaContextStub::kMaximumDepth) { __ mov(StoreGlobalViaContextDescriptor::SlotRegister(), Operand(slot)); - __ mov(StoreGlobalViaContextDescriptor::NameRegister(), - Operand(var->name())); DCHECK(StoreGlobalViaContextDescriptor::ValueRegister().is(r0)); StoreGlobalViaContextStub stub(isolate(), depth, language_mode()); __ CallStub(&stub); } else { __ Push(Smi::FromInt(slot)); - __ Push(var->name()); __ push(r0); __ CallRuntime(is_strict(language_mode()) ? Runtime::kStoreGlobalViaContext_Strict : Runtime::kStoreGlobalViaContext_Sloppy, - 3); + 2); } } else if (var->mode() == LET && op != Token::INIT_LET) { // Non-initializing assignment to let variable needs a write barrier. diff --git a/src/full-codegen/arm64/full-codegen-arm64.cc b/src/full-codegen/arm64/full-codegen-arm64.cc index 9aec582..78681b4 100644 --- a/src/full-codegen/arm64/full-codegen-arm64.cc +++ b/src/full-codegen/arm64/full-codegen-arm64.cc @@ -1402,13 +1402,11 @@ void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, int const depth = scope()->ContextChainLength(var->scope()); if (depth <= LoadGlobalViaContextStub::kMaximumDepth) { __ Mov(LoadGlobalViaContextDescriptor::SlotRegister(), 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 { __ Ldr(LoadDescriptor::ReceiverRegister(), GlobalObjectMemOperand()); @@ -2406,18 +2404,16 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, int const depth = scope()->ContextChainLength(var->scope()); if (depth <= StoreGlobalViaContextStub::kMaximumDepth) { __ Mov(StoreGlobalViaContextDescriptor::SlotRegister(), slot); - __ Mov(StoreGlobalViaContextDescriptor::NameRegister(), var->name()); DCHECK(StoreGlobalViaContextDescriptor::ValueRegister().is(x0)); StoreGlobalViaContextStub stub(isolate(), depth, language_mode()); __ CallStub(&stub); } else { __ Push(Smi::FromInt(slot)); - __ Push(var->name()); __ Push(x0); __ CallRuntime(is_strict(language_mode()) ? Runtime::kStoreGlobalViaContext_Strict : Runtime::kStoreGlobalViaContext_Sloppy, - 3); + 2); } } else if (var->mode() == LET && op != Token::INIT_LET) { // Non-initializing assignment to let variable needs a write barrier. diff --git a/src/full-codegen/ia32/full-codegen-ia32.cc b/src/full-codegen/ia32/full-codegen-ia32.cc index e4d9d04..bebd0fb 100644 --- a/src/full-codegen/ia32/full-codegen-ia32.cc +++ b/src/full-codegen/ia32/full-codegen-ia32.cc @@ -1345,13 +1345,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 { @@ -2627,18 +2625,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/full-codegen/mips/full-codegen-mips.cc b/src/full-codegen/mips/full-codegen-mips.cc index 467c834..35e6da2 100644 --- a/src/full-codegen/mips/full-codegen-mips.cc +++ b/src/full-codegen/mips/full-codegen-mips.cc @@ -1411,13 +1411,11 @@ void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, int const depth = scope()->ContextChainLength(var->scope()); if (depth <= LoadGlobalViaContextStub::kMaximumDepth) { __ li(LoadGlobalViaContextDescriptor::SlotRegister(), Operand(slot)); - __ li(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 { @@ -2710,17 +2708,15 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, int const depth = scope()->ContextChainLength(var->scope()); if (depth <= StoreGlobalViaContextStub::kMaximumDepth) { __ li(StoreGlobalViaContextDescriptor::SlotRegister(), Operand(slot)); - __ li(StoreGlobalViaContextDescriptor::NameRegister(), var->name()); StoreGlobalViaContextStub stub(isolate(), depth, language_mode()); __ CallStub(&stub); } else { __ Push(Smi::FromInt(slot)); - __ Push(var->name()); __ Push(a0); __ 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/full-codegen/mips64/full-codegen-mips64.cc b/src/full-codegen/mips64/full-codegen-mips64.cc index afee137..7b2cda3 100644 --- a/src/full-codegen/mips64/full-codegen-mips64.cc +++ b/src/full-codegen/mips64/full-codegen-mips64.cc @@ -1407,13 +1407,11 @@ void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, int const depth = scope()->ContextChainLength(var->scope()); if (depth <= LoadGlobalViaContextStub::kMaximumDepth) { __ li(LoadGlobalViaContextDescriptor::SlotRegister(), Operand(slot)); - __ li(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 { @@ -2707,17 +2705,15 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, int const depth = scope()->ContextChainLength(var->scope()); if (depth <= StoreGlobalViaContextStub::kMaximumDepth) { __ li(StoreGlobalViaContextDescriptor::SlotRegister(), Operand(slot)); - __ li(StoreGlobalViaContextDescriptor::NameRegister(), var->name()); StoreGlobalViaContextStub stub(isolate(), depth, language_mode()); __ CallStub(&stub); } else { __ Push(Smi::FromInt(slot)); - __ Push(var->name()); __ Push(a0); __ 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/full-codegen/x64/full-codegen-x64.cc b/src/full-codegen/x64/full-codegen-x64.cc index 3e18978..1839d2c 100644 --- a/src/full-codegen/x64/full-codegen-x64.cc +++ b/src/full-codegen/x64/full-codegen-x64.cc @@ -1369,18 +1369,15 @@ void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, if (var->IsGlobalSlot()) { DCHECK(var->index() > 0); DCHECK(var->IsStaticGlobalObjectProperty()); - // Each var occupies two slots in the context: for reads and writes. int const slot = var->index(); int const depth = scope()->ContextChainLength(var->scope()); if (depth <= LoadGlobalViaContextStub::kMaximumDepth) { __ Set(LoadGlobalViaContextDescriptor::SlotRegister(), slot); - __ Move(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 { @@ -2622,18 +2619,16 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, int const depth = scope()->ContextChainLength(var->scope()); if (depth <= StoreGlobalViaContextStub::kMaximumDepth) { __ Set(StoreGlobalViaContextDescriptor::SlotRegister(), slot); - __ Move(StoreGlobalViaContextDescriptor::NameRegister(), var->name()); DCHECK(StoreGlobalViaContextDescriptor::ValueRegister().is(rax)); StoreGlobalViaContextStub stub(isolate(), depth, language_mode()); __ CallStub(&stub); } else { __ Push(Smi::FromInt(slot)); - __ Push(var->name()); __ Push(rax); __ 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/hydrogen-instructions.cc b/src/hydrogen-instructions.cc index 24259c8..b729985 100644 --- a/src/hydrogen-instructions.cc +++ b/src/hydrogen-instructions.cc @@ -3601,8 +3601,8 @@ std::ostream& HStoreNamedGeneric::PrintDataTo( std::ostream& HStoreGlobalViaContext::PrintDataTo( std::ostream& os) const { // NOLINT - return os << name()->ToCString().get() << " = " << NameOf(value()) - << " depth:" << depth() << " slot:" << slot_index(); + return os << " depth:" << depth() << " slot:" << slot_index() << " = " + << NameOf(value()); } @@ -3658,8 +3658,7 @@ std::ostream& HLoadGlobalGeneric::PrintDataTo( std::ostream& HLoadGlobalViaContext::PrintDataTo( std::ostream& os) const { // NOLINT - return os << name()->ToCString().get() << " " - << "depth:" << depth() << " slot:" << slot_index(); + return os << "depth:" << depth() << " slot:" << slot_index(); } diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h index 3d3c56c..63ddf27 100644 --- a/src/hydrogen-instructions.h +++ b/src/hydrogen-instructions.h @@ -5496,11 +5496,9 @@ class HLoadGlobalGeneric final : public HTemplateInstruction<2> { class HLoadGlobalViaContext final : public HTemplateInstruction<1> { public: - DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P3(HLoadGlobalViaContext, - Handle, int, int); + DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P2(HLoadGlobalViaContext, int, int); HValue* context() { return OperandAt(0); } - Handle name() const { return name_; } int depth() const { return depth_; } int slot_index() const { return slot_index_; } @@ -5513,17 +5511,15 @@ class HLoadGlobalViaContext final : public HTemplateInstruction<1> { DECLARE_CONCRETE_INSTRUCTION(LoadGlobalViaContext) private: - HLoadGlobalViaContext(HValue* context, Handle name, int depth, - int slot_index) - : name_(name), depth_(depth), slot_index_(slot_index) { + HLoadGlobalViaContext(HValue* context, int depth, int slot_index) + : depth_(depth), slot_index_(slot_index) { SetOperandAt(0, context); set_representation(Representation::Tagged()); SetAllSideEffects(); } - Handle name_; - int depth_; - int slot_index_; + int const depth_; + int const slot_index_; }; @@ -7069,12 +7065,10 @@ class HStoreNamedGeneric final : public HTemplateInstruction<3> { class HStoreGlobalViaContext final : public HTemplateInstruction<2> { public: - DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P5(HStoreGlobalViaContext, - Handle, HValue*, int, int, - LanguageMode); + DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(HStoreGlobalViaContext, HValue*, + int, int, LanguageMode); HValue* context() const { return OperandAt(0); } HValue* value() const { return OperandAt(1); } - Handle name() const { return name_; } int depth() const { return depth_; } int slot_index() const { return slot_index_; } LanguageMode language_mode() const { return language_mode_; } @@ -7088,21 +7082,17 @@ class HStoreGlobalViaContext final : public HTemplateInstruction<2> { DECLARE_CONCRETE_INSTRUCTION(StoreGlobalViaContext) private: - HStoreGlobalViaContext(HValue* context, Handle name, HValue* value, - int depth, int slot_index, LanguageMode language_mode) - : name_(name), - depth_(depth), - slot_index_(slot_index), - language_mode_(language_mode) { + HStoreGlobalViaContext(HValue* context, HValue* value, int depth, + int slot_index, LanguageMode language_mode) + : depth_(depth), slot_index_(slot_index), language_mode_(language_mode) { SetOperandAt(0, context); SetOperandAt(1, value); SetAllSideEffects(); } - Handle name_; - int depth_; - int slot_index_; - LanguageMode language_mode_; + int const depth_; + int const slot_index_; + LanguageMode const language_mode_; }; diff --git a/src/hydrogen.cc b/src/hydrogen.cc index f4bd417..f652b31 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -5569,7 +5569,7 @@ void HOptimizedGraphBuilder::VisitVariableProxy(VariableProxy* expr) { int depth = scope()->ContextChainLength(variable->scope()); HLoadGlobalViaContext* instr = - New(variable->name(), depth, slot_index); + New(depth, slot_index); return ast_context()->ReturnInstruction(instr, expr->id()); } else { @@ -6801,7 +6801,7 @@ void HOptimizedGraphBuilder::HandleGlobalVariableAssignment( int depth = scope()->ContextChainLength(var->scope()); HStoreGlobalViaContext* instr = Add( - var->name(), value, depth, slot_index, function_language_mode()); + value, depth, slot_index, function_language_mode()); USE(instr); DCHECK(instr->HasObservableSideEffects()); Add(ast_id, REMOVABLE_SIMULATE); diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc index 944206b..525edea 100644 --- a/src/ia32/code-stubs-ia32.cc +++ b/src/ia32/code-stubs-ia32.cc @@ -5119,7 +5119,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; @@ -5143,25 +5142,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. @@ -5203,7 +5200,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. @@ -5245,9 +5243,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. @@ -5267,13 +5262,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/ia32/interface-descriptors-ia32.cc b/src/ia32/interface-descriptors-ia32.cc index a91e1ef..61508ee 100644 --- a/src/ia32/interface-descriptors-ia32.cc +++ b/src/ia32/interface-descriptors-ia32.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/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index db2602c..7f1a983 100644 --- a/src/ia32/lithium-codegen-ia32.cc +++ b/src/ia32/lithium-codegen-ia32.cc @@ -2873,15 +2873,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); } } @@ -4150,20 +4148,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/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc index eeccdd0..e07c1e8 100644 --- a/src/ia32/lithium-ia32.cc +++ b/src/ia32/lithium-ia32.cc @@ -380,8 +380,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()); } @@ -404,10 +403,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/ia32/lithium-ia32.h b/src/ia32/lithium-ia32.h index ac544a6..9bcc5f4 100644 --- a/src/ia32/lithium-ia32.h +++ b/src/ia32/lithium-ia32.h @@ -1730,7 +1730,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(); } }; @@ -2244,7 +2243,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(); } diff --git a/src/interface-descriptors.cc b/src/interface-descriptors.cc index 0526bf9..89ee975 100644 --- a/src/interface-descriptors.cc +++ b/src/interface-descriptors.cc @@ -117,16 +117,15 @@ Type::FunctionType* LoadGlobalViaContextDescriptor::BuildCallInterfaceDescriptorFunctionType( Isolate* isolate, int paramater_count) { Type::FunctionType* function = Type::FunctionType::New( - AnyTagged(), Type::Undefined(), 2, isolate->interface_descriptor_zone()); + AnyTagged(), Type::Undefined(), 1, isolate->interface_descriptor_zone()); function->InitParameter(0, UntaggedSigned32()); - function->InitParameter(1, AnyTagged()); return function; } void LoadGlobalViaContextDescriptor::InitializePlatformSpecific( CallInterfaceDescriptorData* data) { - Register registers[] = {SlotRegister(), NameRegister()}; + Register registers[] = {SlotRegister()}; data->InitializePlatformSpecific(arraysize(registers), registers); } @@ -135,17 +134,16 @@ Type::FunctionType* StoreGlobalViaContextDescriptor::BuildCallInterfaceDescriptorFunctionType( Isolate* isolate, int paramater_count) { Type::FunctionType* function = Type::FunctionType::New( - AnyTagged(), Type::Undefined(), 3, isolate->interface_descriptor_zone()); + AnyTagged(), Type::Undefined(), 2, isolate->interface_descriptor_zone()); function->InitParameter(0, UntaggedSigned32()); function->InitParameter(1, AnyTagged()); - function->InitParameter(2, AnyTagged()); return function; } void StoreGlobalViaContextDescriptor::InitializePlatformSpecific( CallInterfaceDescriptorData* data) { - Register registers[] = {SlotRegister(), NameRegister(), ValueRegister()}; + Register registers[] = {SlotRegister(), ValueRegister()}; data->InitializePlatformSpecific(arraysize(registers), registers); } diff --git a/src/interface-descriptors.h b/src/interface-descriptors.h index 94b1a81..c5e104f 100644 --- a/src/interface-descriptors.h +++ b/src/interface-descriptors.h @@ -424,7 +424,6 @@ class LoadGlobalViaContextDescriptor : public CallInterfaceDescriptor { CallInterfaceDescriptor) static const Register SlotRegister(); - static const Register NameRegister(); }; @@ -434,7 +433,6 @@ class StoreGlobalViaContextDescriptor : public CallInterfaceDescriptor { CallInterfaceDescriptor) static const Register SlotRegister(); - static const Register NameRegister(); static const Register ValueRegister(); }; diff --git a/src/mips/code-stubs-mips.cc b/src/mips/code-stubs-mips.cc index cb6d67f..5ebb70e 100644 --- a/src/mips/code-stubs-mips.cc +++ b/src/mips/code-stubs-mips.cc @@ -5273,7 +5273,6 @@ void InternalArrayConstructorStub::Generate(MacroAssembler* masm) { void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { Register context_reg = cp; Register slot_reg = a2; - Register name_reg = a3; Register result_reg = v0; Label slow_case; @@ -5286,8 +5285,7 @@ void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { // Load the PropertyCell value at the specified slot. __ sll(at, slot_reg, kPointerSizeLog2); __ Addu(at, at, Operand(context_reg)); - __ Addu(at, at, Context::SlotOffset(0)); - __ lw(result_reg, MemOperand(at)); + __ lw(result_reg, ContextOperand(at, 0)); __ lw(result_reg, FieldMemOperand(result_reg, PropertyCell::kValueOffset)); // Check that value is not the_hole. @@ -5298,15 +5296,14 @@ void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { // Fallback to the runtime. __ bind(&slow_case); __ SmiTag(slot_reg); - __ Push(slot_reg, name_reg); - __ TailCallRuntime(Runtime::kLoadGlobalViaContext, 2, 1); + __ Push(slot_reg); + __ TailCallRuntime(Runtime::kLoadGlobalViaContext, 1, 1); } void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { Register context_reg = cp; Register slot_reg = a2; - Register name_reg = a3; Register value_reg = a0; Register cell_reg = t0; Register cell_value_reg = t1; @@ -5316,7 +5313,6 @@ void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { if (FLAG_debug_code) { __ LoadRoot(at, Heap::kTheHoleValueRootIndex); __ Check(ne, kUnexpectedValue, value_reg, Operand(at)); - __ AssertName(name_reg); } // Go up context chain to the script context. @@ -5328,8 +5324,7 @@ void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { // Load the PropertyCell at the specified slot. __ sll(at, slot_reg, kPointerSizeLog2); __ Addu(at, at, Operand(context_reg)); - __ Addu(at, at, Context::SlotOffset(0)); - __ lw(cell_reg, MemOperand(at)); + __ lw(cell_reg, ContextOperand(at, 0)); // Load PropertyDetails for the cell (actually only the cell_type and kind). __ lw(cell_details_reg, @@ -5413,11 +5408,11 @@ void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { // Fallback to the runtime. __ bind(&slow_case); __ SmiTag(slot_reg); - __ Push(slot_reg, name_reg, value_reg); + __ Push(slot_reg, value_reg); __ TailCallRuntime(is_strict(language_mode()) ? Runtime::kStoreGlobalViaContext_Strict : Runtime::kStoreGlobalViaContext_Sloppy, - 3, 1); + 2, 1); } diff --git a/src/mips/interface-descriptors-mips.cc b/src/mips/interface-descriptors-mips.cc index 9169049..f0618ad 100644 --- a/src/mips/interface-descriptors-mips.cc +++ b/src/mips/interface-descriptors-mips.cc @@ -37,11 +37,9 @@ const Register StoreTransitionDescriptor::MapRegister() { return a3; } const Register LoadGlobalViaContextDescriptor::SlotRegister() { return a2; } -const Register LoadGlobalViaContextDescriptor::NameRegister() { return a3; } const Register StoreGlobalViaContextDescriptor::SlotRegister() { return a2; } -const Register StoreGlobalViaContextDescriptor::NameRegister() { return a3; } const Register StoreGlobalViaContextDescriptor::ValueRegister() { return a0; } diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc index c5db715..838cd1c 100644 --- a/src/mips/lithium-codegen-mips.cc +++ b/src/mips/lithium-codegen-mips.cc @@ -2903,15 +2903,12 @@ void LCodeGen::DoLoadGlobalViaContext(LLoadGlobalViaContext* instr) { int const depth = instr->depth(); if (depth <= LoadGlobalViaContextStub::kMaximumDepth) { __ li(LoadGlobalViaContextDescriptor::SlotRegister(), Operand(slot)); - __ li(LoadGlobalViaContextDescriptor::NameRegister(), - Operand(instr->name())); 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); } } @@ -4218,20 +4215,17 @@ void LCodeGen::DoStoreGlobalViaContext(LStoreGlobalViaContext* instr) { int const depth = instr->depth(); if (depth <= StoreGlobalViaContextStub::kMaximumDepth) { __ li(StoreGlobalViaContextDescriptor::SlotRegister(), Operand(slot)); - __ li(StoreGlobalViaContextDescriptor::NameRegister(), - Operand(instr->name())); 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(language_mode()) ? Runtime::kStoreGlobalViaContext_Strict : Runtime::kStoreGlobalViaContext_Sloppy, - 3); + 2); } } diff --git a/src/mips/lithium-mips.cc b/src/mips/lithium-mips.cc index 5506109..9c15d39 100644 --- a/src/mips/lithium-mips.cc +++ b/src/mips/lithium-mips.cc @@ -338,8 +338,7 @@ void LAccessArgumentsAt::PrintDataTo(StringStream* stream) { 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()); } @@ -362,10 +361,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/mips/lithium-mips.h b/src/mips/lithium-mips.h index 1b8b5e5..406f877 100644 --- a/src/mips/lithium-mips.h +++ b/src/mips/lithium-mips.h @@ -1680,7 +1680,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(); } }; @@ -2203,7 +2202,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(); } diff --git a/src/mips64/code-stubs-mips64.cc b/src/mips64/code-stubs-mips64.cc index fdbae1f..494d947 100644 --- a/src/mips64/code-stubs-mips64.cc +++ b/src/mips64/code-stubs-mips64.cc @@ -5304,7 +5304,6 @@ void InternalArrayConstructorStub::Generate(MacroAssembler* masm) { void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { Register context_reg = cp; Register slot_reg = a2; - Register name_reg = a3; Register result_reg = v0; Label slow_case; @@ -5317,8 +5316,7 @@ void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { // Load the PropertyCell value at the specified slot. __ dsll(at, slot_reg, kPointerSizeLog2); __ Daddu(at, at, Operand(context_reg)); - __ Daddu(at, at, Context::SlotOffset(0)); - __ ld(result_reg, MemOperand(at)); + __ ld(result_reg, ContextOperand(at, 0)); __ ld(result_reg, FieldMemOperand(result_reg, PropertyCell::kValueOffset)); // Check that value is not the_hole. @@ -5329,15 +5327,14 @@ void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { // Fallback to the runtime. __ bind(&slow_case); __ SmiTag(slot_reg); - __ Push(slot_reg, name_reg); - __ TailCallRuntime(Runtime::kLoadGlobalViaContext, 2, 1); + __ Push(slot_reg); + __ TailCallRuntime(Runtime::kLoadGlobalViaContext, 1, 1); } void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { Register context_reg = cp; Register slot_reg = a2; - Register name_reg = a3; Register value_reg = a0; Register cell_reg = a4; Register cell_value_reg = a5; @@ -5347,7 +5344,6 @@ void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { if (FLAG_debug_code) { __ LoadRoot(at, Heap::kTheHoleValueRootIndex); __ Check(ne, kUnexpectedValue, value_reg, Operand(at)); - __ AssertName(name_reg); } // Go up context chain to the script context. @@ -5359,8 +5355,7 @@ void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { // Load the PropertyCell at the specified slot. __ dsll(at, slot_reg, kPointerSizeLog2); __ Daddu(at, at, Operand(context_reg)); - __ Daddu(at, at, Context::SlotOffset(0)); - __ ld(cell_reg, MemOperand(at)); + __ ld(cell_reg, ContextOperand(at, 0)); // Load PropertyDetails for the cell (actually only the cell_type and kind). __ ld(cell_details_reg, @@ -5444,11 +5439,11 @@ void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { // Fallback to the runtime. __ bind(&slow_case); __ SmiTag(slot_reg); - __ Push(slot_reg, name_reg, value_reg); + __ Push(slot_reg, value_reg); __ TailCallRuntime(is_strict(language_mode()) ? Runtime::kStoreGlobalViaContext_Strict : Runtime::kStoreGlobalViaContext_Sloppy, - 3, 1); + 2, 1); } diff --git a/src/mips64/interface-descriptors-mips64.cc b/src/mips64/interface-descriptors-mips64.cc index 13a09c3..87c8ffb 100644 --- a/src/mips64/interface-descriptors-mips64.cc +++ b/src/mips64/interface-descriptors-mips64.cc @@ -37,11 +37,9 @@ const Register StoreTransitionDescriptor::MapRegister() { return a3; } const Register LoadGlobalViaContextDescriptor::SlotRegister() { return a2; } -const Register LoadGlobalViaContextDescriptor::NameRegister() { return a3; } const Register StoreGlobalViaContextDescriptor::SlotRegister() { return a2; } -const Register StoreGlobalViaContextDescriptor::NameRegister() { return a3; } const Register StoreGlobalViaContextDescriptor::ValueRegister() { return a0; } diff --git a/src/mips64/lithium-codegen-mips64.cc b/src/mips64/lithium-codegen-mips64.cc index 0313878..f87c852 100644 --- a/src/mips64/lithium-codegen-mips64.cc +++ b/src/mips64/lithium-codegen-mips64.cc @@ -3007,15 +3007,12 @@ void LCodeGen::DoLoadGlobalViaContext(LLoadGlobalViaContext* instr) { int const depth = instr->depth(); if (depth <= LoadGlobalViaContextStub::kMaximumDepth) { __ li(LoadGlobalViaContextDescriptor::SlotRegister(), Operand(slot)); - __ li(LoadGlobalViaContextDescriptor::NameRegister(), - Operand(instr->name())); 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); } } @@ -4411,20 +4408,17 @@ void LCodeGen::DoStoreGlobalViaContext(LStoreGlobalViaContext* instr) { int const depth = instr->depth(); if (depth <= StoreGlobalViaContextStub::kMaximumDepth) { __ li(StoreGlobalViaContextDescriptor::SlotRegister(), Operand(slot)); - __ li(StoreGlobalViaContextDescriptor::NameRegister(), - Operand(instr->name())); 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(language_mode()) ? Runtime::kStoreGlobalViaContext_Strict : Runtime::kStoreGlobalViaContext_Sloppy, - 3); + 2); } } diff --git a/src/mips64/lithium-mips64.cc b/src/mips64/lithium-mips64.cc index 0605825..f6a0f8d 100644 --- a/src/mips64/lithium-mips64.cc +++ b/src/mips64/lithium-mips64.cc @@ -338,8 +338,7 @@ void LAccessArgumentsAt::PrintDataTo(StringStream* stream) { 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()); } @@ -362,10 +361,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/mips64/lithium-mips64.h b/src/mips64/lithium-mips64.h index 2408869..ce40377 100644 --- a/src/mips64/lithium-mips64.h +++ b/src/mips64/lithium-mips64.h @@ -1742,7 +1742,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(); } }; @@ -2249,7 +2248,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(); } diff --git a/src/objects.h b/src/objects.h index 342a00e..9d3a062 100644 --- a/src/objects.h +++ b/src/objects.h @@ -3992,6 +3992,9 @@ class ScopeInfo : public FixedArray { InitializationFlag* init_flag, MaybeAssignedFlag* maybe_assigned_flag); + // Lookup the name of a certain context slot by its index. + String* ContextSlotName(int slot_index); + // Lookup support for serialized scope info. Returns the // parameter index for a given parameter name if the parameter is present; // otherwise returns a value < 0. The name must be an internalized string. diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc index ebaf006..b9c3fdf 100644 --- a/src/runtime/runtime-object.cc +++ b/src/runtime/runtime-object.cc @@ -420,9 +420,8 @@ RUNTIME_FUNCTION(Runtime_ObjectSeal) { RUNTIME_FUNCTION(Runtime_LoadGlobalViaContext) { HandleScope scope(isolate); - DCHECK_EQ(2, args.length()); + DCHECK_EQ(1, args.length()); CONVERT_SMI_ARG_CHECKED(slot, 0); - CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); // Go up context chain to the script context. Handle script_context(isolate->context()->script_context(), isolate); @@ -430,12 +429,15 @@ RUNTIME_FUNCTION(Runtime_LoadGlobalViaContext) { DCHECK(script_context->get(slot)->IsPropertyCell()); // Lookup the named property on the global object. + Handle scope_info(ScopeInfo::cast(script_context->extension()), + isolate); + Handle name(scope_info->ContextSlotName(slot), isolate); Handle global_object(script_context->global_object(), isolate); LookupIterator it(global_object, name, LookupIterator::HIDDEN); // Switch to fast mode only if there is a data property and it's not on // a hidden prototype. - if (it.state() == LookupIterator::DATA && + if (LookupIterator::DATA == it.state() && it.GetHolder()->IsJSGlobalObject()) { // Now update the cell in the script context. Handle cell = it.GetPropertyCell(); @@ -454,8 +456,7 @@ RUNTIME_FUNCTION(Runtime_LoadGlobalViaContext) { namespace { -Object* StoreGlobalViaContext(Isolate* isolate, int slot, Handle name, - Handle value, +Object* StoreGlobalViaContext(Isolate* isolate, int slot, Handle value, LanguageMode language_mode) { // Go up context chain to the script context. Handle script_context(isolate->context()->script_context(), isolate); @@ -463,6 +464,9 @@ Object* StoreGlobalViaContext(Isolate* isolate, int slot, Handle name, DCHECK(script_context->get(slot)->IsPropertyCell()); // Lookup the named property on the global object. + Handle scope_info(ScopeInfo::cast(script_context->extension()), + isolate); + Handle name(scope_info->ContextSlotName(slot), isolate); Handle global_object(script_context->global_object(), isolate); LookupIterator it(global_object, name, LookupIterator::HIDDEN); // Switch to fast mode only if there is a data property and it's not on @@ -491,23 +495,21 @@ Object* StoreGlobalViaContext(Isolate* isolate, int slot, Handle name, RUNTIME_FUNCTION(Runtime_StoreGlobalViaContext_Sloppy) { HandleScope scope(isolate); - DCHECK_EQ(3, args.length()); + DCHECK_EQ(2, args.length()); CONVERT_SMI_ARG_CHECKED(slot, 0); - CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); - CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); + CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); - return StoreGlobalViaContext(isolate, slot, name, value, SLOPPY); + return StoreGlobalViaContext(isolate, slot, value, SLOPPY); } RUNTIME_FUNCTION(Runtime_StoreGlobalViaContext_Strict) { HandleScope scope(isolate); - DCHECK_EQ(3, args.length()); + DCHECK_EQ(2, args.length()); CONVERT_SMI_ARG_CHECKED(slot, 0); - CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); - CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); + CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); - return StoreGlobalViaContext(isolate, slot, name, value, STRICT); + return StoreGlobalViaContext(isolate, slot, value, STRICT); } diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index 1e2471c..b393b77 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h @@ -447,9 +447,9 @@ namespace internal { F(GetPropertyStrong, 2, 1) \ F(KeyedGetProperty, 2, 1) \ F(KeyedGetPropertyStrong, 2, 1) \ - F(LoadGlobalViaContext, 2, 1) \ - F(StoreGlobalViaContext_Sloppy, 3, 1) \ - F(StoreGlobalViaContext_Strict, 3, 1) \ + F(LoadGlobalViaContext, 1, 1) \ + F(StoreGlobalViaContext_Sloppy, 2, 1) \ + F(StoreGlobalViaContext_Strict, 2, 1) \ F(AddNamedProperty, 4, 1) \ F(SetProperty, 4, 1) \ F(AddElement, 3, 1) \ diff --git a/src/scopeinfo.cc b/src/scopeinfo.cc index a621083..c79a980 100644 --- a/src/scopeinfo.cc +++ b/src/scopeinfo.cc @@ -572,6 +572,19 @@ int ScopeInfo::ContextSlotIndex(Handle scope_info, } +String* ScopeInfo::ContextSlotName(int slot_index) { + // TODO(bmeurer): Simplify this once we have only a single slot for both reads + // and writes to context globals; currently we have 2 slots per context + // global, and these are located after the common context slots (of which we + // always have Context::MIN_CONTEXT_SLOTS) and the context locals. + int const var = + slot_index - (Context::MIN_CONTEXT_SLOTS + ContextLocalCount()); + DCHECK_LE(0, var); + DCHECK_LT(var, 2 * ContextGlobalCount()); + return ContextLocalName(ContextLocalCount() + var / 2); +} + + int ScopeInfo::ParameterIndex(String* name) { DCHECK(name->IsInternalizedString()); if (length() > 0) { diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc index d7b7f40..7d71701 100644 --- a/src/x64/code-stubs-x64.cc +++ b/src/x64/code-stubs-x64.cc @@ -5036,7 +5036,6 @@ void InternalArrayConstructorStub::Generate(MacroAssembler* masm) { void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { Register context_reg = rsi; Register slot_reg = rbx; - Register name_reg = rcx; Register result_reg = rax; Label slow_case; @@ -5060,16 +5059,14 @@ void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { __ Integer32ToSmi(slot_reg, slot_reg); __ PopReturnAddressTo(kScratchRegister); __ Push(slot_reg); - __ Push(name_reg); __ Push(kScratchRegister); - __ TailCallRuntime(Runtime::kLoadGlobalViaContext, 2, 1); + __ TailCallRuntime(Runtime::kLoadGlobalViaContext, 1, 1); } void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { Register context_reg = rsi; Register slot_reg = rbx; - Register name_reg = rcx; Register value_reg = rax; Register cell_reg = r8; Register cell_details_reg = rdx; @@ -5079,7 +5076,6 @@ void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { if (FLAG_debug_code) { __ CompareRoot(value_reg, Heap::kTheHoleValueRootIndex); __ Check(not_equal, kUnexpectedValue); - __ AssertName(name_reg); } // Go up context chain to the script context. @@ -5183,13 +5179,12 @@ void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { __ Integer32ToSmi(slot_reg, slot_reg); __ PopReturnAddressTo(kScratchRegister); __ Push(slot_reg); - __ Push(name_reg); __ Push(value_reg); __ Push(kScratchRegister); __ TailCallRuntime(is_strict(language_mode()) ? Runtime::kStoreGlobalViaContext_Strict : Runtime::kStoreGlobalViaContext_Sloppy, - 3, 1); + 2, 1); } diff --git a/src/x64/interface-descriptors-x64.cc b/src/x64/interface-descriptors-x64.cc index e957989..da5e506 100644 --- a/src/x64/interface-descriptors-x64.cc +++ b/src/x64/interface-descriptors-x64.cc @@ -37,11 +37,9 @@ const Register StoreTransitionDescriptor::MapRegister() { return rbx; } const Register LoadGlobalViaContextDescriptor::SlotRegister() { return rbx; } -const Register LoadGlobalViaContextDescriptor::NameRegister() { return rcx; } const Register StoreGlobalViaContextDescriptor::SlotRegister() { return rbx; } -const Register StoreGlobalViaContextDescriptor::NameRegister() { return rcx; } const Register StoreGlobalViaContextDescriptor::ValueRegister() { return rax; } diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc index a4c36b8..a4da708 100644 --- a/src/x64/lithium-codegen-x64.cc +++ b/src/x64/lithium-codegen-x64.cc @@ -2902,14 +2902,12 @@ void LCodeGen::DoLoadGlobalViaContext(LLoadGlobalViaContext* instr) { int const depth = instr->depth(); if (depth <= LoadGlobalViaContextStub::kMaximumDepth) { __ Set(LoadGlobalViaContextDescriptor::SlotRegister(), slot); - __ Move(LoadGlobalViaContextDescriptor::NameRegister(), instr->name()); 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); } } @@ -4279,19 +4277,17 @@ void LCodeGen::DoStoreGlobalViaContext(LStoreGlobalViaContext* instr) { int const depth = instr->depth(); if (depth <= StoreGlobalViaContextStub::kMaximumDepth) { __ Set(StoreGlobalViaContextDescriptor::SlotRegister(), slot); - __ Move(StoreGlobalViaContextDescriptor::NameRegister(), instr->name()); 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/x64/lithium-x64.cc b/src/x64/lithium-x64.cc index 46bb35a..1782845 100644 --- a/src/x64/lithium-x64.cc +++ b/src/x64/lithium-x64.cc @@ -375,8 +375,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()); } @@ -399,10 +398,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/x64/lithium-x64.h b/src/x64/lithium-x64.h index 95d56be..cd51a4d 100644 --- a/src/x64/lithium-x64.h +++ b/src/x64/lithium-x64.h @@ -1707,7 +1707,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(); } }; @@ -2220,7 +2219,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(); }