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

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

Issue 10698153: Change comparison-to-branch fusion to actually remove comparison from the graph. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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_compiler.cc ('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 10
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 520
521 const intptr_t class_id = ReceiverClassId(comp); 521 const intptr_t class_id = ReceiverClassId(comp);
522 switch (class_id) { 522 switch (class_id) {
523 case kArray: 523 case kArray:
524 case kGrowableObjectArray: 524 case kGrowableObjectArray:
525 comp->set_receiver_type(static_cast<ObjectKind>(class_id)); 525 comp->set_receiver_type(static_cast<ObjectKind>(class_id));
526 } 526 }
527 } 527 }
528 528
529 529
530
531
530 static void TryFuseComparisonWithBranch(BindInstr* instr, 532 static void TryFuseComparisonWithBranch(BindInstr* instr,
531 ComparisonComp* comp) { 533 ComparisonComp* comp) {
532 Instruction* next_instr = instr->next(); 534 Instruction* next_instr = instr->next();
533 if ((next_instr != NULL) && next_instr->IsBranch()) { 535 if ((next_instr != NULL) && next_instr->IsBranch()) {
534 BranchInstr* branch = next_instr->AsBranch(); 536 BranchInstr* branch = next_instr->AsBranch();
535 UseVal* use = branch->value()->AsUse(); 537 UseVal* use = branch->value()->AsUse();
536 if (instr == use->definition()) { 538 if (instr == use->definition()) {
537 comp->MarkFusedWithBranch(branch); 539 comp->MarkFusedWithBranch(branch);
538 branch->MarkFusedWithComparison(); 540 branch->MarkFusedWithComparison(comp);
541
542 // Remove comparison from the graph.
543 branch->set_previous(instr->previous());
544 instr->previous()->set_next(branch);
srdjan 2012/07/11 16:19:38 How about factoring this out into a Remove method?
Vyacheslav Egorov (Google) 2012/07/11 17:30:26 It can't be factored into generic remove method be
539 return; 545 return;
540 } 546 }
541 } 547 }
542 if ((next_instr != NULL) && next_instr->IsBind()) { 548 if ((next_instr != NULL) && next_instr->IsBind()) {
543 Computation* next_comp = next_instr->AsBind()->computation(); 549 Computation* next_comp = next_instr->AsBind()->computation();
544 if (next_comp->IsBooleanNegate()) { 550 if (next_comp->IsBooleanNegate()) {
545 Instruction* next_next_instr = next_instr->next(); 551 Instruction* next_next_instr = next_instr->next();
546 if ((next_next_instr != NULL) && next_next_instr->IsBranch()) { 552 if ((next_next_instr != NULL) && next_next_instr->IsBranch()) {
547 BooleanNegateComp* negate = next_comp->AsBooleanNegate(); 553 BooleanNegateComp* negate = next_comp->AsBooleanNegate();
548 BranchInstr* branch = next_next_instr->AsBranch(); 554 BranchInstr* branch = next_next_instr->AsBranch();
549 if ((branch->value()->AsUse()->definition() == next_instr) && 555 if ((branch->value()->AsUse()->definition() == next_instr) &&
550 (negate->value()->AsUse()->definition() == instr)) { 556 (negate->value()->AsUse()->definition() == instr)) {
551 comp->MarkFusedWithBranch(branch); 557 comp->MarkFusedWithBranch(branch);
552 branch->MarkFusedWithComparison(); 558 branch->MarkFusedWithComparison(comp);
553 branch->set_is_negated(true); 559 branch->set_is_negated(true);
554 instr->set_next(next_next_instr); 560
561 // Remove comparison and boolean negation from the graph.
562 branch->set_previous(instr->previous());
563 instr->previous()->set_next(branch);
srdjan 2012/07/11 16:19:38 Ditto. Clear next/previous of branch and negate.
Vyacheslav Egorov (Google) 2012/07/11 17:30:26 Currently we fuse from inside visiting of comparis
555 return; 564 return;
556 } 565 }
557 } 566 }
558 } 567 }
559 } 568 }
560 } 569 }
561 570
562 571
563 void FlowGraphOptimizer::VisitRelationalOp(RelationalOpComp* comp, 572 void FlowGraphOptimizer::VisitRelationalOp(RelationalOpComp* comp,
564 BindInstr* instr) { 573 BindInstr* instr) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 LocationSummary* locs = it.Current()->locs(); 627 LocationSummary* locs = it.Current()->locs();
619 if ((locs != NULL) && locs->is_call()) { 628 if ((locs != NULL) && locs->is_call()) {
620 is_leaf_ = false; 629 is_leaf_ = false;
621 return; 630 return;
622 } 631 }
623 } 632 }
624 } 633 }
625 } 634 }
626 635
627 } // namespace dart 636 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler.cc ('k') | runtime/vm/il_printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698