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

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: Created 5 years, 3 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 e05db65625bc306a7a9b19114d4b0f488b4fa077..ab6b0944362e281a880ccfdbb01304f08b82bf55 100644
--- a/pkg/compiler/lib/src/cps_ir/type_mask_system.dart
+++ b/pkg/compiler/lib/src/cps_ir/type_mask_system.dart
@@ -32,6 +32,7 @@ class TypeMaskSystem {
TypeMask get functionType => inferrer.functionType;
TypeMask get boolType => inferrer.boolType;
TypeMask get intType => inferrer.intType;
+ TypeMask get uint32Type => inferrer.uint32Type;
TypeMask get doubleType => inferrer.doubleType;
TypeMask get numType => inferrer.numType;
TypeMask get stringType => inferrer.stringType;
@@ -42,6 +43,7 @@ class TypeMaskSystem {
TypeMask get extendableNativeListType => backend.extendableArrayType;
TypeMask numStringBoolType;
+ TypeMask fixedLengthType;
ClassElement get jsNullClass => backend.jsNullClass;
@@ -63,6 +65,10 @@ class TypeMaskSystem {
numStringBoolType =
new TypeMask.unionOf(<TypeMask>[anyNum, anyString, anyBool],
classWorld);
+
+ fixedLengthType =
+ new TypeMask.unionOf(<TypeMask>[stringType, inferrer.fixedListType],
sra1 2015/09/30 21:54:20 This needs to include the typed arrays.
asgerf 2015/10/01 09:49:34 Done. Also, there was a pretty serious bug here s
asgerf 2015/10/01 10:35:25 Oh nevermind, I was confused by IntelliJ. JavaScri
+ classWorld);
}
bool methodUsesReceiverArgument(FunctionElement function) {
@@ -183,6 +189,11 @@ class TypeMaskSystem {
return areDisjoint(t, doubleType);
}
+ bool isDefinitelyUInt32(TypeMask t, {bool allowNull: false}) {
+ if (!allowNull && t.isNullable) return false;
+ return t.satisfies(backend.jsUInt32Class, classWorld);
+ }
+
bool isDefinitelyInt(TypeMask t, {bool allowNull: false}) {
if (!allowNull && t.isNullable) return false;
return t.satisfies(backend.jsIntClass, classWorld);
@@ -214,6 +225,16 @@ 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;

Powered by Google App Engine
This is Rietveld 408576698