| 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 import 'cps_ir_nodes.dart' as cps_ir; | 8 import 'cps_ir_nodes.dart' as cps_ir; |
| 9 import '../tracer.dart'; | 9 import '../tracer.dart'; |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 void traceGraph(String name, cps_ir.FunctionDefinition node) { | 23 void traceGraph(String name, cps_ir.FunctionDefinition node) { |
| 24 tag("cfg", () { | 24 tag("cfg", () { |
| 25 printProperty("name", name); | 25 printProperty("name", name); |
| 26 | 26 |
| 27 names = new Names(); | 27 names = new Names(); |
| 28 BlockCollector builder = new BlockCollector(names); | 28 BlockCollector builder = new BlockCollector(names); |
| 29 builder.visit(node); | 29 builder.visit(node); |
| 30 | 30 |
| 31 for (Block block in builder.entries) { | 31 for (Block block in builder.entries) { |
| 32 printBlock(block, entryPointParameters: node.parameters); | 32 printBlock(block, entryPoint: node); |
| 33 } | 33 } |
| 34 for (Block block in builder.cont2block.values) { | 34 for (Block block in builder.cont2block.values) { |
| 35 printBlock(block); | 35 printBlock(block); |
| 36 } | 36 } |
| 37 names = null; | 37 names = null; |
| 38 }); | 38 }); |
| 39 } | 39 } |
| 40 | 40 |
| 41 // Temporary field used during tree walk | 41 // Temporary field used during tree walk |
| 42 Names names; | 42 Names names; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 56 int countUses(cps_ir.Definition definition) { | 56 int countUses(cps_ir.Definition definition) { |
| 57 int count = 0; | 57 int count = 0; |
| 58 cps_ir.Reference ref = definition.firstRef; | 58 cps_ir.Reference ref = definition.firstRef; |
| 59 while (ref != null) { | 59 while (ref != null) { |
| 60 ++count; | 60 ++count; |
| 61 ref = ref.next; | 61 ref = ref.next; |
| 62 } | 62 } |
| 63 return count; | 63 return count; |
| 64 } | 64 } |
| 65 | 65 |
| 66 /// If [entryPointParameters] is given, this block is an entry point | 66 /// If [entryPoint] is given, this block is an entry point. |
| 67 /// and [entryPointParameters] is the list of function parameters. | 67 printBlock(Block block, {cps_ir.FunctionDefinition entryPoint}) { |
| 68 printBlock(Block block, {List<cps_ir.Definition> entryPointParameters}) { | |
| 69 tag("block", () { | 68 tag("block", () { |
| 70 printProperty("name", block.name); | 69 printProperty("name", block.name); |
| 71 printProperty("from_bci", -1); | 70 printProperty("from_bci", -1); |
| 72 printProperty("to_bci", -1); | 71 printProperty("to_bci", -1); |
| 73 printProperty("predecessors", block.pred.map((n) => n.name)); | 72 printProperty("predecessors", block.pred.map((n) => n.name)); |
| 74 printProperty("successors", block.succ.map((n) => n.name)); | 73 printProperty("successors", block.succ.map((n) => n.name)); |
| 75 printEmptyProperty("xhandlers"); | 74 printEmptyProperty("xhandlers"); |
| 76 printEmptyProperty("flags"); | 75 printEmptyProperty("flags"); |
| 77 tag("states", () { | 76 tag("states", () { |
| 78 tag("locals", () { | 77 tag("locals", () { |
| 79 printProperty("size", 0); | 78 printProperty("size", 0); |
| 80 printProperty("method", "None"); | 79 printProperty("method", "None"); |
| 81 }); | 80 }); |
| 82 }); | 81 }); |
| 83 tag("HIR", () { | 82 tag("HIR", () { |
| 84 String formatParameter(cps_ir.Parameter param) { | 83 String formatParameter(cps_ir.Parameter param) { |
| 85 return '${names.name(param)} ${param.type}'; | 84 return '${names.name(param)} ${param.type}'; |
| 86 } | 85 } |
| 87 if (entryPointParameters != null) { | 86 if (entryPoint != null) { |
| 88 String params = entryPointParameters.map(formatParameter).join(', '); | 87 String thisParam = entryPoint.thisParameter != null |
| 89 printStmt('x0', 'Entry ($params)'); | 88 ? formatParameter(entryPoint.thisParameter) |
| 89 : 'no receiver'; |
| 90 String params = entryPoint.parameters.map(formatParameter).join(', '); |
| 91 printStmt('x0', 'Entry ($thisParam) ($params)'); |
| 90 } | 92 } |
| 91 String params = block.parameters.map(formatParameter).join(', '); | 93 String params = block.parameters.map(formatParameter).join(', '); |
| 92 printStmt('x0', 'Parameters ($params)'); | 94 printStmt('x0', 'Parameters ($params)'); |
| 93 visit(block.body); | 95 visit(block.body); |
| 94 }); | 96 }); |
| 95 }); | 97 }); |
| 96 } | 98 } |
| 97 | 99 |
| 98 void printStmt(String resultVar, String contents) { | 100 void printStmt(String resultVar, String contents) { |
| 99 int bci = 0; | 101 int bci = 0; |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 } | 679 } |
| 678 | 680 |
| 679 visitBoundsCheck(cps_ir.BoundsCheck node) { | 681 visitBoundsCheck(cps_ir.BoundsCheck node) { |
| 680 unexpectedNode(node); | 682 unexpectedNode(node); |
| 681 } | 683 } |
| 682 | 684 |
| 683 visitNullCheck(cps_ir.NullCheck node) { | 685 visitNullCheck(cps_ir.NullCheck node) { |
| 684 unexpectedNode(node); | 686 unexpectedNode(node); |
| 685 } | 687 } |
| 686 } | 688 } |
| OLD | NEW |