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; | 7 import 'closure.dart' show ClosureClassElement; |
8 import 'common.dart'; | 8 import 'common.dart'; |
9 import 'constants/constant_system.dart'; | 9 import 'constants/constant_system.dart'; |
10 import 'common_elements.dart' show CommonElements, ElementEnvironment; | 10 import 'common_elements.dart' show CommonElements, ElementEnvironment; |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 final InterceptorData interceptorData; | 407 final InterceptorData interceptorData; |
408 final BackendUsage backendUsage; | 408 final BackendUsage backendUsage; |
409 | 409 |
410 FunctionSet _allFunctions; | 410 FunctionSet _allFunctions; |
411 | 411 |
412 final Set<TypedefElement> _allTypedefs; | 412 final Set<TypedefElement> _allTypedefs; |
413 | 413 |
414 final Map<ClassEntity, Set<ClassEntity>> mixinUses; | 414 final Map<ClassEntity, Set<ClassEntity>> mixinUses; |
415 Map<ClassEntity, List<ClassEntity>> _liveMixinUses; | 415 Map<ClassEntity, List<ClassEntity>> _liveMixinUses; |
416 | 416 |
417 final Map<ClassEntity, Set<ClassEntity>> _typesImplementedBySubclasses; | 417 final Map<ClassEntity, Set<ClassEntity>> typesImplementedBySubclasses; |
418 | 418 |
419 // We keep track of subtype and subclass relationships in four | 419 // We keep track of subtype and subclass relationships in four |
420 // distinct sets to make class hierarchy analysis faster. | 420 // distinct sets to make class hierarchy analysis faster. |
421 final Map<ClassEntity, ClassHierarchyNode> _classHierarchyNodes; | 421 final Map<ClassEntity, ClassHierarchyNode> _classHierarchyNodes; |
422 final Map<ClassEntity, ClassSet> _classSets; | 422 final Map<ClassEntity, ClassSet> _classSets; |
423 | 423 |
424 final Map<ClassEntity, Map<ClassEntity, bool>> _subtypeCoveredByCache = | 424 final Map<ClassEntity, Map<ClassEntity, bool>> _subtypeCoveredByCache = |
425 <ClassEntity, Map<ClassEntity, bool>>{}; | 425 <ClassEntity, Map<ClassEntity, bool>>{}; |
426 | 426 |
427 final Set<MemberEntity> _functionsCalledInLoop = new Set<MemberEntity>(); | 427 final Set<MemberEntity> _functionsCalledInLoop = new Set<MemberEntity>(); |
(...skipping 29 matching lines...) Expand all Loading... |
457 this.commonElements, | 457 this.commonElements, |
458 this.constantSystem, | 458 this.constantSystem, |
459 this.nativeData, | 459 this.nativeData, |
460 this.interceptorData, | 460 this.interceptorData, |
461 this.backendUsage, | 461 this.backendUsage, |
462 Set<ClassEntity> implementedClasses, | 462 Set<ClassEntity> implementedClasses, |
463 this.liveInstanceMembers, | 463 this.liveInstanceMembers, |
464 this.assignedInstanceMembers, | 464 this.assignedInstanceMembers, |
465 Set<TypedefElement> allTypedefs, | 465 Set<TypedefElement> allTypedefs, |
466 this.mixinUses, | 466 this.mixinUses, |
467 Map<ClassEntity, Set<ClassEntity>> typesImplementedBySubclasses, | 467 this.typesImplementedBySubclasses, |
468 Map<ClassEntity, ClassHierarchyNode> classHierarchyNodes, | 468 Map<ClassEntity, ClassHierarchyNode> classHierarchyNodes, |
469 Map<ClassEntity, ClassSet> classSets) | 469 Map<ClassEntity, ClassSet> classSets) |
470 : this._implementedClasses = implementedClasses, | 470 : this._implementedClasses = implementedClasses, |
471 this._allTypedefs = allTypedefs, | 471 this._allTypedefs = allTypedefs, |
472 this._typesImplementedBySubclasses = typesImplementedBySubclasses, | |
473 this._classHierarchyNodes = classHierarchyNodes, | 472 this._classHierarchyNodes = classHierarchyNodes, |
474 this._classSets = classSets { | 473 this._classSets = classSets { |
475 _commonMasks = new CommonMasks(this); | 474 _commonMasks = new CommonMasks(this); |
476 } | 475 } |
477 | 476 |
478 @override | 477 @override |
479 ClosedWorld get closedWorld => this; | 478 ClosedWorld get closedWorld => this; |
480 | 479 |
481 /// Cache of [FlatTypeMask]s grouped by the 8 possible values of the | 480 /// Cache of [FlatTypeMask]s grouped by the 8 possible values of the |
482 /// `FlatTypeMask.flags` property. | 481 /// `FlatTypeMask.flags` property. |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 assert(checkClass(y)); | 796 assert(checkClass(y)); |
798 Map<ClassEntity, bool> secondMap = | 797 Map<ClassEntity, bool> secondMap = |
799 _subtypeCoveredByCache[x] ??= <ClassEntity, bool>{}; | 798 _subtypeCoveredByCache[x] ??= <ClassEntity, bool>{}; |
800 return secondMap[y] ??= subtypesOf(x).every((ClassEntity cls) => | 799 return secondMap[y] ??= subtypesOf(x).every((ClassEntity cls) => |
801 isSubclassOf(cls, y) || isSubclassOfMixinUseOf(cls, y)); | 800 isSubclassOf(cls, y) || isSubclassOfMixinUseOf(cls, y)); |
802 } | 801 } |
803 | 802 |
804 /// Returns `true` if any subclass of [superclass] implements [type]. | 803 /// Returns `true` if any subclass of [superclass] implements [type]. |
805 bool hasAnySubclassThatImplements(ClassEntity superclass, ClassEntity type) { | 804 bool hasAnySubclassThatImplements(ClassEntity superclass, ClassEntity type) { |
806 assert(checkClass(superclass)); | 805 assert(checkClass(superclass)); |
807 Set<ClassEntity> subclasses = _typesImplementedBySubclasses[superclass]; | 806 Set<ClassEntity> subclasses = typesImplementedBySubclasses[superclass]; |
808 if (subclasses == null) return false; | 807 if (subclasses == null) return false; |
809 return subclasses.contains(type); | 808 return subclasses.contains(type); |
810 } | 809 } |
811 | 810 |
812 /// Returns whether a [selector] call on an instance of [cls] | 811 /// Returns whether a [selector] call on an instance of [cls] |
813 /// will hit a method at runtime, and not go through [noSuchMethod]. | 812 /// will hit a method at runtime, and not go through [noSuchMethod]. |
814 bool hasConcreteMatch(covariant ClassEntity cls, Selector selector, | 813 bool hasConcreteMatch(covariant ClassEntity cls, Selector selector, |
815 {covariant ClassEntity stopAtSuperclass}); | 814 {covariant ClassEntity stopAtSuperclass}); |
816 | 815 |
817 @override | 816 @override |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1309 // does not see generative constructor bodies because they are | 1308 // does not see generative constructor bodies because they are |
1310 // created by the backend. Also, it does not make any distinction | 1309 // created by the backend. Also, it does not make any distinction |
1311 // between a constructor and its body for side effects. This | 1310 // between a constructor and its body for side effects. This |
1312 // implies that currently, the side effects of a constructor body | 1311 // implies that currently, the side effects of a constructor body |
1313 // contain the side effects of the initializers. | 1312 // contain the side effects of the initializers. |
1314 assert(!element.isGenerativeConstructorBody); | 1313 assert(!element.isGenerativeConstructorBody); |
1315 assert(!element.isField); | 1314 assert(!element.isField); |
1316 return super.getSideEffectsOfElement(element); | 1315 return super.getSideEffectsOfElement(element); |
1317 } | 1316 } |
1318 } | 1317 } |
OLD | NEW |