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

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

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

Powered by Google App Engine
This is Rietveld 408576698