OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_X64 | 5 #if V8_TARGET_ARCH_X64 |
6 | 6 |
7 #include "src/bootstrapper.h" | 7 #include "src/bootstrapper.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/ic/handler-compiler.h" | 10 #include "src/ic/handler-compiler.h" |
(...skipping 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1493 __ bind(&non_function); | 1493 __ bind(&non_function); |
1494 __ movp(rdx, rdi); | 1494 __ movp(rdx, rdi); |
1495 __ Jump(isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); | 1495 __ Jump(isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
1496 } | 1496 } |
1497 | 1497 |
1498 | 1498 |
1499 void CallICStub::HandleArrayCase(MacroAssembler* masm, Label* miss) { | 1499 void CallICStub::HandleArrayCase(MacroAssembler* masm, Label* miss) { |
1500 // rdi - function | 1500 // rdi - function |
1501 // rdx - slot id | 1501 // rdx - slot id |
1502 // rbx - vector | 1502 // rbx - vector |
| 1503 // rax - number of arguments if argc_in_register() is true. |
1503 // rcx - allocation site (loaded from vector[slot]). | 1504 // rcx - allocation site (loaded from vector[slot]). |
1504 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r8); | 1505 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r8); |
1505 __ cmpp(rdi, r8); | 1506 __ cmpp(rdi, r8); |
1506 __ j(not_equal, miss); | 1507 __ j(not_equal, miss); |
1507 | 1508 |
1508 __ movp(rax, Immediate(arg_count())); | |
1509 | |
1510 // Increment the call count for monomorphic function calls. | 1509 // Increment the call count for monomorphic function calls. |
1511 __ SmiAddConstant(FieldOperand(rbx, rdx, times_pointer_size, | 1510 __ SmiAddConstant(FieldOperand(rbx, rdx, times_pointer_size, |
1512 FixedArray::kHeaderSize + kPointerSize), | 1511 FixedArray::kHeaderSize + kPointerSize), |
1513 Smi::FromInt(CallICNexus::kCallCountIncrement)); | 1512 Smi::FromInt(CallICNexus::kCallCountIncrement)); |
1514 | 1513 |
1515 __ movp(rbx, rcx); | 1514 __ movp(rbx, rcx); |
1516 __ movp(rdx, rdi); | 1515 __ movp(rdx, rdi); |
1517 ArrayConstructorStub stub(masm->isolate(), arg_count()); | 1516 if (argc_in_register()) { |
1518 __ TailCallStub(&stub); | 1517 // Pass a default ArgumentCountKey::Any since the argc is only available |
| 1518 // in rax. We do not have the actual count here. |
| 1519 ArrayConstructorStub stub(masm->isolate()); |
| 1520 __ TailCallStub(&stub); |
| 1521 } else { |
| 1522 // arg_count() is expected in rax if the arg_count() >= 2 |
| 1523 // (ArgumentCountKey::MORE_THAN_ONE). |
| 1524 ArrayConstructorStub stub(masm->isolate(), arg_count()); |
| 1525 __ TailCallStub(&stub); |
| 1526 } |
1519 } | 1527 } |
1520 | 1528 |
1521 | 1529 |
1522 void CallICStub::Generate(MacroAssembler* masm) { | 1530 void CallICStub::Generate(MacroAssembler* masm) { |
1523 // ----------- S t a t e ------------- | 1531 // ----------- S t a t e ------------- |
1524 // -- rdi - function | 1532 // -- rdi - function |
1525 // -- rdx - slot id | 1533 // -- rdx - slot id |
1526 // -- rbx - vector | 1534 // -- rbx - vector |
| 1535 // -- rax - number of arguments if argc_in_register() is true. |
1527 // ----------------------------------- | 1536 // ----------------------------------- |
1528 Isolate* isolate = masm->isolate(); | 1537 Isolate* isolate = masm->isolate(); |
1529 Label extra_checks_or_miss, call, call_function; | 1538 Label extra_checks_or_miss, call, call_function; |
1530 int argc = arg_count(); | 1539 if (!argc_in_register()) { |
1531 StackArgumentsAccessor args(rsp, argc); | 1540 int argc = arg_count(); |
1532 ParameterCount actual(argc); | 1541 __ Set(rax, argc); |
| 1542 } |
1533 | 1543 |
1534 // The checks. First, does rdi match the recorded monomorphic target? | 1544 // The checks. First, does rdi match the recorded monomorphic target? |
1535 __ SmiToInteger32(rdx, rdx); | 1545 __ SmiToInteger32(rdx, rdx); |
1536 __ movp(rcx, | 1546 __ movp(rcx, |
1537 FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize)); | 1547 FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize)); |
1538 | 1548 |
1539 // We don't know that we have a weak cell. We might have a private symbol | 1549 // We don't know that we have a weak cell. We might have a private symbol |
1540 // or an AllocationSite, but the memory is safe to examine. | 1550 // or an AllocationSite, but the memory is safe to examine. |
1541 // AllocationSite::kTransitionInfoOffset - contains a Smi or pointer to | 1551 // AllocationSite::kTransitionInfoOffset - contains a Smi or pointer to |
1542 // FixedArray. | 1552 // FixedArray. |
(...skipping 13 matching lines...) Expand all Loading... |
1556 // The compare above could have been a SMI/SMI comparison. Guard against this | 1566 // The compare above could have been a SMI/SMI comparison. Guard against this |
1557 // convincing us that we have a monomorphic JSFunction. | 1567 // convincing us that we have a monomorphic JSFunction. |
1558 __ JumpIfSmi(rdi, &extra_checks_or_miss); | 1568 __ JumpIfSmi(rdi, &extra_checks_or_miss); |
1559 | 1569 |
1560 // Increment the call count for monomorphic function calls. | 1570 // Increment the call count for monomorphic function calls. |
1561 __ SmiAddConstant(FieldOperand(rbx, rdx, times_pointer_size, | 1571 __ SmiAddConstant(FieldOperand(rbx, rdx, times_pointer_size, |
1562 FixedArray::kHeaderSize + kPointerSize), | 1572 FixedArray::kHeaderSize + kPointerSize), |
1563 Smi::FromInt(CallICNexus::kCallCountIncrement)); | 1573 Smi::FromInt(CallICNexus::kCallCountIncrement)); |
1564 | 1574 |
1565 __ bind(&call_function); | 1575 __ bind(&call_function); |
1566 __ Set(rax, argc); | |
1567 __ Jump(masm->isolate()->builtins()->CallFunction(convert_mode(), | 1576 __ Jump(masm->isolate()->builtins()->CallFunction(convert_mode(), |
1568 tail_call_mode()), | 1577 tail_call_mode()), |
1569 RelocInfo::CODE_TARGET); | 1578 RelocInfo::CODE_TARGET); |
1570 | 1579 |
1571 __ bind(&extra_checks_or_miss); | 1580 __ bind(&extra_checks_or_miss); |
1572 Label uninitialized, miss, not_allocation_site; | 1581 Label uninitialized, miss, not_allocation_site; |
1573 | 1582 |
1574 __ Cmp(rcx, TypeFeedbackVector::MegamorphicSentinel(isolate)); | 1583 __ Cmp(rcx, TypeFeedbackVector::MegamorphicSentinel(isolate)); |
1575 __ j(equal, &call); | 1584 __ j(equal, &call); |
1576 | 1585 |
(...skipping 18 matching lines...) Expand all Loading... |
1595 | 1604 |
1596 // We are going megamorphic. If the feedback is a JSFunction, it is fine | 1605 // We are going megamorphic. If the feedback is a JSFunction, it is fine |
1597 // to handle it here. More complex cases are dealt with in the runtime. | 1606 // to handle it here. More complex cases are dealt with in the runtime. |
1598 __ AssertNotSmi(rcx); | 1607 __ AssertNotSmi(rcx); |
1599 __ CmpObjectType(rcx, JS_FUNCTION_TYPE, rcx); | 1608 __ CmpObjectType(rcx, JS_FUNCTION_TYPE, rcx); |
1600 __ j(not_equal, &miss); | 1609 __ j(not_equal, &miss); |
1601 __ Move(FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize), | 1610 __ Move(FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize), |
1602 TypeFeedbackVector::MegamorphicSentinel(isolate)); | 1611 TypeFeedbackVector::MegamorphicSentinel(isolate)); |
1603 | 1612 |
1604 __ bind(&call); | 1613 __ bind(&call); |
1605 __ Set(rax, argc); | |
1606 __ Jump(masm->isolate()->builtins()->Call(convert_mode(), tail_call_mode()), | 1614 __ Jump(masm->isolate()->builtins()->Call(convert_mode(), tail_call_mode()), |
1607 RelocInfo::CODE_TARGET); | 1615 RelocInfo::CODE_TARGET); |
1608 | 1616 |
1609 __ bind(&uninitialized); | 1617 __ bind(&uninitialized); |
1610 | 1618 |
1611 // We are going monomorphic, provided we actually have a JSFunction. | 1619 // We are going monomorphic, provided we actually have a JSFunction. |
1612 __ JumpIfSmi(rdi, &miss); | 1620 __ JumpIfSmi(rdi, &miss); |
1613 | 1621 |
1614 // Goto miss case if we do not have a function. | 1622 // Goto miss case if we do not have a function. |
1615 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); | 1623 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); |
(...skipping 17 matching lines...) Expand all Loading... |
1633 Smi::FromInt(CallICNexus::kCallCountIncrement)); | 1641 Smi::FromInt(CallICNexus::kCallCountIncrement)); |
1634 | 1642 |
1635 // Store the function. Use a stub since we need a frame for allocation. | 1643 // Store the function. Use a stub since we need a frame for allocation. |
1636 // rbx - vector | 1644 // rbx - vector |
1637 // rdx - slot (needs to be in smi form) | 1645 // rdx - slot (needs to be in smi form) |
1638 // rdi - function | 1646 // rdi - function |
1639 { | 1647 { |
1640 FrameScope scope(masm, StackFrame::INTERNAL); | 1648 FrameScope scope(masm, StackFrame::INTERNAL); |
1641 CreateWeakCellStub create_stub(isolate); | 1649 CreateWeakCellStub create_stub(isolate); |
1642 | 1650 |
| 1651 __ Integer32ToSmi(rax, rax); |
| 1652 __ Push(rax); |
1643 __ Integer32ToSmi(rdx, rdx); | 1653 __ Integer32ToSmi(rdx, rdx); |
1644 __ Push(rdi); | 1654 __ Push(rdi); |
| 1655 |
1645 __ CallStub(&create_stub); | 1656 __ CallStub(&create_stub); |
| 1657 |
1646 __ Pop(rdi); | 1658 __ Pop(rdi); |
| 1659 __ Pop(rax); |
| 1660 __ SmiToInteger32(rax, rax); |
1647 } | 1661 } |
1648 | 1662 |
1649 __ jmp(&call_function); | 1663 __ jmp(&call_function); |
1650 | 1664 |
1651 // We are here because tracing is on or we encountered a MISS case we can't | 1665 // We are here because tracing is on or we encountered a MISS case we can't |
1652 // handle here. | 1666 // handle here. |
1653 __ bind(&miss); | 1667 __ bind(&miss); |
1654 GenerateMiss(masm); | 1668 GenerateMiss(masm); |
1655 | 1669 |
1656 __ jmp(&call); | 1670 __ jmp(&call); |
1657 | 1671 |
1658 // Unreachable | 1672 // Unreachable |
1659 __ int3(); | 1673 __ int3(); |
1660 } | 1674 } |
1661 | 1675 |
1662 | 1676 |
1663 void CallICStub::GenerateMiss(MacroAssembler* masm) { | 1677 void CallICStub::GenerateMiss(MacroAssembler* masm) { |
1664 FrameScope scope(masm, StackFrame::INTERNAL); | 1678 FrameScope scope(masm, StackFrame::INTERNAL); |
1665 | 1679 |
| 1680 // Store the number of arguments to be used later. |
| 1681 __ Integer32ToSmi(rax, rax); |
| 1682 __ Push(rax); |
| 1683 |
1666 // Push the receiver and the function and feedback info. | 1684 // Push the receiver and the function and feedback info. |
1667 __ Push(rdi); | 1685 __ Push(rdi); |
1668 __ Push(rbx); | 1686 __ Push(rbx); |
1669 __ Integer32ToSmi(rdx, rdx); | 1687 __ Integer32ToSmi(rdx, rdx); |
1670 __ Push(rdx); | 1688 __ Push(rdx); |
1671 | 1689 |
1672 // Call the entry. | 1690 // Call the entry. |
1673 __ CallRuntime(Runtime::kCallIC_Miss); | 1691 __ CallRuntime(Runtime::kCallIC_Miss); |
1674 | 1692 |
1675 // Move result to edi and exit the internal frame. | 1693 // Move result to edi and exit the internal frame. |
1676 __ movp(rdi, rax); | 1694 __ movp(rdi, rax); |
| 1695 // rdi, rbx, rdx are arguments to CallIC_Miss. They will be popped by |
| 1696 // Runtime_CallIC_Miss. |
| 1697 __ Pop(rax); |
| 1698 __ SmiToInteger32(rax, rax); |
1677 } | 1699 } |
1678 | 1700 |
1679 | 1701 |
1680 bool CEntryStub::NeedsImmovableCode() { | 1702 bool CEntryStub::NeedsImmovableCode() { |
1681 return false; | 1703 return false; |
1682 } | 1704 } |
1683 | 1705 |
1684 | 1706 |
1685 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { | 1707 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { |
1686 CEntryStub::GenerateAheadOfTime(isolate); | 1708 CEntryStub::GenerateAheadOfTime(isolate); |
(...skipping 3949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5636 NULL); | 5658 NULL); |
5637 } | 5659 } |
5638 | 5660 |
5639 | 5661 |
5640 #undef __ | 5662 #undef __ |
5641 | 5663 |
5642 } // namespace internal | 5664 } // namespace internal |
5643 } // namespace v8 | 5665 } // namespace v8 |
5644 | 5666 |
5645 #endif // V8_TARGET_ARCH_X64 | 5667 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |