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