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

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

Issue 1153243003: dart2js: Use frequency of occurence to sort metadata indices. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Addressed sra's comments Created 5 years, 6 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
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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 // A set of javascript AST nodes that we care about the size of. 407 // A set of javascript AST nodes that we care about the size of.
408 // This set is automatically populated when registerElementAst() 408 // This set is automatically populated when registerElementAst()
409 // is called. 409 // is called.
410 final Set<jsAst.Node> _tracking = new Set<jsAst.Node>(); 410 final Set<jsAst.Node> _tracking = new Set<jsAst.Node>();
411 // A mapping from Dart Elements to Javascript AST Nodes. 411 // A mapping from Dart Elements to Javascript AST Nodes.
412 final Map<Element, List<jsAst.Node>> _elementToNodes = 412 final Map<Element, List<jsAst.Node>> _elementToNodes =
413 <Element, List<jsAst.Node>>{}; 413 <Element, List<jsAst.Node>>{};
414 // A mapping from Javascript AST Nodes to the size of their 414 // A mapping from Javascript AST Nodes to the size of their
415 // pretty-printed contents. 415 // pretty-printed contents.
416 final Map<jsAst.Node, int> _nodeToSize = <jsAst.Node, int>{}; 416 final Map<jsAst.Node, int> _nodeToSize = <jsAst.Node, int>{};
417 final Map<Element, int> _fieldNameToSize = <Element, int>{};
418 417
419 final Map<Element, Set<Selector>> selectorsFromElement = {}; 418 final Map<Element, Set<Selector>> selectorsFromElement = {};
420 final Map<Element, int> inlineCount = <Element, int>{}; 419 final Map<Element, int> inlineCount = <Element, int>{};
421 // A mapping from an element to a list of elements that are 420 // A mapping from an element to a list of elements that are
422 // inlined inside of it. 421 // inlined inside of it.
423 final Map<Element, List<Element>> inlineMap = <Element, List<Element>>{}; 422 final Map<Element, List<Element>> inlineMap = <Element, List<Element>>{};
424 423
425 /// Register the size of the generated output. 424 /// Register the size of the generated output.
426 void reportSize(int programSize) { 425 void reportSize(int programSize) {
427 _programSize = programSize; 426 _programSize = programSize;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 486
488 // Records the size of a dart AST node after it has been 487 // Records the size of a dart AST node after it has been
489 // pretty-printed into the output buffer. 488 // pretty-printed into the output buffer.
490 void recordAstSize(jsAst.Node node, int size) { 489 void recordAstSize(jsAst.Node node, int size) {
491 if (isTracking(node)) { 490 if (isTracking(node)) {
492 //TODO: should I be incrementing here instead? 491 //TODO: should I be incrementing here instead?
493 _nodeToSize[node] = size; 492 _nodeToSize[node] = size;
494 } 493 }
495 } 494 }
496 495
497 // Field names are treated differently by the dart compiler
498 // so they must be recorded seperately.
499 void recordFieldNameSize(Element element, int size) {
500 _fieldNameToSize[element] = size;
501 }
502
503 // Returns the size of the source code that 496 // Returns the size of the source code that
504 // was generated for an element. If no source 497 // was generated for an element. If no source
505 // code was produced, return 0. 498 // code was produced, return 0.
506 int sizeOf(Element element) { 499 int sizeOf(Element element) {
507 if (_fieldNameToSize.containsKey(element)) {
508 return _fieldNameToSize[element];
509 }
510 if (_elementToNodes.containsKey(element)) { 500 if (_elementToNodes.containsKey(element)) {
511 return _elementToNodes[element] 501 return _elementToNodes[element]
512 .map(sizeOfNode) 502 .map(sizeOfNode)
513 .fold(0, (a, b) => a + b); 503 .fold(0, (a, b) => a + b);
514 } else { 504 } else {
515 return 0; 505 return 0;
516 } 506 }
517 } 507 }
518 508
519 int sizeOfNode(jsAst.Node node) { 509 int sizeOfNode(jsAst.Node node) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 ChunkedConversionSink<Object> sink = 632 ChunkedConversionSink<Object> sink =
643 encoder.startChunkedConversion( 633 encoder.startChunkedConversion(
644 new StringConversionSink.fromStringSink(buffer)); 634 new StringConversionSink.fromStringSink(buffer));
645 sink.add(outJson); 635 sink.add(outJson);
646 compiler.reportInfo(NO_LOCATION_SPANNABLE, 636 compiler.reportInfo(NO_LOCATION_SPANNABLE,
647 const MessageKind( 637 const MessageKind(
648 "View the dumped .info.json file at " 638 "View the dumped .info.json file at "
649 "https://dart-lang.github.io/dump-info-visualizer")); 639 "https://dart-lang.github.io/dump-info-visualizer"));
650 } 640 }
651 } 641 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/type_propagation.dart ('k') | pkg/compiler/lib/src/js/rewrite_async.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698