| 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."); |
| 14 |
| 13 // 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. |
| 14 static intptr_t ComputeEdgeCount(const Code& unoptimized_code, | 16 static intptr_t ComputeEdgeCount(const Code& unoptimized_code, |
| 15 intptr_t deopt_id) { | 17 intptr_t deopt_id) { |
| 16 ASSERT(deopt_id != Isolate::kNoDeoptId); | 18 ASSERT(deopt_id != Isolate::kNoDeoptId); |
| 17 | 19 |
| 20 if (!FLAG_emit_edge_counters) { |
| 21 // Assume everything was visited once. |
| 22 return 1; |
| 23 } |
| 18 uword pc = unoptimized_code.GetPcForDeoptId(deopt_id, PcDescriptors::kDeopt); | 24 uword pc = unoptimized_code.GetPcForDeoptId(deopt_id, PcDescriptors::kDeopt); |
| 19 Array& array = Array::Handle(); | 25 Array& array = Array::Handle(); |
| 20 array ^= CodePatcher::GetEdgeCounterAt(pc, unoptimized_code); | 26 array ^= CodePatcher::GetEdgeCounterAt(pc, unoptimized_code); |
| 21 ASSERT(!array.IsNull()); | 27 ASSERT(!array.IsNull()); |
| 22 return Smi::Value(Smi::RawCast(array.At(0))); | 28 return Smi::Value(Smi::RawCast(array.At(0))); |
| 23 } | 29 } |
| 24 | 30 |
| 25 | 31 |
| 26 // There is an edge from instruction->successor. Set its weight (edge count | 32 // There is an edge from instruction->successor. Set its weight (edge count |
| 27 // per function entry). | 33 // per function entry). |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 for (intptr_t i = block_count - 1; i >= 0; --i) { | 203 for (intptr_t i = block_count - 1; i >= 0; --i) { |
| 198 if (chains[i]->first->block == flow_graph()->postorder()[i]) { | 204 if (chains[i]->first->block == flow_graph()->postorder()[i]) { |
| 199 for (Link* link = chains[i]->first; link != NULL; link = link->next) { | 205 for (Link* link = chains[i]->first; link != NULL; link = link->next) { |
| 200 flow_graph()->CodegenBlockOrder(true)->Add(link->block); | 206 flow_graph()->CodegenBlockOrder(true)->Add(link->block); |
| 201 } | 207 } |
| 202 } | 208 } |
| 203 } | 209 } |
| 204 } | 210 } |
| 205 | 211 |
| 206 } // namespace dart | 212 } // namespace dart |
| OLD | NEW |