Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 library dart2js.ir_tracer; | 1 library dart2js.ir_tracer; |
| 2 | 2 |
| 3 import 'dart:async' show EventSink; | 3 import 'dart:async' show EventSink; |
| 4 | 4 |
| 5 import 'ir_nodes.dart' as ir hide Function; | 5 import 'ir_nodes.dart' as ir hide Function; |
| 6 import '../tracer.dart'; | 6 import '../tracer.dart'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * If true, show LetCont expressions in output. | 9 * If true, show LetCont expressions in output. |
| 10 */ | 10 */ |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 } | 86 } |
| 87 | 87 |
| 88 visitInvokeStatic(ir.InvokeStatic node) { | 88 visitInvokeStatic(ir.InvokeStatic node) { |
| 89 String dummy = names.name(node); | 89 String dummy = names.name(node); |
| 90 String callName = node.selector.name; | 90 String callName = node.selector.name; |
| 91 String args = node.arguments.map(formatReference).join(', '); | 91 String args = node.arguments.map(formatReference).join(', '); |
| 92 String kont = formatReference(node.continuation); | 92 String kont = formatReference(node.continuation); |
| 93 printStmt(dummy, "InvokeStatic $callName ($args) $kont"); | 93 printStmt(dummy, "InvokeStatic $callName ($args) $kont"); |
| 94 } | 94 } |
| 95 | 95 |
| 96 visitInvokeMethod(ir.InvokeMethod node) { | |
| 97 String dummy = names.name(node); | |
| 98 String callName = node.selector.name; | |
| 99 String args = node.arguments.map(formatReference).join(', '); | |
| 100 String kont = formatReference(node.continuation); | |
| 101 printStmt(dummy, "InvokeStatic $callName ($args) $kont"); | |
| 102 } | |
| 103 | |
| 104 visitInvokeConstructor(ir.InvokeConstructor node) { | |
| 105 String dummy = names.name(node); | |
| 106 String callName; | |
| 107 if (node.target.name.isEmpty) { | |
| 108 callName = '${node.type}'; | |
| 109 } else { | |
| 110 callName = '${node.type}.${node.target.name}'; | |
| 111 } | |
| 112 String args = node.arguments.map(formatReference).join(', '); | |
| 113 String kont = formatReference(node.continuation); | |
| 114 printStmt(dummy, "InvokeConstructor $callName ($args) $kont"); | |
| 115 } | |
| 116 | |
| 96 visitInvokeContinuation(ir.InvokeContinuation node) { | 117 visitInvokeContinuation(ir.InvokeContinuation node) { |
| 97 String dummy = names.name(node); | 118 String dummy = names.name(node); |
| 98 String kont = formatReference(node.continuation); | 119 String kont = formatReference(node.continuation); |
| 99 String args = node.arguments.map(formatReference).join(', '); | 120 String args = node.arguments.map(formatReference).join(', '); |
| 100 printStmt(dummy, "InvokeContinuation $kont ($args)"); | 121 printStmt(dummy, "InvokeContinuation $kont ($args)"); |
| 101 } | 122 } |
| 102 | 123 |
| 103 visitBranch(ir.Branch node) { | 124 visitBranch(ir.Branch node) { |
| 104 String dummy = names.name(node); | 125 String dummy = names.name(node); |
| 105 String condition = visit(node.condition); | 126 String condition = visit(node.condition); |
| 106 String trueCont = formatReference(node.trueContinuation); | 127 String trueCont = formatReference(node.trueContinuation); |
| 107 String falseCont = formatReference(node.falseContinuation); | 128 String falseCont = formatReference(node.falseContinuation); |
| 108 printStmt(dummy, "Branch $condition ($trueCont, $falseCont)"); | 129 printStmt(dummy, "Branch $condition ($trueCont, $falseCont)"); |
| 109 } | 130 } |
| 110 | 131 |
|
Kevin Millikin (Google)
2014/05/09 10:21:22
Make sure to tell the editor to strip trailing whi
| |
| 111 String formatReference(ir.Reference ref) { | 132 String formatReference(ir.Reference ref) { |
| 112 ir.Definition target = ref.definition; | 133 ir.Definition target = ref.definition; |
| 113 if (target is ir.Continuation && target.body == null) { | 134 if (target is ir.Continuation && target.body == null) { |
| 114 return "return"; // Do not generate a name for the return continuation | 135 return "return"; // Do not generate a name for the return continuation |
| 115 } else { | 136 } else { |
| 116 return names.name(ref.definition); | 137 return names.name(ref.definition); |
| 117 } | 138 } |
| 118 } | 139 } |
| 119 | 140 |
| 120 String formatPrimitive(ir.Primitive p) => visit(p); | 141 String formatPrimitive(ir.Primitive p) => visit(p); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 visit(exp.continuation); | 244 visit(exp.continuation); |
| 224 visit(exp.body); | 245 visit(exp.body); |
| 225 } | 246 } |
| 226 | 247 |
| 227 visitInvokeStatic(ir.InvokeStatic exp) { | 248 visitInvokeStatic(ir.InvokeStatic exp) { |
| 228 ir.Definition target = exp.continuation.definition; | 249 ir.Definition target = exp.continuation.definition; |
| 229 if (target is ir.Continuation && target.body != null) { | 250 if (target is ir.Continuation && target.body != null) { |
| 230 current_block.addEdgeTo(getBlock(target)); | 251 current_block.addEdgeTo(getBlock(target)); |
| 231 } | 252 } |
| 232 } | 253 } |
| 254 | |
| 255 visitInvokeMethod(ir.InvokeMethod exp) { | |
| 256 ir.Definition target = exp.continuation.definition; | |
| 257 if (target is ir.Continuation && target.body != null) { | |
| 258 current_block.addEdgeTo(getBlock(target)); | |
| 259 } | |
| 260 } | |
| 261 | |
| 262 visitInvokeConstructor(ir.InvokeConstructor exp) { | |
| 263 ir.Definition target = exp.continuation.definition; | |
| 264 if (target is ir.Continuation && target.body != null) { | |
| 265 current_block.addEdgeTo(getBlock(target)); | |
| 266 } | |
| 267 } | |
| 233 | 268 |
| 234 visitInvokeContinuation(ir.InvokeContinuation exp) { | 269 visitInvokeContinuation(ir.InvokeContinuation exp) { |
| 235 ir.Definition target = exp.continuation.definition; | 270 ir.Definition target = exp.continuation.definition; |
| 236 if (target is ir.Continuation && target.body != null) { | 271 if (target is ir.Continuation && target.body != null) { |
| 237 current_block.addEdgeTo(getBlock(target)); | 272 current_block.addEdgeTo(getBlock(target)); |
| 238 } | 273 } |
| 239 } | 274 } |
| 240 | 275 |
| 241 visitBranch(ir.Branch exp) { | 276 visitBranch(ir.Branch exp) { |
| 242 ir.Continuation trueTarget = exp.trueContinuation.definition; | 277 ir.Continuation trueTarget = exp.trueContinuation.definition; |
| 243 if (trueTarget.body != null) { | 278 if (trueTarget.body != null) { |
| 244 current_block.addEdgeTo(getBlock(trueTarget)); | 279 current_block.addEdgeTo(getBlock(trueTarget)); |
| 245 } | 280 } |
| 246 ir.Continuation falseTarget = exp.falseContinuation.definition; | 281 ir.Continuation falseTarget = exp.falseContinuation.definition; |
| 247 if (falseTarget.body != null) { | 282 if (falseTarget.body != null) { |
| 248 current_block.addEdgeTo(getBlock(falseTarget)); | 283 current_block.addEdgeTo(getBlock(falseTarget)); |
| 249 } | 284 } |
| 250 } | 285 } |
| 251 | 286 |
| 252 visitContinuation(ir.Continuation c) { | 287 visitContinuation(ir.Continuation c) { |
| 253 var old_node = current_block; | 288 var old_node = current_block; |
| 254 current_block = getBlock(c); | 289 current_block = getBlock(c); |
| 255 visit(c.body); | 290 visit(c.body); |
| 256 current_block = old_node; | 291 current_block = old_node; |
| 257 } | 292 } |
| 258 } | 293 } |
| OLD | NEW |