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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/types/masks.dart
diff --git a/pkg/compiler/lib/src/types/masks.dart b/pkg/compiler/lib/src/types/masks.dart
index 43e06009ef1e95e351919ac7f2cfd0053a92074c..bee132d3d3f668070122b0707d83c9a72dabac65 100644
--- a/pkg/compiler/lib/src/types/masks.dart
+++ b/pkg/compiler/lib/src/types/masks.dart
@@ -163,4 +163,33 @@ class CommonMasks {
TypeMask get unmodifiableArrayType =>
_unmodifiableArrayType ??= new TypeMask.nonNullExact(
backendClasses.constListImplementation, closedWorld);
+
+ bool isTypedArray(TypeMask mask) {
+ // Just checking for [:TypedData:] is not sufficient, as it is an
+ // abstract class any user-defined class can implement. So we also
+ // check for the interface [JavaScriptIndexingBehavior].
+ ClassElement typedDataClass = closedWorld.commonElements.typedDataClass;
+ return typedDataClass != null &&
+ closedWorld.isInstantiated(typedDataClass) &&
+ mask.satisfies(typedDataClass, closedWorld) &&
+ mask.satisfies(
+ closedWorld.backendClasses.indexingBehaviorImplementation,
+ closedWorld);
+ }
+
+ bool couldBeTypedArray(TypeMask mask) {
+ bool intersects(TypeMask type1, TypeMask type2) =>
+ !type1.intersection(type2, closedWorld).isEmpty;
+ // TODO(herhut): Maybe cache the TypeMask for typedDataClass and
+ // jsIndexingBehaviourInterface.
+ ClassElement typedDataClass = closedWorld.commonElements.typedDataClass;
+ return typedDataClass != null &&
+ closedWorld.isInstantiated(typedDataClass) &&
+ intersects(mask, new TypeMask.subtype(typedDataClass, closedWorld)) &&
+ intersects(
+ mask,
+ new TypeMask.subtype(
+ closedWorld.backendClasses.indexingBehaviorImplementation,
+ closedWorld));
+ }
}
« 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