OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 ssa.tracer; | 5 library ssa.tracer; |
6 | 6 |
7 import 'dart:async' show EventSink; | 7 import 'dart:async' show EventSink; |
8 | 8 |
9 import '../compiler.dart' show Compiler; | 9 import '../compiler.dart' show Compiler; |
10 import '../diagnostics/invariant.dart' show DEBUG_MODE; | 10 import '../diagnostics/invariant.dart' show DEBUG_MODE; |
11 import '../js_backend/js_backend.dart'; | 11 import '../js_backend/js_backend.dart'; |
12 import '../tracer.dart'; | 12 import '../tracer.dart'; |
| 13 import '../world.dart' show ClosedWorld; |
13 import 'nodes.dart'; | 14 import 'nodes.dart'; |
14 | 15 |
15 /** | 16 /** |
16 * Outputs SSA code in a format readable by Hydra IR. | 17 * Outputs SSA code in a format readable by Hydra IR. |
17 * Tracing is disabled by default, see ../tracer.dart for how | 18 * Tracing is disabled by default, see ../tracer.dart for how |
18 * to enable it. | 19 * to enable it. |
19 */ | 20 */ |
20 class HTracer extends HGraphVisitor with TracerUtil { | 21 class HTracer extends HGraphVisitor with TracerUtil { |
21 Compiler compiler; | 22 Compiler compiler; |
22 final EventSink<String> output; | 23 final EventSink<String> output; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 }); | 111 }); |
111 } | 112 } |
112 } | 113 } |
113 | 114 |
114 class HInstructionStringifier implements HVisitor<String> { | 115 class HInstructionStringifier implements HVisitor<String> { |
115 final Compiler compiler; | 116 final Compiler compiler; |
116 final HBasicBlock currentBlock; | 117 final HBasicBlock currentBlock; |
117 | 118 |
118 HInstructionStringifier(this.currentBlock, this.compiler); | 119 HInstructionStringifier(this.currentBlock, this.compiler); |
119 | 120 |
| 121 ClosedWorld get closedWorld => compiler.closedWorld; |
| 122 |
120 visit(HInstruction node) => '${node.accept(this)} ${node.instructionType}'; | 123 visit(HInstruction node) => '${node.accept(this)} ${node.instructionType}'; |
121 | 124 |
122 String temporaryId(HInstruction instruction) { | 125 String temporaryId(HInstruction instruction) { |
123 String prefix; | 126 String prefix; |
124 if (instruction.isNull()) { | 127 if (instruction.isNull()) { |
125 prefix = 'u'; | 128 prefix = 'u'; |
126 } else if (instruction.isConflicting()) { | 129 } else if (instruction.isConflicting()) { |
127 prefix = 'c'; | 130 prefix = 'c'; |
128 } else if (instruction.isExtendableArray(compiler)) { | 131 } else if (instruction.isExtendableArray(closedWorld)) { |
129 prefix = 'e'; | 132 prefix = 'e'; |
130 } else if (instruction.isFixedArray(compiler)) { | 133 } else if (instruction.isFixedArray(closedWorld)) { |
131 prefix = 'f'; | 134 prefix = 'f'; |
132 } else if (instruction.isMutableArray(compiler)) { | 135 } else if (instruction.isMutableArray(closedWorld)) { |
133 prefix = 'm'; | 136 prefix = 'm'; |
134 } else if (instruction.isReadableArray(compiler)) { | 137 } else if (instruction.isReadableArray(closedWorld)) { |
135 prefix = 'a'; | 138 prefix = 'a'; |
136 } else if (instruction.isString(compiler)) { | 139 } else if (instruction.isString(closedWorld)) { |
137 prefix = 's'; | 140 prefix = 's'; |
138 } else if (instruction.isIndexablePrimitive(compiler)) { | 141 } else if (instruction.isIndexablePrimitive(closedWorld)) { |
139 prefix = 'r'; | 142 prefix = 'r'; |
140 } else if (instruction.isBoolean(compiler)) { | 143 } else if (instruction.isBoolean(closedWorld)) { |
141 prefix = 'b'; | 144 prefix = 'b'; |
142 } else if (instruction.isInteger(compiler)) { | 145 } else if (instruction.isInteger(closedWorld)) { |
143 prefix = 'i'; | 146 prefix = 'i'; |
144 } else if (instruction.isDouble(compiler)) { | 147 } else if (instruction.isDouble(closedWorld)) { |
145 prefix = 'd'; | 148 prefix = 'd'; |
146 } else if (instruction.isNumber(compiler)) { | 149 } else if (instruction.isNumber(closedWorld)) { |
147 prefix = 'n'; | 150 prefix = 'n'; |
148 } else if (instruction.instructionType.containsAll(compiler.closedWorld)) { | 151 } else if (instruction.instructionType.containsAll(closedWorld)) { |
149 prefix = 'v'; | 152 prefix = 'v'; |
150 } else { | 153 } else { |
151 prefix = 'U'; | 154 prefix = 'U'; |
152 } | 155 } |
153 return "$prefix${instruction.id}"; | 156 return "$prefix${instruction.id}"; |
154 } | 157 } |
155 | 158 |
156 String visitBoolify(HBoolify node) { | 159 String visitBoolify(HBoolify node) { |
157 return "Boolify: ${temporaryId(node.inputs[0])}"; | 160 return "Boolify: ${temporaryId(node.inputs[0])}"; |
158 } | 161 } |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 } | 555 } |
553 | 556 |
554 String visitAwait(HAwait node) { | 557 String visitAwait(HAwait node) { |
555 return "Await: ${temporaryId(node.inputs[0])}"; | 558 return "Await: ${temporaryId(node.inputs[0])}"; |
556 } | 559 } |
557 | 560 |
558 String visitYield(HYield node) { | 561 String visitYield(HYield node) { |
559 return "Yield${node.hasStar ? "*" : ""}: ${temporaryId(node.inputs[0])}"; | 562 return "Yield${node.hasStar ? "*" : ""}: ${temporaryId(node.inputs[0])}"; |
560 } | 563 } |
561 } | 564 } |
OLD | NEW |