| 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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 | 419 |
| 420 void LLoadKeyed::PrintDataTo(StringStream* stream) { | 420 void LLoadKeyed::PrintDataTo(StringStream* stream) { |
| 421 elements()->PrintTo(stream); | 421 elements()->PrintTo(stream); |
| 422 stream->Add("["); | 422 stream->Add("["); |
| 423 key()->PrintTo(stream); | 423 key()->PrintTo(stream); |
| 424 if (hydrogen()->IsDehoisted()) { | 424 if (hydrogen()->IsDehoisted()) { |
| 425 stream->Add(" + %d]", additional_index()); | 425 stream->Add(" + %d]", additional_index()); |
| 426 } else { | 426 } else { |
| 427 stream->Add("]"); | 427 stream->Add("]"); |
| 428 } | 428 } |
| 429 if (prefetch_distance() != NULL) { |
| 430 stream->Add(" "); |
| 431 prefetch_distance()->PrintTo(stream); |
| 432 } |
| 429 } | 433 } |
| 430 | 434 |
| 431 | 435 |
| 432 void LStoreKeyed::PrintDataTo(StringStream* stream) { | 436 void LStoreKeyed::PrintDataTo(StringStream* stream) { |
| 433 elements()->PrintTo(stream); | 437 elements()->PrintTo(stream); |
| 434 stream->Add("["); | 438 stream->Add("["); |
| 435 key()->PrintTo(stream); | 439 key()->PrintTo(stream); |
| 436 if (hydrogen()->IsDehoisted()) { | 440 if (hydrogen()->IsDehoisted()) { |
| 437 stream->Add(" + %d] <-", additional_index()); | 441 stream->Add(" + %d] <-", additional_index()); |
| 438 } else { | 442 } else { |
| (...skipping 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2026 } | 2030 } |
| 2027 | 2031 |
| 2028 | 2032 |
| 2029 LInstruction* LChunkBuilder::DoLoadExternalArrayPointer( | 2033 LInstruction* LChunkBuilder::DoLoadExternalArrayPointer( |
| 2030 HLoadExternalArrayPointer* instr) { | 2034 HLoadExternalArrayPointer* instr) { |
| 2031 LOperand* input = UseRegisterAtStart(instr->value()); | 2035 LOperand* input = UseRegisterAtStart(instr->value()); |
| 2032 return DefineAsRegister(new(zone()) LLoadExternalArrayPointer(input)); | 2036 return DefineAsRegister(new(zone()) LLoadExternalArrayPointer(input)); |
| 2033 } | 2037 } |
| 2034 | 2038 |
| 2035 | 2039 |
| 2040 static bool ShouldPrefetch(HValue* distance, ElementsKind elements_kind) { |
| 2041 bool should_prefetch = true; |
| 2042 |
| 2043 if (distance->IsConstant()) { |
| 2044 HConstant* prefetch_distance = HConstant::cast(distance); |
| 2045 ASSERT(prefetch_distance->HasInteger32Value()); |
| 2046 int32_t distance_value = prefetch_distance->Integer32Value(); |
| 2047 if (distance_value < 0) distance_value = -distance_value; |
| 2048 // Omit the nearby accesses which are supposed to hit the cache. |
| 2049 should_prefetch = |
| 2050 (distance_value >= (64 >> ElementsKindToShiftSize(elements_kind))); |
| 2051 } |
| 2052 |
| 2053 return should_prefetch; |
| 2054 } |
| 2055 |
| 2056 |
| 2036 LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) { | 2057 LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) { |
| 2037 ASSERT(instr->key()->representation().IsInteger32() || | 2058 ASSERT(instr->key()->representation().IsInteger32() || |
| 2038 instr->key()->representation().IsTagged()); | 2059 instr->key()->representation().IsTagged()); |
| 2039 ElementsKind elements_kind = instr->elements_kind(); | 2060 ElementsKind elements_kind = instr->elements_kind(); |
| 2040 bool clobbers_key = ExternalArrayOpRequiresTemp( | 2061 bool clobbers_key = ExternalArrayOpRequiresTemp( |
| 2041 instr->key()->representation(), elements_kind); | 2062 instr->key()->representation(), elements_kind); |
| 2042 LOperand* key = clobbers_key | 2063 LOperand* key = clobbers_key |
| 2043 ? UseTempRegister(instr->key()) | 2064 ? UseTempRegister(instr->key()) |
| 2044 : UseRegisterOrConstantAtStart(instr->key()); | 2065 : UseRegisterOrConstantAtStart(instr->key()); |
| 2045 LLoadKeyed* result = NULL; | 2066 LLoadKeyed* result = NULL; |
| 2046 | 2067 |
| 2068 LOperand* prefetch = NULL; |
| 2069 LOperand* temp = NULL; |
| 2070 if (instr->prefetch_distance() != graph()->GetConstantUndefined() && |
| 2071 ShouldPrefetch(instr->prefetch_distance(), elements_kind)) { |
| 2072 prefetch = UseRegisterOrConstant(instr->prefetch_distance()); |
| 2073 temp = TempRegister(); |
| 2074 } |
| 2075 |
| 2047 if (!instr->is_external()) { | 2076 if (!instr->is_external()) { |
| 2048 LOperand* obj = UseRegisterAtStart(instr->elements()); | 2077 LOperand* obj = UseRegisterAtStart(instr->elements()); |
| 2049 result = new(zone()) LLoadKeyed(obj, key); | 2078 result = new(zone()) LLoadKeyed(obj, key, prefetch, temp); |
| 2050 } else { | 2079 } else { |
| 2051 ASSERT( | 2080 ASSERT( |
| 2052 (instr->representation().IsInteger32() && | 2081 (instr->representation().IsInteger32() && |
| 2053 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && | 2082 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && |
| 2054 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || | 2083 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || |
| 2055 (instr->representation().IsDouble() && | 2084 (instr->representation().IsDouble() && |
| 2056 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || | 2085 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || |
| 2057 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); | 2086 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); |
| 2058 LOperand* external_pointer = UseRegister(instr->elements()); | 2087 LOperand* external_pointer = UseRegister(instr->elements()); |
| 2059 result = new(zone()) LLoadKeyed(external_pointer, key); | 2088 result = new(zone()) LLoadKeyed(external_pointer, key, prefetch, temp); |
| 2060 } | 2089 } |
| 2061 | 2090 |
| 2062 DefineAsRegister(result); | 2091 DefineAsRegister(result); |
| 2063 bool can_deoptimize = instr->RequiresHoleCheck() || | 2092 bool can_deoptimize = instr->RequiresHoleCheck() || |
| 2064 (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS); | 2093 (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS); |
| 2065 // An unsigned int array load might overflow and cause a deopt, make sure it | 2094 // An unsigned int array load might overflow and cause a deopt, make sure it |
| 2066 // has an environment. | 2095 // has an environment. |
| 2067 return can_deoptimize ? AssignEnvironment(result) : result; | 2096 return can_deoptimize ? AssignEnvironment(result) : result; |
| 2068 } | 2097 } |
| 2069 | 2098 |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2510 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2539 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2511 LOperand* object = UseRegister(instr->object()); | 2540 LOperand* object = UseRegister(instr->object()); |
| 2512 LOperand* index = UseTempRegister(instr->index()); | 2541 LOperand* index = UseTempRegister(instr->index()); |
| 2513 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2542 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
| 2514 } | 2543 } |
| 2515 | 2544 |
| 2516 | 2545 |
| 2517 } } // namespace v8::internal | 2546 } } // namespace v8::internal |
| 2518 | 2547 |
| 2519 #endif // V8_TARGET_ARCH_IA32 | 2548 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |