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 dump_info; | 5 library dump_info; |
6 | 6 |
7 import 'dart:convert' | 7 import 'dart:convert' |
8 show HtmlEscape, JsonEncoder, StringConversionSink, ChunkedConversionSink; | 8 show HtmlEscape, JsonEncoder, StringConversionSink, ChunkedConversionSink; |
9 | 9 |
10 import 'common/tasks.dart' show | 10 import 'common/tasks.dart' show |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 int size = compiler.dumpInfoTask.sizeOf(element); | 121 int size = compiler.dumpInfoTask.sizeOf(element); |
122 String code; | 122 String code; |
123 StringBuffer emittedCode = compiler.dumpInfoTask.codeOf(element); | 123 StringBuffer emittedCode = compiler.dumpInfoTask.codeOf(element); |
124 if (emittedCode != null) { | 124 if (emittedCode != null) { |
125 size += emittedCode.length; | 125 size += emittedCode.length; |
126 code = emittedCode.toString(); | 126 code = emittedCode.toString(); |
127 } | 127 } |
128 | 128 |
129 FieldInfo info = new FieldInfo( | 129 FieldInfo info = new FieldInfo( |
130 name: element.name, | 130 name: element.name, |
| 131 // We use element.hashCode because it is globally unique and it is |
| 132 // available while we are doing codegen. |
| 133 coverageId: '${element.hashCode}', |
131 type: '${element.type}', | 134 type: '${element.type}', |
132 inferredType: '$inferredType', | 135 inferredType: '$inferredType', |
133 size: size, | 136 size: size, |
134 code: code, | 137 code: code, |
135 outputUnit: _unitInfoForElement(element)); | 138 outputUnit: _unitInfoForElement(element)); |
136 _elementToInfo[element] = info; | 139 _elementToInfo[element] = info; |
137 | 140 |
138 List<FunctionInfo> nestedClosures = <FunctionInfo>[]; | 141 List<FunctionInfo> nestedClosures = <FunctionInfo>[]; |
139 for (Element closure in element.nestedClosures) { | 142 for (Element closure in element.nestedClosures) { |
140 Info child = this.process(closure); | 143 Info child = this.process(closure); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 } | 264 } |
262 String inferredReturnType = | 265 String inferredReturnType = |
263 '${compiler.typesTask.getGuaranteedReturnTypeOfElement(element)}'; | 266 '${compiler.typesTask.getGuaranteedReturnTypeOfElement(element)}'; |
264 String sideEffects = '${compiler.world.getSideEffectsOfElement(element)}'; | 267 String sideEffects = '${compiler.world.getSideEffectsOfElement(element)}'; |
265 | 268 |
266 int inlinedCount = compiler.dumpInfoTask.inlineCount[element]; | 269 int inlinedCount = compiler.dumpInfoTask.inlineCount[element]; |
267 if (inlinedCount == null) inlinedCount = 0; | 270 if (inlinedCount == null) inlinedCount = 0; |
268 | 271 |
269 FunctionInfo info = new FunctionInfo( | 272 FunctionInfo info = new FunctionInfo( |
270 name: name, | 273 name: name, |
| 274 // We use element.hashCode because it is globally unique and it is |
| 275 // available while we are doing codegen. |
| 276 coverageId: '${element.hashCode}', |
271 modifiers: modifiers, | 277 modifiers: modifiers, |
272 size: size, | 278 size: size, |
273 returnType: returnType, | 279 returnType: returnType, |
274 inferredReturnType: inferredReturnType, | 280 inferredReturnType: inferredReturnType, |
275 parameters: parameters, | 281 parameters: parameters, |
276 sideEffects: sideEffects, | 282 sideEffects: sideEffects, |
277 inlinedCount: inlinedCount, | 283 inlinedCount: inlinedCount, |
278 code: code, | 284 code: code, |
279 type: element.type.toString(), | 285 type: element.type.toString(), |
280 outputUnit: _unitInfoForElement(element)); | 286 outputUnit: _unitInfoForElement(element)); |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 | 538 |
533 ChunkedConversionSink<Object> sink = encoder.startChunkedConversion( | 539 ChunkedConversionSink<Object> sink = encoder.startChunkedConversion( |
534 new StringConversionSink.fromStringSink(buffer)); | 540 new StringConversionSink.fromStringSink(buffer)); |
535 sink.add(result.toJson()); | 541 sink.add(result.toJson()); |
536 compiler.reportInfo(NO_LOCATION_SPANNABLE, MessageKind.GENERIC, { | 542 compiler.reportInfo(NO_LOCATION_SPANNABLE, MessageKind.GENERIC, { |
537 'text': "View the dumped .info.json file at " | 543 'text': "View the dumped .info.json file at " |
538 "https://dart-lang.github.io/dump-info-visualizer" | 544 "https://dart-lang.github.io/dump-info-visualizer" |
539 }); | 545 }); |
540 } | 546 } |
541 } | 547 } |
OLD | NEW |