| OLD | NEW |
| 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 library dart2js.js_helpers.impact; | 5 library dart2js.js_helpers.impact; |
| 6 | 6 |
| 7 import '../common/names.dart'; | 7 import '../common/names.dart'; |
| 8 import '../compiler.dart' show Compiler; | 8 import '../compiler.dart' show Compiler; |
| 9 import '../core_types.dart' show CommonElements; | 9 import '../core_types.dart' show CommonElements; |
| 10 import '../dart_types.dart' show InterfaceType; | 10 import '../dart_types.dart' show InterfaceType; |
| 11 import '../elements/elements.dart' show ClassElement, Element; | 11 import '../elements/elements.dart' show ClassElement, Element; |
| 12 import '../universe/selector.dart'; | 12 import '../universe/selector.dart'; |
| 13 import '../util/enumset.dart'; |
| 13 import 'backend_helpers.dart'; | 14 import 'backend_helpers.dart'; |
| 14 import 'constant_system_javascript.dart'; | 15 import 'constant_system_javascript.dart'; |
| 15 import 'js_backend.dart'; | 16 import 'js_backend.dart'; |
| 16 | 17 |
| 18 /// Backend specific features required by a backend impact. |
| 19 enum BackendFeature { |
| 20 needToInitializeIsolateAffinityTag, |
| 21 needToInitializeDispatchProperty, |
| 22 } |
| 23 |
| 17 /// A set of JavaScript backend dependencies. | 24 /// A set of JavaScript backend dependencies. |
| 18 class BackendImpact { | 25 class BackendImpact { |
| 19 final List<Element> staticUses; | 26 final List<Element> staticUses; |
| 20 final List<Selector> dynamicUses; | 27 final List<Selector> dynamicUses; |
| 21 final List<InterfaceType> instantiatedTypes; | 28 final List<InterfaceType> instantiatedTypes; |
| 22 final List<ClassElement> instantiatedClasses; | 29 final List<ClassElement> instantiatedClasses; |
| 23 final List<BackendImpact> otherImpacts; | 30 final List<BackendImpact> otherImpacts; |
| 31 final EnumSet<BackendFeature> _features; |
| 24 | 32 |
| 25 BackendImpact( | 33 const BackendImpact( |
| 26 {this.staticUses: const <Element>[], | 34 {this.staticUses: const <Element>[], |
| 27 this.dynamicUses: const <Selector>[], | 35 this.dynamicUses: const <Selector>[], |
| 28 this.instantiatedTypes: const <InterfaceType>[], | 36 this.instantiatedTypes: const <InterfaceType>[], |
| 29 this.instantiatedClasses: const <ClassElement>[], | 37 this.instantiatedClasses: const <ClassElement>[], |
| 30 this.otherImpacts: const <BackendImpact>[]}); | 38 this.otherImpacts: const <BackendImpact>[], |
| 39 EnumSet<BackendFeature> features: const EnumSet<BackendFeature>.fixed(0)}) |
| 40 : this._features = features; |
| 41 |
| 42 Iterable<BackendFeature> get features => |
| 43 _features.iterable(BackendFeature.values); |
| 31 } | 44 } |
| 32 | 45 |
| 33 /// The JavaScript backend dependencies for various features. | 46 /// The JavaScript backend dependencies for various features. |
| 34 class BackendImpacts { | 47 class BackendImpacts { |
| 35 final Compiler compiler; | 48 final Compiler compiler; |
| 36 | 49 |
| 37 BackendImpacts(this.compiler); | 50 BackendImpacts(this.compiler); |
| 38 | 51 |
| 39 JavaScriptBackend get backend => compiler.backend; | 52 JavaScriptBackend get backend => compiler.backend; |
| 40 | 53 |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 | 604 |
| 592 BackendImpact _closure; | 605 BackendImpact _closure; |
| 593 | 606 |
| 594 BackendImpact get closure { | 607 BackendImpact get closure { |
| 595 if (_closure == null) { | 608 if (_closure == null) { |
| 596 _closure = new BackendImpact( | 609 _closure = new BackendImpact( |
| 597 instantiatedClasses: [commonElements.functionClass]); | 610 instantiatedClasses: [commonElements.functionClass]); |
| 598 } | 611 } |
| 599 return _closure; | 612 return _closure; |
| 600 } | 613 } |
| 614 |
| 615 BackendImpact _interceptorUse; |
| 616 |
| 617 BackendImpact get interceptorUse { |
| 618 if (_interceptorUse == null) { |
| 619 _interceptorUse = new BackendImpact( |
| 620 staticUses: [ |
| 621 helpers.getNativeInterceptorMethod |
| 622 ], |
| 623 instantiatedClasses: [ |
| 624 helpers.jsJavaScriptObjectClass, |
| 625 helpers.jsPlainJavaScriptObjectClass, |
| 626 helpers.jsJavaScriptFunctionClass |
| 627 ], |
| 628 features: new EnumSet<BackendFeature>.fromValues([ |
| 629 BackendFeature.needToInitializeDispatchProperty, |
| 630 BackendFeature.needToInitializeIsolateAffinityTag |
| 631 ], fixed: true)); |
| 632 } |
| 633 return _interceptorUse; |
| 634 } |
| 601 } | 635 } |
| OLD | NEW |