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

Side by Side Diff: src/ia32/lithium-ia32.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/ia32/lithium-ia32.h ('k') | src/x64/lithium-codegen-x64.cc » ('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 1882 matching lines...) Expand 10 before | Expand all | Expand 10 after
1893 LInstruction* LChunkBuilder::DoLoadExternalArrayPointer( 1893 LInstruction* LChunkBuilder::DoLoadExternalArrayPointer(
1894 HLoadExternalArrayPointer* instr) { 1894 HLoadExternalArrayPointer* instr) {
1895 LOperand* input = UseRegisterAtStart(instr->value()); 1895 LOperand* input = UseRegisterAtStart(instr->value());
1896 return DefineAsRegister(new(zone()) LLoadExternalArrayPointer(input)); 1896 return DefineAsRegister(new(zone()) LLoadExternalArrayPointer(input));
1897 } 1897 }
1898 1898
1899 1899
1900 LInstruction* LChunkBuilder::DoLoadKeyedFastElement( 1900 LInstruction* LChunkBuilder::DoLoadKeyedFastElement(
1901 HLoadKeyedFastElement* instr) { 1901 HLoadKeyedFastElement* instr) {
1902 ASSERT(instr->representation().IsTagged()); 1902 ASSERT(instr->representation().IsTagged());
1903 ASSERT(instr->key()->representation().IsInteger32()); 1903 ASSERT(instr->key()->representation().IsInteger32() ||
1904 instr->key()->representation().IsTagged());
1904 LOperand* obj = UseRegisterAtStart(instr->object()); 1905 LOperand* obj = UseRegisterAtStart(instr->object());
1905 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); 1906 LOperand* key = UseRegisterOrConstantAtStart(instr->key());
1906 LLoadKeyedFastElement* result = new(zone()) LLoadKeyedFastElement(obj, key); 1907 LLoadKeyedFastElement* result = new(zone()) LLoadKeyedFastElement(obj, key);
1907 if (instr->RequiresHoleCheck()) AssignEnvironment(result); 1908 if (instr->RequiresHoleCheck()) AssignEnvironment(result);
1908 return DefineAsRegister(result); 1909 return DefineAsRegister(result);
1909 } 1910 }
1910 1911
1911 1912
1912 LInstruction* LChunkBuilder::DoLoadKeyedFastDoubleElement( 1913 LInstruction* LChunkBuilder::DoLoadKeyedFastDoubleElement(
1913 HLoadKeyedFastDoubleElement* instr) { 1914 HLoadKeyedFastDoubleElement* instr) {
1914 ASSERT(instr->representation().IsDouble()); 1915 ASSERT(instr->representation().IsDouble());
1915 ASSERT(instr->key()->representation().IsInteger32()); 1916 ASSERT(instr->key()->representation().IsInteger32() ||
1917 instr->key()->representation().IsTagged());
1916 LOperand* elements = UseRegisterAtStart(instr->elements()); 1918 LOperand* elements = UseRegisterAtStart(instr->elements());
1917 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); 1919 LOperand* key = UseRegisterOrConstantAtStart(instr->key());
1918 LLoadKeyedFastDoubleElement* result = 1920 LLoadKeyedFastDoubleElement* result =
1919 new(zone()) LLoadKeyedFastDoubleElement(elements, key); 1921 new(zone()) LLoadKeyedFastDoubleElement(elements, key);
1920 return AssignEnvironment(DefineAsRegister(result)); 1922 return AssignEnvironment(DefineAsRegister(result));
1921 } 1923 }
1922 1924
1923 1925
1924 LInstruction* LChunkBuilder::DoLoadKeyedSpecializedArrayElement( 1926 LInstruction* LChunkBuilder::DoLoadKeyedSpecializedArrayElement(
1925 HLoadKeyedSpecializedArrayElement* instr) { 1927 HLoadKeyedSpecializedArrayElement* instr) {
1926 ElementsKind elements_kind = instr->elements_kind(); 1928 ElementsKind elements_kind = instr->elements_kind();
1927 ASSERT( 1929 ASSERT(
1928 (instr->representation().IsInteger32() && 1930 (instr->representation().IsInteger32() &&
1929 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && 1931 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) &&
1930 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || 1932 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) ||
1931 (instr->representation().IsDouble() && 1933 (instr->representation().IsDouble() &&
1932 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || 1934 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) ||
1933 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); 1935 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS))));
1934 ASSERT(instr->key()->representation().IsInteger32()); 1936 ASSERT(instr->key()->representation().IsInteger32() ||
1937 instr->key()->representation().IsTagged());
1935 LOperand* external_pointer = UseRegister(instr->external_pointer()); 1938 LOperand* external_pointer = UseRegister(instr->external_pointer());
1936 LOperand* key = UseRegisterOrConstant(instr->key()); 1939 bool clobbers_key = ExternalArrayOpRequiresTemp(
1940 instr->key()->representation(), elements_kind);
1941 LOperand* key = clobbers_key
1942 ? UseTempRegister(instr->key())
1943 : UseRegisterOrConstant(instr->key());
1944
1937 LLoadKeyedSpecializedArrayElement* result = 1945 LLoadKeyedSpecializedArrayElement* result =
1938 new(zone()) LLoadKeyedSpecializedArrayElement(external_pointer, key); 1946 new(zone()) LLoadKeyedSpecializedArrayElement(external_pointer, key);
1939 LInstruction* load_instr = DefineAsRegister(result); 1947 LInstruction* load_instr = DefineAsRegister(result);
1940 // An unsigned int array load might overflow and cause a deopt, make sure it 1948 // An unsigned int array load might overflow and cause a deopt, make sure it
1941 // has an environment. 1949 // has an environment.
1942 return (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS) 1950 return (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS)
1943 ? AssignEnvironment(load_instr) 1951 ? AssignEnvironment(load_instr)
1944 : load_instr; 1952 : load_instr;
1945 } 1953 }
1946 1954
1947 1955
1948 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) { 1956 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) {
1949 LOperand* context = UseFixed(instr->context(), esi); 1957 LOperand* context = UseFixed(instr->context(), esi);
1950 LOperand* object = UseFixed(instr->object(), edx); 1958 LOperand* object = UseFixed(instr->object(), edx);
1951 LOperand* key = UseFixed(instr->key(), ecx); 1959 LOperand* key = UseFixed(instr->key(), ecx);
1952 1960
1953 LLoadKeyedGeneric* result = 1961 LLoadKeyedGeneric* result =
1954 new(zone()) LLoadKeyedGeneric(context, object, key); 1962 new(zone()) LLoadKeyedGeneric(context, object, key);
1955 return MarkAsCall(DefineFixed(result, eax), instr); 1963 return MarkAsCall(DefineFixed(result, eax), instr);
1956 } 1964 }
1957 1965
1958 1966
1959 LInstruction* LChunkBuilder::DoStoreKeyedFastElement( 1967 LInstruction* LChunkBuilder::DoStoreKeyedFastElement(
1960 HStoreKeyedFastElement* instr) { 1968 HStoreKeyedFastElement* instr) {
1961 bool needs_write_barrier = instr->NeedsWriteBarrier(); 1969 bool needs_write_barrier = instr->NeedsWriteBarrier();
1962 ASSERT(instr->value()->representation().IsTagged()); 1970 ASSERT(instr->value()->representation().IsTagged());
1963 ASSERT(instr->object()->representation().IsTagged()); 1971 ASSERT(instr->object()->representation().IsTagged());
1964 ASSERT(instr->key()->representation().IsInteger32()); 1972 ASSERT(instr->key()->representation().IsInteger32() ||
1973 instr->key()->representation().IsTagged());
1965 1974
1966 LOperand* obj = UseRegister(instr->object()); 1975 LOperand* obj = UseRegister(instr->object());
1967 LOperand* val = needs_write_barrier 1976 LOperand* val = needs_write_barrier
1968 ? UseTempRegister(instr->value()) 1977 ? UseTempRegister(instr->value())
1969 : UseRegisterAtStart(instr->value()); 1978 : UseRegisterAtStart(instr->value());
1970 LOperand* key = needs_write_barrier 1979 LOperand* key = needs_write_barrier
1971 ? UseTempRegister(instr->key()) 1980 ? UseTempRegister(instr->key())
1972 : UseRegisterOrConstantAtStart(instr->key()); 1981 : UseRegisterOrConstantAtStart(instr->key());
1973 return new(zone()) LStoreKeyedFastElement(obj, key, val); 1982 return new(zone()) LStoreKeyedFastElement(obj, key, val);
1974 } 1983 }
1975 1984
1976 1985
1977 LInstruction* LChunkBuilder::DoStoreKeyedFastDoubleElement( 1986 LInstruction* LChunkBuilder::DoStoreKeyedFastDoubleElement(
1978 HStoreKeyedFastDoubleElement* instr) { 1987 HStoreKeyedFastDoubleElement* instr) {
1979 ASSERT(instr->value()->representation().IsDouble()); 1988 ASSERT(instr->value()->representation().IsDouble());
1980 ASSERT(instr->elements()->representation().IsTagged()); 1989 ASSERT(instr->elements()->representation().IsTagged());
1981 ASSERT(instr->key()->representation().IsInteger32()); 1990 ASSERT(instr->key()->representation().IsInteger32() ||
1991 instr->key()->representation().IsTagged());
1982 1992
1983 LOperand* elements = UseRegisterAtStart(instr->elements()); 1993 LOperand* elements = UseRegisterAtStart(instr->elements());
1984 LOperand* val = UseTempRegister(instr->value()); 1994 LOperand* val = UseTempRegister(instr->value());
1985 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); 1995 LOperand* key = UseRegisterOrConstantAtStart(instr->key());
1986 1996
1987 return new(zone()) LStoreKeyedFastDoubleElement(elements, key, val); 1997 return new(zone()) LStoreKeyedFastDoubleElement(elements, key, val);
1988 } 1998 }
1989 1999
1990 2000
1991 LInstruction* LChunkBuilder::DoStoreKeyedSpecializedArrayElement( 2001 LInstruction* LChunkBuilder::DoStoreKeyedSpecializedArrayElement(
1992 HStoreKeyedSpecializedArrayElement* instr) { 2002 HStoreKeyedSpecializedArrayElement* instr) {
1993 ElementsKind elements_kind = instr->elements_kind(); 2003 ElementsKind elements_kind = instr->elements_kind();
1994 ASSERT( 2004 ASSERT(
1995 (instr->value()->representation().IsInteger32() && 2005 (instr->value()->representation().IsInteger32() &&
1996 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && 2006 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) &&
1997 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || 2007 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) ||
1998 (instr->value()->representation().IsDouble() && 2008 (instr->value()->representation().IsDouble() &&
1999 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || 2009 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) ||
2000 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); 2010 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS))));
2001 ASSERT(instr->external_pointer()->representation().IsExternal()); 2011 ASSERT(instr->external_pointer()->representation().IsExternal());
2002 ASSERT(instr->key()->representation().IsInteger32()); 2012 ASSERT(instr->key()->representation().IsInteger32() ||
2013 instr->key()->representation().IsTagged());
2003 2014
2004 LOperand* external_pointer = UseRegister(instr->external_pointer()); 2015 LOperand* external_pointer = UseRegister(instr->external_pointer());
2005 LOperand* key = UseRegisterOrConstant(instr->key());
2006 LOperand* val = NULL; 2016 LOperand* val = NULL;
2007 if (elements_kind == EXTERNAL_BYTE_ELEMENTS || 2017 if (elements_kind == EXTERNAL_BYTE_ELEMENTS ||
2008 elements_kind == EXTERNAL_UNSIGNED_BYTE_ELEMENTS || 2018 elements_kind == EXTERNAL_UNSIGNED_BYTE_ELEMENTS ||
2009 elements_kind == EXTERNAL_PIXEL_ELEMENTS) { 2019 elements_kind == EXTERNAL_PIXEL_ELEMENTS) {
2010 // We need a byte register in this case for the value. 2020 // We need a byte register in this case for the value.
2011 val = UseFixed(instr->value(), eax); 2021 val = UseFixed(instr->value(), eax);
2012 } else { 2022 } else {
2013 val = UseRegister(instr->value()); 2023 val = UseRegister(instr->value());
2014 } 2024 }
2015 2025 bool clobbers_key = ExternalArrayOpRequiresTemp(
2026 instr->key()->representation(), elements_kind);
2027 LOperand* key = clobbers_key
2028 ? UseTempRegister(instr->key())
2029 : UseRegisterOrConstant(instr->key());
2016 return new(zone()) LStoreKeyedSpecializedArrayElement(external_pointer, 2030 return new(zone()) LStoreKeyedSpecializedArrayElement(external_pointer,
2017 key, 2031 key,
2018 val); 2032 val);
2019 } 2033 }
2020 2034
2021 2035
2022 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { 2036 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) {
2023 LOperand* context = UseFixed(instr->context(), esi); 2037 LOperand* context = UseFixed(instr->context(), esi);
2024 LOperand* object = UseFixed(instr->object(), edx); 2038 LOperand* object = UseFixed(instr->object(), edx);
2025 LOperand* key = UseFixed(instr->key(), ecx); 2039 LOperand* key = UseFixed(instr->key(), ecx);
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
2382 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2396 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2383 LOperand* object = UseRegister(instr->object()); 2397 LOperand* object = UseRegister(instr->object());
2384 LOperand* index = UseTempRegister(instr->index()); 2398 LOperand* index = UseTempRegister(instr->index());
2385 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); 2399 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index));
2386 } 2400 }
2387 2401
2388 2402
2389 } } // namespace v8::internal 2403 } } // namespace v8::internal
2390 2404
2391 #endif // V8_TARGET_ARCH_IA32 2405 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-ia32.h ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698