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

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

Issue 48243002: When doing SSA type propagation, refine the receiver after a call. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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
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 * Remove [HTypeKnown] instructions from the graph, to make codegen
9 * analysis easier.
10 */
11 class SsaTypeKnownRemover extends HBaseVisitor {
12
13 void visitGraph(HGraph graph) {
14 visitDominatorTree(graph);
15 }
16
17 void visitBasicBlock(HBasicBlock block) {
18 HInstruction instruction = block.first;
19 while (instruction != null) {
20 HInstruction next = instruction.next;
21 instruction.accept(this);
22 instruction = next;
23 }
24 }
25
26 void visitTypeKnown(HTypeKnown instruction) {
27 instruction.block.rewrite(instruction, instruction.checkedInput);
28 instruction.block.remove(instruction);
29 }
30 }
31
32 /**
8 * Instead of emitting each SSA instruction with a temporary variable 33 * Instead of emitting each SSA instruction with a temporary variable
9 * mark instructions that can be emitted at their use-site. 34 * mark instructions that can be emitted at their use-site.
10 * For example, in: 35 * For example, in:
11 * t0 = 4; 36 * t0 = 4;
12 * t1 = 3; 37 * t1 = 3;
13 * t2 = add(t0, t1); 38 * t2 = add(t0, t1);
14 * t0 and t1 would be marked and the resulting code would then be: 39 * t0 and t1 would be marked and the resulting code would then be:
15 * t2 = add(4, 3); 40 * t2 = add(4, 3);
16 */ 41 */
17 class SsaInstructionMerger extends HBaseVisitor { 42 class SsaInstructionMerger extends HBaseVisitor {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 && !instruction.isReceiverTypeCheck) { 137 && !instruction.isReceiverTypeCheck) {
113 assert(instruction.isCheckedModeCheck || instruction.isCastTypeCheck); 138 assert(instruction.isCheckedModeCheck || instruction.isCastTypeCheck);
114 // Checked mode checks and cast checks compile to code that 139 // Checked mode checks and cast checks compile to code that
115 // only use their input once, so we can safely visit them 140 // only use their input once, so we can safely visit them
116 // and try to merge the input. 141 // and try to merge the input.
117 visitInstruction(instruction); 142 visitInstruction(instruction);
118 } 143 }
119 } 144 }
120 145
121 void visitTypeKnown(HTypeKnown instruction) { 146 void visitTypeKnown(HTypeKnown instruction) {
122 markAsGenerateAtUseSite(instruction); 147 // [HTypeKnown] instructions are removed before code generation.
148 assert(false);
123 } 149 }
124 150
125 void tryGenerateAtUseSite(HInstruction instruction) { 151 void tryGenerateAtUseSite(HInstruction instruction) {
126 if (instruction.isControlFlow()) return; 152 if (instruction.isControlFlow()) return;
127 markAsGenerateAtUseSite(instruction); 153 markAsGenerateAtUseSite(instruction);
128 } 154 }
129 155
130 bool isBlockSinglePredecessor(HBasicBlock block) { 156 bool isBlockSinglePredecessor(HBasicBlock block) {
131 return block.successors.length == 1 157 return block.successors.length == 1
132 && block.successors[0].predecessors.length == 1; 158 && block.successors[0].predecessors.length == 1;
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 } 403 }
378 404
379 // If [thenInput] is defined in the first predecessor, then it is only used 405 // If [thenInput] is defined in the first predecessor, then it is only used
380 // by [phi] and can be generated at use site. 406 // by [phi] and can be generated at use site.
381 if (identical(thenInput.block, end.predecessors[0])) { 407 if (identical(thenInput.block, end.predecessors[0])) {
382 assert(thenInput.usedBy.length == 1); 408 assert(thenInput.usedBy.length == 1);
383 markAsGenerateAtUseSite(thenInput); 409 markAsGenerateAtUseSite(thenInput);
384 } 410 }
385 } 411 }
386 } 412 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698