OLD | NEW |
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 1786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1797 // All HForceRepresentation instructions should be eliminated in the | 1797 // All HForceRepresentation instructions should be eliminated in the |
1798 // representation change phase of Hydrogen. | 1798 // representation change phase of Hydrogen. |
1799 UNREACHABLE(); | 1799 UNREACHABLE(); |
1800 return NULL; | 1800 return NULL; |
1801 } | 1801 } |
1802 | 1802 |
1803 | 1803 |
1804 LInstruction* LChunkBuilder::DoChange(HChange* instr) { | 1804 LInstruction* LChunkBuilder::DoChange(HChange* instr) { |
1805 Representation from = instr->from(); | 1805 Representation from = instr->from(); |
1806 Representation to = instr->to(); | 1806 Representation to = instr->to(); |
| 1807 HValue* val = instr->value(); |
1807 if (from.IsSmi()) { | 1808 if (from.IsSmi()) { |
1808 if (to.IsTagged()) { | 1809 if (to.IsTagged()) { |
1809 LOperand* value = UseRegister(instr->value()); | 1810 LOperand* value = UseRegister(val); |
1810 return DefineSameAsFirst(new(zone()) LDummyUse(value)); | 1811 return DefineSameAsFirst(new(zone()) LDummyUse(value)); |
1811 } | 1812 } |
1812 from = Representation::Tagged(); | 1813 from = Representation::Tagged(); |
1813 } | 1814 } |
1814 // Only mark conversions that might need to allocate as calling rather than | |
1815 // all changes. This makes simple, non-allocating conversion not have to force | |
1816 // building a stack frame. | |
1817 if (from.IsTagged()) { | 1815 if (from.IsTagged()) { |
1818 if (to.IsDouble()) { | 1816 if (to.IsDouble()) { |
1819 LOperand* value = UseRegister(instr->value()); | 1817 LOperand* value = UseRegister(val); |
1820 LInstruction* res = DefineAsRegister(new(zone()) LNumberUntagD(value)); | 1818 LInstruction* result = DefineAsRegister(new(zone()) LNumberUntagD(value)); |
1821 if (!instr->value()->representation().IsSmi()) { | 1819 if (!val->representation().IsSmi()) result = AssignEnvironment(result); |
1822 res = AssignEnvironment(res); | 1820 return result; |
1823 } | |
1824 return res; | |
1825 } else if (to.IsSmi()) { | 1821 } else if (to.IsSmi()) { |
1826 HValue* val = instr->value(); | |
1827 LOperand* value = UseRegister(val); | 1822 LOperand* value = UseRegister(val); |
1828 if (val->type().IsSmi()) { | 1823 if (val->type().IsSmi()) { |
1829 return DefineSameAsFirst(new(zone()) LDummyUse(value)); | 1824 return DefineSameAsFirst(new(zone()) LDummyUse(value)); |
1830 } | 1825 } |
1831 return AssignEnvironment(DefineSameAsFirst(new(zone()) LCheckSmi(value))); | 1826 return AssignEnvironment(DefineSameAsFirst(new(zone()) LCheckSmi(value))); |
1832 } else { | 1827 } else { |
1833 ASSERT(to.IsInteger32()); | 1828 ASSERT(to.IsInteger32()); |
1834 HValue* val = instr->value(); | |
1835 LOperand* value = UseRegister(val); | |
1836 if (val->type().IsSmi() || val->representation().IsSmi()) { | 1829 if (val->type().IsSmi() || val->representation().IsSmi()) { |
| 1830 LOperand* value = UseRegister(val); |
1837 return DefineSameAsFirst(new(zone()) LSmiUntag(value, false)); | 1831 return DefineSameAsFirst(new(zone()) LSmiUntag(value, false)); |
1838 } else { | 1832 } else { |
| 1833 LOperand* value = UseRegister(val); |
1839 bool truncating = instr->CanTruncateToInt32(); | 1834 bool truncating = instr->CanTruncateToInt32(); |
1840 LOperand* xmm_temp = truncating ? NULL : FixedTemp(xmm1); | 1835 LOperand* xmm_temp = truncating ? NULL : FixedTemp(xmm1); |
1841 LInstruction* res = | 1836 LInstruction* result = |
1842 DefineSameAsFirst(new(zone()) LTaggedToI(value, xmm_temp)); | 1837 DefineSameAsFirst(new(zone()) LTaggedToI(value, xmm_temp)); |
1843 if (!instr->value()->representation().IsSmi()) { | 1838 if (!val->representation().IsSmi()) { |
1844 // Note: Only deopts in deferred code. | 1839 // Note: Only deopts in deferred code. |
1845 res = AssignEnvironment(res); | 1840 result = AssignEnvironment(result); |
1846 } | 1841 } |
1847 return res; | 1842 return result; |
1848 } | 1843 } |
1849 } | 1844 } |
1850 } else if (from.IsDouble()) { | 1845 } else if (from.IsDouble()) { |
1851 if (to.IsTagged()) { | 1846 if (to.IsTagged()) { |
1852 info()->MarkAsDeferredCalling(); | 1847 info()->MarkAsDeferredCalling(); |
1853 LOperand* value = UseRegister(instr->value()); | 1848 LOperand* value = UseRegister(val); |
1854 LOperand* temp = TempRegister(); | 1849 LOperand* temp = TempRegister(); |
1855 | |
1856 // Make sure that temp and result_temp are different registers. | |
1857 LUnallocated* result_temp = TempRegister(); | 1850 LUnallocated* result_temp = TempRegister(); |
1858 LNumberTagD* result = new(zone()) LNumberTagD(value, temp); | 1851 LNumberTagD* result = new(zone()) LNumberTagD(value, temp); |
1859 return AssignPointerMap(Define(result, result_temp)); | 1852 return AssignPointerMap(Define(result, result_temp)); |
1860 } else if (to.IsSmi()) { | 1853 } else if (to.IsSmi()) { |
1861 LOperand* value = UseRegister(instr->value()); | 1854 LOperand* value = UseRegister(val); |
1862 return AssignEnvironment( | 1855 return AssignEnvironment( |
1863 DefineAsRegister(new(zone()) LDoubleToSmi(value))); | 1856 DefineAsRegister(new(zone()) LDoubleToSmi(value))); |
1864 } else { | 1857 } else { |
1865 ASSERT(to.IsInteger32()); | 1858 ASSERT(to.IsInteger32()); |
1866 LOperand* value = UseRegister(instr->value()); | 1859 LOperand* value = UseRegister(val); |
1867 LInstruction* result = DefineAsRegister(new(zone()) LDoubleToI(value)); | 1860 LInstruction* result = DefineAsRegister(new(zone()) LDoubleToI(value)); |
1868 if (!instr->CanTruncateToInt32()) { | 1861 if (!instr->CanTruncateToInt32()) result = AssignEnvironment(result); |
1869 result = AssignEnvironment(result); | |
1870 } | |
1871 return result; | 1862 return result; |
1872 } | 1863 } |
1873 } else if (from.IsInteger32()) { | 1864 } else if (from.IsInteger32()) { |
1874 info()->MarkAsDeferredCalling(); | 1865 info()->MarkAsDeferredCalling(); |
1875 if (to.IsTagged()) { | 1866 if (to.IsTagged()) { |
1876 HValue* val = instr->value(); | |
1877 LOperand* value = UseRegister(val); | |
1878 if (!instr->CheckFlag(HValue::kCanOverflow)) { | 1867 if (!instr->CheckFlag(HValue::kCanOverflow)) { |
| 1868 LOperand* value = UseRegister(val); |
1879 return DefineAsRegister(new(zone()) LSmiTag(value)); | 1869 return DefineAsRegister(new(zone()) LSmiTag(value)); |
1880 } else if (val->CheckFlag(HInstruction::kUint32)) { | 1870 } else if (val->CheckFlag(HInstruction::kUint32)) { |
| 1871 LOperand* value = UseRegister(val); |
1881 LOperand* temp1 = TempRegister(); | 1872 LOperand* temp1 = TempRegister(); |
1882 LOperand* temp2 = FixedTemp(xmm1); | 1873 LOperand* temp2 = FixedTemp(xmm1); |
1883 LNumberTagU* result = new(zone()) LNumberTagU(value, temp1, temp2); | 1874 LNumberTagU* result = new(zone()) LNumberTagU(value, temp1, temp2); |
1884 return AssignPointerMap(DefineSameAsFirst(result)); | 1875 return AssignPointerMap(DefineSameAsFirst(result)); |
1885 } else { | 1876 } else { |
| 1877 LOperand* value = UseRegister(val); |
1886 LNumberTagI* result = new(zone()) LNumberTagI(value); | 1878 LNumberTagI* result = new(zone()) LNumberTagI(value); |
1887 return AssignPointerMap(DefineSameAsFirst(result)); | 1879 return AssignPointerMap(DefineSameAsFirst(result)); |
1888 } | 1880 } |
1889 } else if (to.IsSmi()) { | 1881 } else if (to.IsSmi()) { |
1890 HValue* val = instr->value(); | |
1891 LOperand* value = UseRegister(val); | 1882 LOperand* value = UseRegister(val); |
1892 LInstruction* result = DefineAsRegister(new(zone()) LSmiTag(value)); | 1883 LInstruction* result = DefineAsRegister(new(zone()) LSmiTag(value)); |
1893 if (instr->CheckFlag(HValue::kCanOverflow)) { | 1884 if (instr->CheckFlag(HValue::kCanOverflow)) { |
1894 ASSERT(val->CheckFlag(HValue::kUint32)); | |
1895 result = AssignEnvironment(result); | 1885 result = AssignEnvironment(result); |
1896 } | 1886 } |
1897 return result; | 1887 return result; |
1898 } else { | 1888 } else { |
1899 if (instr->value()->CheckFlag(HInstruction::kUint32)) { | 1889 ASSERT(to.IsDouble()); |
| 1890 if (val->CheckFlag(HInstruction::kUint32)) { |
1900 LOperand* temp = FixedTemp(xmm1); | 1891 LOperand* temp = FixedTemp(xmm1); |
1901 return DefineAsRegister( | 1892 return DefineAsRegister( |
1902 new(zone()) LUint32ToDouble(UseRegister(instr->value()), temp)); | 1893 new(zone()) LUint32ToDouble(UseRegister(val), temp)); |
1903 } else { | 1894 } else { |
1904 ASSERT(to.IsDouble()); | 1895 LOperand* value = Use(val); |
1905 LOperand* value = Use(instr->value()); | |
1906 return DefineAsRegister(new(zone()) LInteger32ToDouble(value)); | 1896 return DefineAsRegister(new(zone()) LInteger32ToDouble(value)); |
1907 } | 1897 } |
1908 } | 1898 } |
1909 } | 1899 } |
1910 UNREACHABLE(); | 1900 UNREACHABLE(); |
1911 return NULL; | 1901 return NULL; |
1912 } | 1902 } |
1913 | 1903 |
1914 | 1904 |
1915 LInstruction* LChunkBuilder::DoCheckHeapObject(HCheckHeapObject* instr) { | 1905 LInstruction* LChunkBuilder::DoCheckHeapObject(HCheckHeapObject* instr) { |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2591 LOperand* index = UseTempRegister(instr->index()); | 2581 LOperand* index = UseTempRegister(instr->index()); |
2592 LLoadFieldByIndex* load = new(zone()) LLoadFieldByIndex(object, index); | 2582 LLoadFieldByIndex* load = new(zone()) LLoadFieldByIndex(object, index); |
2593 LInstruction* result = DefineSameAsFirst(load); | 2583 LInstruction* result = DefineSameAsFirst(load); |
2594 return AssignPointerMap(result); | 2584 return AssignPointerMap(result); |
2595 } | 2585 } |
2596 | 2586 |
2597 | 2587 |
2598 } } // namespace v8::internal | 2588 } } // namespace v8::internal |
2599 | 2589 |
2600 #endif // V8_TARGET_ARCH_X64 | 2590 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |