| 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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 | 365 |
| 366 void LStoreNamedGeneric::PrintDataTo(StringStream* stream) { | 366 void LStoreNamedGeneric::PrintDataTo(StringStream* stream) { |
| 367 object()->PrintTo(stream); | 367 object()->PrintTo(stream); |
| 368 stream->Add("."); | 368 stream->Add("."); |
| 369 stream->Add(*String::cast(*name())->ToCString()); | 369 stream->Add(*String::cast(*name())->ToCString()); |
| 370 stream->Add(" <- "); | 370 stream->Add(" <- "); |
| 371 value()->PrintTo(stream); | 371 value()->PrintTo(stream); |
| 372 } | 372 } |
| 373 | 373 |
| 374 | 374 |
| 375 void LStoreKeyedFastElement::PrintDataTo(StringStream* stream) { | 375 void LStoreKeyed::PrintDataTo(StringStream* stream) { |
| 376 object()->PrintTo(stream); | |
| 377 stream->Add("["); | |
| 378 key()->PrintTo(stream); | |
| 379 stream->Add("] <- "); | |
| 380 value()->PrintTo(stream); | |
| 381 } | |
| 382 | |
| 383 | |
| 384 void LStoreKeyedFastDoubleElement::PrintDataTo(StringStream* stream) { | |
| 385 elements()->PrintTo(stream); | 376 elements()->PrintTo(stream); |
| 386 stream->Add("["); | 377 stream->Add("["); |
| 387 key()->PrintTo(stream); | 378 key()->PrintTo(stream); |
| 388 stream->Add("] <- "); | 379 stream->Add("] <- "); |
| 389 value()->PrintTo(stream); | 380 value()->PrintTo(stream); |
| 390 } | 381 } |
| 391 | 382 |
| 392 | 383 |
| 393 void LStoreKeyedGeneric::PrintDataTo(StringStream* stream) { | 384 void LStoreKeyedGeneric::PrintDataTo(StringStream* stream) { |
| 394 object()->PrintTo(stream); | 385 object()->PrintTo(stream); |
| (...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1791 } | 1782 } |
| 1792 | 1783 |
| 1793 | 1784 |
| 1794 LInstruction* LChunkBuilder::DoLoadExternalArrayPointer( | 1785 LInstruction* LChunkBuilder::DoLoadExternalArrayPointer( |
| 1795 HLoadExternalArrayPointer* instr) { | 1786 HLoadExternalArrayPointer* instr) { |
| 1796 LOperand* input = UseRegisterAtStart(instr->value()); | 1787 LOperand* input = UseRegisterAtStart(instr->value()); |
| 1797 return DefineAsRegister(new(zone()) LLoadExternalArrayPointer(input)); | 1788 return DefineAsRegister(new(zone()) LLoadExternalArrayPointer(input)); |
| 1798 } | 1789 } |
| 1799 | 1790 |
| 1800 | 1791 |
| 1801 LInstruction* LChunkBuilder::DoLoadKeyedFastElement( | 1792 LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) { |
| 1802 HLoadKeyedFastElement* instr) { | |
| 1803 ASSERT(instr->representation().IsTagged()); | |
| 1804 ASSERT(instr->key()->representation().IsInteger32() || | 1793 ASSERT(instr->key()->representation().IsInteger32() || |
| 1805 instr->key()->representation().IsTagged()); | 1794 instr->key()->representation().IsTagged()); |
| 1806 LOperand* obj = UseRegisterAtStart(instr->object()); | 1795 ElementsKind elements_kind = instr->elements_kind(); |
| 1807 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); | 1796 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); |
| 1808 LLoadKeyedFastElement* result = new(zone()) LLoadKeyedFastElement(obj, key); | 1797 LLoadKeyed* result = NULL; |
| 1809 if (instr->RequiresHoleCheck()) AssignEnvironment(result); | 1798 |
| 1810 return DefineAsRegister(result); | 1799 if (!instr->is_external()) { |
| 1800 LOperand* obj = NULL; |
| 1801 if (instr->representation().IsDouble()) { |
| 1802 obj = UseTempRegister(instr->elements()); |
| 1803 } else { |
| 1804 ASSERT(instr->representation().IsTagged()); |
| 1805 obj = UseRegisterAtStart(instr->elements()); |
| 1806 } |
| 1807 result = new(zone()) LLoadKeyed(obj, key); |
| 1808 } else { |
| 1809 ASSERT( |
| 1810 (instr->representation().IsInteger32() && |
| 1811 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && |
| 1812 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || |
| 1813 (instr->representation().IsDouble() && |
| 1814 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || |
| 1815 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); |
| 1816 LOperand* external_pointer = UseRegister(instr->elements()); |
| 1817 result = new(zone()) LLoadKeyed(external_pointer, key); |
| 1818 } |
| 1819 |
| 1820 DefineAsRegister(result); |
| 1821 // An unsigned int array load might overflow and cause a deopt, make sure it |
| 1822 // has an environment. |
| 1823 bool can_deoptimize = instr->RequiresHoleCheck() || |
| 1824 (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS); |
| 1825 return can_deoptimize ? AssignEnvironment(result) : result; |
| 1811 } | 1826 } |
| 1812 | 1827 |
| 1813 | 1828 |
| 1814 LInstruction* LChunkBuilder::DoLoadKeyedFastDoubleElement( | |
| 1815 HLoadKeyedFastDoubleElement* instr) { | |
| 1816 ASSERT(instr->representation().IsDouble()); | |
| 1817 ASSERT(instr->key()->representation().IsInteger32() || | |
| 1818 instr->key()->representation().IsTagged()); | |
| 1819 LOperand* elements = UseTempRegister(instr->elements()); | |
| 1820 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); | |
| 1821 LLoadKeyedFastDoubleElement* result = | |
| 1822 new(zone()) LLoadKeyedFastDoubleElement(elements, key); | |
| 1823 return AssignEnvironment(DefineAsRegister(result)); | |
| 1824 } | |
| 1825 | |
| 1826 | |
| 1827 LInstruction* LChunkBuilder::DoLoadKeyedSpecializedArrayElement( | |
| 1828 HLoadKeyedSpecializedArrayElement* instr) { | |
| 1829 ElementsKind elements_kind = instr->elements_kind(); | |
| 1830 ASSERT( | |
| 1831 (instr->representation().IsInteger32() && | |
| 1832 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && | |
| 1833 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || | |
| 1834 (instr->representation().IsDouble() && | |
| 1835 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || | |
| 1836 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); | |
| 1837 ASSERT(instr->key()->representation().IsInteger32() || | |
| 1838 instr->key()->representation().IsTagged()); | |
| 1839 LOperand* external_pointer = UseRegister(instr->external_pointer()); | |
| 1840 LOperand* key = UseRegisterOrConstant(instr->key()); | |
| 1841 LLoadKeyedSpecializedArrayElement* result = | |
| 1842 new(zone()) LLoadKeyedSpecializedArrayElement(external_pointer, key); | |
| 1843 LInstruction* load_instr = DefineAsRegister(result); | |
| 1844 // An unsigned int array load might overflow and cause a deopt, make sure it | |
| 1845 // has an environment. | |
| 1846 return (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS) ? | |
| 1847 AssignEnvironment(load_instr) : load_instr; | |
| 1848 } | |
| 1849 | |
| 1850 | |
| 1851 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) { | 1829 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) { |
| 1852 LOperand* object = UseFixed(instr->object(), a1); | 1830 LOperand* object = UseFixed(instr->object(), a1); |
| 1853 LOperand* key = UseFixed(instr->key(), a0); | 1831 LOperand* key = UseFixed(instr->key(), a0); |
| 1854 | 1832 |
| 1855 LInstruction* result = | 1833 LInstruction* result = |
| 1856 DefineFixed(new(zone()) LLoadKeyedGeneric(object, key), v0); | 1834 DefineFixed(new(zone()) LLoadKeyedGeneric(object, key), v0); |
| 1857 return MarkAsCall(result, instr); | 1835 return MarkAsCall(result, instr); |
| 1858 } | 1836 } |
| 1859 | 1837 |
| 1860 | 1838 |
| 1861 LInstruction* LChunkBuilder::DoStoreKeyedFastElement( | 1839 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { |
| 1862 HStoreKeyedFastElement* instr) { | 1840 ElementsKind elements_kind = instr->elements_kind(); |
| 1863 bool needs_write_barrier = instr->NeedsWriteBarrier(); | 1841 bool needs_write_barrier = instr->NeedsWriteBarrier(); |
| 1864 ASSERT(instr->value()->representation().IsTagged()); | |
| 1865 ASSERT(instr->object()->representation().IsTagged()); | |
| 1866 ASSERT(instr->key()->representation().IsInteger32() || | |
| 1867 instr->key()->representation().IsTagged()); | |
| 1868 | |
| 1869 LOperand* obj = UseTempRegister(instr->object()); | |
| 1870 LOperand* val = needs_write_barrier | |
| 1871 ? UseTempRegister(instr->value()) | |
| 1872 : UseRegisterAtStart(instr->value()); | |
| 1873 LOperand* key = needs_write_barrier | 1842 LOperand* key = needs_write_barrier |
| 1874 ? UseTempRegister(instr->key()) | 1843 ? UseTempRegister(instr->key()) |
| 1875 : UseRegisterOrConstantAtStart(instr->key()); | 1844 : UseRegisterOrConstantAtStart(instr->key()); |
| 1876 return new(zone()) LStoreKeyedFastElement(obj, key, val); | 1845 bool val_is_temp_register = |
| 1846 elements_kind == EXTERNAL_PIXEL_ELEMENTS || |
| 1847 elements_kind == EXTERNAL_FLOAT_ELEMENTS; |
| 1848 LOperand* val = val_is_temp_register || needs_write_barrier |
| 1849 ? UseTempRegister(instr->value()) |
| 1850 : UseRegister(instr->value()); |
| 1851 LStoreKeyed* result = NULL; |
| 1852 if (!instr->is_external()) { |
| 1853 ASSERT(instr->elements()->representation().IsTagged()); |
| 1854 |
| 1855 LOperand* object = NULL; |
| 1856 if (instr->value()->representation().IsDouble()) { |
| 1857 object = UseRegisterAtStart(instr->elements()); |
| 1858 } else { |
| 1859 ASSERT(instr->value()->representation().IsTagged()); |
| 1860 object = UseTempRegister(instr->elements()); |
| 1861 } |
| 1862 |
| 1863 result = new(zone()) LStoreKeyed(object, key, val); |
| 1864 } else { |
| 1865 ASSERT( |
| 1866 (instr->value()->representation().IsInteger32() && |
| 1867 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && |
| 1868 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || |
| 1869 (instr->value()->representation().IsDouble() && |
| 1870 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || |
| 1871 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); |
| 1872 ASSERT(instr->elements()->representation().IsExternal()); |
| 1873 |
| 1874 LOperand* external_pointer = UseRegister(instr->elements()); |
| 1875 result = new(zone()) LStoreKeyed(external_pointer, key, val); |
| 1876 } |
| 1877 |
| 1878 ASSERT(result != NULL); |
| 1879 return result; |
| 1877 } | 1880 } |
| 1878 | 1881 |
| 1879 | 1882 |
| 1880 LInstruction* LChunkBuilder::DoStoreKeyedFastDoubleElement( | |
| 1881 HStoreKeyedFastDoubleElement* instr) { | |
| 1882 ASSERT(instr->value()->representation().IsDouble()); | |
| 1883 ASSERT(instr->elements()->representation().IsTagged()); | |
| 1884 ASSERT(instr->key()->representation().IsInteger32() || | |
| 1885 instr->key()->representation().IsTagged()); | |
| 1886 | |
| 1887 LOperand* elements = UseRegisterAtStart(instr->elements()); | |
| 1888 LOperand* val = UseTempRegister(instr->value()); | |
| 1889 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); | |
| 1890 | |
| 1891 return new(zone()) LStoreKeyedFastDoubleElement(elements, key, val); | |
| 1892 } | |
| 1893 | |
| 1894 | |
| 1895 LInstruction* LChunkBuilder::DoStoreKeyedSpecializedArrayElement( | |
| 1896 HStoreKeyedSpecializedArrayElement* instr) { | |
| 1897 ElementsKind elements_kind = instr->elements_kind(); | |
| 1898 ASSERT( | |
| 1899 (instr->value()->representation().IsInteger32() && | |
| 1900 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && | |
| 1901 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || | |
| 1902 (instr->value()->representation().IsDouble() && | |
| 1903 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || | |
| 1904 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); | |
| 1905 ASSERT(instr->external_pointer()->representation().IsExternal()); | |
| 1906 ASSERT(instr->key()->representation().IsInteger32() || | |
| 1907 instr->key()->representation().IsTagged()); | |
| 1908 | |
| 1909 LOperand* external_pointer = UseRegister(instr->external_pointer()); | |
| 1910 bool val_is_temp_register = | |
| 1911 elements_kind == EXTERNAL_PIXEL_ELEMENTS || | |
| 1912 elements_kind == EXTERNAL_FLOAT_ELEMENTS; | |
| 1913 LOperand* val = val_is_temp_register | |
| 1914 ? UseTempRegister(instr->value()) | |
| 1915 : UseRegister(instr->value()); | |
| 1916 LOperand* key = UseRegisterOrConstant(instr->key()); | |
| 1917 | |
| 1918 return new(zone()) LStoreKeyedSpecializedArrayElement(external_pointer, | |
| 1919 key, | |
| 1920 val); | |
| 1921 } | |
| 1922 | |
| 1923 | |
| 1924 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { | 1883 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { |
| 1925 LOperand* obj = UseFixed(instr->object(), a2); | 1884 LOperand* obj = UseFixed(instr->object(), a2); |
| 1926 LOperand* key = UseFixed(instr->key(), a1); | 1885 LOperand* key = UseFixed(instr->key(), a1); |
| 1927 LOperand* val = UseFixed(instr->value(), a0); | 1886 LOperand* val = UseFixed(instr->value(), a0); |
| 1928 | 1887 |
| 1929 ASSERT(instr->object()->representation().IsTagged()); | 1888 ASSERT(instr->object()->representation().IsTagged()); |
| 1930 ASSERT(instr->key()->representation().IsTagged()); | 1889 ASSERT(instr->key()->representation().IsTagged()); |
| 1931 ASSERT(instr->value()->representation().IsTagged()); | 1890 ASSERT(instr->value()->representation().IsTagged()); |
| 1932 | 1891 |
| 1933 return MarkAsCall(new(zone()) LStoreKeyedGeneric(obj, key, val), instr); | 1892 return MarkAsCall(new(zone()) LStoreKeyedGeneric(obj, key, val), instr); |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2244 | 2203 |
| 2245 | 2204 |
| 2246 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2205 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2247 LOperand* object = UseRegister(instr->object()); | 2206 LOperand* object = UseRegister(instr->object()); |
| 2248 LOperand* index = UseRegister(instr->index()); | 2207 LOperand* index = UseRegister(instr->index()); |
| 2249 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2208 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
| 2250 } | 2209 } |
| 2251 | 2210 |
| 2252 | 2211 |
| 2253 } } // namespace v8::internal | 2212 } } // namespace v8::internal |
| OLD | NEW |