From 9846f386f08e2aaf897851f0f54c0967c51484fb Mon Sep 17 00:00:00 2001 From: bmeurer Date: Tue, 24 Nov 2015 05:03:57 -0800 Subject: [PATCH] [compiler] No need to push literal index in VisitArrayLiteral. The literal index is being pushed onto the stack while evaluating the non-constant subexpressions, but never used in fullcodegen (and hence not used in the optimizing compilers). R=mstarzinger@chromium.org Review URL: https://codereview.chromium.org/1471893003 Cr-Commit-Position: refs/heads/master@{#32205} --- src/compiler/ast-graph-builder.cc | 8 +++----- src/crankshaft/hydrogen.cc | 3 --- src/full-codegen/arm/full-codegen-arm.cc | 5 +---- src/full-codegen/arm64/full-codegen-arm64.cc | 7 ++----- src/full-codegen/ia32/full-codegen-ia32.cc | 5 +---- src/full-codegen/mips/full-codegen-mips.cc | 5 +---- src/full-codegen/mips64/full-codegen-mips64.cc | 5 +---- src/full-codegen/x64/full-codegen-x64.cc | 5 +---- 8 files changed, 10 insertions(+), 33 deletions(-) diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc index 801b0c9aa0..35f6cb022b 100644 --- a/src/compiler/ast-graph-builder.cc +++ b/src/compiler/ast-graph-builder.cc @@ -1929,10 +1929,9 @@ void AstGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { PrepareFrameState(literal, expr->CreateLiteralId(), OutputFrameStateCombine::Push()); - // The array and the literal index are both expected on the operand stack - // during computation of the element values. + // The array is expected on the operand stack during computation of the + // element values. environment()->Push(literal); - environment()->Push(literal_index); // Create nodes to evaluate all the non-constant subexpressions and to store // them into the newly cloned array. @@ -1948,7 +1947,7 @@ void AstGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { VectorSlotPair pair = CreateVectorSlotPair(expr->LiteralFeedbackSlot()); Node* value = environment()->Pop(); Node* index = jsgraph()->Constant(array_index); - Node* literal = environment()->Peek(1); + Node* literal = environment()->Top(); Node* store = BuildKeyedStore(literal, index, value, pair); states.AddToNode(store, expr->GetIdForElement(array_index), OutputFrameStateCombine::Ignore()); @@ -1960,7 +1959,6 @@ void AstGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { // above. The second part is the part after the first spread expression // (inclusive) and these elements gets appended to the array. Note that the // number elements an iterable produces is unknown ahead of time. - environment()->Pop(); // Array literal index. for (; array_index < expr->values()->length(); array_index++) { Expression* subexpr = expr->values()->at(array_index); Node* result; diff --git a/src/crankshaft/hydrogen.cc b/src/crankshaft/hydrogen.cc index 95a334a9a6..59965b18c6 100644 --- a/src/crankshaft/hydrogen.cc +++ b/src/crankshaft/hydrogen.cc @@ -6074,8 +6074,6 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { // The array is expected in the bailout environment during computation // of the property values and is the value of the entire expression. Push(literal); - // The literal index is on the stack, too. - Push(Add(expr->literal_index())); HInstruction* elements = NULL; @@ -6117,7 +6115,6 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { Add(expr->GetIdForElement(i)); } - Drop(1); // array literal index return ast_context()->ReturnValue(Pop()); } diff --git a/src/full-codegen/arm/full-codegen-arm.cc b/src/full-codegen/arm/full-codegen-arm.cc index 3ab949fd35..683ae6e2d1 100644 --- a/src/full-codegen/arm/full-codegen-arm.cc +++ b/src/full-codegen/arm/full-codegen-arm.cc @@ -1768,13 +1768,12 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { if (!result_saved) { __ push(r0); - __ Push(Smi::FromInt(expr->literal_index())); result_saved = true; } VisitForAccumulatorValue(subexpr); __ mov(StoreDescriptor::NameRegister(), Operand(Smi::FromInt(array_index))); - __ ldr(StoreDescriptor::ReceiverRegister(), MemOperand(sp, kPointerSize)); + __ ldr(StoreDescriptor::ReceiverRegister(), MemOperand(sp, 0)); EmitLoadStoreICSlot(expr->LiteralFeedbackSlot()); Handle ic = CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); @@ -1789,7 +1788,6 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { // (inclusive) and these elements gets appended to the array. Note that the // number elements an iterable produces is unknown ahead of time. if (array_index < length && result_saved) { - __ pop(); // literal index __ Pop(r0); result_saved = false; } @@ -1810,7 +1808,6 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { } if (result_saved) { - __ pop(); // literal index context()->PlugTOS(); } else { context()->Plug(r0); diff --git a/src/full-codegen/arm64/full-codegen-arm64.cc b/src/full-codegen/arm64/full-codegen-arm64.cc index 4d41ce7a62..335ded8647 100644 --- a/src/full-codegen/arm64/full-codegen-arm64.cc +++ b/src/full-codegen/arm64/full-codegen-arm64.cc @@ -1750,14 +1750,13 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; if (!result_saved) { - __ Mov(x1, Smi::FromInt(expr->literal_index())); - __ Push(x0, x1); + __ Push(x0); result_saved = true; } VisitForAccumulatorValue(subexpr); __ Mov(StoreDescriptor::NameRegister(), Smi::FromInt(array_index)); - __ Peek(StoreDescriptor::ReceiverRegister(), kPointerSize); + __ Peek(StoreDescriptor::ReceiverRegister(), 0); EmitLoadStoreICSlot(expr->LiteralFeedbackSlot()); Handle ic = CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); @@ -1772,7 +1771,6 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { // (inclusive) and these elements gets appended to the array. Note that the // number elements an iterable produces is unknown ahead of time. if (array_index < length && result_saved) { - __ Drop(1); // literal index __ Pop(x0); result_saved = false; } @@ -1793,7 +1791,6 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { } if (result_saved) { - __ Drop(1); // literal index context()->PlugTOS(); } else { context()->Plug(x0); diff --git a/src/full-codegen/ia32/full-codegen-ia32.cc b/src/full-codegen/ia32/full-codegen-ia32.cc index 00947e7513..ad0227b476 100644 --- a/src/full-codegen/ia32/full-codegen-ia32.cc +++ b/src/full-codegen/ia32/full-codegen-ia32.cc @@ -1690,14 +1690,13 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { if (!result_saved) { __ push(eax); // array literal. - __ push(Immediate(Smi::FromInt(expr->literal_index()))); result_saved = true; } VisitForAccumulatorValue(subexpr); __ mov(StoreDescriptor::NameRegister(), Immediate(Smi::FromInt(array_index))); - __ mov(StoreDescriptor::ReceiverRegister(), Operand(esp, kPointerSize)); + __ mov(StoreDescriptor::ReceiverRegister(), Operand(esp, 0)); EmitLoadStoreICSlot(expr->LiteralFeedbackSlot()); Handle ic = CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); @@ -1711,7 +1710,6 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { // (inclusive) and these elements gets appended to the array. Note that the // number elements an iterable produces is unknown ahead of time. if (array_index < length && result_saved) { - __ Drop(1); // literal index __ Pop(eax); result_saved = false; } @@ -1732,7 +1730,6 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { } if (result_saved) { - __ Drop(1); // literal index context()->PlugTOS(); } else { context()->Plug(eax); diff --git a/src/full-codegen/mips/full-codegen-mips.cc b/src/full-codegen/mips/full-codegen-mips.cc index cded3e49da..5eeb73cf6f 100644 --- a/src/full-codegen/mips/full-codegen-mips.cc +++ b/src/full-codegen/mips/full-codegen-mips.cc @@ -1764,14 +1764,13 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { if (!result_saved) { __ push(v0); // array literal - __ Push(Smi::FromInt(expr->literal_index())); result_saved = true; } VisitForAccumulatorValue(subexpr); __ li(StoreDescriptor::NameRegister(), Operand(Smi::FromInt(array_index))); - __ lw(StoreDescriptor::ReceiverRegister(), MemOperand(sp, kPointerSize)); + __ lw(StoreDescriptor::ReceiverRegister(), MemOperand(sp, 0)); __ mov(StoreDescriptor::ValueRegister(), result_register()); EmitLoadStoreICSlot(expr->LiteralFeedbackSlot()); Handle ic = @@ -1787,7 +1786,6 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { // (inclusive) and these elements gets appended to the array. Note that the // number elements an iterable produces is unknown ahead of time. if (array_index < length && result_saved) { - __ Pop(); // literal index __ Pop(v0); result_saved = false; } @@ -1808,7 +1806,6 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { } if (result_saved) { - __ Pop(); // literal index context()->PlugTOS(); } else { context()->Plug(v0); diff --git a/src/full-codegen/mips64/full-codegen-mips64.cc b/src/full-codegen/mips64/full-codegen-mips64.cc index edc4f69f74..14ba8d21a2 100644 --- a/src/full-codegen/mips64/full-codegen-mips64.cc +++ b/src/full-codegen/mips64/full-codegen-mips64.cc @@ -1764,14 +1764,13 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { if (!result_saved) { __ push(v0); // array literal - __ Push(Smi::FromInt(expr->literal_index())); result_saved = true; } VisitForAccumulatorValue(subexpr); __ li(StoreDescriptor::NameRegister(), Operand(Smi::FromInt(array_index))); - __ ld(StoreDescriptor::ReceiverRegister(), MemOperand(sp, kPointerSize)); + __ ld(StoreDescriptor::ReceiverRegister(), MemOperand(sp, 0)); __ mov(StoreDescriptor::ValueRegister(), result_register()); EmitLoadStoreICSlot(expr->LiteralFeedbackSlot()); Handle ic = @@ -1787,7 +1786,6 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { // (inclusive) and these elements gets appended to the array. Note that the // number elements an iterable produces is unknown ahead of time. if (array_index < length && result_saved) { - __ Pop(); // literal index __ Pop(v0); result_saved = false; } @@ -1808,7 +1806,6 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { } if (result_saved) { - __ Pop(); // literal index context()->PlugTOS(); } else { context()->Plug(v0); diff --git a/src/full-codegen/x64/full-codegen-x64.cc b/src/full-codegen/x64/full-codegen-x64.cc index c181b6954c..c259c1e3c5 100644 --- a/src/full-codegen/x64/full-codegen-x64.cc +++ b/src/full-codegen/x64/full-codegen-x64.cc @@ -1715,13 +1715,12 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { if (!result_saved) { __ Push(rax); // array literal - __ Push(Smi::FromInt(expr->literal_index())); result_saved = true; } VisitForAccumulatorValue(subexpr); __ Move(StoreDescriptor::NameRegister(), Smi::FromInt(array_index)); - __ movp(StoreDescriptor::ReceiverRegister(), Operand(rsp, kPointerSize)); + __ movp(StoreDescriptor::ReceiverRegister(), Operand(rsp, 0)); EmitLoadStoreICSlot(expr->LiteralFeedbackSlot()); Handle ic = CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); @@ -1736,7 +1735,6 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { // (inclusive) and these elements gets appended to the array. Note that the // number elements an iterable produces is unknown ahead of time. if (array_index < length && result_saved) { - __ Drop(1); // literal index __ Pop(rax); result_saved = false; } @@ -1757,7 +1755,6 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { } if (result_saved) { - __ Drop(1); // literal index context()->PlugTOS(); } else { context()->Plug(rax);