Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: pkg/compiler/lib/src/js_backend/backend_usage.dart

Issue 2693163002: Split backend implementation of EnqueuerListener (Closed)
Patch Set: Updated cf. comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 [BackendHelpers.invokeOnMethod] is used.
28 bool get isInvokeOnUsed;
29
30 /// `true` of `Object.runtimeType` is used.
31 bool get isRuntimeTypeUsed;
32
33 /// `true` if the `dart:isolate` library is in use.
34 bool get isIsolateInUse;
35
36 /// `true` if `Function.apply` is used.
37 bool get isFunctionApplyUsed;
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 /// `true` of `Object.runtimeType` is used.
55 bool isRuntimeTypeUsed;
56
57 /// `true` if the `dart:isolate` library is in use.
58 bool isIsolateInUse;
59
60 /// `true` if `Function.apply` is used.
61 bool isFunctionApplyUsed;
38 } 62 }
39 63
40 class BackendUsageImpl implements BackendUsage, BackendUsageBuilder { 64 class BackendUsageImpl implements BackendUsage, BackendUsageBuilder {
41 final CommonElements _commonElements; 65 final CommonElements _commonElements;
42 final BackendHelpers _helpers; 66 final BackendHelpers _helpers;
43 final Resolution _resolution; 67 final Resolution _resolution;
44 // TODO(johnniwinther): Remove the need for this. 68 // TODO(johnniwinther): Remove the need for this.
45 Setlet<Element> _globalDependencies; 69 Setlet<Element> _globalDependencies;
46 70
47 /// List of elements that the backend may use. 71 /// List of elements that the backend may use.
48 final Set<Element> _helpersUsed = new Set<Element>(); 72 final Set<Element> _helpersUsed = new Set<Element>();
49 73
50 bool _needToInitializeIsolateAffinityTag = false; 74 bool _needToInitializeIsolateAffinityTag = false;
51 bool _needToInitializeDispatchProperty = false; 75 bool _needToInitializeDispatchProperty = false;
52 76
77 /// `true` if a core-library function requires the preamble file to function.
78 bool requiresPreamble = false;
79
80 /// `true` if [BackendHelpers.invokeOnMethod] is used.
81 bool isInvokeOnUsed = false;
82
83 /// `true` of `Object.runtimeType` is used.
84 bool isRuntimeTypeUsed = false;
85
86 /// `true` if the `dart:isolate` library is in use.
87 bool isIsolateInUse = false;
88
89 /// `true` if `Function.apply` is used.
90 bool isFunctionApplyUsed = false;
91
53 BackendUsageImpl(this._commonElements, this._helpers, this._resolution); 92 BackendUsageImpl(this._commonElements, this._helpers, this._resolution);
54 93
55 bool get needToInitializeIsolateAffinityTag => 94 bool get needToInitializeIsolateAffinityTag =>
56 _needToInitializeIsolateAffinityTag; 95 _needToInitializeIsolateAffinityTag;
57 bool get needToInitializeDispatchProperty => 96 bool get needToInitializeDispatchProperty =>
58 _needToInitializeDispatchProperty; 97 _needToInitializeDispatchProperty;
59 98
60 /// The backend must *always* call this method when enqueuing an 99 /// The backend must *always* call this method when enqueuing an
61 /// element. Calls done by the backend are not seen by global 100 /// element. Calls done by the backend are not seen by global
62 /// optimizations, so they would make these optimizations unsound. 101 /// optimizations, so they would make these optimizations unsound.
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 case BackendFeature.needToInitializeIsolateAffinityTag: 228 case BackendFeature.needToInitializeIsolateAffinityTag:
190 _needToInitializeIsolateAffinityTag = true; 229 _needToInitializeIsolateAffinityTag = true;
191 break; 230 break;
192 } 231 }
193 } 232 }
194 } 233 }
195 234
196 void registerUsedMember(MemberElement member) { 235 void registerUsedMember(MemberElement member) {
197 if (member == _helpers.getIsolateAffinityTagMarker) { 236 if (member == _helpers.getIsolateAffinityTagMarker) {
198 _needToInitializeIsolateAffinityTag = true; 237 _needToInitializeIsolateAffinityTag = true;
238 } else if (member == _helpers.requiresPreambleMarker) {
239 requiresPreamble = true;
240 } else if (member == _helpers.invokeOnMethod) {
241 isInvokeOnUsed = true;
242 } else if (_commonElements.isFunctionApplyMethod(member)) {
243 isFunctionApplyUsed = true;
199 } 244 }
200 } 245 }
201 246
202 void registerGlobalDependency(Element element) { 247 void registerGlobalDependency(Element element) {
203 if (element == null) return; 248 if (element == null) return;
204 if (_globalDependencies == null) { 249 if (_globalDependencies == null) {
205 _globalDependencies = new Setlet<Element>(); 250 _globalDependencies = new Setlet<Element>();
206 } 251 }
207 _globalDependencies.add(element.implementation); 252 _globalDependencies.add(element.implementation);
208 } 253 }
209 254
210 Iterable<Element> get globalDependencies => _globalDependencies; 255 Iterable<Element> get globalDependencies => _globalDependencies;
211 } 256 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend.dart ('k') | pkg/compiler/lib/src/js_backend/enqueuer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698