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

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
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 /// Information about output units (should be just one entry if not using 107 /// Information about output units (should be just one entry if not using
108 /// deferred loading). 108 /// deferred loading).
109 List<OutputUnitInfo> outputUnits = <OutputUnitInfo>[]; 109 List<OutputUnitInfo> outputUnits = <OutputUnitInfo>[];
110 110
111 /// Details about all deferred imports and what files would be loaded when the 111 /// Details about all deferred imports and what files would be loaded when the
112 /// import is resolved. 112 /// import is resolved.
113 // TODO(sigmund): use a different format for dump-info. This currently emits 113 // TODO(sigmund): use a different format for dump-info. This currently emits
114 // the same map that is created for the `--deferred-map` flag. 114 // the same map that is created for the `--deferred-map` flag.
115 Map<String, Map<String, dynamic>> deferredFiles; 115 Map<String, Map<String, dynamic>> deferredFiles;
116 116
117 Map<Info, List<Info>> deps = {};
Harry Terkelsen 2015/08/11 01:33:09 rename to dependencies
Siggi Cherem (dart-lang) 2015/08/11 19:51:45 Done.
118
117 /// Major version indicating breaking changes in the format. A new version 119 /// Major version indicating breaking changes in the format. A new version
118 /// means that an old deserialization algorithm will not work with the new 120 /// means that an old deserialization algorithm will not work with the new
119 /// format. 121 /// format.
120 final int version = 3; 122 final int version = 3;
121 123
122 /// Minor version indicating non-breaking changes in the format. A change in 124 /// Minor version indicating non-breaking changes in the format. A change in
123 /// this version number means that the json parsing in this library from a 125 /// this version number means that the json parsing in this library from a
124 /// previous will continue to work after the change. This is typically 126 /// previous will continue to work after the change. This is typically
125 /// increased when adding new entries to the file format. 127 /// increased when adding new entries to the file format.
126 // Note: the dump-info.viewer app was written using a json parser version 3.2. 128 // Note: the dump-info.viewer app was written using a json parser version 3.2.
127 final int minorVersion = 4; 129 final int minorVersion = 5;
128 130
129 AllInfo(); 131 AllInfo();
130 132
131 static AllInfo parseFromJson(Map map) => new _ParseHelper().parseAll(map); 133 static AllInfo parseFromJson(Map map) => new _ParseHelper().parseAll(map);
132 134
133 Map _listAsJsonMap(List<Info> list) { 135 Map _listAsJsonMap(List<Info> list) {
134 var map = <String, Map>{}; 136 var map = <String, Map>{};
135 for (var info in list) { 137 for (var info in list) {
136 map['${info.id}'] = info.toJson(); 138 map['${info.id}'] = info.toJson();
137 } 139 }
138 return map; 140 return map;
139 } 141 }
140 142
141 Map _extractHoldingInfo() { 143 Map _extractHoldingInfo() {
142 var map = <String, List>{}; 144 var map = <String, List>{};
143 void helper(CodeInfo info) { 145 void helper(CodeInfo info) {
144 if (info.uses.isEmpty) return; 146 if (info.uses.isEmpty) return;
145 map[info.serializedId] = info.uses.map((u) => u.toJson()).toList(); 147 map[info.serializedId] = info.uses.map((u) => u.toJson()).toList();
146 } 148 }
147 functions.forEach(helper); 149 functions.forEach(helper);
148 fields.forEach(helper); 150 fields.forEach(helper);
149 return map; 151 return map;
150 } 152 }
151 153
154 Map _extractDeps() {
155 var map = <String, List>{};
156 deps.forEach((k, v) {
157 map[k.serializedId] = v.map((i) => i.serializedId).toList();
158 });
159 return map;
160 }
161
152 Map toJson() => { 162 Map toJson() => {
153 'elements': { 163 'elements': {
154 'library': _listAsJsonMap(libraries), 164 'library': _listAsJsonMap(libraries),
155 'class': _listAsJsonMap(classes), 165 'class': _listAsJsonMap(classes),
156 'function': _listAsJsonMap(functions), 166 'function': _listAsJsonMap(functions),
157 'typedef': _listAsJsonMap(typedefs), 167 'typedef': _listAsJsonMap(typedefs),
158 'field': _listAsJsonMap(fields), 168 'field': _listAsJsonMap(fields),
159 }, 169 },
160 'holding': _extractHoldingInfo(), 170 'holding': _extractHoldingInfo(),
171 'deps': _extractDeps(),
161 'outputUnits': outputUnits.map((u) => u.toJson()).toList(), 172 'outputUnits': outputUnits.map((u) => u.toJson()).toList(),
162 'dump_version': version, 173 'dump_version': version,
163 'deferredFiles': deferredFiles, 174 'deferredFiles': deferredFiles,
164 'dump_minor_version': '$minorVersion', 175 'dump_minor_version': '$minorVersion',
165 // TODO(sigmund): change viewer to accept an int? 176 // TODO(sigmund): change viewer to accept an int?
166 'program': program.toJson(), 177 'program': program.toJson(),
167 }; 178 };
168 179
169 void accept(InfoVisitor visitor) => visitor.visitAll(this); 180 void accept(InfoVisitor visitor) => visitor.visitAll(this);
170 } 181 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 json['holding'].forEach((k, deps) { 238 json['holding'].forEach((k, deps) {
228 var src = idMap[k]; 239 var src = idMap[k];
229 assert (src != null); 240 assert (src != null);
230 for (var dep in deps) { 241 for (var dep in deps) {
231 var target = idMap[dep['id']]; 242 var target = idMap[dep['id']];
232 assert (target != null); 243 assert (target != null);
233 src.uses.add(new DependencyInfo(target, dep['mask'])); 244 src.uses.add(new DependencyInfo(target, dep['mask']));
234 } 245 }
235 }); 246 });
236 247
248 json['deps']?.forEach((k, deps) {
249 result.deps[idMap[k]] = deps.map((d) => idMap[d]).toList();
250 });
251
237 result.program = parseProgram(json['program']); 252 result.program = parseProgram(json['program']);
238 // todo: version, etc 253 // todo: version, etc
239 return result; 254 return result;
240 } 255 }
241 256
242 LibraryInfo parseLibrary(Map json) { 257 LibraryInfo parseLibrary(Map json) {
243 var result = parseId(json['id']) 258 var result = parseId(json['id'])
244 ..name = json['name'] 259 ..name = json['name']
245 ..parent = parseId(json['parent']) 260 ..parent = parseId(json['parent'])
246 ..uri = Uri.parse(json['canonicalUri']) 261 ..uri = Uri.parse(json['canonicalUri'])
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 info.closures.forEach(visitFunction); 645 info.closures.forEach(visitFunction);
631 } 646 }
632 647
633 visitFunction(FunctionInfo info) { 648 visitFunction(FunctionInfo info) {
634 info.closures.forEach(visitFunction); 649 info.closures.forEach(visitFunction);
635 } 650 }
636 651
637 visitTypedef(TypedefInfo info) {} 652 visitTypedef(TypedefInfo info) {}
638 visitOutput(OutputUnitInfo info) {} 653 visitOutput(OutputUnitInfo info) {}
639 } 654 }
OLDNEW
« pkg/compiler/lib/src/enqueue.dart ('K') | « pkg/compiler/lib/src/enqueue.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698