| 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_X64 | 5 #if V8_TARGET_ARCH_X64 |
| 6 | 6 |
| 7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
| 8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
| 9 #include "src/counters.h" | 9 #include "src/counters.h" |
| 10 #include "src/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
| (...skipping 1567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1578 __ PushReturnAddressFrom(rcx); | 1578 __ PushReturnAddressFrom(rcx); |
| 1579 } | 1579 } |
| 1580 | 1580 |
| 1581 // ----------- S t a t e ------------- | 1581 // ----------- S t a t e ------------- |
| 1582 // -- rbx : argArray | 1582 // -- rbx : argArray |
| 1583 // -- rdi : receiver | 1583 // -- rdi : receiver |
| 1584 // -- rsp[0] : return address | 1584 // -- rsp[0] : return address |
| 1585 // -- rsp[8] : thisArg | 1585 // -- rsp[8] : thisArg |
| 1586 // ----------------------------------- | 1586 // ----------------------------------- |
| 1587 | 1587 |
| 1588 // 2. Make sure the receiver is actually callable. | 1588 // 2. We don't need to check explicitly for callable receiver here, |
| 1589 Label receiver_not_callable; | 1589 // since that's the first thing the Call/CallWithArrayLike builtins |
| 1590 __ JumpIfSmi(rdi, &receiver_not_callable, Label::kNear); | 1590 // will do. |
| 1591 __ movp(rcx, FieldOperand(rdi, HeapObject::kMapOffset)); | |
| 1592 __ testb(FieldOperand(rcx, Map::kBitFieldOffset), | |
| 1593 Immediate(1 << Map::kIsCallable)); | |
| 1594 __ j(zero, &receiver_not_callable, Label::kNear); | |
| 1595 | 1591 |
| 1596 // 3. Tail call with no arguments if argArray is null or undefined. | 1592 // 3. Tail call with no arguments if argArray is null or undefined. |
| 1597 Label no_arguments; | 1593 Label no_arguments; |
| 1598 __ JumpIfRoot(rbx, Heap::kNullValueRootIndex, &no_arguments, Label::kNear); | 1594 __ JumpIfRoot(rbx, Heap::kNullValueRootIndex, &no_arguments, Label::kNear); |
| 1599 __ JumpIfRoot(rbx, Heap::kUndefinedValueRootIndex, &no_arguments, | 1595 __ JumpIfRoot(rbx, Heap::kUndefinedValueRootIndex, &no_arguments, |
| 1600 Label::kNear); | 1596 Label::kNear); |
| 1601 | 1597 |
| 1602 // 4a. Apply the receiver to the given argArray. | 1598 // 4a. Apply the receiver to the given argArray. |
| 1603 __ Jump(masm->isolate()->builtins()->CallWithArrayLike(), | 1599 __ Jump(masm->isolate()->builtins()->CallWithArrayLike(), |
| 1604 RelocInfo::CODE_TARGET); | 1600 RelocInfo::CODE_TARGET); |
| 1605 | 1601 |
| 1606 // 4b. The argArray is either null or undefined, so we tail call without any | 1602 // 4b. The argArray is either null or undefined, so we tail call without any |
| 1607 // arguments to the receiver. Since we did not create a frame for | 1603 // arguments to the receiver. Since we did not create a frame for |
| 1608 // Function.prototype.apply() yet, we use a normal Call builtin here. | 1604 // Function.prototype.apply() yet, we use a normal Call builtin here. |
| 1609 __ bind(&no_arguments); | 1605 __ bind(&no_arguments); |
| 1610 { | 1606 { |
| 1611 __ Set(rax, 0); | 1607 __ Set(rax, 0); |
| 1612 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 1608 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
| 1613 } | 1609 } |
| 1614 | |
| 1615 // 4c. The receiver is not callable, throw an appropriate TypeError. | |
| 1616 __ bind(&receiver_not_callable); | |
| 1617 { | |
| 1618 StackArgumentsAccessor args(rsp, 0); | |
| 1619 __ movp(args.GetReceiverOperand(), rdi); | |
| 1620 __ TailCallRuntime(Runtime::kThrowApplyNonFunction); | |
| 1621 } | |
| 1622 } | 1610 } |
| 1623 | 1611 |
| 1624 // static | 1612 // static |
| 1625 void Builtins::Generate_FunctionPrototypeCall(MacroAssembler* masm) { | 1613 void Builtins::Generate_FunctionPrototypeCall(MacroAssembler* masm) { |
| 1626 // Stack Layout: | 1614 // Stack Layout: |
| 1627 // rsp[0] : Return address | 1615 // rsp[0] : Return address |
| 1628 // rsp[8] : Argument n | 1616 // rsp[8] : Argument n |
| 1629 // rsp[16] : Argument n-1 | 1617 // rsp[16] : Argument n-1 |
| 1630 // ... | 1618 // ... |
| 1631 // rsp[8 * n] : Argument 1 | 1619 // rsp[8 * n] : Argument 1 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1707 __ PushReturnAddressFrom(rcx); | 1695 __ PushReturnAddressFrom(rcx); |
| 1708 } | 1696 } |
| 1709 | 1697 |
| 1710 // ----------- S t a t e ------------- | 1698 // ----------- S t a t e ------------- |
| 1711 // -- rbx : argumentsList | 1699 // -- rbx : argumentsList |
| 1712 // -- rdi : target | 1700 // -- rdi : target |
| 1713 // -- rsp[0] : return address | 1701 // -- rsp[0] : return address |
| 1714 // -- rsp[8] : thisArgument | 1702 // -- rsp[8] : thisArgument |
| 1715 // ----------------------------------- | 1703 // ----------------------------------- |
| 1716 | 1704 |
| 1717 // 2. Make sure the target is actually callable. | 1705 // 2. We don't need to check explicitly for callable target here, |
| 1718 Label target_not_callable; | 1706 // since that's the first thing the Call/CallWithArrayLike builtins |
| 1719 __ JumpIfSmi(rdi, &target_not_callable, Label::kNear); | 1707 // will do. |
| 1720 __ movp(rcx, FieldOperand(rdi, HeapObject::kMapOffset)); | |
| 1721 __ testb(FieldOperand(rcx, Map::kBitFieldOffset), | |
| 1722 Immediate(1 << Map::kIsCallable)); | |
| 1723 __ j(zero, &target_not_callable, Label::kNear); | |
| 1724 | 1708 |
| 1725 // 3a. Apply the target to the given argumentsList. | 1709 // 3. Apply the target to the given argumentsList. |
| 1726 __ Jump(masm->isolate()->builtins()->CallWithArrayLike(), | 1710 __ Jump(masm->isolate()->builtins()->CallWithArrayLike(), |
| 1727 RelocInfo::CODE_TARGET); | 1711 RelocInfo::CODE_TARGET); |
| 1728 | |
| 1729 // 3b. The target is not callable, throw an appropriate TypeError. | |
| 1730 __ bind(&target_not_callable); | |
| 1731 { | |
| 1732 StackArgumentsAccessor args(rsp, 0); | |
| 1733 __ movp(args.GetReceiverOperand(), rdi); | |
| 1734 __ TailCallRuntime(Runtime::kThrowApplyNonFunction); | |
| 1735 } | |
| 1736 } | 1712 } |
| 1737 | 1713 |
| 1738 void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) { | 1714 void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) { |
| 1739 // ----------- S t a t e ------------- | 1715 // ----------- S t a t e ------------- |
| 1740 // -- rax : argc | 1716 // -- rax : argc |
| 1741 // -- rsp[0] : return address | 1717 // -- rsp[0] : return address |
| 1742 // -- rsp[8] : new.target (optional) | 1718 // -- rsp[8] : new.target (optional) |
| 1743 // -- rsp[16] : argumentsList | 1719 // -- rsp[16] : argumentsList |
| 1744 // -- rsp[24] : target | 1720 // -- rsp[24] : target |
| 1745 // -- rsp[32] : receiver | 1721 // -- rsp[32] : receiver |
| (...skipping 1464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3210 // Now jump to the instructions of the returned code object. | 3186 // Now jump to the instructions of the returned code object. |
| 3211 __ jmp(r11); | 3187 __ jmp(r11); |
| 3212 } | 3188 } |
| 3213 | 3189 |
| 3214 #undef __ | 3190 #undef __ |
| 3215 | 3191 |
| 3216 } // namespace internal | 3192 } // namespace internal |
| 3217 } // namespace v8 | 3193 } // namespace v8 |
| 3218 | 3194 |
| 3219 #endif // V8_TARGET_ARCH_X64 | 3195 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |