| 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 5662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5673 return (result != NULL) ? result->id() : static_cast<intptr_t>(kNoAlias); | 5673 return (result != NULL) ? result->id() : static_cast<intptr_t>(kNoAlias); |
| 5674 } | 5674 } |
| 5675 | 5675 |
| 5676 bool IsStore(Instruction* instr, BitVector** killed) { | 5676 bool IsStore(Instruction* instr, BitVector** killed) { |
| 5677 bool is_load = false, is_store = false; | 5677 bool is_load = false, is_store = false; |
| 5678 Place place(instr, &is_load, &is_store); | 5678 Place place(instr, &is_load, &is_store); |
| 5679 if (is_store && (place.kind() != Place::kNone)) { | 5679 if (is_store && (place.kind() != Place::kNone)) { |
| 5680 const intptr_t alias_id = LookupAliasId(place.ToAlias()); | 5680 const intptr_t alias_id = LookupAliasId(place.ToAlias()); |
| 5681 if (alias_id != kNoAlias) { | 5681 if (alias_id != kNoAlias) { |
| 5682 *killed = GetKilledSet(alias_id); | 5682 *killed = GetKilledSet(alias_id); |
| 5683 } else if (!place.IsFinalField()) { |
| 5684 // We encountered unknown alias: this means intrablock load forwarding |
| 5685 // refined parameter of this store, for example |
| 5686 // |
| 5687 // o <- alloc() |
| 5688 // a.f <- o |
| 5689 // u <- a.f |
| 5690 // u.x <- null ;; this store alias is *.x |
| 5691 // |
| 5692 // after intrablock load forwarding |
| 5693 // |
| 5694 // o <- alloc() |
| 5695 // a.f <- o |
| 5696 // o.x <- null ;; this store alias is o.x |
| 5697 // |
| 5698 // In this case we fallback to using place id recorded in the |
| 5699 // instruction that still points to the old place with a more generic |
| 5700 // alias. |
| 5701 *killed = GetKilledSet( |
| 5702 LookupAliasId(places_[instr->place_id()]->ToAlias())); |
| 5683 } | 5703 } |
| 5684 } | 5704 } |
| 5685 return is_store; | 5705 return is_store; |
| 5686 } | 5706 } |
| 5687 | 5707 |
| 5688 BitVector* GetKilledSet(intptr_t alias) { | 5708 BitVector* GetKilledSet(intptr_t alias) { |
| 5689 return (alias < killed_.length()) ? killed_[alias] : NULL; | 5709 return (alias < killed_.length()) ? killed_[alias] : NULL; |
| 5690 } | 5710 } |
| 5691 | 5711 |
| 5692 intptr_t max_place_id() const { return places().length(); } | 5712 intptr_t max_place_id() const { return places().length(); } |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6191 Isolate* isolate = graph->isolate(); | 6211 Isolate* isolate = graph->isolate(); |
| 6192 ZoneGrowableArray<Place*>* places = | 6212 ZoneGrowableArray<Place*>* places = |
| 6193 new(isolate) ZoneGrowableArray<Place*>(10); | 6213 new(isolate) ZoneGrowableArray<Place*>(10); |
| 6194 | 6214 |
| 6195 bool has_loads = false; | 6215 bool has_loads = false; |
| 6196 bool has_stores = false; | 6216 bool has_stores = false; |
| 6197 for (BlockIterator it = graph->reverse_postorder_iterator(); | 6217 for (BlockIterator it = graph->reverse_postorder_iterator(); |
| 6198 !it.Done(); | 6218 !it.Done(); |
| 6199 it.Advance()) { | 6219 it.Advance()) { |
| 6200 BlockEntryInstr* block = it.Current(); | 6220 BlockEntryInstr* block = it.Current(); |
| 6221 |
| 6201 for (ForwardInstructionIterator instr_it(block); | 6222 for (ForwardInstructionIterator instr_it(block); |
| 6202 !instr_it.Done(); | 6223 !instr_it.Done(); |
| 6203 instr_it.Advance()) { | 6224 instr_it.Advance()) { |
| 6204 Instruction* instr = instr_it.Current(); | 6225 Instruction* instr = instr_it.Current(); |
| 6205 Place place(instr, &has_loads, &has_stores); | 6226 Place place(instr, &has_loads, &has_stores); |
| 6206 if (place.kind() == Place::kNone) { | 6227 if (place.kind() == Place::kNone) { |
| 6207 continue; | 6228 continue; |
| 6208 } | 6229 } |
| 6209 | 6230 |
| 6210 Place* result = map->Lookup(&place); | 6231 Place* result = map->Lookup(&place); |
| (...skipping 3863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10074 | 10095 |
| 10075 // Insert materializations at environment uses. | 10096 // Insert materializations at environment uses. |
| 10076 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { | 10097 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { |
| 10077 CreateMaterializationAt( | 10098 CreateMaterializationAt( |
| 10078 exits_collector_.exits()[i], alloc, alloc->cls(), *slots); | 10099 exits_collector_.exits()[i], alloc, alloc->cls(), *slots); |
| 10079 } | 10100 } |
| 10080 } | 10101 } |
| 10081 | 10102 |
| 10082 | 10103 |
| 10083 } // namespace dart | 10104 } // namespace dart |
| OLD | NEW |