Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 764 // overflowed the smi range). | 764 // overflowed the smi range). |
| 765 switch (op_) { | 765 switch (op_) { |
| 766 case Token::SHL: { | 766 case Token::SHL: { |
| 767 Comment perform_float(masm, "-- Perform float operation on smis"); | 767 Comment perform_float(masm, "-- Perform float operation on smis"); |
| 768 __ bind(&use_fp_on_smis); | 768 __ bind(&use_fp_on_smis); |
| 769 if (runtime_operands_type_ != BinaryOpIC::UNINIT_OR_SMI) { | 769 if (runtime_operands_type_ != BinaryOpIC::UNINIT_OR_SMI) { |
| 770 // Result we want is in left == edx, so we can put the allocated heap | 770 // Result we want is in left == edx, so we can put the allocated heap |
| 771 // number in eax. | 771 // number in eax. |
| 772 __ AllocateHeapNumber(eax, ecx, ebx, slow); | 772 __ AllocateHeapNumber(eax, ecx, ebx, slow); |
| 773 // Store the result in the HeapNumber and return. | 773 // Store the result in the HeapNumber and return. |
| 774 if (masm->isolate()->cpu_features()->IsSupported(SSE2)) { | 774 if (CpuFeatures::IsSupported(SSE2)) { |
| 775 CpuFeatures::Scope use_sse2(SSE2); | 775 CpuFeatures::Scope use_sse2(SSE2); |
| 776 __ cvtsi2sd(xmm0, Operand(left)); | 776 __ cvtsi2sd(xmm0, Operand(left)); |
| 777 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm0); | 777 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm0); |
| 778 } else { | 778 } else { |
| 779 // It's OK to overwrite the right argument on the stack because we | 779 // It's OK to overwrite the right argument on the stack because we |
| 780 // are about to return. | 780 // are about to return. |
| 781 __ mov(Operand(esp, 1 * kPointerSize), left); | 781 __ mov(Operand(esp, 1 * kPointerSize), left); |
| 782 __ fild_s(Operand(esp, 1 * kPointerSize)); | 782 __ fild_s(Operand(esp, 1 * kPointerSize)); |
| 783 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); | 783 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); |
| 784 } | 784 } |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 814 // Left was clobbered but a copy is in edi. Right is in ebx for | 814 // Left was clobbered but a copy is in edi. Right is in ebx for |
| 815 // division. | 815 // division. |
| 816 __ mov(edx, edi); | 816 __ mov(edx, edi); |
| 817 __ mov(eax, right); | 817 __ mov(eax, right); |
| 818 break; | 818 break; |
| 819 default: UNREACHABLE(); | 819 default: UNREACHABLE(); |
| 820 break; | 820 break; |
| 821 } | 821 } |
| 822 if (runtime_operands_type_ != BinaryOpIC::UNINIT_OR_SMI) { | 822 if (runtime_operands_type_ != BinaryOpIC::UNINIT_OR_SMI) { |
| 823 __ AllocateHeapNumber(ecx, ebx, no_reg, slow); | 823 __ AllocateHeapNumber(ecx, ebx, no_reg, slow); |
| 824 if (masm->isolate()->cpu_features()->IsSupported(SSE2)) { | 824 if (CpuFeatures::IsSupported(SSE2)) { |
| 825 CpuFeatures::Scope use_sse2(SSE2); | 825 CpuFeatures::Scope use_sse2(SSE2); |
| 826 FloatingPointHelper::LoadSSE2Smis(masm, ebx); | 826 FloatingPointHelper::LoadSSE2Smis(masm, ebx); |
| 827 switch (op_) { | 827 switch (op_) { |
| 828 case Token::ADD: __ addsd(xmm0, xmm1); break; | 828 case Token::ADD: __ addsd(xmm0, xmm1); break; |
| 829 case Token::SUB: __ subsd(xmm0, xmm1); break; | 829 case Token::SUB: __ subsd(xmm0, xmm1); break; |
| 830 case Token::MUL: __ mulsd(xmm0, xmm1); break; | 830 case Token::MUL: __ mulsd(xmm0, xmm1); break; |
| 831 case Token::DIV: __ divsd(xmm0, xmm1); break; | 831 case Token::DIV: __ divsd(xmm0, xmm1); break; |
| 832 default: UNREACHABLE(); | 832 default: UNREACHABLE(); |
| 833 } | 833 } |
| 834 __ movdbl(FieldOperand(ecx, HeapNumber::kValueOffset), xmm0); | 834 __ movdbl(FieldOperand(ecx, HeapNumber::kValueOffset), xmm0); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 919 // Execution reaches this point when the first non-smi argument occurs | 919 // Execution reaches this point when the first non-smi argument occurs |
| 920 // (and only if smi code is generated). This is the right moment to | 920 // (and only if smi code is generated). This is the right moment to |
| 921 // patch to HEAP_NUMBERS state. The transition is attempted only for | 921 // patch to HEAP_NUMBERS state. The transition is attempted only for |
| 922 // the four basic operations. The stub stays in the DEFAULT state | 922 // the four basic operations. The stub stays in the DEFAULT state |
| 923 // forever for all other operations (also if smi code is skipped). | 923 // forever for all other operations (also if smi code is skipped). |
| 924 GenerateTypeTransition(masm); | 924 GenerateTypeTransition(masm); |
| 925 break; | 925 break; |
| 926 } | 926 } |
| 927 | 927 |
| 928 Label not_floats; | 928 Label not_floats; |
| 929 if (masm->isolate()->cpu_features()->IsSupported(SSE2)) { | 929 if (CpuFeatures::IsSupported(SSE2)) { |
| 930 CpuFeatures::Scope use_sse2(SSE2); | 930 CpuFeatures::Scope use_sse2(SSE2); |
| 931 if (static_operands_type_.IsNumber()) { | 931 if (static_operands_type_.IsNumber()) { |
| 932 if (FLAG_debug_code) { | 932 if (FLAG_debug_code) { |
| 933 // Assert at runtime that inputs are only numbers. | 933 // Assert at runtime that inputs are only numbers. |
| 934 __ AbortIfNotNumber(edx); | 934 __ AbortIfNotNumber(edx); |
| 935 __ AbortIfNotNumber(eax); | 935 __ AbortIfNotNumber(eax); |
| 936 } | 936 } |
| 937 if (static_operands_type_.IsSmi()) { | 937 if (static_operands_type_.IsSmi()) { |
| 938 if (FLAG_debug_code) { | 938 if (FLAG_debug_code) { |
| 939 __ AbortIfNotSmi(edx); | 939 __ AbortIfNotSmi(edx); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1053 __ test(eax, Immediate(kSmiTagMask)); | 1053 __ test(eax, Immediate(kSmiTagMask)); |
| 1054 __ j(not_zero, &skip_allocation, not_taken); | 1054 __ j(not_zero, &skip_allocation, not_taken); |
| 1055 // Fall through! | 1055 // Fall through! |
| 1056 case NO_OVERWRITE: | 1056 case NO_OVERWRITE: |
| 1057 __ AllocateHeapNumber(eax, ecx, edx, &call_runtime); | 1057 __ AllocateHeapNumber(eax, ecx, edx, &call_runtime); |
| 1058 __ bind(&skip_allocation); | 1058 __ bind(&skip_allocation); |
| 1059 break; | 1059 break; |
| 1060 default: UNREACHABLE(); | 1060 default: UNREACHABLE(); |
| 1061 } | 1061 } |
| 1062 // Store the result in the HeapNumber and return. | 1062 // Store the result in the HeapNumber and return. |
| 1063 if (masm->isolate()->cpu_features()->IsSupported(SSE2)) { | 1063 if (CpuFeatures::IsSupported(SSE2)) { |
| 1064 CpuFeatures::Scope use_sse2(SSE2); | 1064 CpuFeatures::Scope use_sse2(SSE2); |
| 1065 __ cvtsi2sd(xmm0, Operand(ebx)); | 1065 __ cvtsi2sd(xmm0, Operand(ebx)); |
| 1066 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm0); | 1066 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm0); |
| 1067 } else { | 1067 } else { |
| 1068 __ mov(Operand(esp, 1 * kPointerSize), ebx); | 1068 __ mov(Operand(esp, 1 * kPointerSize), ebx); |
| 1069 __ fild_s(Operand(esp, 1 * kPointerSize)); | 1069 __ fild_s(Operand(esp, 1 * kPointerSize)); |
| 1070 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); | 1070 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); |
| 1071 } | 1071 } |
| 1072 GenerateReturn(masm); | 1072 GenerateReturn(masm); |
| 1073 } | 1073 } |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1653 } else { | 1653 } else { |
| 1654 ASSERT(allow_heapnumber_results == ALLOW_HEAPNUMBER_RESULTS); | 1654 ASSERT(allow_heapnumber_results == ALLOW_HEAPNUMBER_RESULTS); |
| 1655 switch (op_) { | 1655 switch (op_) { |
| 1656 case Token::SHL: { | 1656 case Token::SHL: { |
| 1657 Comment perform_float(masm, "-- Perform float operation on smis"); | 1657 Comment perform_float(masm, "-- Perform float operation on smis"); |
| 1658 __ bind(&use_fp_on_smis); | 1658 __ bind(&use_fp_on_smis); |
| 1659 // Result we want is in left == edx, so we can put the allocated heap | 1659 // Result we want is in left == edx, so we can put the allocated heap |
| 1660 // number in eax. | 1660 // number in eax. |
| 1661 __ AllocateHeapNumber(eax, ecx, ebx, slow); | 1661 __ AllocateHeapNumber(eax, ecx, ebx, slow); |
| 1662 // Store the result in the HeapNumber and return. | 1662 // Store the result in the HeapNumber and return. |
| 1663 if (masm->isolate()->cpu_features()->IsSupported(SSE2)) { | 1663 if (CpuFeatures::IsSupported(SSE2)) { |
| 1664 CpuFeatures::Scope use_sse2(SSE2); | 1664 CpuFeatures::Scope use_sse2(SSE2); |
| 1665 __ cvtsi2sd(xmm0, Operand(left)); | 1665 __ cvtsi2sd(xmm0, Operand(left)); |
| 1666 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm0); | 1666 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm0); |
| 1667 } else { | 1667 } else { |
| 1668 // It's OK to overwrite the right argument on the stack because we | 1668 // It's OK to overwrite the right argument on the stack because we |
| 1669 // are about to return. | 1669 // are about to return. |
| 1670 __ mov(Operand(esp, 1 * kPointerSize), left); | 1670 __ mov(Operand(esp, 1 * kPointerSize), left); |
| 1671 __ fild_s(Operand(esp, 1 * kPointerSize)); | 1671 __ fild_s(Operand(esp, 1 * kPointerSize)); |
| 1672 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); | 1672 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); |
| 1673 } | 1673 } |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 1698 case Token::DIV: | 1698 case Token::DIV: |
| 1699 // Left was clobbered but a copy is in edi. Right is in ebx for | 1699 // Left was clobbered but a copy is in edi. Right is in ebx for |
| 1700 // division. | 1700 // division. |
| 1701 __ mov(edx, edi); | 1701 __ mov(edx, edi); |
| 1702 __ mov(eax, right); | 1702 __ mov(eax, right); |
| 1703 break; | 1703 break; |
| 1704 default: UNREACHABLE(); | 1704 default: UNREACHABLE(); |
| 1705 break; | 1705 break; |
| 1706 } | 1706 } |
| 1707 __ AllocateHeapNumber(ecx, ebx, no_reg, slow); | 1707 __ AllocateHeapNumber(ecx, ebx, no_reg, slow); |
| 1708 if (masm->isolate()->cpu_features()->IsSupported(SSE2)) { | 1708 if (CpuFeatures::IsSupported(SSE2)) { |
| 1709 CpuFeatures::Scope use_sse2(SSE2); | 1709 CpuFeatures::Scope use_sse2(SSE2); |
| 1710 FloatingPointHelper::LoadSSE2Smis(masm, ebx); | 1710 FloatingPointHelper::LoadSSE2Smis(masm, ebx); |
| 1711 switch (op_) { | 1711 switch (op_) { |
| 1712 case Token::ADD: __ addsd(xmm0, xmm1); break; | 1712 case Token::ADD: __ addsd(xmm0, xmm1); break; |
| 1713 case Token::SUB: __ subsd(xmm0, xmm1); break; | 1713 case Token::SUB: __ subsd(xmm0, xmm1); break; |
| 1714 case Token::MUL: __ mulsd(xmm0, xmm1); break; | 1714 case Token::MUL: __ mulsd(xmm0, xmm1); break; |
| 1715 case Token::DIV: __ divsd(xmm0, xmm1); break; | 1715 case Token::DIV: __ divsd(xmm0, xmm1); break; |
| 1716 default: UNREACHABLE(); | 1716 default: UNREACHABLE(); |
| 1717 } | 1717 } |
| 1718 __ movdbl(FieldOperand(ecx, HeapNumber::kValueOffset), xmm0); | 1718 __ movdbl(FieldOperand(ecx, HeapNumber::kValueOffset), xmm0); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1830 ASSERT(operands_type_ == TRBinaryOpIC::INT32); | 1830 ASSERT(operands_type_ == TRBinaryOpIC::INT32); |
| 1831 | 1831 |
| 1832 // Floating point case. | 1832 // Floating point case. |
| 1833 switch (op_) { | 1833 switch (op_) { |
| 1834 case Token::ADD: | 1834 case Token::ADD: |
| 1835 case Token::SUB: | 1835 case Token::SUB: |
| 1836 case Token::MUL: | 1836 case Token::MUL: |
| 1837 case Token::DIV: { | 1837 case Token::DIV: { |
| 1838 Label not_floats; | 1838 Label not_floats; |
| 1839 Label not_int32; | 1839 Label not_int32; |
| 1840 if (masm->isolate()->cpu_features()->IsSupported(SSE2)) { | 1840 if (CpuFeatures::IsSupported(SSE2)) { |
| 1841 CpuFeatures::Scope use_sse2(SSE2); | 1841 CpuFeatures::Scope use_sse2(SSE2); |
| 1842 FloatingPointHelper::LoadSSE2Operands(masm, ¬_floats); | 1842 FloatingPointHelper::LoadSSE2Operands(masm, ¬_floats); |
| 1843 FloatingPointHelper::CheckSSE2OperandsAreInt32(masm, ¬_int32, ecx); | 1843 FloatingPointHelper::CheckSSE2OperandsAreInt32(masm, ¬_int32, ecx); |
| 1844 switch (op_) { | 1844 switch (op_) { |
| 1845 case Token::ADD: __ addsd(xmm0, xmm1); break; | 1845 case Token::ADD: __ addsd(xmm0, xmm1); break; |
| 1846 case Token::SUB: __ subsd(xmm0, xmm1); break; | 1846 case Token::SUB: __ subsd(xmm0, xmm1); break; |
| 1847 case Token::MUL: __ mulsd(xmm0, xmm1); break; | 1847 case Token::MUL: __ mulsd(xmm0, xmm1); break; |
| 1848 case Token::DIV: __ divsd(xmm0, xmm1); break; | 1848 case Token::DIV: __ divsd(xmm0, xmm1); break; |
| 1849 default: UNREACHABLE(); | 1849 default: UNREACHABLE(); |
| 1850 } | 1850 } |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1951 __ test(eax, Immediate(kSmiTagMask)); | 1951 __ test(eax, Immediate(kSmiTagMask)); |
| 1952 __ j(not_zero, &skip_allocation, not_taken); | 1952 __ j(not_zero, &skip_allocation, not_taken); |
| 1953 // Fall through! | 1953 // Fall through! |
| 1954 case NO_OVERWRITE: | 1954 case NO_OVERWRITE: |
| 1955 __ AllocateHeapNumber(eax, ecx, edx, &call_runtime); | 1955 __ AllocateHeapNumber(eax, ecx, edx, &call_runtime); |
| 1956 __ bind(&skip_allocation); | 1956 __ bind(&skip_allocation); |
| 1957 break; | 1957 break; |
| 1958 default: UNREACHABLE(); | 1958 default: UNREACHABLE(); |
| 1959 } | 1959 } |
| 1960 // Store the result in the HeapNumber and return. | 1960 // Store the result in the HeapNumber and return. |
| 1961 if (masm->isolate()->cpu_features()->IsSupported(SSE2)) { | 1961 if (CpuFeatures::IsSupported(SSE2)) { |
| 1962 CpuFeatures::Scope use_sse2(SSE2); | 1962 CpuFeatures::Scope use_sse2(SSE2); |
| 1963 __ cvtsi2sd(xmm0, Operand(ebx)); | 1963 __ cvtsi2sd(xmm0, Operand(ebx)); |
| 1964 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm0); | 1964 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm0); |
| 1965 } else { | 1965 } else { |
| 1966 __ mov(Operand(esp, 1 * kPointerSize), ebx); | 1966 __ mov(Operand(esp, 1 * kPointerSize), ebx); |
| 1967 __ fild_s(Operand(esp, 1 * kPointerSize)); | 1967 __ fild_s(Operand(esp, 1 * kPointerSize)); |
| 1968 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); | 1968 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); |
| 1969 } | 1969 } |
| 1970 __ ret(2 * kPointerSize); // Drop two pushed arguments from the stack. | 1970 __ ret(2 * kPointerSize); // Drop two pushed arguments from the stack. |
| 1971 } | 1971 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2063 void TypeRecordingBinaryOpStub::GenerateHeapNumberStub(MacroAssembler* masm) { | 2063 void TypeRecordingBinaryOpStub::GenerateHeapNumberStub(MacroAssembler* masm) { |
| 2064 Label call_runtime; | 2064 Label call_runtime; |
| 2065 | 2065 |
| 2066 // Floating point case. | 2066 // Floating point case. |
| 2067 switch (op_) { | 2067 switch (op_) { |
| 2068 case Token::ADD: | 2068 case Token::ADD: |
| 2069 case Token::SUB: | 2069 case Token::SUB: |
| 2070 case Token::MUL: | 2070 case Token::MUL: |
| 2071 case Token::DIV: { | 2071 case Token::DIV: { |
| 2072 Label not_floats; | 2072 Label not_floats; |
| 2073 if (masm->isolate()->cpu_features()->IsSupported(SSE2)) { | 2073 if (CpuFeatures::IsSupported(SSE2)) { |
| 2074 CpuFeatures::Scope use_sse2(SSE2); | 2074 CpuFeatures::Scope use_sse2(SSE2); |
| 2075 FloatingPointHelper::LoadSSE2Operands(masm, ¬_floats); | 2075 FloatingPointHelper::LoadSSE2Operands(masm, ¬_floats); |
| 2076 | 2076 |
| 2077 switch (op_) { | 2077 switch (op_) { |
| 2078 case Token::ADD: __ addsd(xmm0, xmm1); break; | 2078 case Token::ADD: __ addsd(xmm0, xmm1); break; |
| 2079 case Token::SUB: __ subsd(xmm0, xmm1); break; | 2079 case Token::SUB: __ subsd(xmm0, xmm1); break; |
| 2080 case Token::MUL: __ mulsd(xmm0, xmm1); break; | 2080 case Token::MUL: __ mulsd(xmm0, xmm1); break; |
| 2081 case Token::DIV: __ divsd(xmm0, xmm1); break; | 2081 case Token::DIV: __ divsd(xmm0, xmm1); break; |
| 2082 default: UNREACHABLE(); | 2082 default: UNREACHABLE(); |
| 2083 } | 2083 } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2166 __ test(eax, Immediate(kSmiTagMask)); | 2166 __ test(eax, Immediate(kSmiTagMask)); |
| 2167 __ j(not_zero, &skip_allocation, not_taken); | 2167 __ j(not_zero, &skip_allocation, not_taken); |
| 2168 // Fall through! | 2168 // Fall through! |
| 2169 case NO_OVERWRITE: | 2169 case NO_OVERWRITE: |
| 2170 __ AllocateHeapNumber(eax, ecx, edx, &call_runtime); | 2170 __ AllocateHeapNumber(eax, ecx, edx, &call_runtime); |
| 2171 __ bind(&skip_allocation); | 2171 __ bind(&skip_allocation); |
| 2172 break; | 2172 break; |
| 2173 default: UNREACHABLE(); | 2173 default: UNREACHABLE(); |
| 2174 } | 2174 } |
| 2175 // Store the result in the HeapNumber and return. | 2175 // Store the result in the HeapNumber and return. |
| 2176 if (masm->isolate()->cpu_features()->IsSupported(SSE2)) { | 2176 if (CpuFeatures::IsSupported(SSE2)) { |
| 2177 CpuFeatures::Scope use_sse2(SSE2); | 2177 CpuFeatures::Scope use_sse2(SSE2); |
| 2178 __ cvtsi2sd(xmm0, Operand(ebx)); | 2178 __ cvtsi2sd(xmm0, Operand(ebx)); |
| 2179 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm0); | 2179 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm0); |
| 2180 } else { | 2180 } else { |
| 2181 __ mov(Operand(esp, 1 * kPointerSize), ebx); | 2181 __ mov(Operand(esp, 1 * kPointerSize), ebx); |
| 2182 __ fild_s(Operand(esp, 1 * kPointerSize)); | 2182 __ fild_s(Operand(esp, 1 * kPointerSize)); |
| 2183 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); | 2183 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); |
| 2184 } | 2184 } |
| 2185 __ ret(2 * kPointerSize); // Drop two pushed arguments from the stack. | 2185 __ ret(2 * kPointerSize); // Drop two pushed arguments from the stack. |
| 2186 } | 2186 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2268 | 2268 |
| 2269 GenerateSmiCode(masm, &call_runtime, ALLOW_HEAPNUMBER_RESULTS); | 2269 GenerateSmiCode(masm, &call_runtime, ALLOW_HEAPNUMBER_RESULTS); |
| 2270 | 2270 |
| 2271 // Floating point case. | 2271 // Floating point case. |
| 2272 switch (op_) { | 2272 switch (op_) { |
| 2273 case Token::ADD: | 2273 case Token::ADD: |
| 2274 case Token::SUB: | 2274 case Token::SUB: |
| 2275 case Token::MUL: | 2275 case Token::MUL: |
| 2276 case Token::DIV: { | 2276 case Token::DIV: { |
| 2277 Label not_floats; | 2277 Label not_floats; |
| 2278 if (masm->isolate()->cpu_features()->IsSupported(SSE2)) { | 2278 if (CpuFeatures::IsSupported(SSE2)) { |
| 2279 CpuFeatures::Scope use_sse2(SSE2); | 2279 CpuFeatures::Scope use_sse2(SSE2); |
| 2280 FloatingPointHelper::LoadSSE2Operands(masm, ¬_floats); | 2280 FloatingPointHelper::LoadSSE2Operands(masm, ¬_floats); |
| 2281 | 2281 |
| 2282 switch (op_) { | 2282 switch (op_) { |
| 2283 case Token::ADD: __ addsd(xmm0, xmm1); break; | 2283 case Token::ADD: __ addsd(xmm0, xmm1); break; |
| 2284 case Token::SUB: __ subsd(xmm0, xmm1); break; | 2284 case Token::SUB: __ subsd(xmm0, xmm1); break; |
| 2285 case Token::MUL: __ mulsd(xmm0, xmm1); break; | 2285 case Token::MUL: __ mulsd(xmm0, xmm1); break; |
| 2286 case Token::DIV: __ divsd(xmm0, xmm1); break; | 2286 case Token::DIV: __ divsd(xmm0, xmm1); break; |
| 2287 default: UNREACHABLE(); | 2287 default: UNREACHABLE(); |
| 2288 } | 2288 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2366 __ test(eax, Immediate(kSmiTagMask)); | 2366 __ test(eax, Immediate(kSmiTagMask)); |
| 2367 __ j(not_zero, &skip_allocation, not_taken); | 2367 __ j(not_zero, &skip_allocation, not_taken); |
| 2368 // Fall through! | 2368 // Fall through! |
| 2369 case NO_OVERWRITE: | 2369 case NO_OVERWRITE: |
| 2370 __ AllocateHeapNumber(eax, ecx, edx, &call_runtime); | 2370 __ AllocateHeapNumber(eax, ecx, edx, &call_runtime); |
| 2371 __ bind(&skip_allocation); | 2371 __ bind(&skip_allocation); |
| 2372 break; | 2372 break; |
| 2373 default: UNREACHABLE(); | 2373 default: UNREACHABLE(); |
| 2374 } | 2374 } |
| 2375 // Store the result in the HeapNumber and return. | 2375 // Store the result in the HeapNumber and return. |
| 2376 if (masm->isolate()->cpu_features()->IsSupported(SSE2)) { | 2376 if (CpuFeatures::IsSupported(SSE2)) { |
| 2377 CpuFeatures::Scope use_sse2(SSE2); | 2377 CpuFeatures::Scope use_sse2(SSE2); |
| 2378 __ cvtsi2sd(xmm0, Operand(ebx)); | 2378 __ cvtsi2sd(xmm0, Operand(ebx)); |
| 2379 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm0); | 2379 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm0); |
| 2380 } else { | 2380 } else { |
| 2381 __ mov(Operand(esp, 1 * kPointerSize), ebx); | 2381 __ mov(Operand(esp, 1 * kPointerSize), ebx); |
| 2382 __ fild_s(Operand(esp, 1 * kPointerSize)); | 2382 __ fild_s(Operand(esp, 1 * kPointerSize)); |
| 2383 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); | 2383 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); |
| 2384 } | 2384 } |
| 2385 __ ret(2 * kPointerSize); | 2385 __ ret(2 * kPointerSize); |
| 2386 } | 2386 } |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2565 __ cmp(Operand(ebx), Immediate(factory->heap_number_map())); | 2565 __ cmp(Operand(ebx), Immediate(factory->heap_number_map())); |
| 2566 __ j(not_equal, &runtime_call); | 2566 __ j(not_equal, &runtime_call); |
| 2567 // Input is a HeapNumber. Push it on the FPU stack and load its | 2567 // Input is a HeapNumber. Push it on the FPU stack and load its |
| 2568 // low and high words into ebx, edx. | 2568 // low and high words into ebx, edx. |
| 2569 __ fld_d(FieldOperand(eax, HeapNumber::kValueOffset)); | 2569 __ fld_d(FieldOperand(eax, HeapNumber::kValueOffset)); |
| 2570 __ mov(edx, FieldOperand(eax, HeapNumber::kExponentOffset)); | 2570 __ mov(edx, FieldOperand(eax, HeapNumber::kExponentOffset)); |
| 2571 __ mov(ebx, FieldOperand(eax, HeapNumber::kMantissaOffset)); | 2571 __ mov(ebx, FieldOperand(eax, HeapNumber::kMantissaOffset)); |
| 2572 | 2572 |
| 2573 __ bind(&loaded); | 2573 __ bind(&loaded); |
| 2574 } else { // UNTAGGED. | 2574 } else { // UNTAGGED. |
| 2575 if (masm->isolate()->cpu_features()->IsSupported(SSE4_1)) { | 2575 if (CpuFeatures::IsSupported(SSE4_1)) { |
| 2576 CpuFeatures::Scope sse4_scope(SSE4_1); | 2576 CpuFeatures::Scope sse4_scope(SSE4_1); |
| 2577 __ pextrd(Operand(edx), xmm1, 0x1); // copy xmm1[63..32] to edx. | 2577 __ pextrd(Operand(edx), xmm1, 0x1); // copy xmm1[63..32] to edx. |
| 2578 } else { | 2578 } else { |
| 2579 __ pshufd(xmm0, xmm1, 0x1); | 2579 __ pshufd(xmm0, xmm1, 0x1); |
| 2580 __ movd(Operand(edx), xmm0); | 2580 __ movd(Operand(edx), xmm0); |
| 2581 } | 2581 } |
| 2582 __ movd(Operand(ebx), xmm1); | 2582 __ movd(Operand(ebx), xmm1); |
| 2583 } | 2583 } |
| 2584 | 2584 |
| 2585 // ST[0] or xmm1 == double value | 2585 // ST[0] or xmm1 == double value |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2819 // trashed registers. | 2819 // trashed registers. |
| 2820 void IntegerConvert(MacroAssembler* masm, | 2820 void IntegerConvert(MacroAssembler* masm, |
| 2821 Register source, | 2821 Register source, |
| 2822 TypeInfo type_info, | 2822 TypeInfo type_info, |
| 2823 bool use_sse3, | 2823 bool use_sse3, |
| 2824 Label* conversion_failure) { | 2824 Label* conversion_failure) { |
| 2825 ASSERT(!source.is(ecx) && !source.is(edi) && !source.is(ebx)); | 2825 ASSERT(!source.is(ecx) && !source.is(edi) && !source.is(ebx)); |
| 2826 Label done, right_exponent, normal_exponent; | 2826 Label done, right_exponent, normal_exponent; |
| 2827 Register scratch = ebx; | 2827 Register scratch = ebx; |
| 2828 Register scratch2 = edi; | 2828 Register scratch2 = edi; |
| 2829 if (type_info.IsInteger32() && | 2829 if (type_info.IsInteger32() && CpuFeatures::IsSupported(SSE2)) { |
| 2830 masm->isolate()->cpu_features()->IsEnabled(SSE2)) { | |
|
Mads Ager (chromium)
2011/03/31 13:48:21
Auch. Good catch!
| |
| 2831 CpuFeatures::Scope scope(SSE2); | 2830 CpuFeatures::Scope scope(SSE2); |
| 2832 __ cvttsd2si(ecx, FieldOperand(source, HeapNumber::kValueOffset)); | 2831 __ cvttsd2si(ecx, FieldOperand(source, HeapNumber::kValueOffset)); |
| 2833 return; | 2832 return; |
| 2834 } | 2833 } |
| 2835 if (!type_info.IsInteger32() || !use_sse3) { | 2834 if (!type_info.IsInteger32() || !use_sse3) { |
| 2836 // Get exponent word. | 2835 // Get exponent word. |
| 2837 __ mov(scratch, FieldOperand(source, HeapNumber::kExponentOffset)); | 2836 __ mov(scratch, FieldOperand(source, HeapNumber::kExponentOffset)); |
| 2838 // Get exponent alone in scratch2. | 2837 // Get exponent alone in scratch2. |
| 2839 __ mov(scratch2, scratch); | 2838 __ mov(scratch2, scratch); |
| 2840 __ and_(scratch2, HeapNumber::kExponentMask); | 2839 __ and_(scratch2, HeapNumber::kExponentMask); |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3368 | 3367 |
| 3369 // Check if the operand is a heap number. | 3368 // Check if the operand is a heap number. |
| 3370 __ mov(edx, FieldOperand(eax, HeapObject::kMapOffset)); | 3369 __ mov(edx, FieldOperand(eax, HeapObject::kMapOffset)); |
| 3371 __ cmp(edx, masm->isolate()->factory()->heap_number_map()); | 3370 __ cmp(edx, masm->isolate()->factory()->heap_number_map()); |
| 3372 __ j(not_equal, &slow, not_taken); | 3371 __ j(not_equal, &slow, not_taken); |
| 3373 | 3372 |
| 3374 // Convert the heap number in eax to an untagged integer in ecx. | 3373 // Convert the heap number in eax to an untagged integer in ecx. |
| 3375 IntegerConvert(masm, | 3374 IntegerConvert(masm, |
| 3376 eax, | 3375 eax, |
| 3377 TypeInfo::Unknown(), | 3376 TypeInfo::Unknown(), |
| 3378 masm->isolate()->cpu_features()->IsSupported(SSE3), | 3377 CpuFeatures::IsSupported(SSE3), |
| 3379 &slow); | 3378 &slow); |
| 3380 | 3379 |
| 3381 // Do the bitwise operation and check if the result fits in a smi. | 3380 // Do the bitwise operation and check if the result fits in a smi. |
| 3382 NearLabel try_float; | 3381 NearLabel try_float; |
| 3383 __ not_(ecx); | 3382 __ not_(ecx); |
| 3384 __ cmp(ecx, 0xc0000000); | 3383 __ cmp(ecx, 0xc0000000); |
| 3385 __ j(sign, &try_float, not_taken); | 3384 __ j(sign, &try_float, not_taken); |
| 3386 | 3385 |
| 3387 // Tag the result as a smi and we're done. | 3386 // Tag the result as a smi and we're done. |
| 3388 STATIC_ASSERT(kSmiTagSize == 1); | 3387 STATIC_ASSERT(kSmiTagSize == 1); |
| 3389 __ lea(eax, Operand(ecx, times_2, kSmiTag)); | 3388 __ lea(eax, Operand(ecx, times_2, kSmiTag)); |
| 3390 __ jmp(&done); | 3389 __ jmp(&done); |
| 3391 | 3390 |
| 3392 // Try to store the result in a heap number. | 3391 // Try to store the result in a heap number. |
| 3393 __ bind(&try_float); | 3392 __ bind(&try_float); |
| 3394 if (overwrite_ == UNARY_NO_OVERWRITE) { | 3393 if (overwrite_ == UNARY_NO_OVERWRITE) { |
| 3395 // Allocate a fresh heap number, but don't overwrite eax until | 3394 // Allocate a fresh heap number, but don't overwrite eax until |
| 3396 // we're sure we can do it without going through the slow case | 3395 // we're sure we can do it without going through the slow case |
| 3397 // that needs the value in eax. | 3396 // that needs the value in eax. |
| 3398 __ AllocateHeapNumber(ebx, edx, edi, &slow); | 3397 __ AllocateHeapNumber(ebx, edx, edi, &slow); |
| 3399 __ mov(eax, Operand(ebx)); | 3398 __ mov(eax, Operand(ebx)); |
| 3400 } | 3399 } |
| 3401 if (masm->isolate()->cpu_features()->IsSupported(SSE2)) { | 3400 if (CpuFeatures::IsSupported(SSE2)) { |
| 3402 CpuFeatures::Scope use_sse2(SSE2); | 3401 CpuFeatures::Scope use_sse2(SSE2); |
| 3403 __ cvtsi2sd(xmm0, Operand(ecx)); | 3402 __ cvtsi2sd(xmm0, Operand(ecx)); |
| 3404 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm0); | 3403 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm0); |
| 3405 } else { | 3404 } else { |
| 3406 __ push(ecx); | 3405 __ push(ecx); |
| 3407 __ fild_s(Operand(esp, 0)); | 3406 __ fild_s(Operand(esp, 0)); |
| 3408 __ pop(ecx); | 3407 __ pop(ecx); |
| 3409 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); | 3408 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); |
| 3410 } | 3409 } |
| 3411 } else { | 3410 } else { |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4263 __ and_(scratch, Operand(mask)); | 4262 __ and_(scratch, Operand(mask)); |
| 4264 Register index = scratch; | 4263 Register index = scratch; |
| 4265 Register probe = mask; | 4264 Register probe = mask; |
| 4266 __ mov(probe, | 4265 __ mov(probe, |
| 4267 FieldOperand(number_string_cache, | 4266 FieldOperand(number_string_cache, |
| 4268 index, | 4267 index, |
| 4269 times_twice_pointer_size, | 4268 times_twice_pointer_size, |
| 4270 FixedArray::kHeaderSize)); | 4269 FixedArray::kHeaderSize)); |
| 4271 __ test(probe, Immediate(kSmiTagMask)); | 4270 __ test(probe, Immediate(kSmiTagMask)); |
| 4272 __ j(zero, not_found); | 4271 __ j(zero, not_found); |
| 4273 if (masm->isolate()->cpu_features()->IsSupported(SSE2)) { | 4272 if (CpuFeatures::IsSupported(SSE2)) { |
| 4274 CpuFeatures::Scope fscope(SSE2); | 4273 CpuFeatures::Scope fscope(SSE2); |
| 4275 __ movdbl(xmm0, FieldOperand(object, HeapNumber::kValueOffset)); | 4274 __ movdbl(xmm0, FieldOperand(object, HeapNumber::kValueOffset)); |
| 4276 __ movdbl(xmm1, FieldOperand(probe, HeapNumber::kValueOffset)); | 4275 __ movdbl(xmm1, FieldOperand(probe, HeapNumber::kValueOffset)); |
| 4277 __ ucomisd(xmm0, xmm1); | 4276 __ ucomisd(xmm0, xmm1); |
| 4278 } else { | 4277 } else { |
| 4279 __ fld_d(FieldOperand(object, HeapNumber::kValueOffset)); | 4278 __ fld_d(FieldOperand(object, HeapNumber::kValueOffset)); |
| 4280 __ fld_d(FieldOperand(probe, HeapNumber::kValueOffset)); | 4279 __ fld_d(FieldOperand(probe, HeapNumber::kValueOffset)); |
| 4281 __ FCmp(); | 4280 __ FCmp(); |
| 4282 } | 4281 } |
| 4283 __ j(parity_even, not_found); // Bail out if NaN is involved. | 4282 __ j(parity_even, not_found); // Bail out if NaN is involved. |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4502 __ j(equal, &return_not_equal); | 4501 __ j(equal, &return_not_equal); |
| 4503 | 4502 |
| 4504 // Fall through to the general case. | 4503 // Fall through to the general case. |
| 4505 __ bind(&slow); | 4504 __ bind(&slow); |
| 4506 } | 4505 } |
| 4507 | 4506 |
| 4508 // Generate the number comparison code. | 4507 // Generate the number comparison code. |
| 4509 if (include_number_compare_) { | 4508 if (include_number_compare_) { |
| 4510 Label non_number_comparison; | 4509 Label non_number_comparison; |
| 4511 Label unordered; | 4510 Label unordered; |
| 4512 if (masm->isolate()->cpu_features()->IsSupported(SSE2)) { | 4511 if (CpuFeatures::IsSupported(SSE2)) { |
| 4513 CpuFeatures::Scope use_sse2(SSE2); | 4512 CpuFeatures::Scope use_sse2(SSE2); |
| 4514 CpuFeatures::Scope use_cmov(CMOV); | 4513 CpuFeatures::Scope use_cmov(CMOV); |
| 4515 | 4514 |
| 4516 FloatingPointHelper::LoadSSE2Operands(masm, &non_number_comparison); | 4515 FloatingPointHelper::LoadSSE2Operands(masm, &non_number_comparison); |
| 4517 __ ucomisd(xmm0, xmm1); | 4516 __ ucomisd(xmm0, xmm1); |
| 4518 | 4517 |
| 4519 // Don't base result on EFLAGS when a NaN is involved. | 4518 // Don't base result on EFLAGS when a NaN is involved. |
| 4520 __ j(parity_even, &unordered, not_taken); | 4519 __ j(parity_even, &unordered, not_taken); |
| 4521 // Return a result of -1, 0, or 1, based on EFLAGS. | 4520 // Return a result of -1, 0, or 1, based on EFLAGS. |
| 4522 __ mov(eax, 0); // equal | 4521 __ mov(eax, 0); // equal |
| (...skipping 1925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6448 __ test(ecx, Immediate(kSmiTagMask)); | 6447 __ test(ecx, Immediate(kSmiTagMask)); |
| 6449 __ j(zero, &generic_stub, not_taken); | 6448 __ j(zero, &generic_stub, not_taken); |
| 6450 | 6449 |
| 6451 __ CmpObjectType(eax, HEAP_NUMBER_TYPE, ecx); | 6450 __ CmpObjectType(eax, HEAP_NUMBER_TYPE, ecx); |
| 6452 __ j(not_equal, &miss, not_taken); | 6451 __ j(not_equal, &miss, not_taken); |
| 6453 __ CmpObjectType(edx, HEAP_NUMBER_TYPE, ecx); | 6452 __ CmpObjectType(edx, HEAP_NUMBER_TYPE, ecx); |
| 6454 __ j(not_equal, &miss, not_taken); | 6453 __ j(not_equal, &miss, not_taken); |
| 6455 | 6454 |
| 6456 // Inlining the double comparison and falling back to the general compare | 6455 // Inlining the double comparison and falling back to the general compare |
| 6457 // stub if NaN is involved or SS2 or CMOV is unsupported. | 6456 // stub if NaN is involved or SS2 or CMOV is unsupported. |
| 6458 CpuFeatures* cpu_features = masm->isolate()->cpu_features(); | 6457 if (CpuFeatures::IsSupported(SSE2) && CpuFeatures::IsSupported(CMOV)) { |
| 6459 if (cpu_features->IsSupported(SSE2) && cpu_features->IsSupported(CMOV)) { | |
| 6460 CpuFeatures::Scope scope1(SSE2); | 6458 CpuFeatures::Scope scope1(SSE2); |
| 6461 CpuFeatures::Scope scope2(CMOV); | 6459 CpuFeatures::Scope scope2(CMOV); |
| 6462 | 6460 |
| 6463 // Load left and right operand | 6461 // Load left and right operand |
| 6464 __ movdbl(xmm0, FieldOperand(edx, HeapNumber::kValueOffset)); | 6462 __ movdbl(xmm0, FieldOperand(edx, HeapNumber::kValueOffset)); |
| 6465 __ movdbl(xmm1, FieldOperand(eax, HeapNumber::kValueOffset)); | 6463 __ movdbl(xmm1, FieldOperand(eax, HeapNumber::kValueOffset)); |
| 6466 | 6464 |
| 6467 // Compare operands | 6465 // Compare operands |
| 6468 __ ucomisd(xmm0, xmm1); | 6466 __ ucomisd(xmm0, xmm1); |
| 6469 | 6467 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6542 // Do a tail call to the rewritten stub. | 6540 // Do a tail call to the rewritten stub. |
| 6543 __ jmp(Operand(edi)); | 6541 __ jmp(Operand(edi)); |
| 6544 } | 6542 } |
| 6545 | 6543 |
| 6546 | 6544 |
| 6547 #undef __ | 6545 #undef __ |
| 6548 | 6546 |
| 6549 } } // namespace v8::internal | 6547 } } // namespace v8::internal |
| 6550 | 6548 |
| 6551 #endif // V8_TARGET_ARCH_IA32 | 6549 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |