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

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: Oops, removed a TODO 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
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(
1936 HLoadKeyedFastElement* instr) { 1927 HLoadKeyed* instr) {
danno 2012/10/29 14:56:13 nit: put on previous line
mvstanton 2012/10/29 15:23:57 Done.
1937 ASSERT(instr->representation().IsTagged());
1938 ASSERT(instr->key()->representation().IsInteger32() || 1928 ASSERT(instr->key()->representation().IsInteger32() ||
1939 instr->key()->representation().IsTagged()); 1929 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(); 1930 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( 1931 bool clobbers_key = ExternalArrayOpRequiresTemp(
1975 instr->key()->representation(), elements_kind); 1932 instr->key()->representation(), elements_kind);
1976 LOperand* key = clobbers_key 1933 LOperand* key = clobbers_key
1977 ? UseTempRegister(instr->key()) 1934 ? UseTempRegister(instr->key())
1978 : UseRegisterOrConstant(instr->key()); 1935 : UseRegisterOrConstantAtStart(instr->key());
1936 LLoadKeyed* result = NULL;
1979 1937
1980 LLoadKeyedSpecializedArrayElement* result = 1938 if (!instr->is_external()) {
1981 new(zone()) LLoadKeyedSpecializedArrayElement(external_pointer, key); 1939 LOperand* obj = UseRegisterAtStart(instr->elements());
1982 LInstruction* load_instr = DefineAsRegister(result); 1940 result = new(zone()) LLoadKeyed(obj, key);
1941 } else {
1942 ASSERT(
1943 (instr->representation().IsInteger32() &&
1944 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) &&
1945 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) ||
1946 (instr->representation().IsDouble() &&
1947 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) ||
1948 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS))));
1949 LOperand* external_pointer = UseRegister(instr->elements());
1950 result = new(zone()) LLoadKeyed(external_pointer, key);
1951 }
1952
1953 DefineAsRegister(result);
1954 bool can_deoptimize = instr->RequiresHoleCheck() ||
1955 (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS);
1983 // An unsigned int array load might overflow and cause a deopt, make sure it 1956 // An unsigned int array load might overflow and cause a deopt, make sure it
1984 // has an environment. 1957 // has an environment.
1985 return (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS) 1958 return can_deoptimize ? AssignEnvironment(result) : result;
1986 ? AssignEnvironment(load_instr)
1987 : load_instr;
1988 } 1959 }
1989 1960
1990 1961
1991 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) { 1962 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) {
1992 LOperand* context = UseFixed(instr->context(), esi); 1963 LOperand* context = UseFixed(instr->context(), esi);
1993 LOperand* object = UseFixed(instr->object(), edx); 1964 LOperand* object = UseFixed(instr->object(), edx);
1994 LOperand* key = UseFixed(instr->key(), ecx); 1965 LOperand* key = UseFixed(instr->key(), ecx);
1995 1966
1996 LLoadKeyedGeneric* result = 1967 LLoadKeyedGeneric* result =
1997 new(zone()) LLoadKeyedGeneric(context, object, key); 1968 new(zone()) LLoadKeyedGeneric(context, object, key);
1998 return MarkAsCall(DefineFixed(result, eax), instr); 1969 return MarkAsCall(DefineFixed(result, eax), instr);
1999 } 1970 }
2000 1971
2001 1972
2002 LInstruction* LChunkBuilder::DoStoreKeyedFastElement( 1973 LInstruction* LChunkBuilder::DoStoreKeyed(
2003 HStoreKeyedFastElement* instr) { 1974 HStoreKeyed* instr) {
danno 2012/10/29 14:56:13 nit: put on previous line
mvstanton 2012/10/29 15:23:57 Done.
2004 bool needs_write_barrier = instr->NeedsWriteBarrier(); 1975 LStoreKeyed* result = NULL;
2005 ASSERT(instr->value()->representation().IsTagged());
2006 ASSERT(instr->object()->representation().IsTagged());
2007 ASSERT(instr->key()->representation().IsInteger32() ||
2008 instr->key()->representation().IsTagged());
2009 1976
2010 LOperand* obj = UseRegister(instr->object()); 1977 if (!instr->is_external()) {
2011 LOperand* val = needs_write_barrier 1978 ASSERT(instr->elements()->representation().IsTagged());
2012 ? UseTempRegister(instr->value()) 1979 ASSERT(instr->key()->representation().IsInteger32() ||
2013 : UseRegisterAtStart(instr->value()); 1980 instr->key()->representation().IsTagged());
2014 LOperand* key = needs_write_barrier 1981
2015 ? UseTempRegister(instr->key()) 1982 if (instr->value()->representation().IsDouble()) {
2016 : UseRegisterOrConstantAtStart(instr->key()); 1983 LOperand* object = UseRegisterAtStart(instr->elements());
2017 return new(zone()) LStoreKeyedFastElement(obj, key, val); 1984 LOperand* val = UseTempRegister(instr->value());
1985 LOperand* key = UseRegisterOrConstantAtStart(instr->key());
1986
1987 result = new(zone()) LStoreKeyed(object, key, val);
1988 } else {
1989 ASSERT(instr->value()->representation().IsTagged());
1990 bool needs_write_barrier = instr->NeedsWriteBarrier();
1991
1992 LOperand* obj = UseRegister(instr->elements());
1993 LOperand* val = needs_write_barrier
1994 ? UseTempRegister(instr->value())
1995 : UseRegisterAtStart(instr->value());
1996 LOperand* key = needs_write_barrier
1997 ? UseTempRegister(instr->key())
1998 : UseRegisterOrConstantAtStart(instr->key());
1999 result = new(zone()) LStoreKeyed(obj, key, val);
2000 }
2001 } else {
2002 ElementsKind elements_kind = instr->elements_kind();
2003 ASSERT(
2004 (instr->value()->representation().IsInteger32() &&
2005 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) &&
2006 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) ||
2007 (instr->value()->representation().IsDouble() &&
2008 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) ||
2009 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS))));
2010 ASSERT(instr->elements()->representation().IsExternal());
2011
2012 LOperand* external_pointer = UseRegister(instr->elements());
2013 // Determine if we need a byte register in this case for the value.
2014 bool val_is_fixed_register =
2015 elements_kind == EXTERNAL_BYTE_ELEMENTS ||
2016 elements_kind == EXTERNAL_UNSIGNED_BYTE_ELEMENTS ||
2017 elements_kind == EXTERNAL_PIXEL_ELEMENTS;
2018
2019 LOperand* val = val_is_fixed_register
2020 ? UseFixed(instr->value(), eax)
2021 : UseRegister(instr->value());
2022 bool clobbers_key = ExternalArrayOpRequiresTemp(
2023 instr->key()->representation(), elements_kind);
2024 LOperand* key = clobbers_key
2025 ? UseTempRegister(instr->key())
2026 : UseRegisterOrConstantAtStart(instr->key());
2027 result = new(zone()) LStoreKeyed(external_pointer,
2028 key,
2029 val);
2030 }
2031
2032 ASSERT(result != NULL);
2033 return result;
2018 } 2034 }
2019 2035
2020 2036
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) { 2037 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) {
2072 LOperand* context = UseFixed(instr->context(), esi); 2038 LOperand* context = UseFixed(instr->context(), esi);
2073 LOperand* object = UseFixed(instr->object(), edx); 2039 LOperand* object = UseFixed(instr->object(), edx);
2074 LOperand* key = UseFixed(instr->key(), ecx); 2040 LOperand* key = UseFixed(instr->key(), ecx);
2075 LOperand* value = UseFixed(instr->value(), eax); 2041 LOperand* value = UseFixed(instr->value(), eax);
2076 2042
2077 ASSERT(instr->object()->representation().IsTagged()); 2043 ASSERT(instr->object()->representation().IsTagged());
2078 ASSERT(instr->key()->representation().IsTagged()); 2044 ASSERT(instr->key()->representation().IsTagged());
2079 ASSERT(instr->value()->representation().IsTagged()); 2045 ASSERT(instr->value()->representation().IsTagged());
2080 2046
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
2431 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2397 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2432 LOperand* object = UseRegister(instr->object()); 2398 LOperand* object = UseRegister(instr->object());
2433 LOperand* index = UseTempRegister(instr->index()); 2399 LOperand* index = UseTempRegister(instr->index());
2434 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); 2400 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index));
2435 } 2401 }
2436 2402
2437 2403
2438 } } // namespace v8::internal 2404 } } // namespace v8::internal
2439 2405
2440 #endif // V8_TARGET_ARCH_IA32 2406 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698