| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/flow_graph_optimizer.h" | 5 #include "vm/flow_graph_optimizer.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/cha.h" | 8 #include "vm/cha.h" |
| 9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 5574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5585 const PhiPlaceMoves* phi_moves() const { return phi_moves_; } | 5585 const PhiPlaceMoves* phi_moves() const { return phi_moves_; } |
| 5586 | 5586 |
| 5587 // Returns true if the result of an allocation instruction can be aliased by | 5587 // Returns true if the result of an allocation instruction can be aliased by |
| 5588 // some other SSA variable and false otherwise. Currently simply checks if | 5588 // some other SSA variable and false otherwise. Currently simply checks if |
| 5589 // this value is stored in a field, escapes to another function or | 5589 // this value is stored in a field, escapes to another function or |
| 5590 // participates in a phi. | 5590 // participates in a phi. |
| 5591 static bool CanBeAliased(Definition* alloc) { | 5591 static bool CanBeAliased(Definition* alloc) { |
| 5592 ASSERT(alloc->IsAllocateObject() || | 5592 ASSERT(alloc->IsAllocateObject() || |
| 5593 alloc->IsCreateArray() || | 5593 alloc->IsCreateArray() || |
| 5594 (alloc->IsStaticCall() && | 5594 (alloc->IsStaticCall() && |
| 5595 alloc->AsStaticCall()->is_known_list_constructor())); | 5595 alloc->AsStaticCall()->IsRecognizedFactory())); |
| 5596 if (alloc->Identity() == kIdentityUnknown) { | 5596 if (alloc->Identity() == kIdentityUnknown) { |
| 5597 bool escapes = false; | 5597 bool escapes = false; |
| 5598 for (Value* use = alloc->input_use_list(); | 5598 for (Value* use = alloc->input_use_list(); |
| 5599 use != NULL; | 5599 use != NULL; |
| 5600 use = use->next_use()) { | 5600 use = use->next_use()) { |
| 5601 Instruction* instr = use->instruction(); | 5601 Instruction* instr = use->instruction(); |
| 5602 if (instr->IsPushArgument() || | 5602 if (instr->IsPushArgument() || |
| 5603 (instr->IsStoreInstanceField() | 5603 (instr->IsStoreInstanceField() |
| 5604 && (use->use_index() != StoreInstanceFieldInstr::kInstancePos)) || | 5604 && (use->use_index() != StoreInstanceFieldInstr::kInstancePos)) || |
| 5605 (instr->IsStoreIndexed() | 5605 (instr->IsStoreIndexed() |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5672 return GetFieldId(instance_id, field); | 5672 return GetFieldId(instance_id, field); |
| 5673 } | 5673 } |
| 5674 | 5674 |
| 5675 intptr_t GetInstanceVMFieldId(Definition* defn, intptr_t offset) { | 5675 intptr_t GetInstanceVMFieldId(Definition* defn, intptr_t offset) { |
| 5676 intptr_t instance_id = kAnyInstance; | 5676 intptr_t instance_id = kAnyInstance; |
| 5677 | 5677 |
| 5678 ASSERT(defn != NULL); | 5678 ASSERT(defn != NULL); |
| 5679 if ((defn->IsAllocateObject() || | 5679 if ((defn->IsAllocateObject() || |
| 5680 defn->IsCreateArray() || | 5680 defn->IsCreateArray() || |
| 5681 (defn->IsStaticCall() && | 5681 (defn->IsStaticCall() && |
| 5682 defn->AsStaticCall()->is_known_list_constructor())) && | 5682 defn->AsStaticCall()->IsRecognizedFactory())) && |
| 5683 !CanBeAliased(defn)) { | 5683 !CanBeAliased(defn)) { |
| 5684 instance_id = defn->ssa_temp_index(); | 5684 instance_id = defn->ssa_temp_index(); |
| 5685 ASSERT(instance_id != kAnyInstance); | 5685 ASSERT(instance_id != kAnyInstance); |
| 5686 } | 5686 } |
| 5687 | 5687 |
| 5688 intptr_t id = vm_field_ids_.Lookup(VMFieldIdPair::Key(instance_id, offset)); | 5688 intptr_t id = vm_field_ids_.Lookup(VMFieldIdPair::Key(instance_id, offset)); |
| 5689 if (id == 0) { | 5689 if (id == 0) { |
| 5690 id = ++max_vm_field_id_; | 5690 id = ++max_vm_field_id_; |
| 5691 vm_field_ids_.Insert( | 5691 vm_field_ids_.Insert( |
| 5692 VMFieldIdPair(VMFieldIdPair::Key(instance_id, offset), id)); | 5692 VMFieldIdPair(VMFieldIdPair::Key(instance_id, offset), id)); |
| 5693 } | 5693 } |
| 5694 return id; | 5694 return id; |
| 5695 } | 5695 } |
| 5696 | 5696 |
| 5697 intptr_t GetInstanceIndexId(Definition* defn, intptr_t index) { | 5697 intptr_t GetInstanceIndexId(Definition* defn, intptr_t index) { |
| 5698 intptr_t instance_id = kAnyInstance; | 5698 intptr_t instance_id = kAnyInstance; |
| 5699 | 5699 |
| 5700 ASSERT(defn != NULL); | 5700 ASSERT(defn != NULL); |
| 5701 if ((defn->IsCreateArray() || | 5701 if ((defn->IsCreateArray() || |
| 5702 (defn->IsStaticCall() && | 5702 (defn->IsStaticCall() && |
| 5703 defn->AsStaticCall()->is_known_list_constructor())) && | 5703 defn->AsStaticCall()->IsRecognizedFactory())) && |
| 5704 !CanBeAliased(defn)) { | 5704 !CanBeAliased(defn)) { |
| 5705 instance_id = defn->ssa_temp_index(); | 5705 instance_id = defn->ssa_temp_index(); |
| 5706 ASSERT(instance_id != kAnyInstance); | 5706 ASSERT(instance_id != kAnyInstance); |
| 5707 } | 5707 } |
| 5708 | 5708 |
| 5709 return GetIndexId(instance_id, index); | 5709 return GetIndexId(instance_id, index); |
| 5710 } | 5710 } |
| 5711 | 5711 |
| 5712 intptr_t GetUnknownIndexId(Definition* defn) { | 5712 intptr_t GetUnknownIndexId(Definition* defn) { |
| 5713 intptr_t instance_id = kAnyInstance; | 5713 intptr_t instance_id = kAnyInstance; |
| 5714 | 5714 |
| 5715 ASSERT(defn != NULL); | 5715 ASSERT(defn != NULL); |
| 5716 if ((defn->IsCreateArray() || | 5716 if ((defn->IsCreateArray() || |
| 5717 (defn->IsStaticCall() && | 5717 (defn->IsStaticCall() && |
| 5718 defn->AsStaticCall()->is_known_list_constructor())) && | 5718 defn->AsStaticCall()->IsRecognizedFactory())) && |
| 5719 !CanBeAliased(defn)) { | 5719 !CanBeAliased(defn)) { |
| 5720 instance_id = defn->ssa_temp_index(); | 5720 instance_id = defn->ssa_temp_index(); |
| 5721 ASSERT(instance_id != kAnyInstance); | 5721 ASSERT(instance_id != kAnyInstance); |
| 5722 } | 5722 } |
| 5723 | 5723 |
| 5724 intptr_t id = unknown_index_ids_.Lookup( | 5724 intptr_t id = unknown_index_ids_.Lookup( |
| 5725 UnknownIndexIdPair::Key(instance_id)); | 5725 UnknownIndexIdPair::Key(instance_id)); |
| 5726 if (id == 0) { | 5726 if (id == 0) { |
| 5727 // Zero is used to indicate element not found. The first id is one. | 5727 // Zero is used to indicate element not found. The first id is one. |
| 5728 id = ++max_unknown_index_id_; | 5728 id = ++max_unknown_index_id_; |
| (...skipping 3307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9036 } | 9036 } |
| 9037 | 9037 |
| 9038 // Insert materializations at environment uses. | 9038 // Insert materializations at environment uses. |
| 9039 for (intptr_t i = 0; i < exits.length(); i++) { | 9039 for (intptr_t i = 0; i < exits.length(); i++) { |
| 9040 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *slots); | 9040 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *slots); |
| 9041 } | 9041 } |
| 9042 } | 9042 } |
| 9043 | 9043 |
| 9044 | 9044 |
| 9045 } // namespace dart | 9045 } // namespace dart |
| OLD | NEW |