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

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

Issue 27339003: When a value has been optimized away by the compiler, set its value to (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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.h ('k') | runtime/vm/symbols.h » ('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.h" 5 #include "vm/flow_graph.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/flow_graph_builder.h" 8 #include "vm/flow_graph_builder.h"
9 #include "vm/intermediate_language.h" 9 #include "vm/intermediate_language.h"
10 #include "vm/longjump.h" 10 #include "vm/longjump.h"
(...skipping 16 matching lines...) Expand all
27 builder_(builder), 27 builder_(builder),
28 parsed_function_(*builder.parsed_function()), 28 parsed_function_(*builder.parsed_function()),
29 num_copied_params_(builder.num_copied_params()), 29 num_copied_params_(builder.num_copied_params()),
30 num_non_copied_params_(builder.num_non_copied_params()), 30 num_non_copied_params_(builder.num_non_copied_params()),
31 num_stack_locals_(builder.num_stack_locals()), 31 num_stack_locals_(builder.num_stack_locals()),
32 graph_entry_(graph_entry), 32 graph_entry_(graph_entry),
33 preorder_(), 33 preorder_(),
34 postorder_(), 34 postorder_(),
35 reverse_postorder_(), 35 reverse_postorder_(),
36 optimized_block_order_(), 36 optimized_block_order_(),
37 constant_null_(NULL),
38 constant_dead_(NULL),
37 block_effects_(NULL), 39 block_effects_(NULL),
38 licm_allowed_(true), 40 licm_allowed_(true),
39 use_far_branches_(false), 41 use_far_branches_(false),
40 loop_headers_(NULL), 42 loop_headers_(NULL),
41 loop_invariant_loads_(NULL), 43 loop_invariant_loads_(NULL),
42 guarded_fields_(builder.guarded_fields()) { 44 guarded_fields_(builder.guarded_fields()) {
43 DiscoverBlocks(); 45 DiscoverBlocks();
44 } 46 }
45 47
46 48
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 GraphEntryInstr* entry = graph_entry(); 701 GraphEntryInstr* entry = graph_entry();
700 if (!FLAG_optimize_try_catch && (entry->SuccessorCount() > 1)) { 702 if (!FLAG_optimize_try_catch && (entry->SuccessorCount() > 1)) {
701 Bailout("Catch-entry support in SSA."); 703 Bailout("Catch-entry support in SSA.");
702 } 704 }
703 705
704 // Initial renaming environment. 706 // Initial renaming environment.
705 GrowableArray<Definition*> env(variable_count()); 707 GrowableArray<Definition*> env(variable_count());
706 708
707 // Add global constants to the initial definitions. 709 // Add global constants to the initial definitions.
708 constant_null_ = GetConstant(Object::ZoneHandle()); 710 constant_null_ = GetConstant(Object::ZoneHandle());
711 constant_dead_ = GetConstant(Symbols::OptimizedOut());
709 712
710 // Add parameters to the initial definitions and renaming environment. 713 // Add parameters to the initial definitions and renaming environment.
711 if (inlining_parameters != NULL) { 714 if (inlining_parameters != NULL) {
712 // Use known parameters. 715 // Use known parameters.
713 ASSERT(parameter_count() == inlining_parameters->length()); 716 ASSERT(parameter_count() == inlining_parameters->length());
714 for (intptr_t i = 0; i < parameter_count(); ++i) { 717 for (intptr_t i = 0; i < parameter_count(); ++i) {
715 Definition* defn = (*inlining_parameters)[i]; 718 Definition* defn = (*inlining_parameters)[i];
716 defn->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp. 719 defn->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp.
717 AddToInitialDefinitions(defn); 720 AddToInitialDefinitions(defn);
718 env.Add(defn); 721 env.Add(defn);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 (*env)[i] = param; 800 (*env)[i] = param;
798 block_entry->AsCatchBlockEntry()->initial_definitions()->Add(param); 801 block_entry->AsCatchBlockEntry()->initial_definitions()->Add(param);
799 } 802 }
800 } 803 }
801 804
802 // Prune non-live variables at block entry by replacing their environment 805 // Prune non-live variables at block entry by replacing their environment
803 // slots with null. 806 // slots with null.
804 BitVector* live_in = variable_liveness->GetLiveInSet(block_entry); 807 BitVector* live_in = variable_liveness->GetLiveInSet(block_entry);
805 for (intptr_t i = 0; i < variable_count(); i++) { 808 for (intptr_t i = 0; i < variable_count(); i++) {
806 if (!live_in->Contains(i)) { 809 if (!live_in->Contains(i)) {
807 (*env)[i] = constant_null(); 810 (*env)[i] = constant_dead();
808 } 811 }
809 } 812 }
810 813
811 // Attach environment to the block entry. 814 // Attach environment to the block entry.
812 AttachEnvironment(block_entry, env); 815 AttachEnvironment(block_entry, env);
813 816
814 // 2. Process normal instructions. 817 // 2. Process normal instructions.
815 for (ForwardInstructionIterator it(block_entry); !it.Done(); it.Advance()) { 818 for (ForwardInstructionIterator it(block_entry); !it.Done(); it.Advance()) {
816 Instruction* current = it.Current(); 819 Instruction* current = it.Current();
817 820
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 intptr_t index; 871 intptr_t index;
869 Definition* result; 872 Definition* result;
870 if (store != NULL) { 873 if (store != NULL) {
871 // Update renaming environment. 874 // Update renaming environment.
872 index = store->local().BitIndexIn(num_non_copied_params_); 875 index = store->local().BitIndexIn(num_non_copied_params_);
873 result = store->value()->definition(); 876 result = store->value()->definition();
874 877
875 if (variable_liveness->IsStoreAlive(block_entry, store)) { 878 if (variable_liveness->IsStoreAlive(block_entry, store)) {
876 (*env)[index] = result; 879 (*env)[index] = result;
877 } else { 880 } else {
878 (*env)[index] = constant_null(); 881 (*env)[index] = constant_dead();
879 } 882 }
880 } else if (load != NULL) { 883 } else if (load != NULL) {
881 // The graph construction ensures we do not have an unused LoadLocal 884 // The graph construction ensures we do not have an unused LoadLocal
882 // computation. 885 // computation.
883 ASSERT(definition->is_used()); 886 ASSERT(definition->is_used());
884 index = load->local().BitIndexIn(num_non_copied_params_); 887 index = load->local().BitIndexIn(num_non_copied_params_);
885 result = (*env)[index]; 888 result = (*env)[index];
886 889
887 PhiInstr* phi = result->AsPhi(); 890 PhiInstr* phi = result->AsPhi();
888 if ((phi != NULL) && !phi->is_alive()) { 891 if ((phi != NULL) && !phi->is_alive()) {
889 phi->mark_alive(); 892 phi->mark_alive();
890 live_phis->Add(phi); 893 live_phis->Add(phi);
891 } 894 }
892 895
893 if (variable_liveness->IsLastLoad(block_entry, load)) { 896 if (variable_liveness->IsLastLoad(block_entry, load)) {
894 (*env)[index] = constant_null(); 897 (*env)[index] = constant_dead();
895 } 898 }
896 } else if (push != NULL) { 899 } else if (push != NULL) {
897 result = push->value()->definition(); 900 result = push->value()->definition();
898 env->Add(result); 901 env->Add(result);
899 it.RemoveCurrentFromGraph(); 902 it.RemoveCurrentFromGraph();
900 continue; 903 continue;
901 } else if (drop != NULL) { 904 } else if (drop != NULL) {
902 // Drop temps from the environment. 905 // Drop temps from the environment.
903 for (intptr_t j = 0; j < drop->num_temps(); j++) { 906 for (intptr_t j = 0; j < drop->num_temps(); j++) {
904 env->RemoveLast(); 907 env->RemoveLast();
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 } 1195 }
1193 1196
1194 1197
1195 bool BlockEffects::IsSideEffectFreePath(BlockEntryInstr* from, 1198 bool BlockEffects::IsSideEffectFreePath(BlockEntryInstr* from,
1196 BlockEntryInstr* to) const { 1199 BlockEntryInstr* to) const {
1197 return available_at_[to->postorder_number()]->Contains( 1200 return available_at_[to->postorder_number()]->Contains(
1198 from->postorder_number()); 1201 from->postorder_number());
1199 } 1202 }
1200 1203
1201 } // namespace dart 1204 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph.h ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698