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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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); | 411 object()->PrintTo(stream); |
412 stream->Add("["); | 412 stream->Add("["); |
413 key()->PrintTo(stream); | 413 key()->PrintTo(stream); |
414 stream->Add("] <- "); | 414 stream->Add("] <- "); |
415 value()->PrintTo(stream); | 415 value()->PrintTo(stream); |
416 } | 416 } |
417 | 417 |
418 | 418 |
419 void LStoreKeyedFastDoubleElement::PrintDataTo(StringStream* stream) { | |
420 elements()->PrintTo(stream); | |
421 stream->Add("["); | |
422 key()->PrintTo(stream); | |
423 stream->Add("] <- "); | |
424 value()->PrintTo(stream); | |
425 } | |
426 | |
427 | |
428 void LStoreKeyedGeneric::PrintDataTo(StringStream* stream) { | 419 void LStoreKeyedGeneric::PrintDataTo(StringStream* stream) { |
429 object()->PrintTo(stream); | 420 object()->PrintTo(stream); |
430 stream->Add("["); | 421 stream->Add("["); |
431 key()->PrintTo(stream); | 422 key()->PrintTo(stream); |
432 stream->Add("] <- "); | 423 stream->Add("] <- "); |
433 value()->PrintTo(stream); | 424 value()->PrintTo(stream); |
434 } | 425 } |
435 | 426 |
436 | 427 |
437 void LTransitionElementsKind::PrintDataTo(StringStream* stream) { | 428 void LTransitionElementsKind::PrintDataTo(StringStream* stream) { |
(...skipping 1487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) { |
1937 ASSERT(instr->representation().IsTagged()); | 1928 |
1938 ASSERT(instr->key()->representation().IsInteger32() || | 1929 ASSERT(instr->key()->representation().IsInteger32() || |
1939 instr->key()->representation().IsTagged()); | 1930 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 | 1931 |
| 1932 if (!instr->is_external()) { |
| 1933 LOperand* obj = UseRegisterAtStart(instr->object()); |
| 1934 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); |
| 1935 LTemplateInstruction<1, 2, 0> *result; |
| 1936 result = new(zone()) LLoadKeyed(obj, key); |
1947 | 1937 |
1948 LInstruction* LChunkBuilder::DoLoadKeyedFastDoubleElement( | 1938 // TODO(mvstanton) - for fast double case, now we might not assign |
1949 HLoadKeyedFastDoubleElement* instr) { | 1939 // an environment, and we used to before. A problem? |
1950 ASSERT(instr->representation().IsDouble()); | 1940 if (instr->RequiresHoleCheck()) AssignEnvironment(result); |
1951 ASSERT(instr->key()->representation().IsInteger32() || | 1941 return DefineAsRegister(result); |
1952 instr->key()->representation().IsTagged()); | 1942 } |
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 | 1943 |
1960 | |
1961 LInstruction* LChunkBuilder::DoLoadKeyedSpecializedArrayElement( | |
1962 HLoadKeyedSpecializedArrayElement* instr) { | |
1963 ElementsKind elements_kind = instr->elements_kind(); | 1944 ElementsKind elements_kind = instr->elements_kind(); |
1964 ASSERT( | 1945 ASSERT( |
1965 (instr->representation().IsInteger32() && | 1946 (instr->representation().IsInteger32() && |
1966 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && | 1947 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && |
1967 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || | 1948 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || |
1968 (instr->representation().IsDouble() && | 1949 (instr->representation().IsDouble() && |
1969 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || | 1950 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || |
1970 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); | 1951 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); |
1971 ASSERT(instr->key()->representation().IsInteger32() || | |
1972 instr->key()->representation().IsTagged()); | |
1973 LOperand* external_pointer = UseRegister(instr->external_pointer()); | 1952 LOperand* external_pointer = UseRegister(instr->external_pointer()); |
1974 bool clobbers_key = ExternalArrayOpRequiresTemp( | 1953 bool clobbers_key = ExternalArrayOpRequiresTemp( |
1975 instr->key()->representation(), elements_kind); | 1954 instr->key()->representation(), elements_kind); |
1976 LOperand* key = clobbers_key | 1955 LOperand* key = clobbers_key |
1977 ? UseTempRegister(instr->key()) | 1956 ? UseTempRegister(instr->key()) |
1978 : UseRegisterOrConstant(instr->key()); | 1957 : UseRegisterOrConstant(instr->key()); |
1979 | 1958 |
1980 LLoadKeyedSpecializedArrayElement* result = | 1959 LLoadKeyed* result = new(zone()) LLoadKeyed(external_pointer, key); |
1981 new(zone()) LLoadKeyedSpecializedArrayElement(external_pointer, key); | |
1982 LInstruction* load_instr = DefineAsRegister(result); | 1960 LInstruction* load_instr = DefineAsRegister(result); |
1983 // An unsigned int array load might overflow and cause a deopt, make sure it | 1961 // An unsigned int array load might overflow and cause a deopt, make sure it |
1984 // has an environment. | 1962 // has an environment. |
1985 return (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS) | 1963 return (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS) |
1986 ? AssignEnvironment(load_instr) | 1964 ? AssignEnvironment(load_instr) |
1987 : load_instr; | 1965 : load_instr; |
1988 } | 1966 } |
1989 | 1967 |
1990 | 1968 |
1991 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) { | 1969 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) { |
1992 LOperand* context = UseFixed(instr->context(), esi); | 1970 LOperand* context = UseFixed(instr->context(), esi); |
1993 LOperand* object = UseFixed(instr->object(), edx); | 1971 LOperand* object = UseFixed(instr->object(), edx); |
1994 LOperand* key = UseFixed(instr->key(), ecx); | 1972 LOperand* key = UseFixed(instr->key(), ecx); |
1995 | 1973 |
1996 LLoadKeyedGeneric* result = | 1974 LLoadKeyedGeneric* result = |
1997 new(zone()) LLoadKeyedGeneric(context, object, key); | 1975 new(zone()) LLoadKeyedGeneric(context, object, key); |
1998 return MarkAsCall(DefineFixed(result, eax), instr); | 1976 return MarkAsCall(DefineFixed(result, eax), instr); |
1999 } | 1977 } |
2000 | 1978 |
2001 | 1979 |
2002 LInstruction* LChunkBuilder::DoStoreKeyedFastElement( | 1980 LInstruction* LChunkBuilder::DoStoreKeyed( |
2003 HStoreKeyedFastElement* instr) { | 1981 HStoreKeyed* instr) { |
2004 bool needs_write_barrier = instr->NeedsWriteBarrier(); | 1982 if (!instr->is_external()) { |
2005 ASSERT(instr->value()->representation().IsTagged()); | 1983 ASSERT(instr->object()->representation().IsTagged()); |
2006 ASSERT(instr->object()->representation().IsTagged()); | 1984 ASSERT(instr->key()->representation().IsInteger32() || |
2007 ASSERT(instr->key()->representation().IsInteger32() || | 1985 instr->key()->representation().IsTagged()); |
2008 instr->key()->representation().IsTagged()); | |
2009 | 1986 |
2010 LOperand* obj = UseRegister(instr->object()); | 1987 if (instr->value()->representation().IsDouble()) { |
2011 LOperand* val = needs_write_barrier | 1988 LOperand* object = UseRegisterAtStart(instr->object()); |
2012 ? UseTempRegister(instr->value()) | 1989 LOperand* val = UseTempRegister(instr->value()); |
2013 : UseRegisterAtStart(instr->value()); | 1990 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); |
2014 LOperand* key = needs_write_barrier | 1991 |
2015 ? UseTempRegister(instr->key()) | 1992 return new(zone()) LStoreKeyed(object, key, val); |
2016 : UseRegisterOrConstantAtStart(instr->key()); | 1993 } else { |
2017 return new(zone()) LStoreKeyedFastElement(obj, key, val); | 1994 bool needs_write_barrier = instr->NeedsWriteBarrier(); |
| 1995 ASSERT(instr->value()->representation().IsTagged()); |
| 1996 |
| 1997 LOperand* obj = UseRegister(instr->object()); |
| 1998 LOperand* val = needs_write_barrier |
| 1999 ? UseTempRegister(instr->value()) |
| 2000 : UseRegisterAtStart(instr->value()); |
| 2001 LOperand* key = needs_write_barrier |
| 2002 ? UseTempRegister(instr->key()) |
| 2003 : UseRegisterOrConstantAtStart(instr->key()); |
| 2004 return new(zone()) LStoreKeyed(obj, key, val); |
| 2005 } |
| 2006 } else { |
| 2007 ElementsKind elements_kind = instr->elements_kind(); |
| 2008 ASSERT( |
| 2009 (instr->value()->representation().IsInteger32() && |
| 2010 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && |
| 2011 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || |
| 2012 (instr->value()->representation().IsDouble() && |
| 2013 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || |
| 2014 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); |
| 2015 ASSERT(instr->external_pointer()->representation().IsExternal()); |
| 2016 |
| 2017 LOperand* external_pointer = UseRegister(instr->external_pointer()); |
| 2018 LOperand* val = NULL; |
| 2019 if (elements_kind == EXTERNAL_BYTE_ELEMENTS || |
| 2020 elements_kind == EXTERNAL_UNSIGNED_BYTE_ELEMENTS || |
| 2021 elements_kind == EXTERNAL_PIXEL_ELEMENTS) { |
| 2022 // We need a byte register in this case for the value. |
| 2023 val = UseFixed(instr->value(), eax); |
| 2024 } else { |
| 2025 val = UseRegister(instr->value()); |
| 2026 } |
| 2027 bool clobbers_key = ExternalArrayOpRequiresTemp( |
| 2028 instr->key()->representation(), elements_kind); |
| 2029 LOperand* key = clobbers_key |
| 2030 ? UseTempRegister(instr->key()) |
| 2031 : UseRegisterOrConstant(instr->key()); |
| 2032 return new(zone()) LStoreKeyed(external_pointer, |
| 2033 key, |
| 2034 val); |
| 2035 } |
2018 } | 2036 } |
2019 | 2037 |
2020 | 2038 |
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) { | 2039 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { |
2072 LOperand* context = UseFixed(instr->context(), esi); | 2040 LOperand* context = UseFixed(instr->context(), esi); |
2073 LOperand* object = UseFixed(instr->object(), edx); | 2041 LOperand* object = UseFixed(instr->object(), edx); |
2074 LOperand* key = UseFixed(instr->key(), ecx); | 2042 LOperand* key = UseFixed(instr->key(), ecx); |
2075 LOperand* value = UseFixed(instr->value(), eax); | 2043 LOperand* value = UseFixed(instr->value(), eax); |
2076 | 2044 |
2077 ASSERT(instr->object()->representation().IsTagged()); | 2045 ASSERT(instr->object()->representation().IsTagged()); |
2078 ASSERT(instr->key()->representation().IsTagged()); | 2046 ASSERT(instr->key()->representation().IsTagged()); |
2079 ASSERT(instr->value()->representation().IsTagged()); | 2047 ASSERT(instr->value()->representation().IsTagged()); |
2080 | 2048 |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2431 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2399 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2432 LOperand* object = UseRegister(instr->object()); | 2400 LOperand* object = UseRegister(instr->object()); |
2433 LOperand* index = UseTempRegister(instr->index()); | 2401 LOperand* index = UseTempRegister(instr->index()); |
2434 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2402 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2435 } | 2403 } |
2436 | 2404 |
2437 | 2405 |
2438 } } // namespace v8::internal | 2406 } } // namespace v8::internal |
2439 | 2407 |
2440 #endif // V8_TARGET_ARCH_IA32 | 2408 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |