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

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

Issue 18558008: Prune variables that are not live at block entry from the environment. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | « no previous file | no next file » | 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 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 } else if (block_entry->IsCatchBlockEntry()) { 743 } else if (block_entry->IsCatchBlockEntry()) {
744 // Add real definitions for all locals and parameters. 744 // Add real definitions for all locals and parameters.
745 for (intptr_t i = 0; i < env->length(); ++i) { 745 for (intptr_t i = 0; i < env->length(); ++i) {
746 ParameterInstr* param = new ParameterInstr(i, block_entry); 746 ParameterInstr* param = new ParameterInstr(i, block_entry);
747 param->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp. 747 param->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp.
748 (*env)[i] = param; 748 (*env)[i] = param;
749 block_entry->AsCatchBlockEntry()->initial_definitions()->Add(param); 749 block_entry->AsCatchBlockEntry()->initial_definitions()->Add(param);
750 } 750 }
751 } 751 }
752 752
753 // Prune non-live variables at block entry by replacing their environment
754 // slots with null.
755 BitVector* live_in = variable_liveness->GetLiveInSet(block_entry);
756 for (intptr_t i = 0; i < variable_count(); i++) {
757 if (!live_in->Contains(i)) {
758 (*env)[i] = constant_null();
759 }
760 }
761
753 // Attach environment to the block entry. 762 // Attach environment to the block entry.
754 AttachEnvironment(block_entry, env); 763 AttachEnvironment(block_entry, env);
755 764
756 // 2. Process normal instructions. 765 // 2. Process normal instructions.
757 for (ForwardInstructionIterator it(block_entry); !it.Done(); it.Advance()) { 766 for (ForwardInstructionIterator it(block_entry); !it.Done(); it.Advance()) {
758 Instruction* current = it.Current(); 767 Instruction* current = it.Current();
759 768
760 // Attach current environment to the instructions that need it. 769 // Attach current environment to the instructions that need it.
761 if (current->NeedsEnvironment()) { 770 if (current->NeedsEnvironment()) {
762 AttachEnvironment(current, env); 771 AttachEnvironment(current, env);
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 } 1143 }
1135 1144
1136 1145
1137 bool BlockEffects::IsSideEffectFreePath(BlockEntryInstr* from, 1146 bool BlockEffects::IsSideEffectFreePath(BlockEntryInstr* from,
1138 BlockEntryInstr* to) const { 1147 BlockEntryInstr* to) const {
1139 return available_at_[to->postorder_number()]->Contains( 1148 return available_at_[to->postorder_number()]->Contains(
1140 from->postorder_number()); 1149 from->postorder_number());
1141 } 1150 }
1142 1151
1143 } // namespace dart 1152 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698