Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: src/ia32/code-stubs-ia32.cc

Issue 10083044: Fixed type transitions for mod on ia32. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Removed dead code Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 1663 matching lines...) Expand 10 before | Expand all | Expand 10 after
1674 1674
1675 StringAddStub string_add_stub(NO_STRING_CHECK_IN_STUB); 1675 StringAddStub string_add_stub(NO_STRING_CHECK_IN_STUB);
1676 GenerateRegisterArgsPush(masm); 1676 GenerateRegisterArgsPush(masm);
1677 __ TailCallStub(&string_add_stub); 1677 __ TailCallStub(&string_add_stub);
1678 1678
1679 __ bind(&call_runtime); 1679 __ bind(&call_runtime);
1680 GenerateTypeTransition(masm); 1680 GenerateTypeTransition(masm);
1681 } 1681 }
1682 1682
1683 1683
1684 // Input:
1685 // edx: left operand (tagged)
1686 // eax: right operand (tagged)
1687 // Output:
1688 // eax: result (tagged)
1684 void BinaryOpStub::GenerateInt32Stub(MacroAssembler* masm) { 1689 void BinaryOpStub::GenerateInt32Stub(MacroAssembler* masm) {
1685 Label call_runtime; 1690 Label call_runtime;
1686 ASSERT(operands_type_ == BinaryOpIC::INT32); 1691 ASSERT(operands_type_ == BinaryOpIC::INT32);
1687 1692
1688 // Floating point case. 1693 // Floating point case.
1689 switch (op_) { 1694 switch (op_) {
1690 case Token::ADD: 1695 case Token::ADD:
1691 case Token::SUB: 1696 case Token::SUB:
1692 case Token::MUL: 1697 case Token::MUL:
1693 case Token::DIV: { 1698 case Token::DIV:
1699 case Token::MOD: {
1694 Label not_floats; 1700 Label not_floats;
1695 Label not_int32; 1701 Label not_int32;
1696 if (CpuFeatures::IsSupported(SSE2)) { 1702 if (CpuFeatures::IsSupported(SSE2)) {
1697 CpuFeatures::Scope use_sse2(SSE2); 1703 CpuFeatures::Scope use_sse2(SSE2);
1698 FloatingPointHelper::LoadSSE2Operands(masm, &not_floats); 1704 FloatingPointHelper::LoadSSE2Operands(masm, &not_floats);
1699 FloatingPointHelper::CheckSSE2OperandsAreInt32(masm, &not_int32, ecx); 1705 FloatingPointHelper::CheckSSE2OperandsAreInt32(masm, &not_int32, ecx);
1700 switch (op_) { 1706 if (op_ == Token::MOD) {
1701 case Token::ADD: __ addsd(xmm0, xmm1); break; 1707 GenerateRegisterArgsPush(masm);
1702 case Token::SUB: __ subsd(xmm0, xmm1); break; 1708 __ InvokeBuiltin(Builtins::MOD, JUMP_FUNCTION);
1703 case Token::MUL: __ mulsd(xmm0, xmm1); break; 1709 } else {
1704 case Token::DIV: __ divsd(xmm0, xmm1); break; 1710 switch (op_) {
1705 default: UNREACHABLE(); 1711 case Token::ADD: __ addsd(xmm0, xmm1); break;
1712 case Token::SUB: __ subsd(xmm0, xmm1); break;
1713 case Token::MUL: __ mulsd(xmm0, xmm1); break;
1714 case Token::DIV: __ divsd(xmm0, xmm1); break;
1715 default: UNREACHABLE();
1716 }
1717 // Check result type if it is currently Int32.
1718 if (result_type_ <= BinaryOpIC::INT32) {
1719 __ cvttsd2si(ecx, Operand(xmm0));
1720 __ cvtsi2sd(xmm2, ecx);
1721 __ ucomisd(xmm0, xmm2);
1722 __ j(not_zero, &not_int32);
1723 __ j(carry, &not_int32);
1724 }
1725 GenerateHeapResultAllocation(masm, &call_runtime);
1726 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm0);
1727 __ ret(0);
1706 } 1728 }
1707 // Check result type if it is currently Int32.
1708 if (result_type_ <= BinaryOpIC::INT32) {
1709 __ cvttsd2si(ecx, Operand(xmm0));
1710 __ cvtsi2sd(xmm2, ecx);
1711 __ ucomisd(xmm0, xmm2);
1712 __ j(not_zero, &not_int32);
1713 __ j(carry, &not_int32);
1714 }
1715 GenerateHeapResultAllocation(masm, &call_runtime);
1716 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm0);
1717 __ ret(0);
1718 } else { // SSE2 not available, use FPU. 1729 } else { // SSE2 not available, use FPU.
1719 FloatingPointHelper::CheckFloatOperands(masm, &not_floats, ebx); 1730 FloatingPointHelper::CheckFloatOperands(masm, &not_floats, ebx);
1720 FloatingPointHelper::LoadFloatOperands( 1731 FloatingPointHelper::LoadFloatOperands(
1721 masm, 1732 masm,
1722 ecx, 1733 ecx,
1723 FloatingPointHelper::ARGS_IN_REGISTERS); 1734 FloatingPointHelper::ARGS_IN_REGISTERS);
1724 FloatingPointHelper::CheckFloatOperandsAreInt32(masm, &not_int32); 1735 FloatingPointHelper::CheckFloatOperandsAreInt32(masm, &not_int32);
1725 switch (op_) { 1736 if (op_ == Token::MOD) {
1726 case Token::ADD: __ faddp(1); break; 1737 GenerateRegisterArgsPush(masm);
1727 case Token::SUB: __ fsubp(1); break; 1738 __ InvokeBuiltin(Builtins::MOD, JUMP_FUNCTION);
1728 case Token::MUL: __ fmulp(1); break; 1739 } else {
1729 case Token::DIV: __ fdivp(1); break; 1740 switch (op_) {
1730 default: UNREACHABLE(); 1741 case Token::ADD: __ faddp(1); break;
1742 case Token::SUB: __ fsubp(1); break;
1743 case Token::MUL: __ fmulp(1); break;
1744 case Token::DIV: __ fdivp(1); break;
1745 default: UNREACHABLE();
1746 }
1747 Label after_alloc_failure;
1748 GenerateHeapResultAllocation(masm, &after_alloc_failure);
1749 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset));
1750 __ ret(0);
1751 __ bind(&after_alloc_failure);
1752 __ fstp(0); // Pop FPU stack before calling runtime.
1753 __ jmp(&call_runtime);
1731 } 1754 }
1732 Label after_alloc_failure;
1733 GenerateHeapResultAllocation(masm, &after_alloc_failure);
1734 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset));
1735 __ ret(0);
1736 __ bind(&after_alloc_failure);
1737 __ fstp(0); // Pop FPU stack before calling runtime.
1738 __ jmp(&call_runtime);
1739 } 1755 }
1740 1756
1741 __ bind(&not_floats); 1757 __ bind(&not_floats);
1742 __ bind(&not_int32); 1758 __ bind(&not_int32);
1743 GenerateTypeTransition(masm); 1759 GenerateTypeTransition(masm);
1744 break; 1760 break;
1745 } 1761 }
1746 1762
1747 case Token::MOD: {
1748 // For MOD we go directly to runtime in the non-smi case.
1749 break;
1750 }
1751 case Token::BIT_OR: 1763 case Token::BIT_OR:
1752 case Token::BIT_AND: 1764 case Token::BIT_AND:
1753 case Token::BIT_XOR: 1765 case Token::BIT_XOR:
1754 case Token::SAR: 1766 case Token::SAR:
1755 case Token::SHL: 1767 case Token::SHL:
1756 case Token::SHR: { 1768 case Token::SHR: {
1757 GenerateRegisterArgsPush(masm); 1769 GenerateRegisterArgsPush(masm);
1758 Label not_floats; 1770 Label not_floats;
1759 Label not_int32; 1771 Label not_int32;
1760 Label non_smi_result; 1772 Label non_smi_result;
1761 /* {
1762 CpuFeatures::Scope use_sse2(SSE2);
1763 FloatingPointHelper::LoadSSE2Operands(masm, &not_floats);
1764 FloatingPointHelper::CheckSSE2OperandsAreInt32(masm, &not_int32, ecx);
1765 }*/
1766 FloatingPointHelper::LoadUnknownsAsIntegers(masm, 1773 FloatingPointHelper::LoadUnknownsAsIntegers(masm,
1767 use_sse3_, 1774 use_sse3_,
1768 &not_floats); 1775 &not_floats);
1769 FloatingPointHelper::CheckLoadedIntegersWereInt32(masm, use_sse3_, 1776 FloatingPointHelper::CheckLoadedIntegersWereInt32(masm, use_sse3_,
1770 &not_int32); 1777 &not_int32);
1771 switch (op_) { 1778 switch (op_) {
1772 case Token::BIT_OR: __ or_(eax, ecx); break; 1779 case Token::BIT_OR: __ or_(eax, ecx); break;
1773 case Token::BIT_AND: __ and_(eax, ecx); break; 1780 case Token::BIT_AND: __ and_(eax, ecx); break;
1774 case Token::BIT_XOR: __ xor_(eax, ecx); break; 1781 case Token::BIT_XOR: __ xor_(eax, ecx); break;
1775 case Token::SAR: __ sar_cl(eax); break; 1782 case Token::SAR: __ sar_cl(eax); break;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1826 } 1833 }
1827 1834
1828 __ bind(&not_floats); 1835 __ bind(&not_floats);
1829 __ bind(&not_int32); 1836 __ bind(&not_int32);
1830 GenerateTypeTransitionWithSavedArgs(masm); 1837 GenerateTypeTransitionWithSavedArgs(masm);
1831 break; 1838 break;
1832 } 1839 }
1833 default: UNREACHABLE(); break; 1840 default: UNREACHABLE(); break;
1834 } 1841 }
1835 1842
1836 // If an allocation fails, or SHR or MOD hit a hard case, 1843 // If an allocation fails, or SHR hits a hard case, use the runtime system to
1837 // use the runtime system to get the correct result. 1844 // get the correct result.
1838 __ bind(&call_runtime); 1845 __ bind(&call_runtime);
1839 1846
1840 switch (op_) { 1847 switch (op_) {
1841 case Token::ADD: 1848 case Token::ADD:
1842 GenerateRegisterArgsPush(masm); 1849 GenerateRegisterArgsPush(masm);
1843 __ InvokeBuiltin(Builtins::ADD, JUMP_FUNCTION); 1850 __ InvokeBuiltin(Builtins::ADD, JUMP_FUNCTION);
1844 break; 1851 break;
1845 case Token::SUB: 1852 case Token::SUB:
1846 GenerateRegisterArgsPush(masm); 1853 GenerateRegisterArgsPush(masm);
1847 __ InvokeBuiltin(Builtins::SUB, JUMP_FUNCTION); 1854 __ InvokeBuiltin(Builtins::SUB, JUMP_FUNCTION);
1848 break; 1855 break;
1849 case Token::MUL: 1856 case Token::MUL:
1850 GenerateRegisterArgsPush(masm); 1857 GenerateRegisterArgsPush(masm);
1851 __ InvokeBuiltin(Builtins::MUL, JUMP_FUNCTION); 1858 __ InvokeBuiltin(Builtins::MUL, JUMP_FUNCTION);
1852 break; 1859 break;
1853 case Token::DIV: 1860 case Token::DIV:
1854 GenerateRegisterArgsPush(masm); 1861 GenerateRegisterArgsPush(masm);
1855 __ InvokeBuiltin(Builtins::DIV, JUMP_FUNCTION); 1862 __ InvokeBuiltin(Builtins::DIV, JUMP_FUNCTION);
1856 break; 1863 break;
1857 case Token::MOD: 1864 case Token::MOD:
1858 GenerateRegisterArgsPush(masm);
1859 __ InvokeBuiltin(Builtins::MOD, JUMP_FUNCTION);
1860 break; 1865 break;
1861 case Token::BIT_OR: 1866 case Token::BIT_OR:
1862 __ InvokeBuiltin(Builtins::BIT_OR, JUMP_FUNCTION); 1867 __ InvokeBuiltin(Builtins::BIT_OR, JUMP_FUNCTION);
1863 break; 1868 break;
1864 case Token::BIT_AND: 1869 case Token::BIT_AND:
1865 __ InvokeBuiltin(Builtins::BIT_AND, JUMP_FUNCTION); 1870 __ InvokeBuiltin(Builtins::BIT_AND, JUMP_FUNCTION);
1866 break; 1871 break;
1867 case Token::BIT_XOR: 1872 case Token::BIT_XOR:
1868 __ InvokeBuiltin(Builtins::BIT_XOR, JUMP_FUNCTION); 1873 __ InvokeBuiltin(Builtins::BIT_XOR, JUMP_FUNCTION);
1869 break; 1874 break;
(...skipping 5513 matching lines...) Expand 10 before | Expand all | Expand 10 after
7383 false); 7388 false);
7384 __ pop(edx); 7389 __ pop(edx);
7385 __ ret(0); 7390 __ ret(0);
7386 } 7391 }
7387 7392
7388 #undef __ 7393 #undef __
7389 7394
7390 } } // namespace v8::internal 7395 } } // namespace v8::internal
7391 7396
7392 #endif // V8_TARGET_ARCH_IA32 7397 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698