OLD | NEW |
1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
2 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
5 library kernel.treeshaker_membench; | 5 library kernel.treeshaker_membench; |
6 | 6 |
7 import 'package:kernel/kernel.dart'; | 7 import 'package:kernel/kernel.dart'; |
8 import 'package:kernel/transformations/treeshaker.dart'; | 8 import 'package:kernel/transformations/treeshaker.dart'; |
9 import 'package:kernel/class_hierarchy.dart'; | 9 import 'package:kernel/class_hierarchy.dart'; |
10 import 'package:kernel/core_types.dart'; | 10 import 'package:kernel/core_types.dart'; |
(...skipping 21 matching lines...) Expand all Loading... |
32 } | 32 } |
33 ArgResults options = argParser.parse(args); | 33 ArgResults options = argParser.parse(args); |
34 if (options.rest.length != 1) { | 34 if (options.rest.length != 1) { |
35 print('Exactly one file should be given'); | 35 print('Exactly one file should be given'); |
36 exit(1); | 36 exit(1); |
37 } | 37 } |
38 String filename = options.rest.single; | 38 String filename = options.rest.single; |
39 bool strongMode = options['strong']; | 39 bool strongMode = options['strong']; |
40 | 40 |
41 Program program = loadProgramFromBinary(filename); | 41 Program program = loadProgramFromBinary(filename); |
42 ClassHierarchy hierarchy = new ClassHierarchy(program); | 42 ClassHierarchy hierarchy = new ClosedWorldClassHierarchy(program); |
43 CoreTypes coreTypes = new CoreTypes(program); | 43 CoreTypes coreTypes = new CoreTypes(program); |
44 | 44 |
45 int copyCount = int.parse(options['count']); | 45 int copyCount = int.parse(options['count']); |
46 | 46 |
47 TreeShaker buildTreeShaker() { | 47 TreeShaker buildTreeShaker() { |
48 return new TreeShaker(coreTypes, hierarchy, program, | 48 return new TreeShaker(coreTypes, hierarchy, program, |
49 strongMode: strongMode); | 49 strongMode: strongMode); |
50 } | 50 } |
51 | 51 |
52 List<TreeShaker> keepAlive = <TreeShaker>[]; | 52 List<TreeShaker> keepAlive = <TreeShaker>[]; |
53 for (int i = 0; i < copyCount; ++i) { | 53 for (int i = 0; i < copyCount; ++i) { |
54 keepAlive.add(buildTreeShaker()); | 54 keepAlive.add(buildTreeShaker()); |
55 } | 55 } |
56 | 56 |
57 print('$copyCount copies built'); | 57 print('$copyCount copies built'); |
58 | 58 |
59 if (args.contains('-v')) { | 59 if (args.contains('-v')) { |
60 // Use of the list for something to avoid premature GC. | 60 // Use of the list for something to avoid premature GC. |
61 for (var treeShaker in keepAlive) { | 61 for (var treeShaker in keepAlive) { |
62 treeShaker.getClassRetention(coreTypes.objectClass); | 62 treeShaker.getClassRetention(coreTypes.objectClass); |
63 } | 63 } |
64 } | 64 } |
65 } | 65 } |
OLD | NEW |