| 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_optimizer.h" | 5 #include "vm/flow_graph_optimizer.h" |
| 6 | 6 |
| 7 #include "vm/flow_graph_builder.h" | 7 #include "vm/flow_graph_builder.h" |
| 8 #include "vm/il_printer.h" | 8 #include "vm/il_printer.h" |
| 9 #include "vm/object_store.h" | 9 #include "vm/object_store.h" |
| 10 #include "vm/parser.h" | 10 #include "vm/parser.h" |
| 11 #include "vm/scopes.h" | 11 #include "vm/scopes.h" |
| 12 #include "vm/symbols.h" |
| 12 | 13 |
| 13 namespace dart { | 14 namespace dart { |
| 14 | 15 |
| 15 DECLARE_FLAG(bool, eliminate_type_checks); | 16 DECLARE_FLAG(bool, eliminate_type_checks); |
| 16 DECLARE_FLAG(bool, enable_type_checks); | 17 DECLARE_FLAG(bool, enable_type_checks); |
| 17 DEFINE_FLAG(bool, trace_optimization, false, "Print optimization details."); | 18 DEFINE_FLAG(bool, trace_optimization, false, "Print optimization details."); |
| 18 DECLARE_FLAG(bool, trace_type_check_elimination); | 19 DECLARE_FLAG(bool, trace_type_check_elimination); |
| 19 | 20 |
| 20 void FlowGraphOptimizer::ApplyICData() { | 21 void FlowGraphOptimizer::ApplyICData() { |
| 21 VisitBlocks(); | 22 VisitBlocks(); |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 comp->token_pos(), | 585 comp->token_pos(), |
| 585 comp->value(), | 586 comp->value(), |
| 586 comp->dst_type(), | 587 comp->dst_type(), |
| 587 comp->dst_name(), | 588 comp->dst_name(), |
| 588 comp->IsEliminated()); | 589 comp->IsEliminated()); |
| 589 } | 590 } |
| 590 } | 591 } |
| 591 } | 592 } |
| 592 | 593 |
| 593 | 594 |
| 595 void FlowGraphTypePropagator::VisitAssertBoolean(AssertBooleanComp* comp, |
| 596 BindInstr* instr) { |
| 597 if (FLAG_eliminate_type_checks && |
| 598 !comp->IsEliminated() && |
| 599 comp->value()->CompileTypeIsMoreSpecificThan( |
| 600 Type::Handle(Type::BoolInterface()))) { |
| 601 comp->Eliminate(); |
| 602 if (FLAG_trace_type_check_elimination) { |
| 603 const String& name = String::Handle(Symbols::New("boolean expression")); |
| 604 FlowGraphPrinter::PrintTypeCheck(parsed_function(), |
| 605 comp->token_pos(), |
| 606 comp->value(), |
| 607 Type::Handle(Type::BoolInterface()), |
| 608 name, |
| 609 comp->IsEliminated()); |
| 610 } |
| 611 } |
| 612 } |
| 613 |
| 614 |
| 594 void FlowGraphTypePropagator::VisitGraphEntry(GraphEntryInstr* graph_entry) { | 615 void FlowGraphTypePropagator::VisitGraphEntry(GraphEntryInstr* graph_entry) { |
| 595 if (graph_entry->start_env() == NULL) { | 616 if (graph_entry->start_env() == NULL) { |
| 596 return; | 617 return; |
| 597 } | 618 } |
| 598 // Visit incoming parameters. | 619 // Visit incoming parameters. |
| 599 for (intptr_t i = 0; i < graph_entry->start_env()->values().length(); i++) { | 620 for (intptr_t i = 0; i < graph_entry->start_env()->values().length(); i++) { |
| 600 Value* val = graph_entry->start_env()->values()[i]; | 621 Value* val = graph_entry->start_env()->values()[i]; |
| 601 if (val->IsUse()) { | 622 if (val->IsUse()) { |
| 602 ParameterInstr* param = val->AsUse()->definition()->AsParameter(); | 623 ParameterInstr* param = val->AsUse()->definition()->AsParameter(); |
| 603 if (param != NULL) { | 624 if (param != NULL) { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 LocationSummary* locs = it.Current()->locs(); | 711 LocationSummary* locs = it.Current()->locs(); |
| 691 if ((locs != NULL) && locs->is_call()) { | 712 if ((locs != NULL) && locs->is_call()) { |
| 692 is_leaf_ = false; | 713 is_leaf_ = false; |
| 693 return; | 714 return; |
| 694 } | 715 } |
| 695 } | 716 } |
| 696 } | 717 } |
| 697 } | 718 } |
| 698 | 719 |
| 699 } // namespace dart | 720 } // namespace dart |
| OLD | NEW |