Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import '../common.dart'; | 5 import '../common.dart'; |
| 6 import '../common/resolution.dart' show Resolution; | 6 import '../common/resolution.dart' show Resolution; |
| 7 import '../core_types.dart'; | 7 import '../core_types.dart'; |
| 8 import '../elements/elements.dart'; | 8 import '../elements/elements.dart'; |
| 9 import '../elements/resolution_types.dart'; | 9 import '../elements/resolution_types.dart'; |
| 10 import '../universe/selector.dart'; | 10 import '../universe/selector.dart'; |
| 11 import '../universe/use.dart'; | 11 import '../universe/use.dart'; |
| 12 import '../universe/world_impact.dart' | 12 import '../universe/world_impact.dart' |
| 13 show WorldImpact, WorldImpactBuilder, WorldImpactBuilderImpl; | 13 show WorldImpact, WorldImpactBuilder, WorldImpactBuilderImpl; |
| 14 import '../util/util.dart' show Setlet; | 14 import '../util/util.dart' show Setlet; |
| 15 import 'backend_helpers.dart'; | 15 import 'backend_helpers.dart'; |
| 16 import 'backend_impact.dart'; | 16 import 'backend_impact.dart'; |
| 17 | 17 |
| 18 abstract class BackendUsage { | 18 abstract class BackendUsage { |
| 19 bool get needToInitializeIsolateAffinityTag; | 19 bool get needToInitializeIsolateAffinityTag; |
| 20 bool get needToInitializeDispatchProperty; | 20 bool get needToInitializeDispatchProperty; |
| 21 bool usedByBackend(Element element); | 21 bool usedByBackend(Element element); |
| 22 Iterable<Element> get globalDependencies; | 22 Iterable<Element> get globalDependencies; |
| 23 | |
| 24 /// True if a core-library function requires the preamble file to function. | |
| 25 bool get requiresPreamble; | |
| 26 | |
| 27 /// `true` if access to [BackendHelpers.invokeOnMethod] is supported. | |
| 28 bool get hasInvokeOnSupport; | |
|
Siggi Cherem (dart-lang)
2017/02/17 23:05:08
Let's rename a lot of these properties.
Reading t
Johnni Winther
2017/02/20 11:37:42
Done.
| |
| 29 | |
| 30 /// `true` of `Object.runtimeType` is supported. | |
| 31 bool get hasRuntimeTypeSupport; | |
| 32 | |
| 33 /// `true` of use of the `dart:isolate` library is supported. | |
| 34 bool get hasIsolateSupport; | |
| 35 | |
| 36 /// `true` of `Function.apply` is supported. | |
| 37 bool get hasFunctionApplySupport; | |
| 23 } | 38 } |
| 24 | 39 |
| 25 abstract class BackendUsageBuilder { | 40 abstract class BackendUsageBuilder { |
| 26 Element registerBackendUse(Element element); | 41 Element registerBackendUse(Element element); |
| 27 void registerGlobalDependency(Element element); | 42 void registerGlobalDependency(Element element); |
| 28 void registerBackendImpact( | 43 void registerBackendImpact( |
| 29 WorldImpactBuilder worldImpact, BackendImpact backendImpact); | 44 WorldImpactBuilder worldImpact, BackendImpact backendImpact); |
| 30 void registerBackendStaticUse( | 45 void registerBackendStaticUse( |
| 31 WorldImpactBuilder worldImpact, MethodElement element, | 46 WorldImpactBuilder worldImpact, MethodElement element, |
| 32 {bool isGlobal: false}); | 47 {bool isGlobal: false}); |
| 33 void registerBackendInstantiation( | 48 void registerBackendInstantiation( |
| 34 WorldImpactBuilder worldImpact, ClassElement cls, | 49 WorldImpactBuilder worldImpact, ClassElement cls, |
| 35 {bool isGlobal: false}); | 50 {bool isGlobal: false}); |
| 36 WorldImpact createImpactFor(BackendImpact impact); | 51 WorldImpact createImpactFor(BackendImpact impact); |
| 37 void registerUsedMember(MemberElement member); | 52 void registerUsedMember(MemberElement member); |
| 53 | |
| 54 bool hasRuntimeTypeSupport; | |
| 55 | |
| 56 /// `true` of use of the `dart:isolate` library is supported. | |
| 57 bool hasIsolateSupport; | |
| 58 | |
| 59 /// `true` of `Function.apply` is supported. | |
| 60 bool hasFunctionApplySupport; | |
| 38 } | 61 } |
| 39 | 62 |
| 40 class BackendUsageImpl implements BackendUsage, BackendUsageBuilder { | 63 class BackendUsageImpl implements BackendUsage, BackendUsageBuilder { |
| 41 final CommonElements _commonElements; | 64 final CommonElements _commonElements; |
| 42 final BackendHelpers _helpers; | 65 final BackendHelpers _helpers; |
| 43 final Resolution _resolution; | 66 final Resolution _resolution; |
| 44 // TODO(johnniwinther): Remove the need for this. | 67 // TODO(johnniwinther): Remove the need for this. |
| 45 Setlet<Element> _globalDependencies; | 68 Setlet<Element> _globalDependencies; |
| 46 | 69 |
| 47 /// List of elements that the backend may use. | 70 /// List of elements that the backend may use. |
| 48 final Set<Element> _helpersUsed = new Set<Element>(); | 71 final Set<Element> _helpersUsed = new Set<Element>(); |
| 49 | 72 |
| 50 bool _needToInitializeIsolateAffinityTag = false; | 73 bool _needToInitializeIsolateAffinityTag = false; |
| 51 bool _needToInitializeDispatchProperty = false; | 74 bool _needToInitializeDispatchProperty = false; |
| 52 | 75 |
| 76 /// True if a core-library function requires the preamble file to function. | |
| 77 bool requiresPreamble = false; | |
| 78 | |
| 79 /// `true` if access to [BackendHelpers.invokeOnMethod] is supported. | |
| 80 bool hasInvokeOnSupport = false; | |
| 81 | |
| 82 /// `true` of `Object.runtimeType` is supported. | |
| 83 bool hasRuntimeTypeSupport = false; | |
| 84 | |
| 85 /// `true` of use of the `dart:isolate` library is supported. | |
| 86 bool hasIsolateSupport = false; | |
| 87 | |
| 88 /// `true` of `Function.apply` is supported. | |
| 89 bool hasFunctionApplySupport = false; | |
| 90 | |
| 53 BackendUsageImpl(this._commonElements, this._helpers, this._resolution); | 91 BackendUsageImpl(this._commonElements, this._helpers, this._resolution); |
| 54 | 92 |
| 55 bool get needToInitializeIsolateAffinityTag => | 93 bool get needToInitializeIsolateAffinityTag => |
| 56 _needToInitializeIsolateAffinityTag; | 94 _needToInitializeIsolateAffinityTag; |
| 57 bool get needToInitializeDispatchProperty => | 95 bool get needToInitializeDispatchProperty => |
| 58 _needToInitializeDispatchProperty; | 96 _needToInitializeDispatchProperty; |
| 59 | 97 |
| 60 /// The backend must *always* call this method when enqueuing an | 98 /// The backend must *always* call this method when enqueuing an |
| 61 /// element. Calls done by the backend are not seen by global | 99 /// element. Calls done by the backend are not seen by global |
| 62 /// optimizations, so they would make these optimizations unsound. | 100 /// optimizations, so they would make these optimizations unsound. |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 case BackendFeature.needToInitializeIsolateAffinityTag: | 227 case BackendFeature.needToInitializeIsolateAffinityTag: |
| 190 _needToInitializeIsolateAffinityTag = true; | 228 _needToInitializeIsolateAffinityTag = true; |
| 191 break; | 229 break; |
| 192 } | 230 } |
| 193 } | 231 } |
| 194 } | 232 } |
| 195 | 233 |
| 196 void registerUsedMember(MemberElement member) { | 234 void registerUsedMember(MemberElement member) { |
| 197 if (member == _helpers.getIsolateAffinityTagMarker) { | 235 if (member == _helpers.getIsolateAffinityTagMarker) { |
| 198 _needToInitializeIsolateAffinityTag = true; | 236 _needToInitializeIsolateAffinityTag = true; |
| 237 } else if (member == _helpers.requiresPreambleMarker) { | |
| 238 requiresPreamble = true; | |
| 239 } else if (member == _helpers.invokeOnMethod) { | |
| 240 hasInvokeOnSupport = true; | |
| 241 } else if (_commonElements.isFunctionApplyMethod(member)) { | |
| 242 hasFunctionApplySupport = true; | |
| 199 } | 243 } |
| 200 } | 244 } |
| 201 | 245 |
| 202 void registerGlobalDependency(Element element) { | 246 void registerGlobalDependency(Element element) { |
| 203 if (element == null) return; | 247 if (element == null) return; |
| 204 if (_globalDependencies == null) { | 248 if (_globalDependencies == null) { |
| 205 _globalDependencies = new Setlet<Element>(); | 249 _globalDependencies = new Setlet<Element>(); |
| 206 } | 250 } |
| 207 _globalDependencies.add(element.implementation); | 251 _globalDependencies.add(element.implementation); |
| 208 } | 252 } |
| 209 | 253 |
| 210 Iterable<Element> get globalDependencies => _globalDependencies; | 254 Iterable<Element> get globalDependencies => _globalDependencies; |
| 211 } | 255 } |
| OLD | NEW |