| 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/block_scheduler.h" | 5 #include "vm/block_scheduler.h" |
| 6 | 6 |
| 7 #include "vm/allocation.h" | 7 #include "vm/allocation.h" |
| 8 #include "vm/code_patcher.h" | 8 #include "vm/code_patcher.h" |
| 9 #include "vm/compiler.h" |
| 9 #include "vm/flow_graph.h" | 10 #include "vm/flow_graph.h" |
| 10 | 11 |
| 11 namespace dart { | 12 namespace dart { |
| 12 | 13 |
| 13 DEFINE_FLAG(bool, emit_edge_counters, true, "Emit edge counters at targets."); | 14 DEFINE_FLAG(bool, emit_edge_counters, true, "Emit edge counters at targets."); |
| 14 | 15 |
| 15 static intptr_t GetEdgeCount(const Array& edge_counters, intptr_t edge_id) { | 16 static intptr_t GetEdgeCount(const Array& edge_counters, intptr_t edge_id) { |
| 16 if (!FLAG_emit_edge_counters) { | 17 if (!FLAG_emit_edge_counters) { |
| 17 // Assume everything was visited once. | 18 // Assume everything was visited once. |
| 18 return 1; | 19 return 1; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 } | 54 } |
| 54 | 55 |
| 55 | 56 |
| 56 void BlockScheduler::AssignEdgeWeights() const { | 57 void BlockScheduler::AssignEdgeWeights() const { |
| 57 if (!FLAG_emit_edge_counters) { | 58 if (!FLAG_emit_edge_counters) { |
| 58 return; | 59 return; |
| 59 } | 60 } |
| 60 | 61 |
| 61 const Array& ic_data_array = Array::Handle(flow_graph()->zone(), | 62 const Array& ic_data_array = Array::Handle(flow_graph()->zone(), |
| 62 flow_graph()->parsed_function().function().ic_data_array()); | 63 flow_graph()->parsed_function().function().ic_data_array()); |
| 64 if (Compiler::IsBackgroundCompilation() && ic_data_array.IsNull()) { |
| 65 // Deferred loading cleared ic_data_array. |
| 66 Compiler::AbortBackgroundCompilation(Thread::kNoDeoptId); |
| 67 } |
| 68 ASSERT(!ic_data_array.IsNull()); |
| 63 Array& edge_counters = Array::Handle(); | 69 Array& edge_counters = Array::Handle(); |
| 64 edge_counters ^= ic_data_array.At(0); | 70 edge_counters ^= ic_data_array.At(0); |
| 65 | 71 |
| 66 intptr_t entry_count = GetEdgeCount( | 72 intptr_t entry_count = GetEdgeCount( |
| 67 edge_counters, | 73 edge_counters, |
| 68 flow_graph()->graph_entry()->normal_entry()->preorder_number()); | 74 flow_graph()->graph_entry()->normal_entry()->preorder_number()); |
| 69 flow_graph()->graph_entry()->set_entry_count(entry_count); | 75 flow_graph()->graph_entry()->set_entry_count(entry_count); |
| 70 | 76 |
| 71 for (BlockIterator it = flow_graph()->reverse_postorder_iterator(); | 77 for (BlockIterator it = flow_graph()->reverse_postorder_iterator(); |
| 72 !it.Done(); | 78 !it.Done(); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 for (intptr_t i = block_count - 1; i >= 0; --i) { | 210 for (intptr_t i = block_count - 1; i >= 0; --i) { |
| 205 if (chains[i]->first->block == flow_graph()->postorder()[i]) { | 211 if (chains[i]->first->block == flow_graph()->postorder()[i]) { |
| 206 for (Link* link = chains[i]->first; link != NULL; link = link->next) { | 212 for (Link* link = chains[i]->first; link != NULL; link = link->next) { |
| 207 flow_graph()->CodegenBlockOrder(true)->Add(link->block); | 213 flow_graph()->CodegenBlockOrder(true)->Add(link->block); |
| 208 } | 214 } |
| 209 } | 215 } |
| 210 } | 216 } |
| 211 } | 217 } |
| 212 | 218 |
| 213 } // namespace dart | 219 } // namespace dart |
| OLD | NEW |