| 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/compiler.h" |
| 10 #include "vm/class_finalizer.h" | 11 #include "vm/class_finalizer.h" |
| 11 #include "vm/exceptions.h" | 12 #include "vm/exceptions.h" |
| 12 #include "vm/flags.h" | 13 #include "vm/flags.h" |
| 13 #include "vm/flow_graph.h" | 14 #include "vm/flow_graph.h" |
| 14 #include "vm/flow_graph_compiler.h" | 15 #include "vm/flow_graph_compiler.h" |
| 15 #include "vm/heap.h" | 16 #include "vm/heap.h" |
| 16 #include "vm/il_printer.h" | 17 #include "vm/il_printer.h" |
| 17 #include "vm/intermediate_language.h" | 18 #include "vm/intermediate_language.h" |
| 18 #include "vm/isolate.h" | 19 #include "vm/isolate.h" |
| 19 #include "vm/object.h" | 20 #include "vm/object.h" |
| (...skipping 4617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4637 new(Z) GraphEntryInstr(parsed_function(), normal_entry, osr_id_); | 4638 new(Z) GraphEntryInstr(parsed_function(), normal_entry, osr_id_); |
| 4638 EffectGraphVisitor for_effect(this); | 4639 EffectGraphVisitor for_effect(this); |
| 4639 parsed_function().node_sequence()->Visit(&for_effect); | 4640 parsed_function().node_sequence()->Visit(&for_effect); |
| 4640 AppendFragment(normal_entry, for_effect); | 4641 AppendFragment(normal_entry, for_effect); |
| 4641 // Check that the graph is properly terminated. | 4642 // Check that the graph is properly terminated. |
| 4642 ASSERT(!for_effect.is_open()); | 4643 ASSERT(!for_effect.is_open()); |
| 4643 | 4644 |
| 4644 // When compiling for OSR, use a depth first search to prune instructions | 4645 // When compiling for OSR, use a depth first search to prune instructions |
| 4645 // unreachable from the OSR entry. Catch entries are always considered | 4646 // unreachable from the OSR entry. Catch entries are always considered |
| 4646 // reachable, even if they become unreachable after OSR. | 4647 // reachable, even if they become unreachable after OSR. |
| 4647 if (osr_id_ != Thread::kNoDeoptId) { | 4648 if (osr_id_ != Compiler::kNoOSRDeoptId) { |
| 4648 PruneUnreachable(); | 4649 PruneUnreachable(); |
| 4649 } | 4650 } |
| 4650 | 4651 |
| 4651 FlowGraph* graph = | 4652 FlowGraph* graph = |
| 4652 new(Z) FlowGraph(parsed_function(), graph_entry_, last_used_block_id_); | 4653 new(Z) FlowGraph(parsed_function(), graph_entry_, last_used_block_id_); |
| 4653 return graph; | 4654 return graph; |
| 4654 } | 4655 } |
| 4655 | 4656 |
| 4656 | 4657 |
| 4657 void FlowGraphBuilder::PruneUnreachable() { | 4658 void FlowGraphBuilder::PruneUnreachable() { |
| 4658 ASSERT(osr_id_ != Thread::kNoDeoptId); | 4659 ASSERT(osr_id_ != Compiler::kNoOSRDeoptId); |
| 4659 BitVector* block_marks = new(Z) BitVector(Z, last_used_block_id_ + 1); | 4660 BitVector* block_marks = new(Z) BitVector(Z, last_used_block_id_ + 1); |
| 4660 bool found = graph_entry_->PruneUnreachable(this, graph_entry_, NULL, osr_id_, | 4661 bool found = graph_entry_->PruneUnreachable(this, graph_entry_, NULL, osr_id_, |
| 4661 block_marks); | 4662 block_marks); |
| 4662 ASSERT(found); | 4663 ASSERT(found); |
| 4663 } | 4664 } |
| 4664 | 4665 |
| 4665 | 4666 |
| 4666 void FlowGraphBuilder::Bailout(const char* reason) const { | 4667 void FlowGraphBuilder::Bailout(const char* reason) const { |
| 4667 const Function& function = parsed_function_.function(); | 4668 const Function& function = parsed_function_.function(); |
| 4668 Report::MessageF(Report::kBailout, | 4669 Report::MessageF(Report::kBailout, |
| 4669 Script::Handle(function.script()), | 4670 Script::Handle(function.script()), |
| 4670 function.token_pos(), | 4671 function.token_pos(), |
| 4671 "FlowGraphBuilder Bailout: %s %s", | 4672 "FlowGraphBuilder Bailout: %s %s", |
| 4672 String::Handle(function.name()).ToCString(), | 4673 String::Handle(function.name()).ToCString(), |
| 4673 reason); | 4674 reason); |
| 4674 UNREACHABLE(); | 4675 UNREACHABLE(); |
| 4675 } | 4676 } |
| 4676 | 4677 |
| 4677 } // namespace dart | 4678 } // namespace dart |
| OLD | NEW |