Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/flow_graph_builder.h" | 5 #include "vm/flow_graph_builder.h" |
| 6 | 6 |
| 7 #include "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
| 8 #include "vm/ast_printer.h" | 8 #include "vm/ast_printer.h" |
| 9 #include "vm/bit_vector.h" | 9 #include "vm/bit_vector.h" |
| 10 #include "vm/code_descriptors.h" | 10 #include "vm/code_descriptors.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 ASSERT(callee_graph->max_block_id() > caller_graph_->max_block_id()); | 75 ASSERT(callee_graph->max_block_id() > caller_graph_->max_block_id()); |
| 76 ASSERT(callee_graph->max_virtual_register_number() > | 76 ASSERT(callee_graph->max_virtual_register_number() > |
| 77 caller_graph_->max_virtual_register_number()); | 77 caller_graph_->max_virtual_register_number()); |
| 78 | 78 |
| 79 // Adjust the caller's maximum block id and current SSA temp index. | 79 // Adjust the caller's maximum block id and current SSA temp index. |
| 80 caller_graph_->set_max_block_id(callee_graph->max_block_id()); | 80 caller_graph_->set_max_block_id(callee_graph->max_block_id()); |
| 81 caller_graph_->set_current_ssa_temp_index( | 81 caller_graph_->set_current_ssa_temp_index( |
| 82 callee_graph->max_virtual_register_number()); | 82 callee_graph->max_virtual_register_number()); |
| 83 | 83 |
| 84 // Attach the outer environment on each instruction in the callee graph. | 84 // Attach the outer environment on each instruction in the callee graph. |
| 85 // Scale the edge weights by the call count for the inlined function. | |
| 86 double scale_factor = static_cast<double>(call_->CallCount()) | |
| 87 / static_cast<double>(caller_graph_->graph_entry()->entry_count()); | |
| 85 for (BlockIterator block_it = callee_graph->postorder_iterator(); | 88 for (BlockIterator block_it = callee_graph->postorder_iterator(); |
| 86 !block_it.Done(); | 89 !block_it.Done(); |
| 87 block_it.Advance()) { | 90 block_it.Advance()) { |
| 88 for (ForwardInstructionIterator it(block_it.Current()); | 91 BlockEntryInstr* block = block_it.Current(); |
| 89 !it.Done(); | 92 if (block->IsTargetEntry()) { |
| 90 it.Advance()) { | 93 block->AsTargetEntry()->adjust_edge_weight(scale_factor); |
| 91 Instruction* instr = it.Current(); | 94 } |
| 95 Instruction* instr = block; | |
| 96 for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) { | |
| 97 instr = it.Current(); | |
| 92 // TODO(zerny): Avoid creating unnecessary environments. Note that some | 98 // TODO(zerny): Avoid creating unnecessary environments. Note that some |
| 93 // optimizations need deoptimization info for non-deoptable instructions, | 99 // optimizations need deoptimization info for non-deoptable instructions, |
| 94 // eg, LICM on GOTOs. | 100 // eg, LICM on GOTOs. |
| 95 if (instr->env() != NULL) call_->env()->DeepCopyToOuter(instr); | 101 if (instr->env() != NULL) call_->env()->DeepCopyToOuter(instr); |
| 96 } | 102 } |
| 103 if (instr->IsGoto()) { | |
| 104 instr->AsGoto()->adjust_edge_weight(scale_factor); | |
| 105 } | |
| 97 } | 106 } |
| 98 } | 107 } |
| 99 | 108 |
| 100 | 109 |
| 101 void InlineExitCollector::AddExit(ReturnInstr* exit) { | 110 void InlineExitCollector::AddExit(ReturnInstr* exit) { |
| 102 Data data = { NULL, exit }; | 111 Data data = { NULL, exit }; |
| 103 exits_.Add(data); | 112 exits_.Add(data); |
| 104 } | 113 } |
| 105 | 114 |
| 106 | 115 |
| (...skipping 3409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3516 } | 3525 } |
| 3517 | 3526 |
| 3518 FlowGraph* graph = new FlowGraph(*this, graph_entry_, last_used_block_id_); | 3527 FlowGraph* graph = new FlowGraph(*this, graph_entry_, last_used_block_id_); |
| 3519 return graph; | 3528 return graph; |
| 3520 } | 3529 } |
| 3521 | 3530 |
| 3522 | 3531 |
| 3523 void FlowGraphBuilder::PruneUnreachable() { | 3532 void FlowGraphBuilder::PruneUnreachable() { |
| 3524 ASSERT(osr_id_ != Isolate::kNoDeoptId); | 3533 ASSERT(osr_id_ != Isolate::kNoDeoptId); |
| 3525 BitVector* block_marks = new BitVector(last_used_block_id_ + 1); | 3534 BitVector* block_marks = new BitVector(last_used_block_id_ + 1); |
| 3526 bool found = graph_entry_->PruneUnreachable(this, graph_entry_, osr_id_, | 3535 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
| |
| 3527 block_marks); | 3536 block_marks); |
| 3528 ASSERT(found); | 3537 ASSERT(found); |
| 3529 } | 3538 } |
| 3530 | 3539 |
| 3531 | 3540 |
| 3532 void FlowGraphBuilder::Bailout(const char* reason) { | 3541 void FlowGraphBuilder::Bailout(const char* reason) { |
| 3533 const char* kFormat = "FlowGraphBuilder Bailout: %s %s"; | 3542 const char* kFormat = "FlowGraphBuilder Bailout: %s %s"; |
| 3534 const char* function_name = parsed_function_->function().ToCString(); | 3543 const char* function_name = parsed_function_->function().ToCString(); |
| 3535 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 3544 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
| 3536 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 3545 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 3537 OS::SNPrint(chars, len, kFormat, function_name, reason); | 3546 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 3538 const Error& error = Error::Handle( | 3547 const Error& error = Error::Handle( |
| 3539 LanguageError::New(String::Handle(String::New(chars)))); | 3548 LanguageError::New(String::Handle(String::New(chars)))); |
| 3540 Isolate::Current()->long_jump_base()->Jump(1, error); | 3549 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 3541 } | 3550 } |
| 3542 | 3551 |
| 3543 | 3552 |
| 3544 } // namespace dart | 3553 } // namespace dart |
| OLD | NEW |