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

Side by Side Diff: src/x64/lithium-x64.cc

Issue 10735020: Optimize Smi keys for KeyedLoads (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review feedback Created 8 years, 5 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 | « src/x64/lithium-x64.h ('k') | test/mjsunit/external-array.js » ('j') | 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 1797 matching lines...) Expand 10 before | Expand all | Expand 10 after
1808 LInstruction* LChunkBuilder::DoLoadExternalArrayPointer( 1808 LInstruction* LChunkBuilder::DoLoadExternalArrayPointer(
1809 HLoadExternalArrayPointer* instr) { 1809 HLoadExternalArrayPointer* instr) {
1810 LOperand* input = UseRegisterAtStart(instr->value()); 1810 LOperand* input = UseRegisterAtStart(instr->value());
1811 return DefineAsRegister(new(zone()) LLoadExternalArrayPointer(input)); 1811 return DefineAsRegister(new(zone()) LLoadExternalArrayPointer(input));
1812 } 1812 }
1813 1813
1814 1814
1815 LInstruction* LChunkBuilder::DoLoadKeyedFastElement( 1815 LInstruction* LChunkBuilder::DoLoadKeyedFastElement(
1816 HLoadKeyedFastElement* instr) { 1816 HLoadKeyedFastElement* instr) {
1817 ASSERT(instr->representation().IsTagged()); 1817 ASSERT(instr->representation().IsTagged());
1818 ASSERT(instr->key()->representation().IsInteger32()); 1818 ASSERT(instr->key()->representation().IsInteger32() ||
1819 instr->key()->representation().IsTagged());
1819 LOperand* obj = UseRegisterAtStart(instr->object()); 1820 LOperand* obj = UseRegisterAtStart(instr->object());
1820 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); 1821 bool clobbers_key = instr->key()->representation().IsTagged();
1821 LLoadKeyedFastElement* result = new(zone()) LLoadKeyedFastElement(obj, key); 1822 LOperand* key = clobbers_key
1823 ? UseTempRegister(instr->key())
1824 : UseRegisterOrConstantAtStart(instr->key());
1825 LLoadKeyedFastElement* result =
1826 new(zone()) LLoadKeyedFastElement(obj, key);
1822 if (instr->RequiresHoleCheck()) AssignEnvironment(result); 1827 if (instr->RequiresHoleCheck()) AssignEnvironment(result);
1823 return DefineAsRegister(result); 1828 return DefineAsRegister(result);
1824 } 1829 }
1825 1830
1826 1831
1827 LInstruction* LChunkBuilder::DoLoadKeyedFastDoubleElement( 1832 LInstruction* LChunkBuilder::DoLoadKeyedFastDoubleElement(
1828 HLoadKeyedFastDoubleElement* instr) { 1833 HLoadKeyedFastDoubleElement* instr) {
1829 ASSERT(instr->representation().IsDouble()); 1834 ASSERT(instr->representation().IsDouble());
1830 ASSERT(instr->key()->representation().IsInteger32()); 1835 ASSERT(instr->key()->representation().IsInteger32() ||
1836 instr->key()->representation().IsTagged());
1831 LOperand* elements = UseRegisterAtStart(instr->elements()); 1837 LOperand* elements = UseRegisterAtStart(instr->elements());
1832 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); 1838 bool clobbers_key = instr->key()->representation().IsTagged();
1839 LOperand* key = clobbers_key
1840 ? UseTempRegister(instr->key())
1841 : UseRegisterOrConstantAtStart(instr->key());
1833 LLoadKeyedFastDoubleElement* result = 1842 LLoadKeyedFastDoubleElement* result =
1834 new(zone()) LLoadKeyedFastDoubleElement(elements, key); 1843 new(zone()) LLoadKeyedFastDoubleElement(elements, key);
1835 return AssignEnvironment(DefineAsRegister(result)); 1844 return AssignEnvironment(DefineAsRegister(result));
1836 } 1845 }
1837 1846
1838 1847
1839 LInstruction* LChunkBuilder::DoLoadKeyedSpecializedArrayElement( 1848 LInstruction* LChunkBuilder::DoLoadKeyedSpecializedArrayElement(
1840 HLoadKeyedSpecializedArrayElement* instr) { 1849 HLoadKeyedSpecializedArrayElement* instr) {
1841 ElementsKind elements_kind = instr->elements_kind(); 1850 ElementsKind elements_kind = instr->elements_kind();
1842 ASSERT( 1851 ASSERT(
1843 (instr->representation().IsInteger32() && 1852 (instr->representation().IsInteger32() &&
1844 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && 1853 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) &&
1845 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || 1854 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) ||
1846 (instr->representation().IsDouble() && 1855 (instr->representation().IsDouble() &&
1847 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || 1856 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) ||
1848 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); 1857 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS))));
1849 ASSERT(instr->key()->representation().IsInteger32()); 1858 ASSERT(instr->key()->representation().IsInteger32() ||
1859 instr->key()->representation().IsTagged());
1850 LOperand* external_pointer = UseRegister(instr->external_pointer()); 1860 LOperand* external_pointer = UseRegister(instr->external_pointer());
1851 LOperand* key = UseRegisterOrConstant(instr->key()); 1861 bool clobbers_key = instr->key()->representation().IsTagged();
1862 LOperand* key = clobbers_key
1863 ? UseTempRegister(instr->key())
1864 : UseRegisterOrConstantAtStart(instr->key());
1852 LLoadKeyedSpecializedArrayElement* result = 1865 LLoadKeyedSpecializedArrayElement* result =
1853 new(zone()) LLoadKeyedSpecializedArrayElement(external_pointer, key); 1866 new(zone()) LLoadKeyedSpecializedArrayElement(external_pointer, key);
1854 LInstruction* load_instr = DefineAsRegister(result); 1867 LInstruction* load_instr = DefineAsRegister(result);
1855 // An unsigned int array load might overflow and cause a deopt, make sure it 1868 // An unsigned int array load might overflow and cause a deopt, make sure it
1856 // has an environment. 1869 // has an environment.
1857 return (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS) ? 1870 return (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS) ?
1858 AssignEnvironment(load_instr) : load_instr; 1871 AssignEnvironment(load_instr) : load_instr;
1859 } 1872 }
1860 1873
1861 1874
1862 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) { 1875 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) {
1863 LOperand* object = UseFixed(instr->object(), rdx); 1876 LOperand* object = UseFixed(instr->object(), rdx);
1864 LOperand* key = UseFixed(instr->key(), rax); 1877 LOperand* key = UseFixed(instr->key(), rax);
1865 1878
1866 LLoadKeyedGeneric* result = new(zone()) LLoadKeyedGeneric(object, key); 1879 LLoadKeyedGeneric* result = new(zone()) LLoadKeyedGeneric(object, key);
1867 return MarkAsCall(DefineFixed(result, rax), instr); 1880 return MarkAsCall(DefineFixed(result, rax), instr);
1868 } 1881 }
1869 1882
1870 1883
1871 LInstruction* LChunkBuilder::DoStoreKeyedFastElement( 1884 LInstruction* LChunkBuilder::DoStoreKeyedFastElement(
1872 HStoreKeyedFastElement* instr) { 1885 HStoreKeyedFastElement* instr) {
1873 bool needs_write_barrier = instr->NeedsWriteBarrier(); 1886 bool needs_write_barrier = instr->NeedsWriteBarrier();
1874 ASSERT(instr->value()->representation().IsTagged()); 1887 ASSERT(instr->value()->representation().IsTagged());
1875 ASSERT(instr->object()->representation().IsTagged()); 1888 ASSERT(instr->object()->representation().IsTagged());
1876 ASSERT(instr->key()->representation().IsInteger32()); 1889 ASSERT(instr->key()->representation().IsInteger32() ||
1890 instr->key()->representation().IsTagged());
1877 1891
1878 LOperand* obj = UseTempRegister(instr->object()); 1892 LOperand* obj = UseTempRegister(instr->object());
1879 LOperand* val = needs_write_barrier 1893 LOperand* val = needs_write_barrier
1880 ? UseTempRegister(instr->value()) 1894 ? UseTempRegister(instr->value())
1881 : UseRegisterAtStart(instr->value()); 1895 : UseRegisterAtStart(instr->value());
1882 LOperand* key = needs_write_barrier 1896 bool clobbers_key = needs_write_barrier ||
1897 instr->key()->representation().IsTagged();
1898 LOperand* key = clobbers_key
1883 ? UseTempRegister(instr->key()) 1899 ? UseTempRegister(instr->key())
1884 : UseRegisterOrConstantAtStart(instr->key()); 1900 : UseRegisterOrConstantAtStart(instr->key());
1885 return new(zone()) LStoreKeyedFastElement(obj, key, val); 1901 return new(zone()) LStoreKeyedFastElement(obj, key, val);
1886 } 1902 }
1887 1903
1888 1904
1889 LInstruction* LChunkBuilder::DoStoreKeyedFastDoubleElement( 1905 LInstruction* LChunkBuilder::DoStoreKeyedFastDoubleElement(
1890 HStoreKeyedFastDoubleElement* instr) { 1906 HStoreKeyedFastDoubleElement* instr) {
1891 ASSERT(instr->value()->representation().IsDouble()); 1907 ASSERT(instr->value()->representation().IsDouble());
1892 ASSERT(instr->elements()->representation().IsTagged()); 1908 ASSERT(instr->elements()->representation().IsTagged());
1893 ASSERT(instr->key()->representation().IsInteger32()); 1909 ASSERT(instr->key()->representation().IsInteger32() ||
1910 instr->key()->representation().IsTagged());
1894 1911
1895 LOperand* elements = UseRegisterAtStart(instr->elements()); 1912 LOperand* elements = UseRegisterAtStart(instr->elements());
1896 LOperand* val = UseTempRegister(instr->value()); 1913 LOperand* val = UseTempRegister(instr->value());
1897 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); 1914 bool clobbers_key = instr->key()->representation().IsTagged();
1898 1915 LOperand* key = clobbers_key
1916 ? UseTempRegister(instr->key())
1917 : UseRegisterOrConstantAtStart(instr->key());
1899 return new(zone()) LStoreKeyedFastDoubleElement(elements, key, val); 1918 return new(zone()) LStoreKeyedFastDoubleElement(elements, key, val);
1900 } 1919 }
1901 1920
1902 1921
1903 LInstruction* LChunkBuilder::DoStoreKeyedSpecializedArrayElement( 1922 LInstruction* LChunkBuilder::DoStoreKeyedSpecializedArrayElement(
1904 HStoreKeyedSpecializedArrayElement* instr) { 1923 HStoreKeyedSpecializedArrayElement* instr) {
1905 ElementsKind elements_kind = instr->elements_kind(); 1924 ElementsKind elements_kind = instr->elements_kind();
1906 ASSERT( 1925 ASSERT(
1907 (instr->value()->representation().IsInteger32() && 1926 (instr->value()->representation().IsInteger32() &&
1908 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && 1927 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) &&
1909 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || 1928 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) ||
1910 (instr->value()->representation().IsDouble() && 1929 (instr->value()->representation().IsDouble() &&
1911 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || 1930 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) ||
1912 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); 1931 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS))));
1913 ASSERT(instr->external_pointer()->representation().IsExternal()); 1932 ASSERT(instr->external_pointer()->representation().IsExternal());
1914 ASSERT(instr->key()->representation().IsInteger32()); 1933 ASSERT(instr->key()->representation().IsInteger32() ||
1934 instr->key()->representation().IsTagged());
1915 1935
1916 LOperand* external_pointer = UseRegister(instr->external_pointer()); 1936 LOperand* external_pointer = UseRegister(instr->external_pointer());
1917 bool val_is_temp_register = 1937 bool val_is_temp_register =
1918 elements_kind == EXTERNAL_PIXEL_ELEMENTS || 1938 elements_kind == EXTERNAL_PIXEL_ELEMENTS ||
1919 elements_kind == EXTERNAL_FLOAT_ELEMENTS; 1939 elements_kind == EXTERNAL_FLOAT_ELEMENTS;
1920 LOperand* val = val_is_temp_register 1940 LOperand* val = val_is_temp_register
1921 ? UseTempRegister(instr->value()) 1941 ? UseTempRegister(instr->value())
1922 : UseRegister(instr->value()); 1942 : UseRegister(instr->value());
1923 LOperand* key = UseRegisterOrConstant(instr->key()); 1943 bool clobbers_key = instr->key()->representation().IsTagged();
1924 1944 LOperand* key = clobbers_key
1945 ? UseTempRegister(instr->key())
1946 : UseRegisterOrConstantAtStart(instr->key());
1925 return new(zone()) LStoreKeyedSpecializedArrayElement(external_pointer, 1947 return new(zone()) LStoreKeyedSpecializedArrayElement(external_pointer,
1926 key, 1948 key, val);
1927 val);
1928 } 1949 }
1929 1950
1930 1951
1931 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { 1952 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) {
1932 LOperand* object = UseFixed(instr->object(), rdx); 1953 LOperand* object = UseFixed(instr->object(), rdx);
1933 LOperand* key = UseFixed(instr->key(), rcx); 1954 LOperand* key = UseFixed(instr->key(), rcx);
1934 LOperand* value = UseFixed(instr->value(), rax); 1955 LOperand* value = UseFixed(instr->value(), rax);
1935 1956
1936 ASSERT(instr->object()->representation().IsTagged()); 1957 ASSERT(instr->object()->representation().IsTagged());
1937 ASSERT(instr->key()->representation().IsTagged()); 1958 ASSERT(instr->key()->representation().IsTagged());
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
2258 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2279 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2259 LOperand* object = UseRegister(instr->object()); 2280 LOperand* object = UseRegister(instr->object());
2260 LOperand* index = UseTempRegister(instr->index()); 2281 LOperand* index = UseTempRegister(instr->index());
2261 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); 2282 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index));
2262 } 2283 }
2263 2284
2264 2285
2265 } } // namespace v8::internal 2286 } } // namespace v8::internal
2266 2287
2267 #endif // V8_TARGET_ARCH_X64 2288 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/lithium-x64.h ('k') | test/mjsunit/external-array.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698