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

Unified Diff: pkg/compiler/lib/src/cps_ir/type_mask_system.dart

Issue 1409803003: dart2js cps: More interceptor optimizations and fixes. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix indentation Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/cps_ir/type_mask_system.dart
diff --git a/pkg/compiler/lib/src/cps_ir/type_mask_system.dart b/pkg/compiler/lib/src/cps_ir/type_mask_system.dart
index 6910d46392df3b18538939d2143c30cd88b22459..9c46857f443c731f93226c45914f329cf3dc4bb5 100644
--- a/pkg/compiler/lib/src/cps_ir/type_mask_system.dart
+++ b/pkg/compiler/lib/src/cps_ir/type_mask_system.dart
@@ -45,6 +45,7 @@ class TypeMaskSystem {
TypeMask numStringBoolType;
TypeMask fixedLengthType;
TypeMask interceptorType;
+ TypeMask interceptedTypes; // Does not include null.
TypeMask _indexableTypeTest;
@@ -71,6 +72,12 @@ class TypeMaskSystem {
interceptorType =
new TypeMask.nonNullSubtype(backend.jsInterceptorClass, classWorld);
+ // We redundantly include subtypes of num/string/bool as intercepted types,
+ // because the type system does not infer that their implementations are
+ // all subclasses of Interceptor.
+ interceptedTypes = new TypeMask.unionOf(
+ <TypeMask>[interceptorType, numStringBoolType], classWorld);
+
TypeMask typedArray = nonNullSubclass(backend.typedArrayClass);
fixedLengthType = new TypeMask.unionOf(
<TypeMask>[stringType, backend.fixedArrayType, typedArray],
@@ -281,6 +288,24 @@ class TypeMaskSystem {
return fixedLengthType.containsMask(t.nonNullable(), classWorld);
}
+ bool isDefinitelyIntercepted(TypeMask t, {bool allowNull}) {
+ assert(allowNull != null);
+ if (!allowNull && t.isNullable) return false;
+ return interceptedTypes.containsMask(t.nonNullable(), classWorld);
+ }
+
+ /// Given a class from the interceptor hierarchy, returns a [TypeMask]
+ /// matching all values with that interceptor (or a subtype thereof).
+ TypeMask getInterceptorSubtypes(ClassElement class_) {
+ if (class_ == backend.jsInterceptorClass) {
+ return interceptorType.nullable();
+ } else if (class_ == backend.jsNullClass) {
+ return nullType;
+ } else {
+ return nonNullSubclass(class_);
+ }
+ }
+
bool areDisjoint(TypeMask leftType, TypeMask rightType) {
TypeMask intersection = leftType.intersection(rightType, classWorld);
return intersection.isEmpty && !intersection.isNullable;
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/share_interceptors.dart ('k') | pkg/compiler/lib/src/cps_ir/type_propagation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698