| 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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 | 415 |
| 416 void LLoadKeyed::PrintDataTo(StringStream* stream) { | 416 void LLoadKeyed::PrintDataTo(StringStream* stream) { |
| 417 elements()->PrintTo(stream); | 417 elements()->PrintTo(stream); |
| 418 stream->Add("["); | 418 stream->Add("["); |
| 419 key()->PrintTo(stream); | 419 key()->PrintTo(stream); |
| 420 if (hydrogen()->IsDehoisted()) { | 420 if (hydrogen()->IsDehoisted()) { |
| 421 stream->Add(" + %d]", additional_index()); | 421 stream->Add(" + %d]", additional_index()); |
| 422 } else { | 422 } else { |
| 423 stream->Add("]"); | 423 stream->Add("]"); |
| 424 } | 424 } |
| 425 if (prefetch_distance() != NULL) { |
| 426 stream->Add(" "); |
| 427 prefetch_distance()->PrintTo(stream); |
| 428 } |
| 425 } | 429 } |
| 426 | 430 |
| 427 | 431 |
| 428 void LStoreKeyed::PrintDataTo(StringStream* stream) { | 432 void LStoreKeyed::PrintDataTo(StringStream* stream) { |
| 429 elements()->PrintTo(stream); | 433 elements()->PrintTo(stream); |
| 430 stream->Add("["); | 434 stream->Add("["); |
| 431 key()->PrintTo(stream); | 435 key()->PrintTo(stream); |
| 432 if (hydrogen()->IsDehoisted()) { | 436 if (hydrogen()->IsDehoisted()) { |
| 433 stream->Add(" + %d] <-", additional_index()); | 437 stream->Add(" + %d] <-", additional_index()); |
| 434 } else { | 438 } else { |
| (...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1951 } | 1955 } |
| 1952 | 1956 |
| 1953 | 1957 |
| 1954 LInstruction* LChunkBuilder::DoLoadExternalArrayPointer( | 1958 LInstruction* LChunkBuilder::DoLoadExternalArrayPointer( |
| 1955 HLoadExternalArrayPointer* instr) { | 1959 HLoadExternalArrayPointer* instr) { |
| 1956 LOperand* input = UseRegisterAtStart(instr->value()); | 1960 LOperand* input = UseRegisterAtStart(instr->value()); |
| 1957 return DefineAsRegister(new(zone()) LLoadExternalArrayPointer(input)); | 1961 return DefineAsRegister(new(zone()) LLoadExternalArrayPointer(input)); |
| 1958 } | 1962 } |
| 1959 | 1963 |
| 1960 | 1964 |
| 1965 static bool ShouldPrefetch(HValue* distance, ElementsKind elements_kind) { |
| 1966 bool should_prefetch = true; |
| 1967 |
| 1968 if (distance->IsConstant()) { |
| 1969 HConstant* prefetch_distance = HConstant::cast(distance); |
| 1970 ASSERT(prefetch_distance->HasInteger32Value()); |
| 1971 int32_t distance_value = prefetch_distance->Integer32Value(); |
| 1972 if (distance_value < 0) distance_value = -distance_value; |
| 1973 // Omit the nearby accesses which are supposed to hit the cache. |
| 1974 should_prefetch = |
| 1975 (distance_value >= (64 >> ElementsKindToShiftSize(elements_kind))); |
| 1976 } |
| 1977 |
| 1978 return should_prefetch; |
| 1979 } |
| 1980 |
| 1981 |
| 1961 LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) { | 1982 LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) { |
| 1962 ASSERT(instr->key()->representation().IsInteger32() || | 1983 ASSERT(instr->key()->representation().IsInteger32() || |
| 1963 instr->key()->representation().IsTagged()); | 1984 instr->key()->representation().IsTagged()); |
| 1964 ElementsKind elements_kind = instr->elements_kind(); | 1985 ElementsKind elements_kind = instr->elements_kind(); |
| 1965 bool clobbers_key = ExternalArrayOpRequiresTemp( | 1986 bool clobbers_key = ExternalArrayOpRequiresTemp( |
| 1966 instr->key()->representation(), elements_kind); | 1987 instr->key()->representation(), elements_kind); |
| 1967 LOperand* key = clobbers_key | 1988 LOperand* key = clobbers_key |
| 1968 ? UseTempRegister(instr->key()) | 1989 ? UseTempRegister(instr->key()) |
| 1969 : UseRegisterOrConstantAtStart(instr->key()); | 1990 : UseRegisterOrConstantAtStart(instr->key()); |
| 1970 LLoadKeyed* result = NULL; | 1991 LLoadKeyed* result = NULL; |
| 1971 | 1992 |
| 1993 LOperand* prefetch = NULL; |
| 1994 LOperand* temp = NULL; |
| 1995 if (instr->prefetch_distance() != graph()->GetConstantUndefined() && |
| 1996 ShouldPrefetch(instr->prefetch_distance(), elements_kind)) { |
| 1997 prefetch = UseRegisterOrConstant(instr->prefetch_distance()); |
| 1998 temp = TempRegister(); |
| 1999 } |
| 2000 |
| 1972 if (!instr->is_external()) { | 2001 if (!instr->is_external()) { |
| 1973 LOperand* obj = UseRegisterAtStart(instr->elements()); | 2002 LOperand* obj = UseRegisterAtStart(instr->elements()); |
| 1974 result = new(zone()) LLoadKeyed(obj, key); | 2003 result = new(zone()) LLoadKeyed(obj, key, prefetch, temp); |
| 1975 } else { | 2004 } else { |
| 1976 ASSERT( | 2005 ASSERT( |
| 1977 (instr->representation().IsInteger32() && | 2006 (instr->representation().IsInteger32() && |
| 1978 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && | 2007 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && |
| 1979 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || | 2008 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || |
| 1980 (instr->representation().IsDouble() && | 2009 (instr->representation().IsDouble() && |
| 1981 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || | 2010 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || |
| 1982 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); | 2011 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); |
| 1983 LOperand* external_pointer = UseRegister(instr->elements()); | 2012 LOperand* external_pointer = UseRegister(instr->elements()); |
| 1984 result = new(zone()) LLoadKeyed(external_pointer, key); | 2013 result = new(zone()) LLoadKeyed(external_pointer, key, prefetch, temp); |
| 1985 } | 2014 } |
| 1986 | 2015 |
| 1987 DefineAsRegister(result); | 2016 DefineAsRegister(result); |
| 1988 bool can_deoptimize = instr->RequiresHoleCheck() || | 2017 bool can_deoptimize = instr->RequiresHoleCheck() || |
| 1989 (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS); | 2018 (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS); |
| 1990 // An unsigned int array load might overflow and cause a deopt, make sure it | 2019 // An unsigned int array load might overflow and cause a deopt, make sure it |
| 1991 // has an environment. | 2020 // has an environment. |
| 1992 return can_deoptimize ? AssignEnvironment(result) : result; | 2021 return can_deoptimize ? AssignEnvironment(result) : result; |
| 1993 } | 2022 } |
| 1994 | 2023 |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2425 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2454 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2426 LOperand* object = UseRegister(instr->object()); | 2455 LOperand* object = UseRegister(instr->object()); |
| 2427 LOperand* index = UseTempRegister(instr->index()); | 2456 LOperand* index = UseTempRegister(instr->index()); |
| 2428 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2457 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
| 2429 } | 2458 } |
| 2430 | 2459 |
| 2431 | 2460 |
| 2432 } } // namespace v8::internal | 2461 } } // namespace v8::internal |
| 2433 | 2462 |
| 2434 #endif // V8_TARGET_ARCH_IA32 | 2463 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |