| 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/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 } | 197 } |
| 198 return case_targets_[i]; | 198 return case_targets_[i]; |
| 199 } | 199 } |
| 200 return NULL; | 200 return NULL; |
| 201 } | 201 } |
| 202 | 202 |
| 203 | 203 |
| 204 FlowGraphBuilder::FlowGraphBuilder(ParsedFunction* parsed_function, | 204 FlowGraphBuilder::FlowGraphBuilder(ParsedFunction* parsed_function, |
| 205 const Array& ic_data_array, | 205 const Array& ic_data_array, |
| 206 InlineExitCollector* exit_collector, | 206 InlineExitCollector* exit_collector, |
| 207 intptr_t osr_id) | 207 intptr_t osr_id, |
| 208 bool is_optimizing) |
| 208 : parsed_function_(parsed_function), | 209 : parsed_function_(parsed_function), |
| 209 ic_data_array_(ic_data_array), | 210 ic_data_array_(ic_data_array), |
| 210 num_copied_params_(parsed_function->num_copied_params()), | 211 num_copied_params_(parsed_function->num_copied_params()), |
| 211 // All parameters are copied if any parameter is. | 212 // All parameters are copied if any parameter is. |
| 212 num_non_copied_params_((num_copied_params_ == 0) | 213 num_non_copied_params_((num_copied_params_ == 0) |
| 213 ? parsed_function->function().num_fixed_parameters() | 214 ? parsed_function->function().num_fixed_parameters() |
| 214 : 0), | 215 : 0), |
| 215 num_stack_locals_(parsed_function->num_stack_locals()), | 216 num_stack_locals_(parsed_function->num_stack_locals()), |
| 216 exit_collector_(exit_collector), | 217 exit_collector_(exit_collector), |
| 217 guarded_fields_(new ZoneGrowableArray<const Field*>()), | 218 guarded_fields_(new ZoneGrowableArray<const Field*>()), |
| 218 last_used_block_id_(0), // 0 is used for the graph entry. | 219 last_used_block_id_(0), // 0 is used for the graph entry. |
| 219 try_index_(CatchClauseNode::kInvalidTryIndex), | 220 try_index_(CatchClauseNode::kInvalidTryIndex), |
| 220 catch_try_index_(CatchClauseNode::kInvalidTryIndex), | 221 catch_try_index_(CatchClauseNode::kInvalidTryIndex), |
| 221 loop_depth_(0), | 222 loop_depth_(0), |
| 222 graph_entry_(NULL), | 223 graph_entry_(NULL), |
| 223 temp_count_(0), | 224 temp_count_(0), |
| 224 args_pushed_(0), | 225 args_pushed_(0), |
| 225 nesting_stack_(NULL), | 226 nesting_stack_(NULL), |
| 226 osr_id_(osr_id) { } | 227 osr_id_(osr_id), |
| 228 is_optimizing_(is_optimizing) { } |
| 227 | 229 |
| 228 | 230 |
| 229 void FlowGraphBuilder::AddCatchEntry(CatchBlockEntryInstr* entry) { | 231 void FlowGraphBuilder::AddCatchEntry(CatchBlockEntryInstr* entry) { |
| 230 graph_entry_->AddCatchEntry(entry); | 232 graph_entry_->AddCatchEntry(entry); |
| 231 } | 233 } |
| 232 | 234 |
| 233 | 235 |
| 234 void InlineExitCollector::PrepareGraphs(FlowGraph* callee_graph) { | 236 void InlineExitCollector::PrepareGraphs(FlowGraph* callee_graph) { |
| 235 ASSERT(callee_graph->graph_entry()->SuccessorCount() == 1); | 237 ASSERT(callee_graph->graph_entry()->SuccessorCount() == 1); |
| 236 ASSERT(callee_graph->max_block_id() > caller_graph_->max_block_id()); | 238 ASSERT(callee_graph->max_block_id() > caller_graph_->max_block_id()); |
| (...skipping 3602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3839 | 3841 |
| 3840 void FlowGraphBuilder::PruneUnreachable() { | 3842 void FlowGraphBuilder::PruneUnreachable() { |
| 3841 ASSERT(osr_id_ != Isolate::kNoDeoptId); | 3843 ASSERT(osr_id_ != Isolate::kNoDeoptId); |
| 3842 BitVector* block_marks = new BitVector(last_used_block_id_ + 1); | 3844 BitVector* block_marks = new BitVector(last_used_block_id_ + 1); |
| 3843 bool found = graph_entry_->PruneUnreachable(this, graph_entry_, NULL, osr_id_, | 3845 bool found = graph_entry_->PruneUnreachable(this, graph_entry_, NULL, osr_id_, |
| 3844 block_marks); | 3846 block_marks); |
| 3845 ASSERT(found); | 3847 ASSERT(found); |
| 3846 } | 3848 } |
| 3847 | 3849 |
| 3848 | 3850 |
| 3849 void FlowGraphBuilder::Bailout(const char* reason) { | 3851 void FlowGraphBuilder::Bailout(const char* reason) const { |
| 3850 const Function& function = parsed_function_->function(); | 3852 const Function& function = parsed_function_->function(); |
| 3851 const Error& error = Error::Handle( | 3853 const Error& error = Error::Handle( |
| 3852 LanguageError::NewFormatted(Error::Handle(), // No previous error. | 3854 LanguageError::NewFormatted(Error::Handle(), // No previous error. |
| 3853 Script::Handle(function.script()), | 3855 Script::Handle(function.script()), |
| 3854 function.token_pos(), | 3856 function.token_pos(), |
| 3855 LanguageError::kError, | 3857 LanguageError::kError, |
| 3856 Heap::kNew, | 3858 Heap::kNew, |
| 3857 "FlowGraphBuilder Bailout: %s %s", | 3859 "FlowGraphBuilder Bailout: %s %s", |
| 3858 String::Handle(function.name()).ToCString(), | 3860 String::Handle(function.name()).ToCString(), |
| 3859 reason)); | 3861 reason)); |
| 3860 Isolate::Current()->long_jump_base()->Jump(1, error); | 3862 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 3861 } | 3863 } |
| 3862 | 3864 |
| 3863 | |
| 3864 } // namespace dart | 3865 } // namespace dart |
| OLD | NEW |