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 1742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1753 // All HForceRepresentation instructions should be eliminated in the | 1753 // All HForceRepresentation instructions should be eliminated in the |
1754 // representation change phase of Hydrogen. | 1754 // representation change phase of Hydrogen. |
1755 UNREACHABLE(); | 1755 UNREACHABLE(); |
1756 return NULL; | 1756 return NULL; |
1757 } | 1757 } |
1758 | 1758 |
1759 | 1759 |
1760 LInstruction* LChunkBuilder::DoChange(HChange* instr) { | 1760 LInstruction* LChunkBuilder::DoChange(HChange* instr) { |
1761 Representation from = instr->from(); | 1761 Representation from = instr->from(); |
1762 Representation to = instr->to(); | 1762 Representation to = instr->to(); |
| 1763 if (from.IsSmi()) { |
| 1764 if (to.IsTagged()) { |
| 1765 LOperand* value = UseRegister(instr->value()); |
| 1766 return DefineSameAsFirst(new(zone()) LDummyUse(value)); |
| 1767 } |
| 1768 from = Representation::Tagged(); |
| 1769 } |
1763 if (from.IsTagged()) { | 1770 if (from.IsTagged()) { |
1764 if (to.IsDouble()) { | 1771 if (to.IsDouble()) { |
1765 info()->MarkAsDeferredCalling(); | 1772 info()->MarkAsDeferredCalling(); |
1766 LOperand* value = UseRegister(instr->value()); | 1773 LOperand* value = UseRegister(instr->value()); |
1767 LNumberUntagD* res = new(zone()) LNumberUntagD(value); | 1774 LNumberUntagD* res = new(zone()) LNumberUntagD(value); |
1768 return AssignEnvironment(DefineAsRegister(res)); | 1775 return AssignEnvironment(DefineAsRegister(res)); |
| 1776 } else if (to.IsSmi()) { |
| 1777 HValue* val = instr->value(); |
| 1778 LOperand* value = UseRegisterAtStart(val); |
| 1779 return AssignEnvironment( |
| 1780 DefineSameAsFirst(new(zone()) LCheckSmi(value))); |
1769 } else { | 1781 } else { |
1770 ASSERT(to.IsInteger32()); | 1782 ASSERT(to.IsInteger32()); |
1771 LOperand* value = NULL; | 1783 LOperand* value = NULL; |
1772 LInstruction* res = NULL; | 1784 LInstruction* res = NULL; |
1773 if (instr->value()->type().IsSmi()) { | 1785 if (instr->value()->type().IsSmi()) { |
1774 value = UseRegisterAtStart(instr->value()); | 1786 value = UseRegisterAtStart(instr->value()); |
1775 res = DefineAsRegister(new(zone()) LSmiUntag(value, false)); | 1787 res = DefineAsRegister(new(zone()) LSmiUntag(value, false)); |
1776 if (instr->value()->IsLoadKeyed()) { | 1788 if (instr->value()->IsLoadKeyed()) { |
1777 HLoadKeyed* load_keyed = HLoadKeyed::cast(instr->value()); | 1789 HLoadKeyed* load_keyed = HLoadKeyed::cast(instr->value()); |
1778 if (load_keyed->UsesMustHandleHole() && | 1790 if (load_keyed->UsesMustHandleHole() && |
(...skipping 21 matching lines...) Expand all Loading... |
1800 LOperand* value = UseRegister(instr->value()); | 1812 LOperand* value = UseRegister(instr->value()); |
1801 LOperand* temp1 = TempRegister(); | 1813 LOperand* temp1 = TempRegister(); |
1802 LOperand* temp2 = TempRegister(); | 1814 LOperand* temp2 = TempRegister(); |
1803 | 1815 |
1804 // Make sure that the temp and result_temp registers are | 1816 // Make sure that the temp and result_temp registers are |
1805 // different. | 1817 // different. |
1806 LUnallocated* result_temp = TempRegister(); | 1818 LUnallocated* result_temp = TempRegister(); |
1807 LNumberTagD* result = new(zone()) LNumberTagD(value, temp1, temp2); | 1819 LNumberTagD* result = new(zone()) LNumberTagD(value, temp1, temp2); |
1808 Define(result, result_temp); | 1820 Define(result, result_temp); |
1809 return AssignPointerMap(result); | 1821 return AssignPointerMap(result); |
| 1822 } else if (to.IsSmi()) { |
| 1823 LOperand* value = UseRegister(instr->value()); |
| 1824 return AssignEnvironment(DefineAsRegister(new(zone()) LDoubleToSmi(value, |
| 1825 TempRegister(), TempRegister()))); |
1810 } else { | 1826 } else { |
1811 ASSERT(to.IsInteger32()); | 1827 ASSERT(to.IsInteger32()); |
1812 LOperand* value = UseRegister(instr->value()); | 1828 LOperand* value = UseRegister(instr->value()); |
1813 LOperand* temp1 = TempRegister(); | 1829 LOperand* temp1 = TempRegister(); |
1814 LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister() : NULL; | 1830 LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister() : NULL; |
1815 LDoubleToI* res = new(zone()) LDoubleToI(value, temp1, temp2); | 1831 LDoubleToI* res = new(zone()) LDoubleToI(value, temp1, temp2); |
1816 return AssignEnvironment(DefineAsRegister(res)); | 1832 return AssignEnvironment(DefineAsRegister(res)); |
1817 } | 1833 } |
1818 } else if (from.IsInteger32()) { | 1834 } else if (from.IsInteger32()) { |
1819 info()->MarkAsDeferredCalling(); | 1835 info()->MarkAsDeferredCalling(); |
1820 if (to.IsTagged()) { | 1836 if (to.IsTagged()) { |
1821 HValue* val = instr->value(); | 1837 HValue* val = instr->value(); |
1822 LOperand* value = UseRegisterAtStart(val); | 1838 LOperand* value = UseRegisterAtStart(val); |
1823 if (val->CheckFlag(HInstruction::kUint32)) { | 1839 if (val->CheckFlag(HInstruction::kUint32)) { |
1824 LNumberTagU* result = new(zone()) LNumberTagU(value); | 1840 LNumberTagU* result = new(zone()) LNumberTagU(value); |
1825 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); | 1841 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); |
1826 } else if (val->HasRange() && val->range()->IsInSmiRange()) { | 1842 } else if (val->HasRange() && val->range()->IsInSmiRange()) { |
1827 return DefineAsRegister(new(zone()) LSmiTag(value)); | 1843 return DefineAsRegister(new(zone()) LSmiTag(value)); |
1828 } else { | 1844 } else { |
1829 LNumberTagI* result = new(zone()) LNumberTagI(value); | 1845 LNumberTagI* result = new(zone()) LNumberTagI(value); |
1830 return AssignEnvironment(AssignPointerMap(DefineAsRegister(result))); | 1846 return AssignEnvironment(AssignPointerMap(DefineAsRegister(result))); |
1831 } | 1847 } |
| 1848 } else if (to.IsSmi()) { |
| 1849 HValue* val = instr->value(); |
| 1850 LOperand* value = UseRegister(val); |
| 1851 LInstruction* result = |
| 1852 DefineSameAsFirst(new(zone()) LInteger32ToSmi(value)); |
| 1853 if (val->HasRange() && val->range()->IsInSmiRange()) { |
| 1854 return result; |
| 1855 } |
| 1856 return AssignEnvironment(result); |
1832 } else { | 1857 } else { |
1833 ASSERT(to.IsDouble()); | 1858 ASSERT(to.IsDouble()); |
1834 if (instr->value()->CheckFlag(HInstruction::kUint32)) { | 1859 if (instr->value()->CheckFlag(HInstruction::kUint32)) { |
1835 return DefineAsRegister( | 1860 return DefineAsRegister( |
1836 new(zone()) LUint32ToDouble(UseRegister(instr->value()))); | 1861 new(zone()) LUint32ToDouble(UseRegister(instr->value()))); |
1837 } else { | 1862 } else { |
1838 return DefineAsRegister( | 1863 return DefineAsRegister( |
1839 new(zone()) LInteger32ToDouble(Use(instr->value()))); | 1864 new(zone()) LInteger32ToDouble(Use(instr->value()))); |
1840 } | 1865 } |
1841 } | 1866 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1916 parameter_count); | 1941 parameter_count); |
1917 } | 1942 } |
1918 | 1943 |
1919 | 1944 |
1920 LInstruction* LChunkBuilder::DoConstant(HConstant* instr) { | 1945 LInstruction* LChunkBuilder::DoConstant(HConstant* instr) { |
1921 Representation r = instr->representation(); | 1946 Representation r = instr->representation(); |
1922 if (r.IsInteger32()) { | 1947 if (r.IsInteger32()) { |
1923 return DefineAsRegister(new(zone()) LConstantI); | 1948 return DefineAsRegister(new(zone()) LConstantI); |
1924 } else if (r.IsDouble()) { | 1949 } else if (r.IsDouble()) { |
1925 return DefineAsRegister(new(zone()) LConstantD); | 1950 return DefineAsRegister(new(zone()) LConstantD); |
1926 } else if (r.IsTagged()) { | 1951 } else if (r.IsTagged() || r.IsSmi()) { |
1927 return DefineAsRegister(new(zone()) LConstantT); | 1952 return DefineAsRegister(new(zone()) LConstantT); |
1928 } else { | 1953 } else { |
1929 UNREACHABLE(); | 1954 UNREACHABLE(); |
1930 return NULL; | 1955 return NULL; |
1931 } | 1956 } |
1932 } | 1957 } |
1933 | 1958 |
1934 | 1959 |
1935 LInstruction* LChunkBuilder::DoLoadGlobalCell(HLoadGlobalCell* instr) { | 1960 LInstruction* LChunkBuilder::DoLoadGlobalCell(HLoadGlobalCell* instr) { |
1936 LLoadGlobalCell* result = new(zone()) LLoadGlobalCell; | 1961 LLoadGlobalCell* result = new(zone()) LLoadGlobalCell; |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2490 | 2515 |
2491 | 2516 |
2492 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2517 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2493 LOperand* object = UseRegister(instr->object()); | 2518 LOperand* object = UseRegister(instr->object()); |
2494 LOperand* index = UseRegister(instr->index()); | 2519 LOperand* index = UseRegister(instr->index()); |
2495 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2520 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
2496 } | 2521 } |
2497 | 2522 |
2498 | 2523 |
2499 } } // namespace v8::internal | 2524 } } // namespace v8::internal |
OLD | NEW |