| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 library dart2js.world; | 5 library dart2js.world; |
| 6 | 6 |
| 7 import 'closure.dart' show ClosureClassElement, SynthesizedCallMethodElementX; | 7 import 'closure.dart' show ClosureClassElement, SynthesizedCallMethodElementX; |
| 8 import 'common/backend_api.dart' show BackendClasses; | 8 import 'common/backend_api.dart' show BackendClasses; |
| 9 import 'common.dart'; | 9 import 'common.dart'; |
| 10 import 'constants/constant_system.dart'; | 10 import 'constants/constant_system.dart'; |
| 11 import 'core_types.dart' show CommonElements; | 11 import 'core_types.dart' show CommonElements; |
| 12 import 'elements/entities.dart'; | 12 import 'elements/entities.dart'; |
| 13 import 'elements/elements.dart' | 13 import 'elements/elements.dart' |
| 14 show | 14 show |
| 15 ClassElement, | 15 ClassElement, |
| 16 Element, | 16 Element, |
| 17 FunctionElement, | 17 FunctionElement, |
| 18 MemberElement, | 18 MemberElement, |
| 19 MixinApplicationElement, | 19 MixinApplicationElement, |
| 20 TypedefElement, | 20 TypedefElement, |
| 21 FieldElement; | 21 FieldElement; |
| 22 import 'elements/resolution_types.dart'; | 22 import 'elements/resolution_types.dart'; |
| 23 import 'js_backend/backend.dart' show JavaScriptBackend; | 23 import 'js_backend/backend.dart' show JavaScriptBackend; |
| 24 import 'js_backend/interceptor_data.dart' show InterceptorData; |
| 24 import 'ordered_typeset.dart'; | 25 import 'ordered_typeset.dart'; |
| 25 import 'types/masks.dart' show CommonMasks, FlatTypeMask, TypeMask; | 26 import 'types/masks.dart' show CommonMasks, FlatTypeMask, TypeMask; |
| 26 import 'universe/class_set.dart'; | 27 import 'universe/class_set.dart'; |
| 27 import 'universe/function_set.dart' show FunctionSet, FunctionSetBuilder; | 28 import 'universe/function_set.dart' show FunctionSet, FunctionSetBuilder; |
| 28 import 'universe/selector.dart' show Selector; | 29 import 'universe/selector.dart' show Selector; |
| 29 import 'universe/side_effects.dart' show SideEffects; | 30 import 'universe/side_effects.dart' show SideEffects; |
| 30 import 'universe/world_builder.dart' show ResolutionWorldBuilder; | 31 import 'universe/world_builder.dart' show ResolutionWorldBuilder; |
| 31 import 'util/util.dart' show Link; | 32 import 'util/util.dart' show Link; |
| 32 | 33 |
| 33 /// Common superinterface for [OpenWorld] and [ClosedWorld]. | 34 /// Common superinterface for [OpenWorld] and [ClosedWorld]. |
| 34 abstract class World {} | 35 abstract class World {} |
| 35 | 36 |
| 36 /// The [ClosedWorld] represents the information known about a program when | 37 /// The [ClosedWorld] represents the information known about a program when |
| 37 /// compiling with closed-world semantics. | 38 /// compiling with closed-world semantics. |
| 38 /// | 39 /// |
| 39 /// Given the entrypoint of an application, we can track what's reachable from | 40 /// Given the entrypoint of an application, we can track what's reachable from |
| 40 /// it, what functions are called, what classes are allocated, which native | 41 /// it, what functions are called, what classes are allocated, which native |
| 41 /// JavaScript types are touched, what language features are used, and so on. | 42 /// JavaScript types are touched, what language features are used, and so on. |
| 42 /// This precise knowledge about what's live in the program is later used in | 43 /// This precise knowledge about what's live in the program is later used in |
| 43 /// optimizations and other compiler decisions during code generation. | 44 /// optimizations and other compiler decisions during code generation. |
| 44 abstract class ClosedWorld implements World { | 45 abstract class ClosedWorld implements World { |
| 45 /// Access to core classes used by the backend. | 46 /// Access to core classes used by the backend. |
| 46 BackendClasses get backendClasses; | 47 BackendClasses get backendClasses; |
| 47 | 48 |
| 49 InterceptorData get interceptorData; |
| 50 |
| 48 CommonElements get commonElements; | 51 CommonElements get commonElements; |
| 49 | 52 |
| 50 CommonMasks get commonMasks; | 53 CommonMasks get commonMasks; |
| 51 | 54 |
| 52 ConstantSystem get constantSystem; | 55 ConstantSystem get constantSystem; |
| 53 | 56 |
| 54 /// Returns `true` if [cls] is either directly or indirectly instantiated. | 57 /// Returns `true` if [cls] is either directly or indirectly instantiated. |
| 55 bool isInstantiated(ClassEntity cls); | 58 bool isInstantiated(ClassEntity cls); |
| 56 | 59 |
| 57 /// Returns `true` if [cls] is directly instantiated. This means that at | 60 /// Returns `true` if [cls] is directly instantiated. This means that at |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 SUBCLASS, | 381 SUBCLASS, |
| 379 | 382 |
| 380 /// The class and all classes that implement or subclass it (transitively) | 383 /// The class and all classes that implement or subclass it (transitively) |
| 381 /// are included. | 384 /// are included. |
| 382 SUBTYPE, | 385 SUBTYPE, |
| 383 } | 386 } |
| 384 | 387 |
| 385 class ClosedWorldImpl implements ClosedWorld, ClosedWorldRefiner { | 388 class ClosedWorldImpl implements ClosedWorld, ClosedWorldRefiner { |
| 386 final JavaScriptBackend _backend; | 389 final JavaScriptBackend _backend; |
| 387 BackendClasses get backendClasses => _backend.backendClasses; | 390 BackendClasses get backendClasses => _backend.backendClasses; |
| 391 InterceptorData get interceptorData => _backend.interceptorData; |
| 388 FunctionSet _allFunctions; | 392 FunctionSet _allFunctions; |
| 389 | 393 |
| 390 final Iterable<TypedefElement> _allTypedefs; | 394 final Iterable<TypedefElement> _allTypedefs; |
| 391 | 395 |
| 392 final Map<ClassElement, Set<MixinApplicationElement>> _mixinUses; | 396 final Map<ClassElement, Set<MixinApplicationElement>> _mixinUses; |
| 393 Map<ClassElement, List<MixinApplicationElement>> _liveMixinUses; | 397 Map<ClassElement, List<MixinApplicationElement>> _liveMixinUses; |
| 394 | 398 |
| 395 final Map<ClassElement, Set<ClassElement>> _typesImplementedBySubclasses; | 399 final Map<ClassElement, Set<ClassElement>> _typesImplementedBySubclasses; |
| 396 | 400 |
| 397 // We keep track of subtype and subclass relationships in four | 401 // We keep track of subtype and subclass relationships in four |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1183 return getMightBePassedToApply(element.expression); | 1187 return getMightBePassedToApply(element.expression); |
| 1184 } | 1188 } |
| 1185 return functionsThatMightBePassedToApply.contains(element); | 1189 return functionsThatMightBePassedToApply.contains(element); |
| 1186 } | 1190 } |
| 1187 | 1191 |
| 1188 @override | 1192 @override |
| 1189 bool getCurrentlyKnownMightBePassedToApply(Element element) { | 1193 bool getCurrentlyKnownMightBePassedToApply(Element element) { |
| 1190 return getMightBePassedToApply(element); | 1194 return getMightBePassedToApply(element); |
| 1191 } | 1195 } |
| 1192 } | 1196 } |
| OLD | NEW |