| Index: lib/info.dart
|
| diff --git a/lib/info.dart b/lib/info.dart
|
| index 40cefe2f15c2c9145c4de88994957293afa10f9d..0c07c1bb35034c86a2564647921858f31bb98585 100644
|
| --- a/lib/info.dart
|
| +++ b/lib/info.dart
|
| @@ -5,8 +5,12 @@
|
| /// Data produced by dart2js when run with the `--dump-info` flag.
|
| library dart2js_info.info;
|
|
|
| +import 'src/measurements.dart';
|
| +export 'src/measurements.dart';
|
| +
|
| /// Common interface to many pieces of information generated by the dart2js
|
| -/// compiler.
|
| +/// compiler that are directly associated with an element (compilation unit,
|
| +/// library, class, function, or field).
|
| abstract class Info {
|
| /// An identifier for the kind of information.
|
| InfoKind get kind;
|
| @@ -369,12 +373,34 @@ class _ParseHelper {
|
| ..code = json['code']
|
| ..sideEffects = json['sideEffects']
|
| ..modifiers = parseModifiers(json['modifiers'])
|
| - ..closures = json['children'].map(parseId).toList();
|
| + ..closures = json['children'].map(parseId).toList()
|
| + ..measurements = parseMeasurements(json['measurements']);
|
| }
|
|
|
| ParameterInfo parseParameter(Map json) =>
|
| new ParameterInfo(json['name'], json['type'], json['declaredType']);
|
|
|
| + Measurements parseMeasurements(Map json) {
|
| + if (json == null) return null;
|
| + var uri = json['sourceFile'];
|
| + var res = new Measurements(uri == null ? null : Uri.parse(uri));
|
| + for (var key in json.keys) {
|
| + var value = json[key];
|
| + if (value == null) continue;
|
| + if (key == 'entries') {
|
| + value.forEach((metricName, entries) {
|
| + var metric = Metric.fromJson(metricName);
|
| + for (var i = 0; i < entries.length; i += 2) {
|
| + res.record(metric, entries[i], entries[i + 1]);
|
| + }
|
| + });
|
| + } else {
|
| + res.counters[Metric.fromJson(key)] = value;
|
| + }
|
| + }
|
| + return res;
|
| + }
|
| +
|
| FunctionModifiers parseModifiers(Map<String, bool> json) {
|
| return new FunctionModifiers(
|
| isStatic: json['static'] == true,
|
| @@ -422,6 +448,10 @@ class LibraryInfo extends BasicInfo {
|
| /// Typedefs defined within the library.
|
| final List<TypedefInfo> typedefs = <TypedefInfo>[];
|
|
|
| + // TODO(sigmund): add here a list of parts. That can help us improve how we
|
| + // encode source-span information in metrics (rather than include the uri on
|
| + // each function, include an index into this list).
|
| +
|
| static int _id = 0;
|
|
|
| /// Whether there is any information recorded for this library.
|
| @@ -618,6 +648,9 @@ class FunctionInfo extends BasicInfo with CodeInfo {
|
| /// The actual generated code.
|
| String code;
|
|
|
| + /// Measurements collected for this function.
|
| + Measurements measurements;
|
| +
|
| FunctionInfo(
|
| {String name,
|
| String coverageId,
|
| @@ -632,7 +665,8 @@ class FunctionInfo extends BasicInfo with CodeInfo {
|
| this.parameters,
|
| this.sideEffects,
|
| this.inlinedCount,
|
| - this.code})
|
| + this.code,
|
| + this.measurements})
|
| : super(InfoKind.function, _ids++, name, outputUnit, size, coverageId);
|
|
|
| FunctionInfo._(String serializedId) : super._fromId(serializedId);
|
| @@ -648,6 +682,7 @@ class FunctionInfo extends BasicInfo with CodeInfo {
|
| 'inlinedCount': inlinedCount,
|
| 'code': code,
|
| 'type': type,
|
| + 'measurements': measurements?.toJson(),
|
| // Note: version 3.2 of dump-info serializes `uses` in a section called
|
| // `holding` at the top-level.
|
| });
|
|
|