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

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

Issue 1617083002: Base JavaScript code position computation on JavaScript tracer. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments Created 4 years, 11 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 ChunkedConversionSink, 8 ChunkedConversionSink,
9 HtmlEscape, 9 HtmlEscape,
10 JsonEncoder, 10 JsonEncoder,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 final Map<Element, Info> _elementToInfo = <Element, Info>{}; 47 final Map<Element, Info> _elementToInfo = <Element, Info>{};
48 final Map<ConstantValue, Info> _constantToInfo = <ConstantValue, Info>{}; 48 final Map<ConstantValue, Info> _constantToInfo = <ConstantValue, Info>{};
49 final Map<OutputUnit, OutputUnitInfo> _outputToInfo = {}; 49 final Map<OutputUnit, OutputUnitInfo> _outputToInfo = {};
50 50
51 ElementInfoCollector(this.compiler); 51 ElementInfoCollector(this.compiler);
52 52
53 void run() { 53 void run() {
54 compiler.dumpInfoTask._constantToNode.forEach((constant, node) { 54 compiler.dumpInfoTask._constantToNode.forEach((constant, node) {
55 // TODO(sigmund): add dependencies on other constants 55 // TODO(sigmund): add dependencies on other constants
56 var size = compiler.dumpInfoTask._nodeToSize[node]; 56 var size = compiler.dumpInfoTask._nodeToSize[node];
57 var code = jsAst.prettyPrint(node, compiler).getText(); 57 var code = jsAst.prettyPrint(node, compiler);
58 var info = new ConstantInfo( 58 var info = new ConstantInfo(
59 size: size, code: code, outputUnit: _unitInfoForConstant(constant)); 59 size: size, code: code, outputUnit: _unitInfoForConstant(constant));
60 _constantToInfo[constant] = info; 60 _constantToInfo[constant] = info;
61 result.constants.add(info); 61 result.constants.add(info);
62 }); 62 });
63 compiler.libraryLoader.libraries.forEach(visit); 63 compiler.libraryLoader.libraries.forEach(visit);
64 } 64 }
65 65
66 Info visit(Element e, [_]) => e.accept(this, null); 66 Info visit(Element e, [_]) => e.accept(this, null);
67 67
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 var size = _nodeToSize[node]; 522 var size = _nodeToSize[node];
523 return size == null ? 0 : size; 523 return size == null ? 0 : size;
524 } 524 }
525 525
526 String codeOf(Element element) { 526 String codeOf(Element element) {
527 List<jsAst.Node> code = _elementToNodes[element]; 527 List<jsAst.Node> code = _elementToNodes[element];
528 if (code == null) return null; 528 if (code == null) return null;
529 // Concatenate rendered ASTs. 529 // Concatenate rendered ASTs.
530 StringBuffer sb = new StringBuffer(); 530 StringBuffer sb = new StringBuffer();
531 for (jsAst.Node ast in code) { 531 for (jsAst.Node ast in code) {
532 sb.writeln(jsAst.prettyPrint(ast, compiler).getText()); 532 sb.writeln(jsAst.prettyPrint(ast, compiler));
533 } 533 }
534 return sb.toString(); 534 return sb.toString();
535 } 535 }
536 536
537 void dumpInfo() { 537 void dumpInfo() {
538 measure(() { 538 measure(() {
539 infoCollector = new ElementInfoCollector(compiler)..run(); 539 infoCollector = new ElementInfoCollector(compiler)..run();
540 StringBuffer jsonBuffer = new StringBuffer(); 540 StringBuffer jsonBuffer = new StringBuffer();
541 dumpInfoJson(jsonBuffer); 541 dumpInfoJson(jsonBuffer);
542 compiler.outputProvider('', 'info.json') 542 compiler.outputProvider('', 'info.json')
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 604
605 ChunkedConversionSink<Object> sink = encoder.startChunkedConversion( 605 ChunkedConversionSink<Object> sink = encoder.startChunkedConversion(
606 new StringConversionSink.fromStringSink(buffer)); 606 new StringConversionSink.fromStringSink(buffer));
607 sink.add(new AllInfoJsonCodec().encode(result)); 607 sink.add(new AllInfoJsonCodec().encode(result));
608 reporter.reportInfo(NO_LOCATION_SPANNABLE, MessageKind.GENERIC, { 608 reporter.reportInfo(NO_LOCATION_SPANNABLE, MessageKind.GENERIC, {
609 'text': "View the dumped .info.json file at " 609 'text': "View the dumped .info.json file at "
610 "https://dart-lang.github.io/dump-info-visualizer" 610 "https://dart-lang.github.io/dump-info-visualizer"
611 }); 611 });
612 } 612 }
613 } 613 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698