| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 dart2js.ir_tracer; | 5 library dart2js.ir_tracer; |
| 6 | 6 |
| 7 import 'dart:async' show EventSink; | 7 import 'dart:async' show EventSink; |
| 8 | 8 |
| 9 import 'ir_nodes.dart' as ir hide Function; | 9 import 'ir_nodes.dart' as ir hide Function; |
| 10 import '../tracer.dart'; | 10 import '../tracer.dart'; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 BlockCollector builder = new BlockCollector(names); | 37 BlockCollector builder = new BlockCollector(names); |
| 38 builder.visit(f); | 38 builder.visit(f); |
| 39 | 39 |
| 40 printNode(builder.entry); | 40 printNode(builder.entry); |
| 41 for (Block block in builder.cont2block.values) { | 41 for (Block block in builder.cont2block.values) { |
| 42 printNode(block); | 42 printNode(block); |
| 43 } | 43 } |
| 44 names = null; | 44 names = null; |
| 45 } | 45 } |
| 46 | 46 |
| 47 int countUses(ir.Definition definition) { |
| 48 int count = 0; |
| 49 ir.Reference ref = definition.firstRef; |
| 50 while (ref != null) { |
| 51 ++count; |
| 52 ref = ref.nextRef; |
| 53 } |
| 54 return count; |
| 55 } |
| 56 |
| 47 printNode(Block block) { | 57 printNode(Block block) { |
| 48 tag("block", () { | 58 tag("block", () { |
| 49 printProperty("name", block.name); | 59 printProperty("name", block.name); |
| 50 printProperty("from_bci", -1); | 60 printProperty("from_bci", -1); |
| 51 printProperty("to_bci", -1); | 61 printProperty("to_bci", -1); |
| 52 printProperty("predecessors", block.pred.map((n) => n.name)); | 62 printProperty("predecessors", block.pred.map((n) => n.name)); |
| 53 printProperty("successors", block.succ.map((n) => n.name)); | 63 printProperty("successors", block.succ.map((n) => n.name)); |
| 54 printEmptyProperty("xhandlers"); | 64 printEmptyProperty("xhandlers"); |
| 55 printEmptyProperty("flags"); | 65 printEmptyProperty("flags"); |
| 56 tag("states", () { | 66 tag("states", () { |
| 57 tag("locals", () { | 67 tag("locals", () { |
| 58 printProperty("size", 0); | 68 printProperty("size", 0); |
| 59 printProperty("method", "None"); | 69 printProperty("method", "None"); |
| 60 // We could print parameters here, | |
| 61 // but does the hydra tool actually use this info?? | |
| 62 }); | 70 }); |
| 63 }); | 71 }); |
| 64 tag("HIR", () { | 72 tag("HIR", () { |
| 73 for (ir.Parameter param in block.parameters) { |
| 74 String name = names.name(param); |
| 75 printStmt(name, "Parameter $name [useCount=${countUses(param)}]"); |
| 76 } |
| 65 visit(block.body); | 77 visit(block.body); |
| 66 }); | 78 }); |
| 67 }); | 79 }); |
| 68 } | 80 } |
| 69 | 81 |
| 70 void printStmt(String resultVar, String contents) { | 82 void printStmt(String resultVar, String contents) { |
| 71 int bci = 0; | 83 int bci = 0; |
| 72 int uses = 0; | 84 int uses = 0; |
| 73 addIndent(); | 85 addIndent(); |
| 74 add("$bci $uses $resultVar $contents <|@\n"); | 86 add("$bci $uses $resultVar $contents <|@\n"); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 196 |
| 185 visitParameter(ir.Parameter node) { | 197 visitParameter(ir.Parameter node) { |
| 186 return "Parameter ${names.name(node)}"; | 198 return "Parameter ${names.name(node)}"; |
| 187 } | 199 } |
| 188 | 200 |
| 189 visitContinuation(ir.Continuation node) { | 201 visitContinuation(ir.Continuation node) { |
| 190 return "Continuation ${names.name(node)}"; | 202 return "Continuation ${names.name(node)}"; |
| 191 } | 203 } |
| 192 | 204 |
| 193 visitIsTrue(ir.IsTrue node) { | 205 visitIsTrue(ir.IsTrue node) { |
| 194 return "IsTrue(${names.name(node)})"; | 206 return "IsTrue(${names.name(node.value.definition)})"; |
| 195 } | 207 } |
| 196 | 208 |
| 197 visitCondition(ir.Condition c) {} | 209 visitCondition(ir.Condition c) {} |
| 198 visitExpression(ir.Expression e) {} | 210 visitExpression(ir.Expression e) {} |
| 199 visitPrimitive(ir.Primitive p) {} | 211 visitPrimitive(ir.Primitive p) {} |
| 200 visitDefinition(ir.Definition d) {} | 212 visitDefinition(ir.Definition d) {} |
| 201 visitNode(ir.Node n) {} | 213 visitNode(ir.Node n) {} |
| 202 } | 214 } |
| 203 | 215 |
| 204 /** | 216 /** |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 } | 341 } |
| 330 } | 342 } |
| 331 | 343 |
| 332 visitContinuation(ir.Continuation c) { | 344 visitContinuation(ir.Continuation c) { |
| 333 var old_node = current_block; | 345 var old_node = current_block; |
| 334 current_block = getBlock(c); | 346 current_block = getBlock(c); |
| 335 visit(c.body); | 347 visit(c.body); |
| 336 current_block = old_node; | 348 current_block = old_node; |
| 337 } | 349 } |
| 338 } | 350 } |
| OLD | NEW |