| 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 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 | 31 |
| 32 // 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 |
| 33 // per function entry). | 33 // per function entry). |
| 34 static void SetEdgeWeight(Instruction* instruction, | 34 static void SetEdgeWeight(Instruction* instruction, |
| 35 BlockEntryInstr* successor, | 35 BlockEntryInstr* successor, |
| 36 const Code& unoptimized_code, | 36 const Code& unoptimized_code, |
| 37 intptr_t entry_count) { | 37 intptr_t entry_count) { |
| 38 TargetEntryInstr* target = successor->AsTargetEntry(); | 38 TargetEntryInstr* target = successor->AsTargetEntry(); |
| 39 if (target != NULL) { | 39 if (target != NULL) { |
| 40 intptr_t count = ComputeEdgeCount(unoptimized_code, target->deopt_id()); | 40 // If this block ends in a goto, the edge count of this edge is the same |
| 41 // as the count on the single outgoing edge. This is true as long as the |
| 42 // block does not throw an exception. |
| 43 GotoInstr* jump = target->last_instruction()->AsGoto(); |
| 44 const intptr_t deopt_id = |
| 45 (jump != NULL) ? jump->deopt_id() : target->deopt_id(); |
| 46 intptr_t count = ComputeEdgeCount(unoptimized_code, deopt_id); |
| 41 if ((count >= 0) && (entry_count != 0)) { | 47 if ((count >= 0) && (entry_count != 0)) { |
| 42 double weight = | 48 double weight = |
| 43 static_cast<double>(count) / static_cast<double>(entry_count); | 49 static_cast<double>(count) / static_cast<double>(entry_count); |
| 44 target->set_edge_weight(weight); | 50 target->set_edge_weight(weight); |
| 45 } | 51 } |
| 46 } else { | 52 } else { |
| 47 GotoInstr* jump = instruction->AsGoto(); | 53 GotoInstr* jump = instruction->AsGoto(); |
| 48 if (jump != NULL) { | 54 if (jump != NULL) { |
| 49 intptr_t count = ComputeEdgeCount(unoptimized_code, jump->deopt_id()); | 55 intptr_t count = ComputeEdgeCount(unoptimized_code, jump->deopt_id()); |
| 50 if ((count >= 0) && (entry_count != 0)) { | 56 if ((count >= 0) && (entry_count != 0)) { |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 for (intptr_t i = block_count - 1; i >= 0; --i) { | 208 for (intptr_t i = block_count - 1; i >= 0; --i) { |
| 203 if (chains[i]->first->block == flow_graph()->postorder()[i]) { | 209 if (chains[i]->first->block == flow_graph()->postorder()[i]) { |
| 204 for (Link* link = chains[i]->first; link != NULL; link = link->next) { | 210 for (Link* link = chains[i]->first; link != NULL; link = link->next) { |
| 205 flow_graph()->CodegenBlockOrder(true)->Add(link->block); | 211 flow_graph()->CodegenBlockOrder(true)->Add(link->block); |
| 206 } | 212 } |
| 207 } | 213 } |
| 208 } | 214 } |
| 209 } | 215 } |
| 210 | 216 |
| 211 } // namespace dart | 217 } // namespace dart |
| OLD | NEW |