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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/codegen_helpers.dart

Issue 14602011: Fix issue 10321 by invalidating previous "generate at use site" optimizations based on a pure instr… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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 | tests/language/issue10321_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 part of ssa; 5 part of ssa;
6 6
7 /** 7 /**
8 * Instead of emitting each SSA instruction with a temporary variable 8 * Instead of emitting each SSA instruction with a temporary variable
9 * mark instructions that can be emitted at their use-site. 9 * mark instructions that can be emitted at their use-site.
10 * For example, in: 10 * For example, in:
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 && !input.isJsStatement()) { 51 && !input.isJsStatement()) {
52 if (input.isPure()) { 52 if (input.isPure()) {
53 // Only consider a pure input if it is in the same loop. 53 // Only consider a pure input if it is in the same loop.
54 // Otherwise, we might move GVN'ed instruction back into the 54 // Otherwise, we might move GVN'ed instruction back into the
55 // loop. 55 // loop.
56 if (user.hasSameLoopHeaderAs(input)) { 56 if (user.hasSameLoopHeaderAs(input)) {
57 // Move it closer to [user], so that instructions in 57 // Move it closer to [user], so that instructions in
58 // between do not prevent making it generate at use site. 58 // between do not prevent making it generate at use site.
59 input.moveBefore(user); 59 input.moveBefore(user);
60 pureInputs.add(input); 60 pureInputs.add(input);
61 // Previous computations done on [input] are now invalid
62 // because we moved [input] to another place. So all
63 // non-nure, non-code motion invariant, instructions need
ahe 2013/04/30 20:06:25 nure -> pure
64 // to be removed from the [generateAtUseSite] set.
65 input.inputs.forEach((instruction) {
66 if (!instruction.isCodeMotionInvariant()
67 && !instruction.isPure()) {
68 generateAtUseSite.remove(instruction);
69 }
70 });
61 // Visit the pure input now so that the expected inputs 71 // Visit the pure input now so that the expected inputs
62 // are after the expected inputs of [user]. 72 // are after the expected inputs of [user].
63 input.accept(this); 73 input.accept(this);
64 } 74 }
65 } else { 75 } else {
66 expectedInputs.add(input); 76 expectedInputs.add(input);
67 } 77 }
68 } 78 }
69 } 79 }
70 } 80 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 assert(!generateAtUseSite.contains(nextInput)); 163 assert(!generateAtUseSite.contains(nextInput));
154 assert(nextInput.usedBy.length == 1); 164 assert(nextInput.usedBy.length == 1);
155 if (identical(nextInput, instruction)) { 165 if (identical(nextInput, instruction)) {
156 return true; 166 return true;
157 } 167 }
158 } 168 }
159 return false; 169 return false;
160 } 170 }
161 171
162 block.last.accept(this); 172 block.last.accept(this);
163 bool dontVisitPure = false;
164 for (HInstruction instruction = block.last.previous; 173 for (HInstruction instruction = block.last.previous;
165 instruction != null; 174 instruction != null;
166 instruction = instruction.previous) { 175 instruction = instruction.previous) {
167 if (generateAtUseSite.contains(instruction)) { 176 if (generateAtUseSite.contains(instruction)) {
168 continue; 177 continue;
169 } 178 }
170 if (instruction.isCodeMotionInvariant()) { 179 if (instruction.isCodeMotionInvariant()) {
171 markAsGenerateAtUseSite(instruction); 180 markAsGenerateAtUseSite(instruction);
172 continue; 181 continue;
173 } 182 }
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 } 373 }
365 374
366 // If [thenInput] is defined in the first predecessor, then it is only used 375 // If [thenInput] is defined in the first predecessor, then it is only used
367 // by [phi] and can be generated at use site. 376 // by [phi] and can be generated at use site.
368 if (identical(thenInput.block, end.predecessors[0])) { 377 if (identical(thenInput.block, end.predecessors[0])) {
369 assert(thenInput.usedBy.length == 1); 378 assert(thenInput.usedBy.length == 1);
370 markAsGenerateAtUseSite(thenInput); 379 markAsGenerateAtUseSite(thenInput);
371 } 380 }
372 } 381 }
373 } 382 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/issue10321_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698