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

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

Issue 1408383006: Rename UniverseSelector to DynamicUse and move it to use.dart (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
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 HtmlEscape, JsonEncoder, StringConversionSink, ChunkedConversionSink; 8 show HtmlEscape, JsonEncoder, StringConversionSink, ChunkedConversionSink;
9 9
10 import 'package:dart2js_info/info.dart'; 10 import 'package:dart2js_info/info.dart';
11 11
12 import 'common.dart'; 12 import 'common.dart';
13 import 'common/tasks.dart' show 13 import 'common/tasks.dart' show
14 CompilerTask; 14 CompilerTask;
15 import 'constants/values.dart' show ConstantValue; 15 import 'constants/values.dart' show ConstantValue;
16 import 'compiler.dart' show 16 import 'compiler.dart' show
17 Compiler; 17 Compiler;
18 import 'elements/elements.dart'; 18 import 'elements/elements.dart';
19 import 'elements/visitor.dart'; 19 import 'elements/visitor.dart';
20 import 'types/types.dart' show 20 import 'types/types.dart' show
21 TypeMask; 21 TypeMask;
22 import 'deferred_load.dart' show 22 import 'deferred_load.dart' show
23 OutputUnit; 23 OutputUnit;
24 import 'js_backend/js_backend.dart' show 24 import 'js_backend/js_backend.dart' show
25 JavaScriptBackend; 25 JavaScriptBackend;
26 import 'js_emitter/full_emitter/emitter.dart' as full show 26 import 'js_emitter/full_emitter/emitter.dart' as full show
27 Emitter; 27 Emitter;
28 import 'js/js.dart' as jsAst; 28 import 'js/js.dart' as jsAst;
29 import 'universe/universe.dart' show 29 import 'universe/use.dart' show
30 UniverseSelector; 30 DynamicUse;
31 import 'info/send_info.dart' show collectSendMeasurements; 31 import 'info/send_info.dart' show collectSendMeasurements;
32 32
33 class ElementInfoCollector extends BaseElementVisitor<Info, dynamic> { 33 class ElementInfoCollector extends BaseElementVisitor<Info, dynamic> {
34 final Compiler compiler; 34 final Compiler compiler;
35 35
36 final AllInfo result = new AllInfo(); 36 final AllInfo result = new AllInfo();
37 final Map<Element, Info> _elementToInfo = <Element, Info>{}; 37 final Map<Element, Info> _elementToInfo = <Element, Info>{};
38 final Map<ConstantValue, Info> _constantToInfo = <ConstantValue, Info>{}; 38 final Map<ConstantValue, Info> _constantToInfo = <ConstantValue, Info>{};
39 final Map<OutputUnit, OutputUnitInfo> _outputToInfo = {}; 39 final Map<OutputUnit, OutputUnitInfo> _outputToInfo = {};
40 40
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 final Set<jsAst.Node> _tracking = new Set<jsAst.Node>(); 371 final Set<jsAst.Node> _tracking = new Set<jsAst.Node>();
372 // A mapping from Dart Elements to Javascript AST Nodes. 372 // A mapping from Dart Elements to Javascript AST Nodes.
373 final Map<Element, List<jsAst.Node>> _elementToNodes = 373 final Map<Element, List<jsAst.Node>> _elementToNodes =
374 <Element, List<jsAst.Node>>{}; 374 <Element, List<jsAst.Node>>{};
375 final Map<ConstantValue, jsAst.Node> _constantToNode = 375 final Map<ConstantValue, jsAst.Node> _constantToNode =
376 <ConstantValue, jsAst.Node>{}; 376 <ConstantValue, jsAst.Node>{};
377 // A mapping from Javascript AST Nodes to the size of their 377 // A mapping from Javascript AST Nodes to the size of their
378 // pretty-printed contents. 378 // pretty-printed contents.
379 final Map<jsAst.Node, int> _nodeToSize = <jsAst.Node, int>{}; 379 final Map<jsAst.Node, int> _nodeToSize = <jsAst.Node, int>{};
380 380
381 final Map<Element, Set<UniverseSelector>> selectorsFromElement = {}; 381 final Map<Element, Set<DynamicUse>> selectorsFromElement = {};
382 final Map<Element, int> inlineCount = <Element, int>{}; 382 final Map<Element, int> inlineCount = <Element, int>{};
383 // A mapping from an element to a list of elements that are 383 // A mapping from an element to a list of elements that are
384 // inlined inside of it. 384 // inlined inside of it.
385 final Map<Element, List<Element>> inlineMap = <Element, List<Element>>{}; 385 final Map<Element, List<Element>> inlineMap = <Element, List<Element>>{};
386 386
387 /// Register the size of the generated output. 387 /// Register the size of the generated output.
388 void reportSize(int programSize) { 388 void reportSize(int programSize) {
389 _programSize = programSize; 389 _programSize = programSize;
390 } 390 }
391 391
392 void reportInlined(Element element, Element inlinedFrom) { 392 void reportInlined(Element element, Element inlinedFrom) {
393 inlineCount.putIfAbsent(element, () => 0); 393 inlineCount.putIfAbsent(element, () => 0);
394 inlineCount[element] += 1; 394 inlineCount[element] += 1;
395 inlineMap.putIfAbsent(inlinedFrom, () => new List<Element>()); 395 inlineMap.putIfAbsent(inlinedFrom, () => new List<Element>());
396 inlineMap[inlinedFrom].add(element); 396 inlineMap[inlinedFrom].add(element);
397 } 397 }
398 398
399 /** 399 /**
400 * Registers that a function uses a selector in the 400 * Registers that a function uses a selector in the
401 * function body 401 * function body
402 */ 402 */
403 void elementUsesSelector(Element element, UniverseSelector selector) { 403 void elementUsesSelector(Element element, DynamicUse selector) {
404 if (compiler.dumpInfo) { 404 if (compiler.dumpInfo) {
405 selectorsFromElement 405 selectorsFromElement
406 .putIfAbsent(element, () => new Set<UniverseSelector>()) 406 .putIfAbsent(element, () => new Set<DynamicUse>())
407 .add(selector); 407 .add(selector);
408 } 408 }
409 } 409 }
410 410
411 final Map<Element, Set<Element>> _dependencies = {}; 411 final Map<Element, Set<Element>> _dependencies = {};
412 void registerDependency(Element source, Element target) { 412 void registerDependency(Element source, Element target) {
413 _dependencies.putIfAbsent(source, () => new Set()).add(target); 413 _dependencies.putIfAbsent(source, () => new Set()).add(target);
414 } 414 }
415 415
416 /** 416 /**
417 * Returns an iterable of [Selection]s that are used by 417 * Returns an iterable of [Selection]s that are used by
418 * [element]. Each [Selection] contains an element that is 418 * [element]. Each [Selection] contains an element that is
419 * used and the selector that selected the element. 419 * used and the selector that selected the element.
420 */ 420 */
421 Iterable<Selection> getRetaining(Element element) { 421 Iterable<Selection> getRetaining(Element element) {
422 if (!selectorsFromElement.containsKey(element)) { 422 if (!selectorsFromElement.containsKey(element)) {
423 return const <Selection>[]; 423 return const <Selection>[];
424 } else { 424 } else {
425 return selectorsFromElement[element].expand((UniverseSelector selector) { 425 return selectorsFromElement[element].expand((DynamicUse selector) {
426 return compiler.world.allFunctions 426 return compiler.world.allFunctions
427 .filter(selector.selector, selector.mask) 427 .filter(selector.selector, selector.mask)
428 .map((element) { 428 .map((element) {
429 return new Selection(element, selector.mask); 429 return new Selection(element, selector.mask);
430 }); 430 });
431 }); 431 });
432 } 432 }
433 } 433 }
434 434
435 // Returns true if we care about tracking the size of 435 // Returns true if we care about tracking the size of
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 567
568 ChunkedConversionSink<Object> sink = encoder.startChunkedConversion( 568 ChunkedConversionSink<Object> sink = encoder.startChunkedConversion(
569 new StringConversionSink.fromStringSink(buffer)); 569 new StringConversionSink.fromStringSink(buffer));
570 sink.add(new AllInfoJsonCodec().encode(result)); 570 sink.add(new AllInfoJsonCodec().encode(result));
571 reporter.reportInfo(NO_LOCATION_SPANNABLE, MessageKind.GENERIC, { 571 reporter.reportInfo(NO_LOCATION_SPANNABLE, MessageKind.GENERIC, {
572 'text': "View the dumped .info.json file at " 572 'text': "View the dumped .info.json file at "
573 "https://dart-lang.github.io/dump-info-visualizer" 573 "https://dart-lang.github.io/dump-info-visualizer"
574 }); 574 });
575 } 575 }
576 } 576 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698