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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/dump_info.dart

Issue 435263002: Attribute closure sizes to their containing functions and closures. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Got dartanalyzer to be quiet Created 6 years, 4 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 | Annotate | Revision Log
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' show 7 import 'dart:convert' show
8 HtmlEscape, 8 HtmlEscape,
9 JsonEncoder, 9 JsonEncoder,
10 StringConversionSink, 10 StringConversionSink,
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 232
233 // Omit element if it is not needed. 233 // Omit element if it is not needed.
234 JavaScriptBackend backend = compiler.backend; 234 JavaScriptBackend backend = compiler.backend;
235 if (!backend.emitter.neededClasses.contains(element)) return null; 235 if (!backend.emitter.neededClasses.contains(element)) return null;
236 Map<String, dynamic> modifiers = { 'abstract': element.isAbstract }; 236 Map<String, dynamic> modifiers = { 'abstract': element.isAbstract };
237 237
238 element.forEachLocalMember((Element member) { 238 element.forEachLocalMember((Element member) {
239 Map<String, dynamic> childJson = this.process(member); 239 Map<String, dynamic> childJson = this.process(member);
240 if (childJson != null) { 240 if (childJson != null) {
241 children.add(childJson['id']); 241 children.add(childJson['id']);
242
243 // Closures are placed in the library namespace, but
244 // we want to attribute them to a function, and by
245 // extension, this class. Process and add the sizes
246 // here.
247 if (member is MemberElement) {
248 for (Element closure in member.nestedClosures) {
249 Map<String, dynamic> child = this.process(closure);
250 if (child != null) {
251 size += child['size'];
252 }
253 }
254 }
242 } 255 }
243 }); 256 });
244 257
245 return { 258 return {
246 'name': element.name, 259 'name': element.name,
247 'size': size, 260 'size': size,
248 'kind': 'class', 261 'kind': 'class',
249 'modifiers': modifiers, 262 'modifiers': modifiers,
250 'children': children, 263 'children': children,
251 'id': id 264 'id': id
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 'name': parameter.name, 312 'name': parameter.name,
300 'type': compiler.typesTask 313 'type': compiler.typesTask
301 .getGuaranteedTypeOfElement(parameter).toString() 314 .getGuaranteedTypeOfElement(parameter).toString()
302 }); 315 });
303 }); 316 });
304 inferredReturnType = compiler.typesTask 317 inferredReturnType = compiler.typesTask
305 .getGuaranteedReturnTypeOfElement(element).toString(); 318 .getGuaranteedReturnTypeOfElement(element).toString();
306 sideEffects = compiler.world.getSideEffectsOfElement(element).toString(); 319 sideEffects = compiler.world.getSideEffectsOfElement(element).toString();
307 code = emittedCode.toString(); 320 code = emittedCode.toString();
308 } 321 }
309 if (element is MethodElement) { 322
310 for (Element closure in element.nestedClosures) { 323 if (element is MemberElement) {
324 for (Element closure in (element as MemberElement).nestedClosures) {
sra1 2014/08/05 23:05:37 We prefer a declaration with a type assertion: Me
311 Map<String, dynamic> child = this.process(closure); 325 Map<String, dynamic> child = this.process(closure);
312 if (child != null) { 326 if (child != null) {
313 children.add(child['id']); 327 children.add(child['id']);
314 size += child['size']; 328 size += child['size'];
315 } 329 }
316 } 330 }
317 } 331 }
318 332
319 if (size == 0 && !shouldKeep(element)) { 333 if (size == 0 && !shouldKeep(element)) {
320 return null; 334 return null;
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 }; 554 };
541 555
542 outJson['program'] = generalProgramInfo; 556 outJson['program'] = generalProgramInfo;
543 557
544 ChunkedConversionSink<Object> sink = 558 ChunkedConversionSink<Object> sink =
545 encoder.startChunkedConversion( 559 encoder.startChunkedConversion(
546 new StringConversionSink.fromStringSink(buffer)); 560 new StringConversionSink.fromStringSink(buffer));
547 sink.add(outJson); 561 sink.add(outJson);
548 } 562 }
549 } 563 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698