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

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

Issue 1353443002: dart2js cps: Add a pass for eliminating bounds checks. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Put "pending statics" error in status file 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
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/optimizers.dart ('k') | pkg/compiler/lib/src/cps_ir/type_propagation.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c2d704291545fe865a83285849b38ed31c4afc94..ba44ed1c26068069ff6a6f6fa747d90ff988e5c5 100644
--- a/pkg/compiler/lib/src/cps_ir/type_mask_system.dart
+++ b/pkg/compiler/lib/src/cps_ir/type_mask_system.dart
@@ -43,6 +43,7 @@ class TypeMaskSystem {
TypeMask get uintType => inferrer.positiveIntType;
TypeMask numStringBoolType;
+ TypeMask fixedLengthType;
TypeMask interceptorType;
ClassElement get jsNullClass => backend.jsNullClass;
@@ -67,6 +68,11 @@ class TypeMaskSystem {
classWorld);
interceptorType =
new TypeMask.nonNullSubtype(backend.jsInterceptorClass, classWorld);
+
+ TypeMask typedArray = nonNullSubclass(backend.typedArrayClass);
+ fixedLengthType = new TypeMask.unionOf(
+ <TypeMask>[stringType, backend.fixedArrayType, typedArray],
+ classWorld);
}
bool methodUsesReceiverArgument(FunctionElement function) {
@@ -198,6 +204,12 @@ class TypeMaskSystem {
return areDisjoint(t, doubleType);
}
+ bool isDefinitelyNonNegativeInt(TypeMask t, {bool allowNull: false}) {
+ if (!allowNull && t.isNullable) return false;
+ // The JSPositiveInt class includes zero, despite the name.
+ return t.satisfies(backend.jsPositiveIntClass, classWorld);
+ }
+
bool isDefinitelyInt(TypeMask t, {bool allowNull: false}) {
if (!allowNull && t.isNullable) return false;
return t.satisfies(backend.jsIntClass, classWorld);
@@ -247,6 +259,17 @@ class TypeMaskSystem {
return t.nonNullable().satisfies(backend.jsIndexableClass, classWorld);
}
+ bool isDefinitelyMutableIndexable(TypeMask t, {bool allowNull: false}) {
+ if (!allowNull && t.isNullable) return false;
+ return t.nonNullable().satisfies(backend.jsMutableIndexableClass,
+ classWorld);
+ }
+
+ bool isDefinitelyFixedLengthIndexable(TypeMask t, {bool allowNull: false}) {
+ if (!allowNull && t.isNullable) return false;
+ return fixedLengthType.containsMask(t.nonNullable(), classWorld);
+ }
+
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/optimizers.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