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

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

Issue 1467733002: Revert "Remove WorldImpact from caches when no longer needed." (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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 | « pkg/compiler/lib/src/deferred_load.dart ('k') | pkg/compiler/lib/src/enqueue.dart » ('j') | 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' show 7 import 'dart:convert'
8 ChunkedConversionSink, 8 show HtmlEscape, JsonEncoder, StringConversionSink, ChunkedConversionSink;
9 HtmlEscape,
10 JsonEncoder,
11 StringConversionSink;
12 9
13 import 'package:dart2js_info/info.dart'; 10 import 'package:dart2js_info/info.dart';
14 11
15 import 'common.dart'; 12 import 'common.dart';
16 import 'common/tasks.dart' show 13 import 'common/tasks.dart' show CompilerTask;
17 CompilerTask; 14 import 'constants/values.dart' show ConstantValue, InterceptorConstantValue;
18 import 'constants/values.dart' show 15 import 'compiler.dart' show Compiler;
19 ConstantValue,
20 InterceptorConstantValue;
21 import 'compiler.dart' show
22 Compiler;
23 import 'deferred_load.dart' show
24 OutputUnit;
25 import 'elements/elements.dart'; 16 import 'elements/elements.dart';
26 import 'elements/visitor.dart'; 17 import 'elements/visitor.dart';
27 import 'info/send_info.dart' show 18 import 'types/types.dart' show TypeMask;
28 collectSendMeasurements; 19 import 'deferred_load.dart' show OutputUnit;
29 import 'js_backend/js_backend.dart' show 20 import 'js_backend/js_backend.dart' show JavaScriptBackend;
30 JavaScriptBackend; 21 import 'js_emitter/full_emitter/emitter.dart' as full show Emitter;
31 import 'js_emitter/full_emitter/emitter.dart' as full show
32 Emitter;
33 import 'js/js.dart' as jsAst; 22 import 'js/js.dart' as jsAst;
34 import 'types/types.dart' show 23 import 'universe/universe.dart' show ReceiverConstraint;
35 TypeMask; 24 import 'universe/world_impact.dart' show WorldImpact;
36 import 'universe/universe.dart' show 25 import 'info/send_info.dart' show collectSendMeasurements;
37 ReceiverConstraint;
38 import 'universe/world_impact.dart' show
39 ImpactUseCase,
40 WorldImpact,
41 WorldImpactVisitorImpl;
42 26
43 class ElementInfoCollector extends BaseElementVisitor<Info, dynamic> { 27 class ElementInfoCollector extends BaseElementVisitor<Info, dynamic> {
44 final Compiler compiler; 28 final Compiler compiler;
45 29
46 final AllInfo result = new AllInfo(); 30 final AllInfo result = new AllInfo();
47 final Map<Element, Info> _elementToInfo = <Element, Info>{}; 31 final Map<Element, Info> _elementToInfo = <Element, Info>{};
48 final Map<ConstantValue, Info> _constantToInfo = <ConstantValue, Info>{}; 32 final Map<ConstantValue, Info> _constantToInfo = <ConstantValue, Info>{};
49 final Map<OutputUnit, OutputUnitInfo> _outputToInfo = {}; 33 final Map<OutputUnit, OutputUnitInfo> _outputToInfo = {};
50 34
51 ElementInfoCollector(this.compiler); 35 ElementInfoCollector(this.compiler);
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 /// we can emit them in the dump-info task. 359 /// we can emit them in the dump-info task.
376 // TODO(sigmund,het): move more features here. Ideally the dump-info task 360 // TODO(sigmund,het): move more features here. Ideally the dump-info task
377 // shouldn't reach into internals of other parts of the compiler. For example, 361 // shouldn't reach into internals of other parts of the compiler. For example,
378 // we currently reach into the full emitter and as a result we don't support 362 // we currently reach into the full emitter and as a result we don't support
379 // dump-info when using the startup-emitter (issue #24190). 363 // dump-info when using the startup-emitter (issue #24190).
380 abstract class InfoReporter { 364 abstract class InfoReporter {
381 void reportInlined(Element element, Element inlinedFrom); 365 void reportInlined(Element element, Element inlinedFrom);
382 } 366 }
383 367
384 class DumpInfoTask extends CompilerTask implements InfoReporter { 368 class DumpInfoTask extends CompilerTask implements InfoReporter {
385 static const ImpactUseCase IMPACT_USE = const ImpactUseCase('Dump info');
386
387 DumpInfoTask(Compiler compiler) : super(compiler); 369 DumpInfoTask(Compiler compiler) : super(compiler);
388 370
389 String get name => "Dump Info"; 371 String get name => "Dump Info";
390 372
391 ElementInfoCollector infoCollector; 373 ElementInfoCollector infoCollector;
392 374
393 /// The size of the generated output. 375 /// The size of the generated output.
394 int _programSize; 376 int _programSize;
395 377
396 // A set of javascript AST nodes that we care about the size of. 378 // A set of javascript AST nodes that we care about the size of.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 void registerDependency(Element source, Element target) { 411 void registerDependency(Element source, Element target) {
430 _dependencies.putIfAbsent(source, () => new Set()).add(target); 412 _dependencies.putIfAbsent(source, () => new Set()).add(target);
431 } 413 }
432 414
433 void registerImpact(Element element, WorldImpact impact) { 415 void registerImpact(Element element, WorldImpact impact) {
434 if (compiler.dumpInfo) { 416 if (compiler.dumpInfo) {
435 impacts[element] = impact; 417 impacts[element] = impact;
436 } 418 }
437 } 419 }
438 420
439 void unregisterImpact(Element element) {
440 impacts.remove(element);
441 }
442
443 /** 421 /**
444 * Returns an iterable of [Selection]s that are used by 422 * Returns an iterable of [Selection]s that are used by
445 * [element]. Each [Selection] contains an element that is 423 * [element]. Each [Selection] contains an element that is
446 * used and the selector that selected the element. 424 * used and the selector that selected the element.
447 */ 425 */
448 Iterable<Selection> getRetaining(Element element) { 426 Iterable<Selection> getRetaining(Element element) {
449 WorldImpact impact = impacts[element]; 427 var impact = impacts[element];
450 if (impact == null) return const <Selection>[]; 428 if (impact == null) return const <Selection>[];
451 429
452 var selections = <Selection>[]; 430 var selections = <Selection>[];
453 compiler.impactStrategy.visitImpact( 431 selections.addAll(impact.dynamicUses.expand((dynamicUse) {
454 element, 432 return compiler.world.allFunctions
455 impact, 433 .filter(dynamicUse.selector, dynamicUse.mask)
456 new WorldImpactVisitorImpl( 434 .map((e) => new Selection(e, dynamicUse.mask));
457 visitDynamicUse: (dynamicUse) { 435 }));
458 selections.addAll(compiler.world.allFunctions 436 selections.addAll(impact.staticUses
459 .filter(dynamicUse.selector, dynamicUse.mask) 437 .map((staticUse) => new Selection(staticUse.element, null)));
460 .map((e) => new Selection(e, dynamicUse.mask)));
461 },
462 visitStaticUse: (staticUse) {
463 selections.add(new Selection(staticUse.element, null));
464 }
465 ),
466 IMPACT_USE);
467 return selections; 438 return selections;
468 } 439 }
469 440
470 // Returns true if we care about tracking the size of 441 // Returns true if we care about tracking the size of
471 // this node. 442 // this node.
472 bool isTracking(jsAst.Node code) { 443 bool isTracking(jsAst.Node code) {
473 if (compiler.dumpInfo) { 444 if (compiler.dumpInfo) {
474 return _tracking.contains(code); 445 return _tracking.contains(code);
475 } else { 446 } else {
476 return false; 447 return false;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 573
603 ChunkedConversionSink<Object> sink = encoder.startChunkedConversion( 574 ChunkedConversionSink<Object> sink = encoder.startChunkedConversion(
604 new StringConversionSink.fromStringSink(buffer)); 575 new StringConversionSink.fromStringSink(buffer));
605 sink.add(new AllInfoJsonCodec().encode(result)); 576 sink.add(new AllInfoJsonCodec().encode(result));
606 reporter.reportInfo(NO_LOCATION_SPANNABLE, MessageKind.GENERIC, { 577 reporter.reportInfo(NO_LOCATION_SPANNABLE, MessageKind.GENERIC, {
607 'text': "View the dumped .info.json file at " 578 'text': "View the dumped .info.json file at "
608 "https://dart-lang.github.io/dump-info-visualizer" 579 "https://dart-lang.github.io/dump-info-visualizer"
609 }); 580 });
610 } 581 }
611 } 582 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/deferred_load.dart ('k') | pkg/compiler/lib/src/enqueue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698