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

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

Issue 1279093003: dart2js: dump info about dependencies added by the enqueuer (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « pkg/compiler/lib/src/enqueue.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 /// Data collected by the dump-info task. 5 /// Data collected by the dump-info task.
6 library compiler.src.lib.info; 6 library compiler.src.lib.info;
7 7
8 // Note: this file intentionally doesn't import anything from the compiler. That 8 // Note: this file intentionally doesn't import anything from the compiler. That
9 // should make it easier for tools to depend on this library. The idea is that 9 // should make it easier for tools to depend on this library. The idea is that
10 // by using this library, tools can consume the information in the same way it 10 // by using this library, tools can consume the information in the same way it
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 /// Information about output units (should be just one entry if not using 112 /// Information about output units (should be just one entry if not using
113 /// deferred loading). 113 /// deferred loading).
114 List<OutputUnitInfo> outputUnits = <OutputUnitInfo>[]; 114 List<OutputUnitInfo> outputUnits = <OutputUnitInfo>[];
115 115
116 /// Details about all deferred imports and what files would be loaded when the 116 /// Details about all deferred imports and what files would be loaded when the
117 /// import is resolved. 117 /// import is resolved.
118 // TODO(sigmund): use a different format for dump-info. This currently emits 118 // TODO(sigmund): use a different format for dump-info. This currently emits
119 // the same map that is created for the `--deferred-map` flag. 119 // the same map that is created for the `--deferred-map` flag.
120 Map<String, Map<String, dynamic>> deferredFiles; 120 Map<String, Map<String, dynamic>> deferredFiles;
121 121
122 /// A new representation of dependencies form one info to another. An entry in
123 /// this map indicates that an Info depends on another (e.g. a function
124 /// invokes another). Please note that the data in this field might not be
125 /// accurate yet (this is work in progress).
126 Map<Info, List<Info>> dependencies = {};
127
122 /// Major version indicating breaking changes in the format. A new version 128 /// Major version indicating breaking changes in the format. A new version
123 /// means that an old deserialization algorithm will not work with the new 129 /// means that an old deserialization algorithm will not work with the new
124 /// format. 130 /// format.
125 final int version = 3; 131 final int version = 3;
126 132
127 /// Minor version indicating non-breaking changes in the format. A change in 133 /// Minor version indicating non-breaking changes in the format. A change in
128 /// this version number means that the json parsing in this library from a 134 /// this version number means that the json parsing in this library from a
129 /// previous will continue to work after the change. This is typically 135 /// previous will continue to work after the change. This is typically
130 /// increased when adding new entries to the file format. 136 /// increased when adding new entries to the file format.
131 // Note: the dump-info.viewer app was written using a json parser version 3.2. 137 // Note: the dump-info.viewer app was written using a json parser version 3.2.
132 final int minorVersion = 4; 138 final int minorVersion = 5;
133 139
134 AllInfo(); 140 AllInfo();
135 141
136 static AllInfo parseFromJson(Map map) => new _ParseHelper().parseAll(map); 142 static AllInfo parseFromJson(Map map) => new _ParseHelper().parseAll(map);
137 143
138 Map _listAsJsonMap(List<Info> list) { 144 Map _listAsJsonMap(List<Info> list) {
139 var map = <String, Map>{}; 145 var map = <String, Map>{};
140 for (var info in list) { 146 for (var info in list) {
141 map['${info.id}'] = info.toJson(); 147 map['${info.id}'] = info.toJson();
142 } 148 }
143 return map; 149 return map;
144 } 150 }
145 151
146 Map _extractHoldingInfo() { 152 Map _extractHoldingInfo() {
147 var map = <String, List>{}; 153 var map = <String, List>{};
148 void helper(CodeInfo info) { 154 void helper(CodeInfo info) {
149 if (info.uses.isEmpty) return; 155 if (info.uses.isEmpty) return;
150 map[info.serializedId] = info.uses.map((u) => u.toJson()).toList(); 156 map[info.serializedId] = info.uses.map((u) => u.toJson()).toList();
151 } 157 }
152 functions.forEach(helper); 158 functions.forEach(helper);
153 fields.forEach(helper); 159 fields.forEach(helper);
154 return map; 160 return map;
155 } 161 }
156 162
163 Map _extractDependencies() {
164 var map = <String, List>{};
165 dependencies.forEach((k, v) {
166 map[k.serializedId] = v.map((i) => i.serializedId).toList();
167 });
168 return map;
169 }
170
157 Map toJson() => { 171 Map toJson() => {
158 'elements': { 172 'elements': {
159 'library': _listAsJsonMap(libraries), 173 'library': _listAsJsonMap(libraries),
160 'class': _listAsJsonMap(classes), 174 'class': _listAsJsonMap(classes),
161 'function': _listAsJsonMap(functions), 175 'function': _listAsJsonMap(functions),
162 'typedef': _listAsJsonMap(typedefs), 176 'typedef': _listAsJsonMap(typedefs),
163 'field': _listAsJsonMap(fields), 177 'field': _listAsJsonMap(fields),
164 }, 178 },
165 'holding': _extractHoldingInfo(), 179 'holding': _extractHoldingInfo(),
180 'dependencies': _extractDependencies(),
166 'outputUnits': outputUnits.map((u) => u.toJson()).toList(), 181 'outputUnits': outputUnits.map((u) => u.toJson()).toList(),
167 'dump_version': version, 182 'dump_version': version,
168 'deferredFiles': deferredFiles, 183 'deferredFiles': deferredFiles,
169 'dump_minor_version': '$minorVersion', 184 'dump_minor_version': '$minorVersion',
170 // TODO(sigmund): change viewer to accept an int? 185 // TODO(sigmund): change viewer to accept an int?
171 'program': program.toJson(), 186 'program': program.toJson(),
172 }; 187 };
173 188
174 void accept(InfoVisitor visitor) => visitor.visitAll(this); 189 void accept(InfoVisitor visitor) => visitor.visitAll(this);
175 } 190 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 json['holding'].forEach((k, deps) { 248 json['holding'].forEach((k, deps) {
234 var src = idMap[k]; 249 var src = idMap[k];
235 assert (src != null); 250 assert (src != null);
236 for (var dep in deps) { 251 for (var dep in deps) {
237 var target = idMap[dep['id']]; 252 var target = idMap[dep['id']];
238 assert (target != null); 253 assert (target != null);
239 src.uses.add(new DependencyInfo(target, dep['mask'])); 254 src.uses.add(new DependencyInfo(target, dep['mask']));
240 } 255 }
241 }); 256 });
242 257
258 json['dependencies']?.forEach((k, deps) {
259 result.deps[idMap[k]] = deps.map((d) => idMap[d]).toList();
260 });
261
243 result.program = parseProgram(json['program']); 262 result.program = parseProgram(json['program']);
244 // todo: version, etc 263 // todo: version, etc
245 return result; 264 return result;
246 } 265 }
247 266
248 LibraryInfo parseLibrary(Map json) { 267 LibraryInfo parseLibrary(Map json) {
249 LibraryInfo result = parseId(json['id']); 268 LibraryInfo result = parseId(json['id']);
250 result..name = json['name'] 269 result..name = json['name']
251 ..uri = Uri.parse(json['canonicalUri']) 270 ..uri = Uri.parse(json['canonicalUri'])
252 ..outputUnit = parseId(json['outputUnit']) 271 ..outputUnit = parseId(json['outputUnit'])
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 } 724 }
706 725
707 visitField(FieldInfo info) { 726 visitField(FieldInfo info) {
708 info.closures.forEach(visitFunction); 727 info.closures.forEach(visitFunction);
709 } 728 }
710 729
711 visitFunction(FunctionInfo info) { 730 visitFunction(FunctionInfo info) {
712 info.closures.forEach(visitFunction); 731 info.closures.forEach(visitFunction);
713 } 732 }
714 } 733 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/enqueue.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698