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

Side by Side Diff: bin/verify_deps.dart

Issue 1412903002: include fields in verify_deps, refactor graph dfs (Closed) Base URL: git@github.com:dart-lang/dart2js_info.git@master
Patch Set: Created 5 years, 2 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 | « bin/function_size_analysis.dart ('k') | lib/src/graph.dart » ('j') | 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 /// This tools verifies that all elements that are included in the output are 5 /// This tools verifies that all elements that are included in the output are
6 /// reachable from the program entrypoint. If there are elements that are not 6 /// reachable from the program entrypoint. If there are elements that are not
7 /// reachable from the entrypoint, then this indicates that we are missing 7 /// reachable from the entrypoint, then this indicates that we are missing
8 /// dependencies. If all functions are reachable from the entrypoint, this 8 /// dependencies. If all functions are reachable from the entrypoint, this
9 /// script will return with exitcode 0. Otherwise it will list the unreachable 9 /// script will return with exitcode 0. Otherwise it will list the unreachable
10 /// functions and return with exitcode 1. 10 /// functions and return with exitcode 1.
(...skipping 11 matching lines...) Expand all
22 if (args.length > 1) { 22 if (args.length > 1) {
23 printUsage(); 23 printUsage();
24 exit(1); 24 exit(1);
25 } 25 }
26 var json = JSON.decode(await new File(args[0]).readAsString()); 26 var json = JSON.decode(await new File(args[0]).readAsString());
27 var info = new AllInfoJsonCodec().decode(json); 27 var info = new AllInfoJsonCodec().decode(json);
28 var graph = graphFromInfo(info); 28 var graph = graphFromInfo(info);
29 var entrypoint = info.program.entrypoint; 29 var entrypoint = info.program.entrypoint;
30 var reachables = findReachable(graph, entrypoint); 30 var reachables = findReachable(graph, entrypoint);
31 31
32 var unreachables = info.functions.where((func) => !reachables.contains(func)); 32 var functionsAndFields = []..addAll(info.functions)..addAll(info.fields);
33 var unreachables =
34 functionsAndFields.where((func) => !reachables.contains(func));
33 if (unreachables.isNotEmpty) { 35 if (unreachables.isNotEmpty) {
34 unreachables.forEach(print); 36 unreachables.forEach((x) => print(longName(x)));
35 exit(1); 37 exit(1);
36 } else { 38 } else {
37 print('all elements are reachable from the entrypoint'); 39 print('all elements are reachable from the entrypoint');
38 } 40 }
39 } 41 }
40 42
41 /// Finds the set of nodes reachable from [start] in [graph]. 43 /// Finds the set of nodes reachable from [start] in [graph].
42 Set<Info> findReachable(Graph<Info> graph, Info start) { 44 Set<Info> findReachable(Graph<Info> graph, Info start) =>
43 var visited = new Set<Info>(); 45 new Set.from(graph.preOrder(start));
44 var stack = <Info>[start];
45 while (stack.isNotEmpty) {
46 var next = stack.removeLast();
47 visited.add(next);
48 stack.addAll(
49 graph.targetsOf(next).where((target) => !visited.contains(target)));
50 }
51 return visited;
52 }
53 46
54 void printUsage() { 47 void printUsage() {
55 print('usage: dart2js_info_verify_deps <info file>'); 48 print('usage: dart2js_info_verify_deps <info file>');
56 } 49 }
OLDNEW
« no previous file with comments | « bin/function_size_analysis.dart ('k') | lib/src/graph.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698