OLD | NEW |
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 library fletchc.dynamic_call_enqueuer; | 5 library dartino_compiler.dynamic_call_enqueuer; |
6 | 6 |
7 import 'dart:collection' show | 7 import 'dart:collection' show |
8 Queue; | 8 Queue; |
9 | 9 |
10 import 'package:compiler/src/universe/selector.dart' show | 10 import 'package:compiler/src/universe/selector.dart' show |
11 Selector; | 11 Selector; |
12 | 12 |
13 import 'package:compiler/src/universe/use.dart' show | 13 import 'package:compiler/src/universe/use.dart' show |
14 DynamicUse; | 14 DynamicUse; |
15 | 15 |
(...skipping 10 matching lines...) Expand all Loading... |
26 MemberElement, | 26 MemberElement, |
27 Name; | 27 Name; |
28 | 28 |
29 import 'package:compiler/src/common/names.dart' show | 29 import 'package:compiler/src/common/names.dart' show |
30 Identifiers, | 30 Identifiers, |
31 Names; | 31 Names; |
32 | 32 |
33 import 'package:compiler/src/util/util.dart' show | 33 import 'package:compiler/src/util/util.dart' show |
34 Hashing; | 34 Hashing; |
35 | 35 |
36 import 'fletch_compiler_implementation.dart' show | 36 import 'dartino_compiler_implementation.dart' show |
37 FletchCompilerImplementation; | 37 DartinoCompilerImplementation; |
38 | 38 |
39 import 'fletch_enqueuer.dart' show | 39 import 'dartino_enqueuer.dart' show |
40 shouldReportEnqueuingOfElement; | 40 shouldReportEnqueuingOfElement; |
41 | 41 |
42 import 'fletch_registry.dart' show | 42 import 'dartino_registry.dart' show |
43 ClosureKind; | 43 ClosureKind; |
44 | 44 |
45 abstract class UsageRecorder { | 45 abstract class UsageRecorder { |
46 void recordElementUsage(Element element, Selector selector); | 46 void recordElementUsage(Element element, Selector selector); |
47 | 47 |
48 void recordClosurizationUsage(Closurization closurization, Selector selector); | 48 void recordClosurizationUsage(Closurization closurization, Selector selector); |
49 | 49 |
50 void recordTypeTest(ClassElement element, InterfaceType type); | 50 void recordTypeTest(ClassElement element, InterfaceType type); |
51 } | 51 } |
52 | 52 |
53 /// Implements the dynamic part of the tree-shaking algorithm. | 53 /// Implements the dynamic part of the tree-shaking algorithm. |
54 /// | 54 /// |
55 /// By "dynamic" part we mean the part that is about matching instantiated | 55 /// By "dynamic" part we mean the part that is about matching instantiated |
56 /// classes with called instance methods. | 56 /// classes with called instance methods. |
57 class DynamicCallEnqueuer { | 57 class DynamicCallEnqueuer { |
58 final FletchCompilerImplementation compiler; | 58 final DartinoCompilerImplementation compiler; |
59 | 59 |
60 final Set<ClassElement> instantiatedClasses = new Set<ClassElement>(); | 60 final Set<ClassElement> instantiatedClasses = new Set<ClassElement>(); |
61 | 61 |
62 final Queue<ClassElement> pendingInstantiatedClasses = | 62 final Queue<ClassElement> pendingInstantiatedClasses = |
63 new Queue<ClassElement>(); | 63 new Queue<ClassElement>(); |
64 | 64 |
65 final Set<Selector> enqueuedSelectors = new Set<Selector>(); | 65 final Set<Selector> enqueuedSelectors = new Set<Selector>(); |
66 | 66 |
67 final Queue<Selector> pendingSelectors = new Queue<Selector>(); | 67 final Queue<Selector> pendingSelectors = new Queue<Selector>(); |
68 | 68 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 if (element.isInstanceMember) { | 227 if (element.isInstanceMember) { |
228 ClassElement modifiedClass = element.enclosingClass; | 228 ClassElement modifiedClass = element.enclosingClass; |
229 revisitClass(modifiedClass); | 229 revisitClass(modifiedClass); |
230 MemberElement member = element; | 230 MemberElement member = element; |
231 for (ClassElement cls in instantiatedClasses) { | 231 for (ClassElement cls in instantiatedClasses) { |
232 // TODO(ahe): Make O(1). | 232 // TODO(ahe): Make O(1). |
233 if (cls.lookupByName(member.memberName) == member) { | 233 if (cls.lookupByName(member.memberName) == member) { |
234 revisitClass(cls); | 234 revisitClass(cls); |
235 // Once we have found one class that implements [member], we're | 235 // Once we have found one class that implements [member], we're |
236 // done. When we later call [enqueueInstanceMethods] (via | 236 // done. When we later call [enqueueInstanceMethods] (via |
237 // [FletchEnqueuer.processQueue]) the method will be enqueued again | 237 // [DartinoEnqueuer.processQueue]) the method will be enqueued again |
238 // (if it exists). | 238 // (if it exists). |
239 break; | 239 break; |
240 } | 240 } |
241 } | 241 } |
242 } | 242 } |
243 List<Closurization> toBeRemoved = <Closurization>[]; | 243 List<Closurization> toBeRemoved = <Closurization>[]; |
244 for (Closurization closurization in implicitClosurizations) { | 244 for (Closurization closurization in implicitClosurizations) { |
245 if (closurization.function == element) { | 245 if (closurization.function == element) { |
246 toBeRemoved.add(closurization); | 246 toBeRemoved.add(closurization); |
247 } | 247 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 kind = kind, | 288 kind = kind, |
289 hashCode = Hashing.mixHashCodeBits(function.hashCode, kind.hashCode); | 289 hashCode = Hashing.mixHashCodeBits(function.hashCode, kind.hashCode); |
290 | 290 |
291 bool operator ==(other) { | 291 bool operator ==(other) { |
292 return other is Closurization && | 292 return other is Closurization && |
293 function == other.function && kind == other.kind; | 293 function == other.function && kind == other.kind; |
294 } | 294 } |
295 | 295 |
296 String toString() => "Closurization($function, $kind)"; | 296 String toString() => "Closurization($function, $kind)"; |
297 } | 297 } |
OLD | NEW |