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/compiler.h" |
(...skipping 4453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4464 EffectGraphVisitor for_effect(this); | 4464 EffectGraphVisitor for_effect(this); |
4465 parsed_function().node_sequence()->Visit(&for_effect); | 4465 parsed_function().node_sequence()->Visit(&for_effect); |
4466 AppendFragment(normal_entry, for_effect); | 4466 AppendFragment(normal_entry, for_effect); |
4467 // Check that the graph is properly terminated. | 4467 // Check that the graph is properly terminated. |
4468 ASSERT(!for_effect.is_open()); | 4468 ASSERT(!for_effect.is_open()); |
4469 | 4469 |
4470 // When compiling for OSR, use a depth first search to prune instructions | 4470 // When compiling for OSR, use a depth first search to prune instructions |
4471 // unreachable from the OSR entry. Catch entries are always considered | 4471 // unreachable from the OSR entry. Catch entries are always considered |
4472 // reachable, even if they become unreachable after OSR. | 4472 // reachable, even if they become unreachable after OSR. |
4473 if (osr_id_ != Compiler::kNoOSRDeoptId) { | 4473 if (osr_id_ != Compiler::kNoOSRDeoptId) { |
4474 PruneUnreachable(); | 4474 graph_entry_->PruneUnreachableForOSR(Z, last_used_block_id_); |
4475 } | 4475 } |
4476 | 4476 |
4477 FlowGraph* graph = | 4477 FlowGraph* graph = |
4478 new (Z) FlowGraph(parsed_function(), graph_entry_, last_used_block_id_); | 4478 new (Z) FlowGraph(parsed_function(), graph_entry_, last_used_block_id_); |
4479 graph->set_await_token_positions(await_token_positions_); | 4479 graph->set_await_token_positions(await_token_positions_); |
4480 return graph; | 4480 return graph; |
4481 } | 4481 } |
4482 | 4482 |
4483 | 4483 |
4484 void FlowGraphBuilder::AppendAwaitTokenPosition(TokenPosition token_pos) { | 4484 void FlowGraphBuilder::AppendAwaitTokenPosition(TokenPosition token_pos) { |
4485 await_token_positions_->Add(token_pos); | 4485 await_token_positions_->Add(token_pos); |
4486 } | 4486 } |
4487 | 4487 |
4488 | 4488 |
4489 void FlowGraphBuilder::PruneUnreachable() { | |
4490 ASSERT(osr_id_ != Compiler::kNoOSRDeoptId); | |
4491 BitVector* block_marks = new (Z) BitVector(Z, last_used_block_id_ + 1); | |
4492 bool found = | |
4493 graph_entry_->PruneUnreachable(graph_entry_, NULL, osr_id_, block_marks); | |
4494 ASSERT(found); | |
4495 } | |
4496 | |
4497 | |
4498 void FlowGraphBuilder::Bailout(const char* reason) const { | 4489 void FlowGraphBuilder::Bailout(const char* reason) const { |
4499 parsed_function_.Bailout("FlowGraphBuilder", reason); | 4490 parsed_function_.Bailout("FlowGraphBuilder", reason); |
4500 } | 4491 } |
4501 | 4492 |
4502 | 4493 |
4503 bool FlowGraphBuilder::SimpleInstanceOfType(const AbstractType& type) { | 4494 bool FlowGraphBuilder::SimpleInstanceOfType(const AbstractType& type) { |
4504 // Bail if the type is still uninstantiated at compile time. | 4495 // Bail if the type is still uninstantiated at compile time. |
4505 if (!type.IsInstantiated()) return false; | 4496 if (!type.IsInstantiated()) return false; |
4506 | 4497 |
4507 // Bail if the type is a function or a Dart Function type. | 4498 // Bail if the type is a function or a Dart Function type. |
4508 if (type.IsFunctionType() || type.IsDartFunctionType()) return false; | 4499 if (type.IsFunctionType() || type.IsDartFunctionType()) return false; |
4509 | 4500 |
4510 ASSERT(type.HasResolvedTypeClass()); | 4501 ASSERT(type.HasResolvedTypeClass()); |
4511 const Class& type_class = Class::Handle(type.type_class()); | 4502 const Class& type_class = Class::Handle(type.type_class()); |
4512 // Bail if the type has any type parameters. | 4503 // Bail if the type has any type parameters. |
4513 if (type_class.IsGeneric()) return false; | 4504 if (type_class.IsGeneric()) return false; |
4514 | 4505 |
4515 // Finally a simple class for instance of checking. | 4506 // Finally a simple class for instance of checking. |
4516 return true; | 4507 return true; |
4517 } | 4508 } |
4518 | 4509 |
4519 } // namespace dart | 4510 } // namespace dart |
OLD | NEW |