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