[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}
This commit is contained in:
bmeurer 2015-11-24 05:03:57 -08:00 committed by Commit bot
parent a19f2d7eca
commit 9846f386f0
8 changed files with 10 additions and 33 deletions

View File

@ -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;

View File

@ -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<HConstant>(expr->literal_index()));
HInstruction* elements = NULL;
@ -6117,7 +6115,6 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
Add<HSimulate>(expr->GetIdForElement(i));
}
Drop(1); // array literal index
return ast_context()->ReturnValue(Pop());
}

View File

@ -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<Code> 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);

View File

@ -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<Code> 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);

View File

@ -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<Code> 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);

View File

@ -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<Code> 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);

View File

@ -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<Code> 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);

View File

@ -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<Code> 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);