Chromium Code Reviews| Index: runtime/vm/flow_graph_builder.cc |
| diff --git a/runtime/vm/flow_graph_builder.cc b/runtime/vm/flow_graph_builder.cc |
| index e3700f6db1dc428eabbcda5eb55387396d1c0df3..3bf11def99497c052f5ee73547ac30977f8fd66d 100644 |
| --- a/runtime/vm/flow_graph_builder.cc |
| +++ b/runtime/vm/flow_graph_builder.cc |
| @@ -82,18 +82,27 @@ void InlineExitCollector::PrepareGraphs(FlowGraph* callee_graph) { |
| callee_graph->max_virtual_register_number()); |
| // Attach the outer environment on each instruction in the callee graph. |
| + // Scale the edge weights by the call count for the inlined function. |
| + double scale_factor = static_cast<double>(call_->CallCount()) |
| + / static_cast<double>(caller_graph_->graph_entry()->entry_count()); |
| for (BlockIterator block_it = callee_graph->postorder_iterator(); |
| !block_it.Done(); |
| block_it.Advance()) { |
| - for (ForwardInstructionIterator it(block_it.Current()); |
| - !it.Done(); |
| - it.Advance()) { |
| - Instruction* instr = it.Current(); |
| + BlockEntryInstr* block = block_it.Current(); |
| + if (block->IsTargetEntry()) { |
| + block->AsTargetEntry()->adjust_edge_weight(scale_factor); |
| + } |
| + Instruction* instr = block; |
| + for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) { |
| + instr = it.Current(); |
| // TODO(zerny): Avoid creating unnecessary environments. Note that some |
| // optimizations need deoptimization info for non-deoptable instructions, |
| // eg, LICM on GOTOs. |
| if (instr->env() != NULL) call_->env()->DeepCopyToOuter(instr); |
| } |
| + if (instr->IsGoto()) { |
| + instr->AsGoto()->adjust_edge_weight(scale_factor); |
| + } |
| } |
| } |
| @@ -3523,7 +3532,7 @@ FlowGraph* FlowGraphBuilder::BuildGraph() { |
| void FlowGraphBuilder::PruneUnreachable() { |
| ASSERT(osr_id_ != Isolate::kNoDeoptId); |
| BitVector* block_marks = new BitVector(last_used_block_id_ + 1); |
| - bool found = graph_entry_->PruneUnreachable(this, graph_entry_, osr_id_, |
| + bool found = graph_entry_->PruneUnreachable(this, graph_entry_, NULL, osr_id_, |
|
srdjan
2013/08/14 00:28:24
Document what NULL means, e.g., const xxxx pkParen
|
| block_marks); |
| ASSERT(found); |
| } |