Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: pkg/compiler/lib/src/dump_info.dart

Issue 2676693003: Only generate coverageIds when needed (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 ChunkedConversionSink, JsonEncoder, StringConversionSink; 8 show ChunkedConversionSink, JsonEncoder, StringConversionSink;
9 9
10 import 'package:dart2js_info/info.dart'; 10 import 'package:dart2js_info/info.dart';
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 TypeMask inferredType = _resultOf(element).type; 123 TypeMask inferredType = _resultOf(element).type;
124 // If a field has an empty inferred type it is never used. 124 // If a field has an empty inferred type it is never used.
125 if (inferredType == null || inferredType.isEmpty) return null; 125 if (inferredType == null || inferredType.isEmpty) return null;
126 126
127 int size = compiler.dumpInfoTask.sizeOf(element); 127 int size = compiler.dumpInfoTask.sizeOf(element);
128 String code = compiler.dumpInfoTask.codeOf(element); 128 String code = compiler.dumpInfoTask.codeOf(element);
129 if (code != null) size += code.length; 129 if (code != null) size += code.length;
130 130
131 FieldInfo info = new FieldInfo( 131 FieldInfo info = new FieldInfo(
132 name: element.name, 132 name: element.name,
133 // We use element.hashCode because it is globally unique and it is
134 // available while we are doing codegen.
135 coverageId: '${element.hashCode}',
136 type: '${element.type}', 133 type: '${element.type}',
137 inferredType: '$inferredType', 134 inferredType: '$inferredType',
138 code: code, 135 code: code,
139 outputUnit: _unitInfoForElement(element), 136 outputUnit: _unitInfoForElement(element),
140 isConst: element.isConst); 137 isConst: element.isConst);
141 _elementToInfo[element] = info; 138 _elementToInfo[element] = info;
142 if (element.isConst) { 139 if (element.isConst) {
143 var value = compiler.backend.constantCompilerTask 140 var value = compiler.backend.constantCompilerTask
144 .getConstantValue(element.constant); 141 .getConstantValue(element.constant);
145 if (value != null) { 142 if (value != null) {
146 info.initializer = _constantToInfo[value]; 143 info.initializer = _constantToInfo[value];
147 } 144 }
148 } 145 }
149 146
147 if (JavaScriptBackend.TRACE_METHOD == 'post') {
148 // We use element.hashCode because it is globally unique and it is
149 // available while we are doing codegen.
150 info.coverageId = '${element.hashCode}';
151 }
152
150 int closureSize = _addClosureInfo(info, element); 153 int closureSize = _addClosureInfo(info, element);
151 info.size = size + closureSize; 154 info.size = size + closureSize;
152 155
153 result.fields.add(info); 156 result.fields.add(info);
154 return info; 157 return info;
155 } 158 }
156 159
157 ClassInfo visitClassElement(ClassElement element, _) { 160 ClassInfo visitClassElement(ClassElement element, _) {
158 ClassInfo classInfo = new ClassInfo( 161 ClassInfo classInfo = new ClassInfo(
159 name: element.name, 162 name: element.name,
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 } 270 }
268 String inferredReturnType = '${_resultOf(element).returnType}'; 271 String inferredReturnType = '${_resultOf(element).returnType}';
269 String sideEffects = '${closedWorld.getSideEffectsOfElement(element)}'; 272 String sideEffects = '${closedWorld.getSideEffectsOfElement(element)}';
270 273
271 int inlinedCount = compiler.dumpInfoTask.inlineCount[element]; 274 int inlinedCount = compiler.dumpInfoTask.inlineCount[element];
272 if (inlinedCount == null) inlinedCount = 0; 275 if (inlinedCount == null) inlinedCount = 0;
273 276
274 FunctionInfo info = new FunctionInfo( 277 FunctionInfo info = new FunctionInfo(
275 name: name, 278 name: name,
276 functionKind: kind, 279 functionKind: kind,
277 // We use element.hashCode because it is globally unique and it is
278 // available while we are doing codegen.
279 coverageId: '${element.hashCode}',
280 modifiers: modifiers, 280 modifiers: modifiers,
281 returnType: returnType, 281 returnType: returnType,
282 inferredReturnType: inferredReturnType, 282 inferredReturnType: inferredReturnType,
283 parameters: parameters, 283 parameters: parameters,
284 sideEffects: sideEffects, 284 sideEffects: sideEffects,
285 inlinedCount: inlinedCount, 285 inlinedCount: inlinedCount,
286 code: code, 286 code: code,
287 type: element.type.toString(), 287 type: element.type.toString(),
288 outputUnit: _unitInfoForElement(element)); 288 outputUnit: _unitInfoForElement(element));
289 _elementToInfo[element] = info; 289 _elementToInfo[element] = info;
290 290
291 if (element is MemberElement) { 291 if (element is MemberElement) {
292 int closureSize = _addClosureInfo(info, element as MemberElement); 292 int closureSize = _addClosureInfo(info, element as MemberElement);
293 size += closureSize; 293 size += closureSize;
294 } else { 294 } else {
295 info.closures = <ClosureInfo>[]; 295 info.closures = <ClosureInfo>[];
296 } 296 }
297 297
298 if (JavaScriptBackend.TRACE_METHOD == 'post') {
299 // We use element.hashCode because it is globally unique and it is
300 // available while we are doing codegen.
301 info.coverageId = '${element.hashCode}';
302 }
303
298 info.size = size; 304 info.size = size;
299 305
300 result.functions.add(info); 306 result.functions.add(info);
301 return info; 307 return info;
302 } 308 }
303 309
304 /// Adds closure information to [info], using all nested closures in [member]. 310 /// Adds closure information to [info], using all nested closures in [member].
305 /// 311 ///
306 /// Returns the total size of the nested closures, to add to the info size. 312 /// Returns the total size of the nested closures, to add to the info size.
307 int _addClosureInfo(Info info, MemberElement member) { 313 int _addClosureInfo(Info info, MemberElement member) {
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 606
601 ChunkedConversionSink<Object> sink = encoder.startChunkedConversion( 607 ChunkedConversionSink<Object> sink = encoder.startChunkedConversion(
602 new StringConversionSink.fromStringSink(buffer)); 608 new StringConversionSink.fromStringSink(buffer));
603 sink.add(new AllInfoJsonCodec().encode(result)); 609 sink.add(new AllInfoJsonCodec().encode(result));
604 compiler.reporter.reportInfo(NO_LOCATION_SPANNABLE, MessageKind.GENERIC, { 610 compiler.reporter.reportInfo(NO_LOCATION_SPANNABLE, MessageKind.GENERIC, {
605 'text': "View the dumped .info.json file at " 611 'text': "View the dumped .info.json file at "
606 "https://dart-lang.github.io/dump-info-visualizer" 612 "https://dart-lang.github.io/dump-info-visualizer"
607 }); 613 });
608 } 614 }
609 } 615 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698