Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 constant = HConstant::cast(binary_operation->right()); | 46 constant = HConstant::cast(binary_operation->right()); |
| 47 } else { | 47 } else { |
| 48 return; | 48 return; |
| 49 } | 49 } |
| 50 | 50 |
| 51 if (!constant->HasInteger32Value()) return; | 51 if (!constant->HasInteger32Value()) return; |
| 52 int32_t sign = binary_operation->IsSub() ? -1 : 1; | 52 int32_t sign = binary_operation->IsSub() ? -1 : 1; |
| 53 int32_t value = constant->Integer32Value() * sign; | 53 int32_t value = constant->Integer32Value() * sign; |
| 54 // We limit offset values to 30 bits because we want to avoid the risk of | 54 // We limit offset values to 30 bits because we want to avoid the risk of |
| 55 // overflows when the offset is added to the object header size. | 55 // overflows when the offset is added to the object header size. |
| 56 if (value >= 1 << array_operation->MaxIndexOffsetBits() || value < 0) return; | 56 if (value >= 1 << array_operation->MaxBaseOffsetBits() || value < 0) return; |
|
Toon Verwaest
2013/12/04 17:29:26
"value >= 1 << ..." is quite hard to understand. C
danno
2014/06/06 15:43:50
Done.
| |
| 57 array_operation->SetKey(subexpression); | 57 array_operation->SetKey(subexpression); |
| 58 if (binary_operation->HasNoUses()) { | 58 if (binary_operation->HasNoUses()) { |
| 59 binary_operation->DeleteAndReplaceWith(NULL); | 59 binary_operation->DeleteAndReplaceWith(NULL); |
| 60 } | 60 } |
| 61 array_operation->SetIndexOffset(static_cast<uint32_t>(value)); | 61 value <<= ElementsKindToShiftSize(array_operation->elements_kind()); |
| 62 array_operation->IncreaseBaseOffset(static_cast<uint32_t>(value)); | |
| 62 array_operation->SetDehoisted(true); | 63 array_operation->SetDehoisted(true); |
| 63 } | 64 } |
| 64 | 65 |
| 65 | 66 |
| 66 void HDehoistIndexComputationsPhase::Run() { | 67 void HDehoistIndexComputationsPhase::Run() { |
| 67 const ZoneList<HBasicBlock*>* blocks(graph()->blocks()); | 68 const ZoneList<HBasicBlock*>* blocks(graph()->blocks()); |
| 68 for (int i = 0; i < blocks->length(); ++i) { | 69 for (int i = 0; i < blocks->length(); ++i) { |
| 69 for (HInstructionIterator it(blocks->at(i)); !it.Done(); it.Advance()) { | 70 for (HInstructionIterator it(blocks->at(i)); !it.Done(); it.Advance()) { |
| 70 HInstruction* instr = it.Current(); | 71 HInstruction* instr = it.Current(); |
| 71 if (instr->IsLoadKeyed()) { | 72 if (instr->IsLoadKeyed()) { |
| 72 DehoistArrayIndex(HLoadKeyed::cast(instr)); | 73 DehoistArrayIndex(HLoadKeyed::cast(instr)); |
| 73 } else if (instr->IsStoreKeyed()) { | 74 } else if (instr->IsStoreKeyed()) { |
| 74 DehoistArrayIndex(HStoreKeyed::cast(instr)); | 75 DehoistArrayIndex(HStoreKeyed::cast(instr)); |
| 75 } | 76 } |
| 76 } | 77 } |
| 77 } | 78 } |
| 78 } | 79 } |
| 79 | 80 |
| 80 } } // namespace v8::internal | 81 } } // namespace v8::internal |
| OLD | NEW |