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

Side by Side Diff: pkg/compiler/lib/src/types/masks.dart

Issue 2569733002: Even less reliance on Compiler.closedWorld (Closed)
Patch Set: Updated cf. comments. Created 4 years 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
« no previous file with comments | « pkg/compiler/lib/src/ssa/types_propagation.dart ('k') | pkg/compiler/lib/src/types/types.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 masks; 5 library masks;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/backend_api.dart' show BackendClasses; 8 import '../common/backend_api.dart' show BackendClasses;
9 import '../compiler.dart' show Compiler; 9 import '../compiler.dart' show Compiler;
10 import '../constants/values.dart' show PrimitiveConstantValue; 10 import '../constants/values.dart' show PrimitiveConstantValue;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 TypeMask get fixedArrayType => _fixedArrayType ??= new TypeMask.nonNullExact( 156 TypeMask get fixedArrayType => _fixedArrayType ??= new TypeMask.nonNullExact(
157 backendClasses.fixedListImplementation, closedWorld); 157 backendClasses.fixedListImplementation, closedWorld);
158 158
159 TypeMask get extendableArrayType => 159 TypeMask get extendableArrayType =>
160 _extendableArrayType ??= new TypeMask.nonNullExact( 160 _extendableArrayType ??= new TypeMask.nonNullExact(
161 backendClasses.growableListImplementation, closedWorld); 161 backendClasses.growableListImplementation, closedWorld);
162 162
163 TypeMask get unmodifiableArrayType => 163 TypeMask get unmodifiableArrayType =>
164 _unmodifiableArrayType ??= new TypeMask.nonNullExact( 164 _unmodifiableArrayType ??= new TypeMask.nonNullExact(
165 backendClasses.constListImplementation, closedWorld); 165 backendClasses.constListImplementation, closedWorld);
166
167 bool isTypedArray(TypeMask mask) {
168 // Just checking for [:TypedData:] is not sufficient, as it is an
169 // abstract class any user-defined class can implement. So we also
170 // check for the interface [JavaScriptIndexingBehavior].
171 ClassElement typedDataClass = closedWorld.commonElements.typedDataClass;
172 return typedDataClass != null &&
173 closedWorld.isInstantiated(typedDataClass) &&
174 mask.satisfies(typedDataClass, closedWorld) &&
175 mask.satisfies(
176 closedWorld.backendClasses.indexingBehaviorImplementation,
177 closedWorld);
178 }
179
180 bool couldBeTypedArray(TypeMask mask) {
181 bool intersects(TypeMask type1, TypeMask type2) =>
182 !type1.intersection(type2, closedWorld).isEmpty;
183 // TODO(herhut): Maybe cache the TypeMask for typedDataClass and
184 // jsIndexingBehaviourInterface.
185 ClassElement typedDataClass = closedWorld.commonElements.typedDataClass;
186 return typedDataClass != null &&
187 closedWorld.isInstantiated(typedDataClass) &&
188 intersects(mask, new TypeMask.subtype(typedDataClass, closedWorld)) &&
189 intersects(
190 mask,
191 new TypeMask.subtype(
192 closedWorld.backendClasses.indexingBehaviorImplementation,
193 closedWorld));
194 }
166 } 195 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/types_propagation.dart ('k') | pkg/compiler/lib/src/types/types.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698