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

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

Issue 12079096: Make use lists into doubly-linked lists. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/intermediate_language.h" 5 #include "vm/intermediate_language.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/dart_entry.h" 8 #include "vm/dart_entry.h"
9 #include "vm/flow_graph_allocator.h" 9 #include "vm/flow_graph_allocator.h"
10 #include "vm/flow_graph_builder.h" 10 #include "vm/flow_graph_builder.h"
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 } 620 }
621 621
622 622
623 void Instruction::RecordAssignedVars(BitVector* assigned_vars, 623 void Instruction::RecordAssignedVars(BitVector* assigned_vars,
624 intptr_t fixed_parameter_count) { 624 intptr_t fixed_parameter_count) {
625 // Nothing to do for the base class. 625 // Nothing to do for the base class.
626 } 626 }
627 627
628 628
629 void Value::AddToInputUseList() { 629 void Value::AddToInputUseList() {
630 set_next_use(definition()->input_use_list()); 630 Value* next = definition()->input_use_list();
631 definition()->set_input_use_list(this); 631 definition()->set_input_use_list(this);
632 set_next_use(next);
633 set_previous_use(NULL);
634 if (next != NULL) next->set_previous_use(this);
632 } 635 }
633 636
634 637
635 void Value::AddToEnvUseList() { 638 void Value::AddToEnvUseList() {
636 set_next_use(definition()->env_use_list()); 639 Value* next = definition()->env_use_list();
637 definition()->set_env_use_list(this); 640 definition()->set_env_use_list(this);
641 set_next_use(next);
642 set_previous_use(NULL);
643 if (next != NULL) next->set_previous_use(this);
638 } 644 }
639 645
640 646
641 void Value::RemoveFromInputUseList() { 647 void Value::RemoveFromInputUseList() {
642 if (definition_->input_use_list() == this) { 648 Value* previous = previous_use();
643 definition_->set_input_use_list(next_use_); 649 Value* next = next_use();
644 return; 650 if (previous == NULL) {
651 definition()->set_input_use_list(next);
652 } else {
653 previous->set_next_use(next);
645 } 654 }
646 655 if (next != NULL) next->set_previous_use(previous);
647 Value* prev = definition_->input_use_list(); 656 set_definition(NULL);
648 while (prev->next_use_ != this) {
649 prev = prev->next_use_;
650 }
651 prev->next_use_ = next_use_;
652 definition_ = NULL;
653 } 657 }
654 658
655 659
656 void Definition::ReplaceUsesWith(Definition* other) { 660 void Definition::ReplaceUsesWith(Definition* other) {
657 ASSERT(other != NULL); 661 ASSERT(other != NULL);
658 ASSERT(this != other); 662 ASSERT(this != other);
659 while (input_use_list_ != NULL) { 663 Value* next = input_use_list();
660 Value* current = input_use_list_; 664 while (next != NULL) {
661 input_use_list_ = input_use_list_->next_use(); 665 Value* current = next;
666 next = current->next_use();
662 current->set_definition(other); 667 current->set_definition(other);
663 current->AddToInputUseList(); 668 current->AddToInputUseList();
Vyacheslav Egorov (Google) 2013/01/31 13:42:19 I don't really understand why we adding them one b
Kevin Millikin (Google) 2013/01/31 13:46:47 There's no good reason. I'll change it.
664 } 669 }
665 while (env_use_list_ != NULL) { 670
666 Value* current = env_use_list_; 671 next = env_use_list();
667 env_use_list_ = env_use_list_->next_use(); 672 while (next != NULL) {
673 Value* current = next;
674 next = current->next_use();
668 current->set_definition(other); 675 current->set_definition(other);
669 current->AddToEnvUseList(); 676 current->AddToEnvUseList();
670 } 677 }
678
679 set_input_use_list(NULL);
680 set_env_use_list(NULL);
671 } 681 }
672 682
673 683
674 void Definition::ReplaceWith(Definition* other, 684 void Definition::ReplaceWith(Definition* other,
675 ForwardInstructionIterator* iterator) { 685 ForwardInstructionIterator* iterator) {
676 if ((iterator != NULL) && (this == iterator->Current())) { 686 if ((iterator != NULL) && (this == iterator->Current())) {
677 iterator->ReplaceCurrentWith(other); 687 iterator->ReplaceCurrentWith(other);
678 } else { 688 } else {
679 ReplaceUsesWith(other); 689 ReplaceUsesWith(other);
680 ASSERT(other->env() == NULL); 690 ASSERT(other->env() == NULL);
(...skipping 2078 matching lines...) Expand 10 before | Expand all | Expand 10 after
2759 default: 2769 default:
2760 UNREACHABLE(); 2770 UNREACHABLE();
2761 } 2771 }
2762 return kPowRuntimeEntry; 2772 return kPowRuntimeEntry;
2763 } 2773 }
2764 2774
2765 2775
2766 #undef __ 2776 #undef __
2767 2777
2768 } // namespace dart 2778 } // namespace dart
OLDNEW
« runtime/vm/flow_graph_optimizer.cc ('K') | « runtime/vm/intermediate_language.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698