| 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/compiler.h" |
| 10 #include "vm/flow_graph.h" | 10 #include "vm/flow_graph.h" |
| 11 | 11 |
| 12 namespace dart { | 12 namespace dart { |
| 13 | 13 |
| 14 static intptr_t GetEdgeCount(const Array& edge_counters, intptr_t edge_id) { | 14 static intptr_t GetEdgeCount(const Array& edge_counters, intptr_t edge_id) { |
| 15 if (!FLAG_emit_edge_counters) { | 15 if (!FLAG_reorder_basic_blocks) { |
| 16 // Assume everything was visited once. | 16 // Assume everything was visited once. |
| 17 return 1; | 17 return 1; |
| 18 } | 18 } |
| 19 return Smi::Value(Smi::RawCast(edge_counters.At(edge_id))); | 19 return Smi::Value(Smi::RawCast(edge_counters.At(edge_id))); |
| 20 } | 20 } |
| 21 | 21 |
| 22 | 22 |
| 23 // There is an edge from instruction->successor. Set its weight (edge count | 23 // There is an edge from instruction->successor. Set its weight (edge count |
| 24 // per function entry). | 24 // per function entry). |
| 25 static void SetEdgeWeight(BlockEntryInstr* block, | 25 static void SetEdgeWeight(BlockEntryInstr* block, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 46 double weight = | 46 double weight = |
| 47 static_cast<double>(count) / static_cast<double>(entry_count); | 47 static_cast<double>(count) / static_cast<double>(entry_count); |
| 48 jump->set_edge_weight(weight); | 48 jump->set_edge_weight(weight); |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 | 54 |
| 55 void BlockScheduler::AssignEdgeWeights() const { | 55 void BlockScheduler::AssignEdgeWeights() const { |
| 56 if (!FLAG_emit_edge_counters) { | 56 if (!FLAG_reorder_basic_blocks) { |
| 57 return; | 57 return; |
| 58 } | 58 } |
| 59 | 59 |
| 60 const Array& ic_data_array = Array::Handle(flow_graph()->zone(), | 60 const Array& ic_data_array = Array::Handle(flow_graph()->zone(), |
| 61 flow_graph()->parsed_function().function().ic_data_array()); | 61 flow_graph()->parsed_function().function().ic_data_array()); |
| 62 if (Compiler::IsBackgroundCompilation() && ic_data_array.IsNull()) { | 62 if (Compiler::IsBackgroundCompilation() && ic_data_array.IsNull()) { |
| 63 // Deferred loading cleared ic_data_array. | 63 // Deferred loading cleared ic_data_array. |
| 64 Compiler::AbortBackgroundCompilation(Thread::kNoDeoptId); | 64 Compiler::AbortBackgroundCompilation(Thread::kNoDeoptId); |
| 65 } | 65 } |
| 66 ASSERT(!ic_data_array.IsNull()); | 66 ASSERT(!ic_data_array.IsNull()); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 for (intptr_t i = block_count - 1; i >= 0; --i) { | 208 for (intptr_t i = block_count - 1; i >= 0; --i) { |
| 209 if (chains[i]->first->block == flow_graph()->postorder()[i]) { | 209 if (chains[i]->first->block == flow_graph()->postorder()[i]) { |
| 210 for (Link* link = chains[i]->first; link != NULL; link = link->next) { | 210 for (Link* link = chains[i]->first; link != NULL; link = link->next) { |
| 211 flow_graph()->CodegenBlockOrder(true)->Add(link->block); | 211 flow_graph()->CodegenBlockOrder(true)->Add(link->block); |
| 212 } | 212 } |
| 213 } | 213 } |
| 214 } | 214 } |
| 215 } | 215 } |
| 216 | 216 |
| 217 } // namespace dart | 217 } // namespace dart |
| OLD | NEW |