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

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

Issue 10827180: Move types out of the HInstructions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Cosmetic change (updated comment). Created 8 years, 4 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
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 #library('tracer'); 5 #library('tracer');
6 6
7 #import('dart:io'); 7 #import('dart:io');
8 #import('ssa.dart'); 8 #import('ssa.dart');
9 #import('../leg.dart'); 9 #import('../leg.dart');
10 10
11 final bool GENERATE_SSA_TRACE = false; 11 final bool GENERATE_SSA_TRACE = false;
12 final String SSA_TRACE_FILTER = null; 12 final String SSA_TRACE_FILTER = null;
13 13
14 class HTracer extends HGraphVisitor implements Tracer { 14 class HTracer extends HGraphVisitor implements Tracer {
15 JavaScriptWorkItem work;
15 int indent = 0; 16 int indent = 0;
16 final RandomAccessFile output; 17 final RandomAccessFile output;
17 final bool enabled = GENERATE_SSA_TRACE; 18 final bool enabled = GENERATE_SSA_TRACE;
18 bool traceActive = false; 19 bool traceActive = false;
19 20
20 HTracer([String path = "dart.cfg"]) 21 HTracer([String path = "dart.cfg"])
21 : output = GENERATE_SSA_TRACE ? new File(path).openSync(FileMode.WRITE) 22 : output = GENERATE_SSA_TRACE ? new File(path).openSync(FileMode.WRITE)
22 : null; 23 : null;
23 24
24 void close() { 25 void close() {
25 if (enabled) output.closeSync(); 26 if (enabled) output.closeSync();
26 } 27 }
27 28
28 void traceCompilation(String methodName) { 29 void traceCompilation(String methodName, JavaScriptWorkItem workItem) {
29 if (!enabled) return; 30 if (!enabled) return;
31 this.work = workItem;
30 traceActive = 32 traceActive =
31 SSA_TRACE_FILTER == null || methodName.contains(SSA_TRACE_FILTER); 33 SSA_TRACE_FILTER == null || methodName.contains(SSA_TRACE_FILTER);
32 if (!traceActive) return; 34 if (!traceActive) return;
33 tag("compilation", () { 35 tag("compilation", () {
34 printProperty("name", methodName); 36 printProperty("name", methodName);
35 printProperty("method", methodName); 37 printProperty("method", methodName);
36 printProperty("date", new Date.now().millisecondsSinceEpoch); 38 printProperty("date", new Date.now().millisecondsSinceEpoch);
37 }); 39 });
38 } 40 }
39 41
(...skipping 26 matching lines...) Expand all
66 add("successors"); 68 add("successors");
67 for (HBasicBlock successor in block.successors) { 69 for (HBasicBlock successor in block.successors) {
68 add(' "B${successor.id}"'); 70 add(' "B${successor.id}"');
69 } 71 }
70 add("\n"); 72 add("\n");
71 } 73 }
72 } 74 }
73 75
74 void addInstructions(HInstructionStringifier stringifier, 76 void addInstructions(HInstructionStringifier stringifier,
75 HInstructionList list) { 77 HInstructionList list) {
78 HTypeMap types = work.types;
76 for (HInstruction instruction = list.first; 79 for (HInstruction instruction = list.first;
77 instruction !== null; 80 instruction !== null;
78 instruction = instruction.next) { 81 instruction = instruction.next) {
79 int bci = 0; 82 int bci = 0;
80 int uses = instruction.usedBy.length; 83 int uses = instruction.usedBy.length;
81 String changes = instruction.hasSideEffects() ? '!' : ' '; 84 String changes = instruction.hasSideEffects(types) ? '!' : ' ';
82 String depends = instruction.dependsOnSomething() ? '?' : ''; 85 String depends = instruction.dependsOnSomething() ? '?' : '';
83 addIndent(); 86 addIndent();
84 String temporaryId = stringifier.temporaryId(instruction); 87 String temporaryId = stringifier.temporaryId(instruction);
85 String instructionString = stringifier.visit(instruction); 88 String instructionString = stringifier.visit(instruction);
86 add("$bci $uses $temporaryId $instructionString $changes $depends <|@\n"); 89 add("$bci $uses $temporaryId $instructionString $changes $depends <|@\n");
87 } 90 }
88 } 91 }
89 92
90 void visitBasicBlock(HBasicBlock block) { 93 void visitBasicBlock(HBasicBlock block) {
91 HInstructionStringifier stringifier = new HInstructionStringifier(block); 94 HInstructionStringifier stringifier =
95 new HInstructionStringifier(work, block);
92 assert(block.id !== null); 96 assert(block.id !== null);
93 tag("block", () { 97 tag("block", () {
94 printProperty("name", "B${block.id}"); 98 printProperty("name", "B${block.id}");
95 printProperty("from_bci", -1); 99 printProperty("from_bci", -1);
96 printProperty("to_bci", -1); 100 printProperty("to_bci", -1);
97 addPredecessors(block); 101 addPredecessors(block);
98 addSuccessors(block); 102 addSuccessors(block);
99 printEmptyProperty("xhandlers"); 103 printEmptyProperty("xhandlers");
100 printEmptyProperty("flags"); 104 printEmptyProperty("flags");
101 if (block.dominator !== null) { 105 if (block.dominator !== null) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 158 }
155 159
156 void addIndent() { 160 void addIndent() {
157 for (int i = 0; i < indent; i++) { 161 for (int i = 0; i < indent; i++) {
158 add(" "); 162 add(" ");
159 } 163 }
160 } 164 }
161 } 165 }
162 166
163 class HInstructionStringifier implements HVisitor<String> { 167 class HInstructionStringifier implements HVisitor<String> {
168 JavaScriptWorkItem work;
164 HBasicBlock currentBlock; 169 HBasicBlock currentBlock;
165 170
166 HInstructionStringifier(this.currentBlock); 171 HInstructionStringifier(this.work, this.currentBlock);
167 172
168 visit(HInstruction node) => node.accept(this); 173 visit(HInstruction node) => node.accept(this);
169 174
170 String temporaryId(HInstruction instruction) { 175 String temporaryId(HInstruction instruction) {
171 String prefix; 176 String prefix;
172 HType type = instruction.propagatedType; 177 HType type = work.types[instruction];
173 if (!type.isPrimitive()) { 178 if (!type.isPrimitive()) {
174 prefix = 'U'; 179 prefix = 'U';
175 } else { 180 } else {
176 if (type == HType.MUTABLE_ARRAY) { 181 if (type == HType.MUTABLE_ARRAY) {
177 prefix = 'm'; 182 prefix = 'm';
178 } else if (type == HType.READABLE_ARRAY) { 183 } else if (type == HType.READABLE_ARRAY) {
179 prefix = 'a'; 184 prefix = 'a';
180 } else if (type == HType.EXTENDABLE_ARRAY) { 185 } else if (type == HType.EXTENDABLE_ARRAY) {
181 prefix = 'e'; 186 prefix = 'e';
182 } else if (type == HType.BOOLEAN) { 187 } else if (type == HType.BOOLEAN) {
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 return "TypeGuard($on): $guardedId is $type bailout: $bailoutId " 510 return "TypeGuard($on): $guardedId is $type bailout: $bailoutId "
506 "env: $envBuffer"; 511 "env: $envBuffer";
507 } 512 }
508 513
509 String visitIs(HIs node) { 514 String visitIs(HIs node) {
510 String type = node.typeExpression.toString(); 515 String type = node.typeExpression.toString();
511 return "TypeTest: ${temporaryId(node.expression)} is $type"; 516 return "TypeTest: ${temporaryId(node.expression)} is $type";
512 } 517 }
513 518
514 String visitTypeConversion(HTypeConversion node) { 519 String visitTypeConversion(HTypeConversion node) {
515 String type = node.propagatedType.toString(); 520 return "TypeConversion: ${temporaryId(node.inputs[0])} to ${node.type}";
516 return "TypeConversion: ${temporaryId(node.inputs[0])} to $type";
517 } 521 }
518 } 522 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698