Chromium Code Reviews| Index: pkg/compiler/lib/src/dump_info.dart |
| diff --git a/pkg/compiler/lib/src/dump_info.dart b/pkg/compiler/lib/src/dump_info.dart |
| index 0d305d15e150981f220a143669387dd2fca19b51..ab1ab4952ed101d0207d994c8110e1428225ec99 100644 |
| --- a/pkg/compiler/lib/src/dump_info.dart |
| +++ b/pkg/compiler/lib/src/dump_info.dart |
| @@ -10,24 +10,17 @@ import 'dart:convert' |
| import 'package:dart2js_info/info.dart'; |
| import 'common.dart'; |
| -import 'common/tasks.dart' show |
| - CompilerTask; |
| -import 'constants/values.dart' show ConstantValue; |
| -import 'compiler.dart' show |
| - Compiler; |
| +import 'common/tasks.dart' show CompilerTask; |
| +import 'constants/values.dart' show ConstantValue, InterceptorConstantValue; |
| +import 'compiler.dart' show Compiler; |
| import 'elements/elements.dart'; |
| import 'elements/visitor.dart'; |
| -import 'types/types.dart' show |
| - TypeMask; |
| -import 'deferred_load.dart' show |
| - OutputUnit; |
| -import 'js_backend/js_backend.dart' show |
| - JavaScriptBackend; |
| -import 'js_emitter/full_emitter/emitter.dart' as full show |
| - Emitter; |
| +import 'types/types.dart' show TypeMask; |
| +import 'deferred_load.dart' show OutputUnit; |
| +import 'js_backend/js_backend.dart' show JavaScriptBackend; |
| +import 'js_emitter/full_emitter/emitter.dart' as full show Emitter; |
| import 'js/js.dart' as jsAst; |
| -import 'universe/universe.dart' show |
| - UniverseSelector; |
| +import 'universe/universe.dart' show UniverseSelector; |
| import 'info/send_info.dart' show collectSendMeasurements; |
| class ElementInfoCollector extends BaseElementVisitor<Info, dynamic> { |
| @@ -45,10 +38,10 @@ class ElementInfoCollector extends BaseElementVisitor<Info, dynamic> { |
| // TODO(sigmund): add dependencies on other constants |
| var size = compiler.dumpInfoTask._nodeToSize[node]; |
| var code = jsAst.prettyPrint(node, compiler).getText(); |
| - var info = new ConstantInfo(size: size, code: code); |
| + var info = new ConstantInfo( |
| + size: size, code: code, outputUnit: _unitInfoForConstant(constant)); |
| _constantToInfo[constant] = info; |
| result.constants.add(info); |
| - |
| }); |
| compiler.libraryLoader.libraries.forEach(visit); |
| } |
| @@ -82,7 +75,7 @@ class ElementInfoCollector extends BaseElementVisitor<Info, dynamic> { |
| String libname = element.hasLibraryName ? element.libraryName : "<unnamed>"; |
| int size = compiler.dumpInfoTask.sizeOf(element); |
| LibraryInfo info = |
| - new LibraryInfo(libname, element.canonicalUri, null, size); |
| + new LibraryInfo(libname, element.canonicalUri, null, size); |
| _elementToInfo[element] = info; |
| LibraryElement realElement = element.isPatched ? element.patch : element; |
| @@ -113,8 +106,8 @@ class ElementInfoCollector extends BaseElementVisitor<Info, dynamic> { |
| TypedefInfo visitTypedefElement(TypedefElement element, _) { |
| if (!element.isResolved) return null; |
| - TypedefInfo info = new TypedefInfo(element.name, '${element.alias}', |
| - _unitInfoForElement(element)); |
| + TypedefInfo info = new TypedefInfo( |
| + element.name, '${element.alias}', _unitInfoForElement(element)); |
| _elementToInfo[element] = info; |
| result.typedefs.add(info); |
| return info; |
| @@ -284,6 +277,7 @@ class ElementInfoCollector extends BaseElementVisitor<Info, dynamic> { |
| FunctionInfo info = new FunctionInfo( |
| name: name, |
| + functionKind: kind, |
| // We use element.hashCode because it is globally unique and it is |
| // available while we are doing codegen. |
| coverageId: '${element.hashCode}', |
| @@ -325,7 +319,26 @@ class ElementInfoCollector extends BaseElementVisitor<Info, dynamic> { |
| OutputUnitInfo _unitInfoForElement(Element element) { |
| OutputUnit outputUnit = |
| - compiler.deferredLoadTask.outputUnitForElement(element); |
| + compiler.deferredLoadTask.outputUnitForElement(element); |
| + return _outputToInfo.putIfAbsent(outputUnit, () { |
| + // Dump-info currently only works with the full emitter. If another |
| + // emitter is used it will fail here. |
| + JavaScriptBackend backend = compiler.backend; |
| + full.Emitter emitter = backend.emitter.emitter; |
| + OutputUnitInfo info = new OutputUnitInfo( |
| + outputUnit.name, emitter.outputBuffers[outputUnit].length); |
| + result.outputUnits.add(info); |
| + return info; |
| + }); |
| + } |
| + |
| + OutputUnitInfo _unitInfoForConstant(ConstantValue constant) { |
| + OutputUnit outputUnit = |
| + compiler.deferredLoadTask.outputUnitForConstant(constant); |
| + if (outputUnit == null) { |
| + assert(constant is InterceptorConstantValue); |
| + return null; |
| + } |
| return _outputToInfo.putIfAbsent(outputUnit, () { |
|
Siggi Cherem (dart-lang)
2015/11/03 02:30:18
nit: let's factor out this common part of the code
Harry Terkelsen
2015/11/03 02:43:34
Done.
|
| // Dump-info currently only works with the full emitter. If another |
| // emitter is used it will fail here. |
| @@ -547,9 +560,9 @@ class DumpInfoTask extends CompilerTask implements InfoReporter { |
| var a = infoCollector._elementToInfo[element]; |
| if (a == null) continue; |
| result.dependencies[a] = _dependencies[element] |
| - .map((o) => infoCollector._elementToInfo[o]) |
| - .where((o) => o != null) |
| - .toList(); |
| + .map((o) => infoCollector._elementToInfo[o]) |
| + .where((o) => o != null) |
| + .toList(); |
| } |
| result.deferredFiles = compiler.deferredLoadTask.computeDeferredMap(); |