Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: runtime/vm/flow_graph_optimizer.cc

Issue 10832277: Eliminate condition type check when possible. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/flow_graph_optimizer.h ('k') | runtime/vm/il_printer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 569
569 570
570 void FlowGraphOptimizer::VisitBind(BindInstr* instr) { 571 void FlowGraphOptimizer::VisitBind(BindInstr* instr) {
571 instr->computation()->Accept(this, instr); 572 instr->computation()->Accept(this, instr);
572 } 573 }
573 574
574 575
575 void FlowGraphTypePropagator::VisitAssertAssignable(AssertAssignableComp* comp, 576 void FlowGraphTypePropagator::VisitAssertAssignable(AssertAssignableComp* comp,
576 BindInstr* instr) { 577 BindInstr* instr) {
577 if (FLAG_eliminate_type_checks && 578 if (FLAG_eliminate_type_checks &&
578 !comp->IsEliminated() && 579 !comp->is_eliminated() &&
579 !comp->dst_type().IsMalformed() && 580 !comp->dst_type().IsMalformed() &&
580 comp->value()->CompileTypeIsMoreSpecificThan(comp->dst_type())) { 581 comp->value()->CompileTypeIsMoreSpecificThan(comp->dst_type())) {
581 comp->Eliminate(); 582 comp->eliminate();
582 if (FLAG_trace_type_check_elimination) { 583 if (FLAG_trace_type_check_elimination) {
583 FlowGraphPrinter::PrintTypeCheck(parsed_function(), 584 FlowGraphPrinter::PrintTypeCheck(parsed_function(),
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->is_eliminated());
590 }
591 }
592 }
593
594
595 void FlowGraphTypePropagator::VisitAssertBoolean(AssertBooleanComp* comp,
596 BindInstr* instr) {
597 if (FLAG_eliminate_type_checks &&
598 !comp->is_eliminated() &&
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->is_eliminated());
589 } 610 }
590 } 611 }
591 } 612 }
592 613
593 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.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_optimizer.h ('k') | runtime/vm/il_printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698