Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 | 12 |
| 13 class HTracer extends HGraphVisitor implements Tracer { | 13 class HTracer extends HGraphVisitor implements Tracer { |
| 14 int indent = 0; | 14 int indent = 0; |
| 15 final RandomAccessFile output; | 15 final RandomAccessFile output; |
| 16 final bool enabled = GENERATE_SSA_TRACE; | 16 final bool enabled = GENERATE_SSA_TRACE; |
| 17 | 17 |
| 18 HTracer([String path = "dart.cfg"]) | 18 HTracer([String path = "dart.cfg"]) |
| 19 : output = GENERATE_SSA_TRACE ? new File(path).openSync(FileMode.WRITE) | 19 : output = GENERATE_SSA_TRACE ? new File(path).openSync(FileMode.WRITE) |
| 20 : null; | 20 : null; |
| 21 | 21 |
| 22 void close() { | 22 void close() { |
| 23 if (enabled) output.closeSync(); | 23 if (enabled) output.closeSync(); |
| 24 } | 24 } |
| 25 | 25 |
| 26 String method; | |
|
Lasse Reichstein Nielsen
2012/05/30 09:35:14
Is this used?
ngeoffray
2012/05/30 10:19:07
Leftover debugging. Removed.
| |
| 26 void traceCompilation(String methodName) { | 27 void traceCompilation(String methodName) { |
| 27 tag("compilation", () { | 28 tag("compilation", () { |
| 28 printProperty("name", methodName); | 29 printProperty("name", methodName); |
| 29 printProperty("method", methodName); | 30 printProperty("method", methodName); |
| 30 printProperty("date", new Date.now().value); | 31 printProperty("date", new Date.now().value); |
| 31 }); | 32 }); |
| 32 } | 33 } |
| 33 | 34 |
| 34 void traceGraph(String name, HGraph graph) { | 35 void traceGraph(String name, HGraph graph) { |
| 35 if (!enabled) return; | 36 if (!enabled) return; |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 return "Continue: (B${target.id})"; | 229 return "Continue: (B${target.id})"; |
| 229 } | 230 } |
| 230 | 231 |
| 231 String visitDivide(HDivide node) => visitInvokeStatic(node); | 232 String visitDivide(HDivide node) => visitInvokeStatic(node); |
| 232 | 233 |
| 233 String visitEquals(HEquals node) => visitInvokeStatic(node); | 234 String visitEquals(HEquals node) => visitInvokeStatic(node); |
| 234 | 235 |
| 235 String visitExit(HExit node) => "exit"; | 236 String visitExit(HExit node) => "exit"; |
| 236 | 237 |
| 237 String visitFieldGet(HFieldGet node) { | 238 String visitFieldGet(HFieldGet node) { |
| 238 return 'get ${node.name.slowToString()}'; | 239 return 'get ${temporaryId(node.receiver)}'; |
| 239 } | 240 } |
| 240 | 241 |
| 241 String visitFieldSet(HFieldSet node) { | 242 String visitFieldSet(HFieldSet node) { |
| 242 String valueId = temporaryId(node.value); | 243 String valueId = temporaryId(node.value); |
| 243 return 'set ${node.name.slowToString()} to $valueId'; | 244 return 'set ${temporaryId(node.receiver)} to $valueId'; |
| 244 } | 245 } |
| 245 | 246 |
| 246 String visitGoto(HGoto node) { | 247 String visitGoto(HGoto node) { |
| 247 HBasicBlock target = currentBlock.successors[0]; | 248 HBasicBlock target = currentBlock.successors[0]; |
| 248 return "Goto: (B${target.id})"; | 249 return "Goto: (B${target.id})"; |
| 249 } | 250 } |
| 250 | 251 |
| 251 String visitGreater(HGreater node) => visitInvokeStatic(node); | 252 String visitGreater(HGreater node) => visitInvokeStatic(node); |
| 252 String visitGreaterEqual(HGreaterEqual node) => visitInvokeStatic(node); | 253 String visitGreaterEqual(HGreaterEqual node) => visitInvokeStatic(node); |
| 253 | 254 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 387 | 388 |
| 388 String visitThrow(HThrow node) => "Throw ${temporaryId(node.inputs[0])}"; | 389 String visitThrow(HThrow node) => "Throw ${temporaryId(node.inputs[0])}"; |
| 389 | 390 |
| 390 String visitTruncatingDivide(HTruncatingDivide node) { | 391 String visitTruncatingDivide(HTruncatingDivide node) { |
| 391 return visitInvokeStatic(node); | 392 return visitInvokeStatic(node); |
| 392 } | 393 } |
| 393 | 394 |
| 394 String visitTry(HTry node) { | 395 String visitTry(HTry node) { |
| 395 List<HBasicBlock> successors = currentBlock.successors; | 396 List<HBasicBlock> successors = currentBlock.successors; |
| 396 String tryBlock = 'B${successors[0].id}'; | 397 String tryBlock = 'B${successors[0].id}'; |
| 397 StringBuffer catchBlocks = new StringBuffer(); | 398 String catchBlock = 'none'; |
| 398 for (int i = 1; i < successors.length - 1; i++) { | 399 if (node.catchBlock != null) { |
| 399 catchBlocks.add('B${successors[i].id}, '); | 400 catchBlock = 'B${successors[1].id}'; |
| 400 } | 401 } |
| 401 | 402 |
| 402 String finallyBlock; | 403 String finallyBlock = 'none'; |
| 403 if (node.finallyBlock != null) { | 404 if (node.finallyBlock != null) { |
| 404 finallyBlock = 'B${node.finallyBlock.id}'; | 405 finallyBlock = 'B${node.finallyBlock.id}'; |
| 405 } else { | |
| 406 catchBlocks.add('B${successors[successors.length - 1].id}'); | |
| 407 finallyBlock = 'none'; | |
| 408 } | 406 } |
| 409 return "Try: $tryBlock, Catch: $catchBlocks, Finally: $finallyBlock"; | 407 |
| 408 return "Try: $tryBlock, Catch: $catchBlock, Finally: $finallyBlock, " | |
| 409 "Join: B${successors.last().id}"; | |
| 410 } | 410 } |
| 411 | 411 |
| 412 String visitTypeGuard(HTypeGuard node) { | 412 String visitTypeGuard(HTypeGuard node) { |
| 413 String type; | 413 String type; |
| 414 switch (node.guardedType) { | 414 switch (node.guardedType) { |
| 415 case HType.MUTABLE_ARRAY: type = "mutable_array"; break; | 415 case HType.MUTABLE_ARRAY: type = "mutable_array"; break; |
| 416 case HType.READABLE_ARRAY: type = "readable_array"; break; | 416 case HType.READABLE_ARRAY: type = "readable_array"; break; |
| 417 case HType.EXTENDABLE_ARRAY: type = "extendable_array"; break; | 417 case HType.EXTENDABLE_ARRAY: type = "extendable_array"; break; |
| 418 case HType.BOOLEAN: type = "bool"; break; | 418 case HType.BOOLEAN: type = "bool"; break; |
| 419 case HType.INTEGER: type = "integer"; break; | 419 case HType.INTEGER: type = "integer"; break; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 442 String visitIs(HIs node) { | 442 String visitIs(HIs node) { |
| 443 String type = node.typeExpression.toString(); | 443 String type = node.typeExpression.toString(); |
| 444 return "TypeTest: ${temporaryId(node.expression)} is $type"; | 444 return "TypeTest: ${temporaryId(node.expression)} is $type"; |
| 445 } | 445 } |
| 446 | 446 |
| 447 String visitTypeConversion(HTypeConversion node) { | 447 String visitTypeConversion(HTypeConversion node) { |
| 448 String type = node.propagatedType.toString(); | 448 String type = node.propagatedType.toString(); |
| 449 return "TypeConversion: ${temporaryId(node.inputs[0])} to $type"; | 449 return "TypeConversion: ${temporaryId(node.inputs[0])} to $type"; |
| 450 } | 450 } |
| 451 } | 451 } |
| OLD | NEW |