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/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 1645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1656 __ bind(&loop); | 1656 __ bind(&loop); |
1657 { | 1657 { |
1658 // Check if all parameters done. | 1658 // Check if all parameters done. |
1659 __ testp(rcx, rcx); | 1659 __ testp(rcx, rcx); |
1660 __ j(zero, &done_loop); | 1660 __ j(zero, &done_loop); |
1661 | 1661 |
1662 // Load the next parameter tagged value into rbx. | 1662 // Load the next parameter tagged value into rbx. |
1663 __ movp(rbx, Operand(rsp, rcx, times_pointer_size, 0)); | 1663 __ movp(rbx, Operand(rsp, rcx, times_pointer_size, 0)); |
1664 | 1664 |
1665 // Load the double value of the parameter into xmm1, maybe converting the | 1665 // Load the double value of the parameter into xmm1, maybe converting the |
1666 // parameter to a number first using the ToNumberStub if necessary. | 1666 // parameter to a number first using the ToNumber builtin if necessary. |
1667 Label convert, convert_smi, convert_number, done_convert; | 1667 Label convert, convert_smi, convert_number, done_convert; |
1668 __ bind(&convert); | 1668 __ bind(&convert); |
1669 __ JumpIfSmi(rbx, &convert_smi); | 1669 __ JumpIfSmi(rbx, &convert_smi); |
1670 __ JumpIfRoot(FieldOperand(rbx, HeapObject::kMapOffset), | 1670 __ JumpIfRoot(FieldOperand(rbx, HeapObject::kMapOffset), |
1671 Heap::kHeapNumberMapRootIndex, &convert_number); | 1671 Heap::kHeapNumberMapRootIndex, &convert_number); |
1672 { | 1672 { |
1673 // Parameter is not a Number, use the ToNumberStub to convert it. | 1673 // Parameter is not a Number, use the ToNumber builtin to convert it. |
1674 FrameScope scope(masm, StackFrame::INTERNAL); | 1674 FrameScope scope(masm, StackFrame::INTERNAL); |
1675 __ Integer32ToSmi(rax, rax); | 1675 __ Integer32ToSmi(rax, rax); |
1676 __ Integer32ToSmi(rcx, rcx); | 1676 __ Integer32ToSmi(rcx, rcx); |
1677 __ Push(rax); | 1677 __ Push(rax); |
1678 __ Push(rcx); | 1678 __ Push(rcx); |
1679 __ Push(rdx); | 1679 __ Push(rdx); |
1680 __ movp(rax, rbx); | 1680 __ movp(rax, rbx); |
1681 ToNumberStub stub(masm->isolate()); | 1681 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET); |
1682 __ CallStub(&stub); | |
1683 __ movp(rbx, rax); | 1682 __ movp(rbx, rax); |
1684 __ Pop(rdx); | 1683 __ Pop(rdx); |
1685 __ Pop(rcx); | 1684 __ Pop(rcx); |
1686 __ Pop(rax); | 1685 __ Pop(rax); |
1687 { | 1686 { |
1688 // Restore the double accumulator value (xmm0). | 1687 // Restore the double accumulator value (xmm0). |
1689 Label restore_smi, done_restore; | 1688 Label restore_smi, done_restore; |
1690 __ JumpIfSmi(rdx, &restore_smi, Label::kNear); | 1689 __ JumpIfSmi(rdx, &restore_smi, Label::kNear); |
1691 __ Movsd(xmm0, FieldOperand(rdx, HeapNumber::kValueOffset)); | 1690 __ Movsd(xmm0, FieldOperand(rdx, HeapNumber::kValueOffset)); |
1692 __ jmp(&done_restore, Label::kNear); | 1691 __ jmp(&done_restore, Label::kNear); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1762 __ testp(rax, rax); | 1761 __ testp(rax, rax); |
1763 __ j(zero, &no_arguments, Label::kNear); | 1762 __ j(zero, &no_arguments, Label::kNear); |
1764 __ movp(rbx, args.GetArgumentOperand(1)); | 1763 __ movp(rbx, args.GetArgumentOperand(1)); |
1765 __ PopReturnAddressTo(rcx); | 1764 __ PopReturnAddressTo(rcx); |
1766 __ leap(rsp, Operand(rsp, rax, times_pointer_size, kPointerSize)); | 1765 __ leap(rsp, Operand(rsp, rax, times_pointer_size, kPointerSize)); |
1767 __ PushReturnAddressFrom(rcx); | 1766 __ PushReturnAddressFrom(rcx); |
1768 __ movp(rax, rbx); | 1767 __ movp(rax, rbx); |
1769 } | 1768 } |
1770 | 1769 |
1771 // 2a. Convert the first argument to a number. | 1770 // 2a. Convert the first argument to a number. |
1772 ToNumberStub stub(masm->isolate()); | 1771 __ Jump(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET); |
1773 __ TailCallStub(&stub); | |
1774 | 1772 |
1775 // 2b. No arguments, return +0 (already in rax). | 1773 // 2b. No arguments, return +0 (already in rax). |
1776 __ bind(&no_arguments); | 1774 __ bind(&no_arguments); |
1777 __ ret(1 * kPointerSize); | 1775 __ ret(1 * kPointerSize); |
1778 } | 1776 } |
1779 | 1777 |
1780 | 1778 |
1781 // static | 1779 // static |
1782 void Builtins::Generate_NumberConstructor_ConstructStub(MacroAssembler* masm) { | 1780 void Builtins::Generate_NumberConstructor_ConstructStub(MacroAssembler* masm) { |
1783 // ----------- S t a t e ------------- | 1781 // ----------- S t a t e ------------- |
(...skipping 30 matching lines...) Expand all Loading... |
1814 Label done_convert; | 1812 Label done_convert; |
1815 __ JumpIfSmi(rbx, &done_convert); | 1813 __ JumpIfSmi(rbx, &done_convert); |
1816 __ CompareRoot(FieldOperand(rbx, HeapObject::kMapOffset), | 1814 __ CompareRoot(FieldOperand(rbx, HeapObject::kMapOffset), |
1817 Heap::kHeapNumberMapRootIndex); | 1815 Heap::kHeapNumberMapRootIndex); |
1818 __ j(equal, &done_convert); | 1816 __ j(equal, &done_convert); |
1819 { | 1817 { |
1820 FrameScope scope(masm, StackFrame::INTERNAL); | 1818 FrameScope scope(masm, StackFrame::INTERNAL); |
1821 __ Push(rdx); | 1819 __ Push(rdx); |
1822 __ Push(rdi); | 1820 __ Push(rdi); |
1823 __ Move(rax, rbx); | 1821 __ Move(rax, rbx); |
1824 ToNumberStub stub(masm->isolate()); | 1822 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET); |
1825 __ CallStub(&stub); | |
1826 __ Move(rbx, rax); | 1823 __ Move(rbx, rax); |
1827 __ Pop(rdi); | 1824 __ Pop(rdi); |
1828 __ Pop(rdx); | 1825 __ Pop(rdx); |
1829 } | 1826 } |
1830 __ bind(&done_convert); | 1827 __ bind(&done_convert); |
1831 } | 1828 } |
1832 | 1829 |
1833 // 4. Check if new target and constructor differ. | 1830 // 4. Check if new target and constructor differ. |
1834 Label new_object; | 1831 Label new_object; |
1835 __ cmpp(rdx, rdi); | 1832 __ cmpp(rdx, rdi); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2089 __ IndexFromHash(rax, rax); | 2086 __ IndexFromHash(rax, rax); |
2090 __ Ret(); | 2087 __ Ret(); |
2091 | 2088 |
2092 __ bind(&runtime); | 2089 __ bind(&runtime); |
2093 __ PopReturnAddressTo(rcx); // Pop return address. | 2090 __ PopReturnAddressTo(rcx); // Pop return address. |
2094 __ Push(rax); // Push argument. | 2091 __ Push(rax); // Push argument. |
2095 __ PushReturnAddressFrom(rcx); // Push return address. | 2092 __ PushReturnAddressFrom(rcx); // Push return address. |
2096 __ TailCallRuntime(Runtime::kStringToNumber); | 2093 __ TailCallRuntime(Runtime::kStringToNumber); |
2097 } | 2094 } |
2098 | 2095 |
| 2096 // static |
| 2097 void Builtins::Generate_ToNumber(MacroAssembler* masm) { |
| 2098 // The ToNumber stub takes one argument in rax. |
| 2099 Label not_smi; |
| 2100 __ JumpIfNotSmi(rax, ¬_smi, Label::kNear); |
| 2101 __ Ret(); |
| 2102 __ bind(¬_smi); |
| 2103 |
| 2104 Label not_heap_number; |
| 2105 __ CompareRoot(FieldOperand(rax, HeapObject::kMapOffset), |
| 2106 Heap::kHeapNumberMapRootIndex); |
| 2107 __ j(not_equal, ¬_heap_number, Label::kNear); |
| 2108 __ Ret(); |
| 2109 __ bind(¬_heap_number); |
| 2110 |
| 2111 __ Jump(masm->isolate()->builtins()->NonNumberToNumber(), |
| 2112 RelocInfo::CODE_TARGET); |
| 2113 } |
| 2114 |
| 2115 // static |
| 2116 void Builtins::Generate_NonNumberToNumber(MacroAssembler* masm) { |
| 2117 // The NonNumberToNumber stub takes one argument in rax. |
| 2118 __ AssertNotNumber(rax); |
| 2119 |
| 2120 Label not_string; |
| 2121 __ CmpObjectType(rax, FIRST_NONSTRING_TYPE, rdi); |
| 2122 // rax: object |
| 2123 // rdi: object map |
| 2124 __ j(above_equal, ¬_string, Label::kNear); |
| 2125 __ Jump(masm->isolate()->builtins()->StringToNumber(), |
| 2126 RelocInfo::CODE_TARGET); |
| 2127 __ bind(¬_string); |
| 2128 |
| 2129 Label not_oddball; |
| 2130 __ CmpInstanceType(rdi, ODDBALL_TYPE); |
| 2131 __ j(not_equal, ¬_oddball, Label::kNear); |
| 2132 __ movp(rax, FieldOperand(rax, Oddball::kToNumberOffset)); |
| 2133 __ Ret(); |
| 2134 __ bind(¬_oddball); |
| 2135 |
| 2136 __ PopReturnAddressTo(rcx); // Pop return address. |
| 2137 __ Push(rax); // Push argument. |
| 2138 __ PushReturnAddressFrom(rcx); // Push return address. |
| 2139 __ TailCallRuntime(Runtime::kToNumber); |
| 2140 } |
| 2141 |
2099 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { | 2142 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { |
2100 // ----------- S t a t e ------------- | 2143 // ----------- S t a t e ------------- |
2101 // -- rax : actual number of arguments | 2144 // -- rax : actual number of arguments |
2102 // -- rbx : expected number of arguments | 2145 // -- rbx : expected number of arguments |
2103 // -- rdx : new target (passed through to callee) | 2146 // -- rdx : new target (passed through to callee) |
2104 // -- rdi : function (passed through to callee) | 2147 // -- rdi : function (passed through to callee) |
2105 // ----------------------------------- | 2148 // ----------------------------------- |
2106 | 2149 |
2107 Label invoke, dont_adapt_arguments, stack_overflow; | 2150 Label invoke, dont_adapt_arguments, stack_overflow; |
2108 Counters* counters = masm->isolate()->counters(); | 2151 Counters* counters = masm->isolate()->counters(); |
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2981 __ ret(0); | 3024 __ ret(0); |
2982 } | 3025 } |
2983 | 3026 |
2984 | 3027 |
2985 #undef __ | 3028 #undef __ |
2986 | 3029 |
2987 } // namespace internal | 3030 } // namespace internal |
2988 } // namespace v8 | 3031 } // namespace v8 |
2989 | 3032 |
2990 #endif // V8_TARGET_ARCH_X64 | 3033 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |