| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #if V8_TARGET_ARCH_X87 | 5 #if V8_TARGET_ARCH_X87 |
| 6 | 6 |
| 7 #include "src/full-codegen/full-codegen.h" | 7 #include "src/full-codegen/full-codegen.h" |
| 8 #include "src/ast/compile-time-value.h" | 8 #include "src/ast/compile-time-value.h" |
| 9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
| 10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
| (...skipping 1483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1494 __ CallStub(&stub); | 1494 __ CallStub(&stub); |
| 1495 } | 1495 } |
| 1496 PrepareForBailoutForId(expr->CreateLiteralId(), BailoutState::TOS_REGISTER); | 1496 PrepareForBailoutForId(expr->CreateLiteralId(), BailoutState::TOS_REGISTER); |
| 1497 | 1497 |
| 1498 bool result_saved = false; // Is the result saved to the stack? | 1498 bool result_saved = false; // Is the result saved to the stack? |
| 1499 ZoneList<Expression*>* subexprs = expr->values(); | 1499 ZoneList<Expression*>* subexprs = expr->values(); |
| 1500 int length = subexprs->length(); | 1500 int length = subexprs->length(); |
| 1501 | 1501 |
| 1502 // Emit code to evaluate all the non-constant subexpressions and to store | 1502 // Emit code to evaluate all the non-constant subexpressions and to store |
| 1503 // them into the newly cloned array. | 1503 // them into the newly cloned array. |
| 1504 int array_index = 0; | 1504 for (int array_index = 0; array_index < length; array_index++) { |
| 1505 for (; array_index < length; array_index++) { | |
| 1506 Expression* subexpr = subexprs->at(array_index); | 1505 Expression* subexpr = subexprs->at(array_index); |
| 1507 DCHECK(!subexpr->IsSpread()); | 1506 DCHECK(!subexpr->IsSpread()); |
| 1508 | 1507 |
| 1509 // If the subexpression is a literal or a simple materialized literal it | 1508 // If the subexpression is a literal or a simple materialized literal it |
| 1510 // is already set in the cloned array. | 1509 // is already set in the cloned array. |
| 1511 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; | 1510 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; |
| 1512 | 1511 |
| 1513 if (!result_saved) { | 1512 if (!result_saved) { |
| 1514 PushOperand(eax); // array literal. | 1513 PushOperand(eax); // array literal. |
| 1515 result_saved = true; | 1514 result_saved = true; |
| 1516 } | 1515 } |
| 1517 VisitForAccumulatorValue(subexpr); | 1516 VisitForAccumulatorValue(subexpr); |
| 1518 | 1517 |
| 1519 __ mov(StoreDescriptor::NameRegister(), | 1518 __ mov(StoreDescriptor::NameRegister(), |
| 1520 Immediate(Smi::FromInt(array_index))); | 1519 Immediate(Smi::FromInt(array_index))); |
| 1521 __ mov(StoreDescriptor::ReceiverRegister(), Operand(esp, 0)); | 1520 __ mov(StoreDescriptor::ReceiverRegister(), Operand(esp, 0)); |
| 1522 EmitLoadStoreICSlot(expr->LiteralFeedbackSlot()); | 1521 EmitLoadStoreICSlot(expr->LiteralFeedbackSlot()); |
| 1523 CallKeyedStoreIC(); | 1522 CallKeyedStoreIC(); |
| 1524 PrepareForBailoutForId(expr->GetIdForElement(array_index), | 1523 PrepareForBailoutForId(expr->GetIdForElement(array_index), |
| 1525 BailoutState::NO_REGISTERS); | 1524 BailoutState::NO_REGISTERS); |
| 1526 } | 1525 } |
| 1527 | 1526 |
| 1528 // In case the array literal contains spread expressions it has two parts. The | |
| 1529 // first part is the "static" array which has a literal index is handled | |
| 1530 // above. The second part is the part after the first spread expression | |
| 1531 // (inclusive) and these elements gets appended to the array. Note that the | |
| 1532 // number elements an iterable produces is unknown ahead of time. | |
| 1533 if (array_index < length && result_saved) { | |
| 1534 PopOperand(eax); | |
| 1535 result_saved = false; | |
| 1536 } | |
| 1537 for (; array_index < length; array_index++) { | |
| 1538 Expression* subexpr = subexprs->at(array_index); | |
| 1539 | |
| 1540 PushOperand(eax); | |
| 1541 DCHECK(!subexpr->IsSpread()); | |
| 1542 VisitForStackValue(subexpr); | |
| 1543 CallRuntimeWithOperands(Runtime::kAppendElement); | |
| 1544 | |
| 1545 PrepareForBailoutForId(expr->GetIdForElement(array_index), | |
| 1546 BailoutState::NO_REGISTERS); | |
| 1547 } | |
| 1548 | |
| 1549 if (result_saved) { | 1527 if (result_saved) { |
| 1550 context()->PlugTOS(); | 1528 context()->PlugTOS(); |
| 1551 } else { | 1529 } else { |
| 1552 context()->Plug(eax); | 1530 context()->Plug(eax); |
| 1553 } | 1531 } |
| 1554 } | 1532 } |
| 1555 | 1533 |
| 1556 | 1534 |
| 1557 void FullCodeGenerator::VisitAssignment(Assignment* expr) { | 1535 void FullCodeGenerator::VisitAssignment(Assignment* expr) { |
| 1558 DCHECK(expr->target()->IsValidReferenceExpressionOrThis()); | 1536 DCHECK(expr->target()->IsValidReferenceExpressionOrThis()); |
| (...skipping 2060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3619 isolate->builtins()->OnStackReplacement()->entry(), | 3597 isolate->builtins()->OnStackReplacement()->entry(), |
| 3620 Assembler::target_address_at(call_target_address, unoptimized_code)); | 3598 Assembler::target_address_at(call_target_address, unoptimized_code)); |
| 3621 return ON_STACK_REPLACEMENT; | 3599 return ON_STACK_REPLACEMENT; |
| 3622 } | 3600 } |
| 3623 | 3601 |
| 3624 | 3602 |
| 3625 } // namespace internal | 3603 } // namespace internal |
| 3626 } // namespace v8 | 3604 } // namespace v8 |
| 3627 | 3605 |
| 3628 #endif // V8_TARGET_ARCH_X87 | 3606 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |