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

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

Issue 11238016: Consolidated all the key store/load classes in the Hydrogen and Lithium (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Last batch of comment response, formatting issues. Created 8 years, 1 month 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.h » ('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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 400
401 void LStoreNamedGeneric::PrintDataTo(StringStream* stream) { 401 void LStoreNamedGeneric::PrintDataTo(StringStream* stream) {
402 object()->PrintTo(stream); 402 object()->PrintTo(stream);
403 stream->Add("."); 403 stream->Add(".");
404 stream->Add(*String::cast(*name())->ToCString()); 404 stream->Add(*String::cast(*name())->ToCString());
405 stream->Add(" <- "); 405 stream->Add(" <- ");
406 value()->PrintTo(stream); 406 value()->PrintTo(stream);
407 } 407 }
408 408
409 409
410 void LStoreKeyedFastElement::PrintDataTo(StringStream* stream) { 410 void LStoreKeyed::PrintDataTo(StringStream* stream) {
411 object()->PrintTo(stream);
412 stream->Add("[");
413 key()->PrintTo(stream);
414 stream->Add("] <- ");
415 value()->PrintTo(stream);
416 }
417
418
419 void LStoreKeyedFastDoubleElement::PrintDataTo(StringStream* stream) {
420 elements()->PrintTo(stream); 411 elements()->PrintTo(stream);
421 stream->Add("["); 412 stream->Add("[");
422 key()->PrintTo(stream); 413 key()->PrintTo(stream);
423 stream->Add("] <- "); 414 stream->Add("] <- ");
424 value()->PrintTo(stream); 415 value()->PrintTo(stream);
425 } 416 }
426 417
427 418
428 void LStoreKeyedGeneric::PrintDataTo(StringStream* stream) { 419 void LStoreKeyedGeneric::PrintDataTo(StringStream* stream) {
429 object()->PrintTo(stream); 420 object()->PrintTo(stream);
(...skipping 1495 matching lines...) Expand 10 before | Expand all | Expand 10 after
1925 } 1916 }
1926 1917
1927 1918
1928 LInstruction* LChunkBuilder::DoLoadExternalArrayPointer( 1919 LInstruction* LChunkBuilder::DoLoadExternalArrayPointer(
1929 HLoadExternalArrayPointer* instr) { 1920 HLoadExternalArrayPointer* instr) {
1930 LOperand* input = UseRegisterAtStart(instr->value()); 1921 LOperand* input = UseRegisterAtStart(instr->value());
1931 return DefineAsRegister(new(zone()) LLoadExternalArrayPointer(input)); 1922 return DefineAsRegister(new(zone()) LLoadExternalArrayPointer(input));
1932 } 1923 }
1933 1924
1934 1925
1935 LInstruction* LChunkBuilder::DoLoadKeyedFastElement( 1926 LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) {
1936 HLoadKeyedFastElement* instr) {
1937 ASSERT(instr->representation().IsTagged());
1938 ASSERT(instr->key()->representation().IsInteger32() || 1927 ASSERT(instr->key()->representation().IsInteger32() ||
1939 instr->key()->representation().IsTagged()); 1928 instr->key()->representation().IsTagged());
1940 LOperand* obj = UseRegisterAtStart(instr->object());
1941 LOperand* key = UseRegisterOrConstantAtStart(instr->key());
1942 LLoadKeyedFastElement* result = new(zone()) LLoadKeyedFastElement(obj, key);
1943 if (instr->RequiresHoleCheck()) AssignEnvironment(result);
1944 return DefineAsRegister(result);
1945 }
1946
1947
1948 LInstruction* LChunkBuilder::DoLoadKeyedFastDoubleElement(
1949 HLoadKeyedFastDoubleElement* instr) {
1950 ASSERT(instr->representation().IsDouble());
1951 ASSERT(instr->key()->representation().IsInteger32() ||
1952 instr->key()->representation().IsTagged());
1953 LOperand* elements = UseRegisterAtStart(instr->elements());
1954 LOperand* key = UseRegisterOrConstantAtStart(instr->key());
1955 LLoadKeyedFastDoubleElement* result =
1956 new(zone()) LLoadKeyedFastDoubleElement(elements, key);
1957 return AssignEnvironment(DefineAsRegister(result));
1958 }
1959
1960
1961 LInstruction* LChunkBuilder::DoLoadKeyedSpecializedArrayElement(
1962 HLoadKeyedSpecializedArrayElement* instr) {
1963 ElementsKind elements_kind = instr->elements_kind(); 1929 ElementsKind elements_kind = instr->elements_kind();
1964 ASSERT(
1965 (instr->representation().IsInteger32() &&
1966 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) &&
1967 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) ||
1968 (instr->representation().IsDouble() &&
1969 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) ||
1970 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS))));
1971 ASSERT(instr->key()->representation().IsInteger32() ||
1972 instr->key()->representation().IsTagged());
1973 LOperand* external_pointer = UseRegister(instr->external_pointer());
1974 bool clobbers_key = ExternalArrayOpRequiresTemp( 1930 bool clobbers_key = ExternalArrayOpRequiresTemp(
1975 instr->key()->representation(), elements_kind); 1931 instr->key()->representation(), elements_kind);
1976 LOperand* key = clobbers_key 1932 LOperand* key = clobbers_key
1977 ? UseTempRegister(instr->key()) 1933 ? UseTempRegister(instr->key())
1978 : UseRegisterOrConstant(instr->key()); 1934 : UseRegisterOrConstantAtStart(instr->key());
1935 LLoadKeyed* result = NULL;
1979 1936
1980 LLoadKeyedSpecializedArrayElement* result = 1937 if (!instr->is_external()) {
1981 new(zone()) LLoadKeyedSpecializedArrayElement(external_pointer, key); 1938 LOperand* obj = UseRegisterAtStart(instr->elements());
1982 LInstruction* load_instr = DefineAsRegister(result); 1939 result = new(zone()) LLoadKeyed(obj, key);
1940 } else {
1941 ASSERT(
1942 (instr->representation().IsInteger32() &&
1943 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) &&
1944 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) ||
1945 (instr->representation().IsDouble() &&
1946 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) ||
1947 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS))));
1948 LOperand* external_pointer = UseRegister(instr->elements());
1949 result = new(zone()) LLoadKeyed(external_pointer, key);
1950 }
1951
1952 DefineAsRegister(result);
1953 bool can_deoptimize = instr->RequiresHoleCheck() ||
1954 (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS);
1983 // An unsigned int array load might overflow and cause a deopt, make sure it 1955 // An unsigned int array load might overflow and cause a deopt, make sure it
1984 // has an environment. 1956 // has an environment.
1985 return (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS) 1957 return can_deoptimize ? AssignEnvironment(result) : result;
1986 ? AssignEnvironment(load_instr)
1987 : load_instr;
1988 } 1958 }
1989 1959
1990 1960
1991 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) { 1961 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) {
1992 LOperand* context = UseFixed(instr->context(), esi); 1962 LOperand* context = UseFixed(instr->context(), esi);
1993 LOperand* object = UseFixed(instr->object(), edx); 1963 LOperand* object = UseFixed(instr->object(), edx);
1994 LOperand* key = UseFixed(instr->key(), ecx); 1964 LOperand* key = UseFixed(instr->key(), ecx);
1995 1965
1996 LLoadKeyedGeneric* result = 1966 LLoadKeyedGeneric* result =
1997 new(zone()) LLoadKeyedGeneric(context, object, key); 1967 new(zone()) LLoadKeyedGeneric(context, object, key);
1998 return MarkAsCall(DefineFixed(result, eax), instr); 1968 return MarkAsCall(DefineFixed(result, eax), instr);
1999 } 1969 }
2000 1970
2001 1971
2002 LInstruction* LChunkBuilder::DoStoreKeyedFastElement( 1972 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) {
2003 HStoreKeyedFastElement* instr) { 1973 LStoreKeyed* result = NULL;
2004 bool needs_write_barrier = instr->NeedsWriteBarrier();
2005 ASSERT(instr->value()->representation().IsTagged());
2006 ASSERT(instr->object()->representation().IsTagged());
2007 ASSERT(instr->key()->representation().IsInteger32() ||
2008 instr->key()->representation().IsTagged());
2009 1974
2010 LOperand* obj = UseRegister(instr->object()); 1975 if (!instr->is_external()) {
2011 LOperand* val = needs_write_barrier 1976 ASSERT(instr->elements()->representation().IsTagged());
2012 ? UseTempRegister(instr->value()) 1977 ASSERT(instr->key()->representation().IsInteger32() ||
2013 : UseRegisterAtStart(instr->value()); 1978 instr->key()->representation().IsTagged());
2014 LOperand* key = needs_write_barrier 1979
2015 ? UseTempRegister(instr->key()) 1980 if (instr->value()->representation().IsDouble()) {
2016 : UseRegisterOrConstantAtStart(instr->key()); 1981 LOperand* object = UseRegisterAtStart(instr->elements());
2017 return new(zone()) LStoreKeyedFastElement(obj, key, val); 1982 LOperand* val = UseTempRegister(instr->value());
1983 LOperand* key = UseRegisterOrConstantAtStart(instr->key());
1984
1985 result = new(zone()) LStoreKeyed(object, key, val);
1986 } else {
1987 ASSERT(instr->value()->representation().IsTagged());
1988 bool needs_write_barrier = instr->NeedsWriteBarrier();
1989
1990 LOperand* obj = UseRegister(instr->elements());
1991 LOperand* val = needs_write_barrier
1992 ? UseTempRegister(instr->value())
1993 : UseRegisterAtStart(instr->value());
1994 LOperand* key = needs_write_barrier
1995 ? UseTempRegister(instr->key())
1996 : UseRegisterOrConstantAtStart(instr->key());
1997 result = new(zone()) LStoreKeyed(obj, key, val);
1998 }
1999 } else {
2000 ElementsKind elements_kind = instr->elements_kind();
2001 ASSERT(
2002 (instr->value()->representation().IsInteger32() &&
2003 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) &&
2004 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) ||
2005 (instr->value()->representation().IsDouble() &&
2006 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) ||
2007 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS))));
2008 ASSERT(instr->elements()->representation().IsExternal());
2009
2010 LOperand* external_pointer = UseRegister(instr->elements());
2011 // Determine if we need a byte register in this case for the value.
2012 bool val_is_fixed_register =
2013 elements_kind == EXTERNAL_BYTE_ELEMENTS ||
2014 elements_kind == EXTERNAL_UNSIGNED_BYTE_ELEMENTS ||
2015 elements_kind == EXTERNAL_PIXEL_ELEMENTS;
2016
2017 LOperand* val = val_is_fixed_register
2018 ? UseFixed(instr->value(), eax)
2019 : UseRegister(instr->value());
2020 bool clobbers_key = ExternalArrayOpRequiresTemp(
2021 instr->key()->representation(), elements_kind);
2022 LOperand* key = clobbers_key
2023 ? UseTempRegister(instr->key())
2024 : UseRegisterOrConstantAtStart(instr->key());
2025 result = new(zone()) LStoreKeyed(external_pointer,
2026 key,
2027 val);
2028 }
2029
2030 ASSERT(result != NULL);
2031 return result;
2018 } 2032 }
2019 2033
2020 2034
2021 LInstruction* LChunkBuilder::DoStoreKeyedFastDoubleElement(
2022 HStoreKeyedFastDoubleElement* instr) {
2023 ASSERT(instr->value()->representation().IsDouble());
2024 ASSERT(instr->elements()->representation().IsTagged());
2025 ASSERT(instr->key()->representation().IsInteger32() ||
2026 instr->key()->representation().IsTagged());
2027
2028 LOperand* elements = UseRegisterAtStart(instr->elements());
2029 LOperand* val = UseTempRegister(instr->value());
2030 LOperand* key = UseRegisterOrConstantAtStart(instr->key());
2031
2032 return new(zone()) LStoreKeyedFastDoubleElement(elements, key, val);
2033 }
2034
2035
2036 LInstruction* LChunkBuilder::DoStoreKeyedSpecializedArrayElement(
2037 HStoreKeyedSpecializedArrayElement* instr) {
2038 ElementsKind elements_kind = instr->elements_kind();
2039 ASSERT(
2040 (instr->value()->representation().IsInteger32() &&
2041 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) &&
2042 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) ||
2043 (instr->value()->representation().IsDouble() &&
2044 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) ||
2045 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS))));
2046 ASSERT(instr->external_pointer()->representation().IsExternal());
2047 ASSERT(instr->key()->representation().IsInteger32() ||
2048 instr->key()->representation().IsTagged());
2049
2050 LOperand* external_pointer = UseRegister(instr->external_pointer());
2051 LOperand* val = NULL;
2052 if (elements_kind == EXTERNAL_BYTE_ELEMENTS ||
2053 elements_kind == EXTERNAL_UNSIGNED_BYTE_ELEMENTS ||
2054 elements_kind == EXTERNAL_PIXEL_ELEMENTS) {
2055 // We need a byte register in this case for the value.
2056 val = UseFixed(instr->value(), eax);
2057 } else {
2058 val = UseRegister(instr->value());
2059 }
2060 bool clobbers_key = ExternalArrayOpRequiresTemp(
2061 instr->key()->representation(), elements_kind);
2062 LOperand* key = clobbers_key
2063 ? UseTempRegister(instr->key())
2064 : UseRegisterOrConstant(instr->key());
2065 return new(zone()) LStoreKeyedSpecializedArrayElement(external_pointer,
2066 key,
2067 val);
2068 }
2069
2070
2071 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { 2035 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) {
2072 LOperand* context = UseFixed(instr->context(), esi); 2036 LOperand* context = UseFixed(instr->context(), esi);
2073 LOperand* object = UseFixed(instr->object(), edx); 2037 LOperand* object = UseFixed(instr->object(), edx);
2074 LOperand* key = UseFixed(instr->key(), ecx); 2038 LOperand* key = UseFixed(instr->key(), ecx);
2075 LOperand* value = UseFixed(instr->value(), eax); 2039 LOperand* value = UseFixed(instr->value(), eax);
2076 2040
2077 ASSERT(instr->object()->representation().IsTagged()); 2041 ASSERT(instr->object()->representation().IsTagged());
2078 ASSERT(instr->key()->representation().IsTagged()); 2042 ASSERT(instr->key()->representation().IsTagged());
2079 ASSERT(instr->value()->representation().IsTagged()); 2043 ASSERT(instr->value()->representation().IsTagged());
2080 2044
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
2431 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2395 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2432 LOperand* object = UseRegister(instr->object()); 2396 LOperand* object = UseRegister(instr->object());
2433 LOperand* index = UseTempRegister(instr->index()); 2397 LOperand* index = UseTempRegister(instr->index());
2434 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); 2398 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index));
2435 } 2399 }
2436 2400
2437 2401
2438 } } // namespace v8::internal 2402 } } // namespace v8::internal
2439 2403
2440 #endif // V8_TARGET_ARCH_IA32 2404 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-ia32.h ('k') | src/x64/lithium-codegen-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698