| 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/flow_graph.h" | 9 #include "vm/flow_graph.h" |
| 10 | 10 |
| 11 namespace dart { | 11 namespace dart { |
| 12 | 12 |
| 13 DEFINE_FLAG(bool, emit_edge_counters, true, "Emit edge counters at targets."); | 13 DEFINE_FLAG(bool, emit_edge_counters, true, "Emit edge counters at targets."); |
| 14 | 14 |
| 15 // Compute the edge count at the deopt id of a TargetEntry or Goto. | 15 // Compute the edge count at the deopt id of a TargetEntry or Goto. |
| 16 static intptr_t ComputeEdgeCount(const Code& unoptimized_code, | 16 static intptr_t ComputeEdgeCount(const Code& unoptimized_code, |
| 17 intptr_t deopt_id) { | 17 intptr_t deopt_id) { |
| 18 ASSERT(deopt_id != Isolate::kNoDeoptId); | 18 ASSERT(deopt_id != Isolate::kNoDeoptId); |
| 19 | 19 |
| 20 if (!FLAG_emit_edge_counters) { | 20 if (!FLAG_emit_edge_counters) { |
| 21 // Assume everything was visited once. | 21 // Assume everything was visited once. |
| 22 return 1; | 22 return 1; |
| 23 } | 23 } |
| 24 uword pc = unoptimized_code.GetPcForDeoptId(deopt_id, PcDescriptors::kDeopt); | 24 const uword pc = |
| 25 unoptimized_code.GetPcForDeoptId(deopt_id, RawPcDescriptors::kDeopt); |
| 25 Array& array = Array::Handle(); | 26 Array& array = Array::Handle(); |
| 26 array ^= CodePatcher::GetEdgeCounterAt(pc, unoptimized_code); | 27 array ^= CodePatcher::GetEdgeCounterAt(pc, unoptimized_code); |
| 27 ASSERT(!array.IsNull()); | 28 ASSERT(!array.IsNull()); |
| 28 return Smi::Value(Smi::RawCast(array.At(0))); | 29 return Smi::Value(Smi::RawCast(array.At(0))); |
| 29 } | 30 } |
| 30 | 31 |
| 31 | 32 |
| 32 // There is an edge from instruction->successor. Set its weight (edge count | 33 // There is an edge from instruction->successor. Set its weight (edge count |
| 33 // per function entry). | 34 // per function entry). |
| 34 static void SetEdgeWeight(Instruction* instruction, | 35 static void SetEdgeWeight(Instruction* instruction, |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 for (intptr_t i = block_count - 1; i >= 0; --i) { | 209 for (intptr_t i = block_count - 1; i >= 0; --i) { |
| 209 if (chains[i]->first->block == flow_graph()->postorder()[i]) { | 210 if (chains[i]->first->block == flow_graph()->postorder()[i]) { |
| 210 for (Link* link = chains[i]->first; link != NULL; link = link->next) { | 211 for (Link* link = chains[i]->first; link != NULL; link = link->next) { |
| 211 flow_graph()->CodegenBlockOrder(true)->Add(link->block); | 212 flow_graph()->CodegenBlockOrder(true)->Add(link->block); |
| 212 } | 213 } |
| 213 } | 214 } |
| 214 } | 215 } |
| 215 } | 216 } |
| 216 | 217 |
| 217 } // namespace dart | 218 } // namespace dart |
| OLD | NEW |