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

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

Issue 10855101: RemoveFromGraph on definitions asserts empty use lists. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Corrected invariants of def-use chains. 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_allocator.cc ('k') | runtime/vm/flow_graph_optimizer.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_builder.h" 5 #include "vm/flow_graph_builder.h"
6 6
7 #include "vm/ast_printer.h" 7 #include "vm/ast_printer.h"
8 #include "vm/bit_vector.h" 8 #include "vm/bit_vector.h"
9 #include "vm/code_descriptors.h" 9 #include "vm/code_descriptors.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 2692 matching lines...) Expand 10 before | Expand all | Expand 10 after
2703 ASSERT(env->length() > variable_count()); 2703 ASSERT(env->length() > variable_count());
2704 2704
2705 Value* input_value = env->Last(); 2705 Value* input_value = env->Last();
2706 ASSERT(input_value->IsUse()); 2706 ASSERT(input_value->IsUse());
2707 env->RemoveLast(); 2707 env->RemoveLast();
2708 2708
2709 BindInstr* as_bind = v->AsUse()->definition()->AsBind(); 2709 BindInstr* as_bind = v->AsUse()->definition()->AsBind();
2710 if ((as_bind != NULL) && 2710 if ((as_bind != NULL) &&
2711 (as_bind->computation()->IsLoadLocal() || 2711 (as_bind->computation()->IsLoadLocal() ||
2712 as_bind->computation()->IsStoreLocal())) { 2712 as_bind->computation()->IsStoreLocal())) {
2713 // Assert exactly one use.
2714 ASSERT(as_bind->use_list() == v);
2715 ASSERT(as_bind->use_list()->next_use() == NULL);
2716 // Remove the use, its defintion and copy the environment value.
2717 v->RemoveFromUseList();
2718 as_bind->RemoveFromGraph();
2713 current->SetInputAt(i, CopyValue(input_value)); 2719 current->SetInputAt(i, CopyValue(input_value));
2714 } 2720 }
2715 } 2721 }
2716 2722
2717 // Drop pushed arguments for calls. 2723 // Drop pushed arguments for calls.
2718 for (intptr_t j = 0; j < current->ArgumentCount(); j++) { 2724 for (intptr_t j = 0; j < current->ArgumentCount(); j++) {
2719 env->RemoveLast(); 2725 env->RemoveLast();
2720 } 2726 }
2721 2727
2722 // 2b. Handle LoadLocal and StoreLocal. 2728 // 2b. Handle LoadLocal and StoreLocal.
(...skipping 17 matching lines...) Expand all
2740 2746
2741 Value* value = (*env)[index]; 2747 Value* value = (*env)[index];
2742 if (value->IsUse()) { 2748 if (value->IsUse()) {
2743 PhiInstr* phi = value->AsUse()->definition()->AsPhi(); 2749 PhiInstr* phi = value->AsUse()->definition()->AsPhi();
2744 if ((phi != NULL) && !phi->is_alive()) { 2750 if ((phi != NULL) && !phi->is_alive()) {
2745 phi->mark_alive(); 2751 phi->mark_alive();
2746 live_phis->Add(phi); 2752 live_phis->Add(phi);
2747 } 2753 }
2748 } 2754 }
2749 } 2755 }
2750 // Update expression stack and remove from graph. 2756 // Update expression stack or remove from graph.
2751 if (bind->is_used()) { 2757 if (bind->is_used()) {
2758 // Assert exactly one use.
2759 ASSERT(bind->use_list() != NULL);
2760 ASSERT(bind->use_list()->next_use() == NULL);
2752 env->Add(CopyValue((*env)[index])); 2761 env->Add(CopyValue((*env)[index]));
2762 // We remove load/store instructions when we find their use in 2a.
2763 } else {
2764 it.RemoveCurrentFromGraph();
2753 } 2765 }
2754 it.RemoveCurrentFromGraph();
2755 } else { 2766 } else {
2756 // Not a load or store. 2767 // Not a load or store.
2757 if (bind->is_used()) { 2768 if (bind->is_used()) {
2758 // Assign fresh SSA temporary and update expression stack. 2769 // Assign fresh SSA temporary and update expression stack.
2759 bind->set_ssa_temp_index(alloc_ssa_temp_index()); 2770 bind->set_ssa_temp_index(alloc_ssa_temp_index());
2760 env->Add(new UseVal(bind)); 2771 env->Add(new UseVal(bind));
2761 } 2772 }
2762 } 2773 }
2763 } 2774 }
2764 2775
(...skipping 18 matching lines...) Expand all
2783 block_entry->last_instruction()->SuccessorAt(0)->IsJoinEntry()) { 2794 block_entry->last_instruction()->SuccessorAt(0)->IsJoinEntry()) {
2784 JoinEntryInstr* successor = 2795 JoinEntryInstr* successor =
2785 block_entry->last_instruction()->SuccessorAt(0)->AsJoinEntry(); 2796 block_entry->last_instruction()->SuccessorAt(0)->AsJoinEntry();
2786 intptr_t pred_index = successor->IndexOfPredecessor(block_entry); 2797 intptr_t pred_index = successor->IndexOfPredecessor(block_entry);
2787 ASSERT(pred_index >= 0); 2798 ASSERT(pred_index >= 0);
2788 if (successor->phis() != NULL) { 2799 if (successor->phis() != NULL) {
2789 for (intptr_t i = 0; i < successor->phis()->length(); ++i) { 2800 for (intptr_t i = 0; i < successor->phis()->length(); ++i) {
2790 PhiInstr* phi = (*successor->phis())[i]; 2801 PhiInstr* phi = (*successor->phis())[i];
2791 if (phi != NULL) { 2802 if (phi != NULL) {
2792 // Rename input operand and make a copy if it is a UseVal. 2803 // Rename input operand and make a copy if it is a UseVal.
2793 Value* new_val = (*env)[i]->IsUse() 2804 phi->SetInputAt(pred_index, CopyValue((*env)[i]));
2794 ? new UseVal((*env)[i]->AsUse()->definition())
2795 : (*env)[i];
2796 phi->SetInputAt(pred_index, new_val);
2797 } 2805 }
2798 } 2806 }
2799 } 2807 }
2800 } 2808 }
2801 } 2809 }
2802 2810
2803 2811
2804 void FlowGraphBuilder::MarkLivePhis(GrowableArray<PhiInstr*>* live_phis) { 2812 void FlowGraphBuilder::MarkLivePhis(GrowableArray<PhiInstr*>* live_phis) {
2805 while (!live_phis->is_empty()) { 2813 while (!live_phis->is_empty()) {
2806 PhiInstr* phi = live_phis->Last(); 2814 PhiInstr* phi = live_phis->Last();
(...skipping 16 matching lines...) Expand all
2823 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; 2831 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1;
2824 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 2832 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
2825 OS::SNPrint(chars, len, kFormat, function_name, reason); 2833 OS::SNPrint(chars, len, kFormat, function_name, reason);
2826 const Error& error = Error::Handle( 2834 const Error& error = Error::Handle(
2827 LanguageError::New(String::Handle(String::New(chars)))); 2835 LanguageError::New(String::Handle(String::New(chars))));
2828 Isolate::Current()->long_jump_base()->Jump(1, error); 2836 Isolate::Current()->long_jump_base()->Jump(1, error);
2829 } 2837 }
2830 2838
2831 2839
2832 } // namespace dart 2840 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_allocator.cc ('k') | runtime/vm/flow_graph_optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698