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

Side by Side Diff: lib/compiler/implementation/ssa/variable_allocator.dart

Issue 10566021: Reapply change to GVN all HFieldGet instructions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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 | « lib/compiler/implementation/ssa/value_set.dart ('k') | tests/language/gvn_test.dart » ('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 /** 5 /**
6 * The [LiveRange] class covers a range where an instruction is live. 6 * The [LiveRange] class covers a range where an instruction is live.
7 */ 7 */
8 class LiveRange { 8 class LiveRange {
9 final int start; 9 final int start;
10 // [end] is not final because it can be updated due to loops. 10 // [end] is not final because it can be updated due to loops.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 * updates the live interval of [instruction] to contain the new 111 * updates the live interval of [instruction] to contain the new
112 * range: [id, / id contained in [liveInstructions] /]. 112 * range: [id, / id contained in [liveInstructions] /].
113 */ 113 */
114 void remove(HInstruction instruction, int id) { 114 void remove(HInstruction instruction, int id) {
115 // Special case the HCheck instruction to have the same live 115 // Special case the HCheck instruction to have the same live
116 // interval as the instruction it is checking. 116 // interval as the instruction it is checking.
117 if (instruction is HCheck) { 117 if (instruction is HCheck) {
118 var input = instruction.checkedInput; 118 var input = instruction.checkedInput;
119 while (input is HCheck) input = input.checkedInput; 119 while (input is HCheck) input = input.checkedInput;
120 liveIntervals.putIfAbsent(input, () => new LiveInterval()); 120 liveIntervals.putIfAbsent(input, () => new LiveInterval());
121 liveIntervals.putIfAbsent(instruction, () => liveIntervals[input]); 121 // Unconditionally force the live interval of the HCheck to
122 // be the live interval of the instruction it is checking.
123 liveIntervals[instruction] = liveIntervals[input];
122 } else { 124 } else {
123 LiveInterval range = liveIntervals.putIfAbsent( 125 LiveInterval range = liveIntervals.putIfAbsent(
124 instruction, () => new LiveInterval()); 126 instruction, () => new LiveInterval());
125 int lastId = liveInstructions[instruction]; 127 int lastId = liveInstructions[instruction];
126 // If [lastId] is null, then this instruction is not being used. 128 // If [lastId] is null, then this instruction is not being used.
127 range.add(new LiveRange(id, lastId == null ? id : lastId)); 129 range.add(new LiveRange(id, lastId == null ? id : lastId));
128 // The instruction is defined at [id]. 130 // The instruction is defined at [id].
129 range.start = id; 131 range.start = id;
130 } 132 }
131 liveInstructions.remove(instruction); 133 liveInstructions.remove(instruction);
132 } 134 }
133 135
134 /** 136 /**
135 * Add [instruction] to the liveIn set. If the instruction is not 137 * Add [instruction] to the liveIn set. If the instruction is not
136 * already in the set, we save the id where it dies. 138 * already in the set, we save the id where it dies.
137 */ 139 */
138 void add(HInstruction instruction, int userId) { 140 void add(HInstruction instruction, int userId) {
139 // Note that we are visiting the grap in post-dominator order, so 141 // Note that we are visiting the grap in post-dominator order, so
140 // the first time we see a variable is when it dies. 142 // the first time we see a variable is when it dies.
141 liveInstructions.putIfAbsent(instruction, () => userId); 143 liveInstructions.putIfAbsent(instruction, () => userId);
142 if (instruction is HCheck) { 144 if (instruction is HCheck) {
143 // Special case the HCheck instruction to mark the actual 145 // Special case the HCheck instruction to mark the actual
144 // checked instruction live. 146 // checked instruction live.
145 liveInstructions.putIfAbsent(instruction, () => userId);
146 var input = instruction.checkedInput; 147 var input = instruction.checkedInput;
147 while (input is HCheck) input = input.checkedInput; 148 while (input is HCheck) input = input.checkedInput;
148 liveInstructions.putIfAbsent(input, () => userId); 149 liveInstructions.putIfAbsent(input, () => userId);
149 } 150 }
150 } 151 }
151 152
152 /** 153 /**
153 * Merge this environment with [other]. Update the end id of 154 * Merge this environment with [other]. Update the end id of
154 * instructions in case they are different between this and [other]. 155 * instructions in case they are different between this and [other].
155 */ 156 */
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 if (generateAtUseSite.contains(instruction)) return false; 570 if (generateAtUseSite.contains(instruction)) return false;
570 // A [HCheck] instruction that has control flow needs a name only if its 571 // A [HCheck] instruction that has control flow needs a name only if its
571 // checked input needs a name (e.g. a check [HConstant] does not 572 // checked input needs a name (e.g. a check [HConstant] does not
572 // need a name). 573 // need a name).
573 if (instruction is HCheck && instruction.isControlFlow()) { 574 if (instruction is HCheck && instruction.isControlFlow()) {
574 HCheck check = instruction; 575 HCheck check = instruction;
575 return needsName(instruction.checkedInput); 576 return needsName(instruction.checkedInput);
576 } 577 }
577 return true; 578 return true;
578 } 579 }
579 580
580 /** 581 /**
581 * Returns whether [instruction] dies at the instruction [at]. 582 * Returns whether [instruction] dies at the instruction [at].
582 */ 583 */
583 bool diesAt(HInstruction instruction, HInstruction at) { 584 bool diesAt(HInstruction instruction, HInstruction at) {
584 LiveInterval atInterval = liveIntervals[at]; 585 LiveInterval atInterval = liveIntervals[at];
585 LiveInterval instructionInterval = liveIntervals[instruction]; 586 LiveInterval instructionInterval = liveIntervals[instruction];
586 int start = atInterval.start; 587 int start = atInterval.start;
587 return instructionInterval.diesAt(start); 588 return instructionInterval.diesAt(start);
588 } 589 }
589 590
(...skipping 21 matching lines...) Expand all
611 if (!needsName(input)) { 612 if (!needsName(input)) {
612 names.addAssignment(predecessor, input, phi); 613 names.addAssignment(predecessor, input, phi);
613 } else { 614 } else {
614 names.addCopy(predecessor, input, phi); 615 names.addCopy(predecessor, input, phi);
615 } 616 }
616 } 617 }
617 618
618 namer.allocateName(phi); 619 namer.allocateName(phi);
619 } 620 }
620 } 621 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/ssa/value_set.dart ('k') | tests/language/gvn_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698