| 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/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 1668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1679 } | 1679 } |
| 1680 | 1680 |
| 1681 // Run the native code for the Array function called as a normal function. | 1681 // Run the native code for the Array function called as a normal function. |
| 1682 // tail call a stub | 1682 // tail call a stub |
| 1683 __ mov(ebx, masm->isolate()->factory()->undefined_value()); | 1683 __ mov(ebx, masm->isolate()->factory()->undefined_value()); |
| 1684 ArrayConstructorStub stub(masm->isolate()); | 1684 ArrayConstructorStub stub(masm->isolate()); |
| 1685 __ TailCallStub(&stub); | 1685 __ TailCallStub(&stub); |
| 1686 } | 1686 } |
| 1687 | 1687 |
| 1688 // static | 1688 // static |
| 1689 void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) { | |
| 1690 // ----------- S t a t e ------------- | |
| 1691 // -- eax : number of arguments | |
| 1692 // -- edi : function | |
| 1693 // -- esi : context | |
| 1694 // -- esp[0] : return address | |
| 1695 // -- esp[(argc - n) * 8] : arg[n] (zero-based) | |
| 1696 // -- esp[(argc + 1) * 8] : receiver | |
| 1697 // ----------------------------------- | |
| 1698 Condition const cc = (kind == MathMaxMinKind::kMin) ? below : above; | |
| 1699 Heap::RootListIndex const root_index = | |
| 1700 (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex | |
| 1701 : Heap::kMinusInfinityValueRootIndex; | |
| 1702 const int reg_sel = (kind == MathMaxMinKind::kMin) ? 1 : 0; | |
| 1703 | |
| 1704 // Load the accumulator with the default return value (either -Infinity or | |
| 1705 // +Infinity), with the tagged value in edx and the double value in stx_0. | |
| 1706 __ LoadRoot(edx, root_index); | |
| 1707 __ fld_d(FieldOperand(edx, HeapNumber::kValueOffset)); | |
| 1708 __ Move(ecx, eax); | |
| 1709 | |
| 1710 Label done_loop, loop; | |
| 1711 __ bind(&loop); | |
| 1712 { | |
| 1713 // Check if all parameters done. | |
| 1714 __ test(ecx, ecx); | |
| 1715 __ j(zero, &done_loop); | |
| 1716 | |
| 1717 // Load the next parameter tagged value into ebx. | |
| 1718 __ mov(ebx, Operand(esp, ecx, times_pointer_size, 0)); | |
| 1719 | |
| 1720 // Load the double value of the parameter into stx_1, maybe converting the | |
| 1721 // parameter to a number first using the ToNumber builtin if necessary. | |
| 1722 Label convert, convert_smi, convert_number, done_convert; | |
| 1723 __ bind(&convert); | |
| 1724 __ JumpIfSmi(ebx, &convert_smi); | |
| 1725 __ JumpIfRoot(FieldOperand(ebx, HeapObject::kMapOffset), | |
| 1726 Heap::kHeapNumberMapRootIndex, &convert_number); | |
| 1727 { | |
| 1728 // Parameter is not a Number, use the ToNumber builtin to convert it. | |
| 1729 FrameScope scope(masm, StackFrame::MANUAL); | |
| 1730 __ SmiTag(eax); | |
| 1731 __ SmiTag(ecx); | |
| 1732 __ EnterBuiltinFrame(esi, edi, eax); | |
| 1733 __ Push(ecx); | |
| 1734 __ Push(edx); | |
| 1735 __ mov(eax, ebx); | |
| 1736 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET); | |
| 1737 __ mov(ebx, eax); | |
| 1738 __ Pop(edx); | |
| 1739 __ Pop(ecx); | |
| 1740 __ LeaveBuiltinFrame(esi, edi, eax); | |
| 1741 __ SmiUntag(ecx); | |
| 1742 __ SmiUntag(eax); | |
| 1743 { | |
| 1744 // Restore the double accumulator value (stX_0). | |
| 1745 Label restore_smi, done_restore; | |
| 1746 __ JumpIfSmi(edx, &restore_smi, Label::kNear); | |
| 1747 __ fld_d(FieldOperand(edx, HeapNumber::kValueOffset)); | |
| 1748 __ jmp(&done_restore, Label::kNear); | |
| 1749 __ bind(&restore_smi); | |
| 1750 __ SmiUntag(edx); | |
| 1751 __ push(edx); | |
| 1752 __ fild_s(Operand(esp, 0)); | |
| 1753 __ pop(edx); | |
| 1754 __ SmiTag(edx); | |
| 1755 __ bind(&done_restore); | |
| 1756 } | |
| 1757 } | |
| 1758 __ jmp(&convert); | |
| 1759 __ bind(&convert_number); | |
| 1760 // Load another value into stx_1 | |
| 1761 __ fld_d(FieldOperand(ebx, HeapNumber::kValueOffset)); | |
| 1762 __ fxch(); | |
| 1763 __ jmp(&done_convert, Label::kNear); | |
| 1764 __ bind(&convert_smi); | |
| 1765 __ SmiUntag(ebx); | |
| 1766 __ push(ebx); | |
| 1767 __ fild_s(Operand(esp, 0)); | |
| 1768 __ pop(ebx); | |
| 1769 __ fxch(); | |
| 1770 __ SmiTag(ebx); | |
| 1771 __ bind(&done_convert); | |
| 1772 | |
| 1773 // Perform the actual comparison with the accumulator value on the left hand | |
| 1774 // side (stx_0) and the next parameter value on the right hand side (stx_1). | |
| 1775 Label compare_equal, compare_nan, compare_swap, done_compare; | |
| 1776 | |
| 1777 // Duplicates the 2 float data for FCmp | |
| 1778 __ fld(1); | |
| 1779 __ fld(1); | |
| 1780 __ FCmp(); | |
| 1781 __ j(parity_even, &compare_nan, Label::kNear); | |
| 1782 __ j(cc, &done_compare, Label::kNear); | |
| 1783 __ j(equal, &compare_equal, Label::kNear); | |
| 1784 | |
| 1785 // Result is on the right hand side(stx_0). | |
| 1786 __ bind(&compare_swap); | |
| 1787 __ fxch(); | |
| 1788 __ mov(edx, ebx); | |
| 1789 __ jmp(&done_compare, Label::kNear); | |
| 1790 | |
| 1791 // At least one side is NaN, which means that the result will be NaN too. | |
| 1792 __ bind(&compare_nan); | |
| 1793 // Set the result on the right hand side (stx_0) to nan | |
| 1794 __ fstp(0); | |
| 1795 __ LoadRoot(edx, Heap::kNanValueRootIndex); | |
| 1796 __ fld_d(FieldOperand(edx, HeapNumber::kValueOffset)); | |
| 1797 __ jmp(&done_compare, Label::kNear); | |
| 1798 | |
| 1799 // Left and right hand side are equal, check for -0 vs. +0. | |
| 1800 __ bind(&compare_equal); | |
| 1801 // Check the sign of the value in reg_sel | |
| 1802 __ fld(reg_sel); | |
| 1803 __ FXamSign(); | |
| 1804 __ j(not_zero, &compare_swap); | |
| 1805 | |
| 1806 __ bind(&done_compare); | |
| 1807 // The right result is on the right hand side(stx_0) | |
| 1808 // and can remove the useless stx_1 now. | |
| 1809 __ fxch(); | |
| 1810 __ fstp(0); | |
| 1811 __ dec(ecx); | |
| 1812 __ jmp(&loop); | |
| 1813 } | |
| 1814 | |
| 1815 __ bind(&done_loop); | |
| 1816 __ PopReturnAddressTo(ecx); | |
| 1817 __ lea(esp, Operand(esp, eax, times_pointer_size, kPointerSize)); | |
| 1818 __ PushReturnAddressFrom(ecx); | |
| 1819 __ mov(eax, edx); | |
| 1820 __ Ret(); | |
| 1821 } | |
| 1822 | |
| 1823 // static | |
| 1824 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { | 1689 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { |
| 1825 // ----------- S t a t e ------------- | 1690 // ----------- S t a t e ------------- |
| 1826 // -- eax : number of arguments | 1691 // -- eax : number of arguments |
| 1827 // -- edi : constructor function | 1692 // -- edi : constructor function |
| 1828 // -- esi : context | 1693 // -- esi : context |
| 1829 // -- esp[0] : return address | 1694 // -- esp[0] : return address |
| 1830 // -- esp[(argc - n) * 4] : arg[n] (zero-based) | 1695 // -- esp[(argc - n) * 4] : arg[n] (zero-based) |
| 1831 // -- esp[(argc + 1) * 4] : receiver | 1696 // -- esp[(argc + 1) * 4] : receiver |
| 1832 // ----------------------------------- | 1697 // ----------------------------------- |
| 1833 | 1698 |
| (...skipping 1583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3417 | 3282 |
| 3418 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { | 3283 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { |
| 3419 Generate_OnStackReplacementHelper(masm, true); | 3284 Generate_OnStackReplacementHelper(masm, true); |
| 3420 } | 3285 } |
| 3421 | 3286 |
| 3422 #undef __ | 3287 #undef __ |
| 3423 } // namespace internal | 3288 } // namespace internal |
| 3424 } // namespace v8 | 3289 } // namespace v8 |
| 3425 | 3290 |
| 3426 #endif // V8_TARGET_ARCH_X87 | 3291 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |