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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/types.dart

Issue 14997006: Introduce a UnionTypeMask, currently limited to 4 types. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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 | « no previous file | sdk/lib/_internal/compiler/implementation/types/concrete_types_inferrer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/ssa/types.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/ssa/types.dart (revision 23010)
+++ sdk/lib/_internal/compiler/implementation/ssa/types.dart (working copy)
@@ -18,11 +18,13 @@
return isNullable ? HType.NULL : HType.CONFLICTING;
}
+ JavaScriptBackend backend = compiler.backend;
if (mask.containsOnlyInt(compiler)) {
return isNullable ? HType.INTEGER_OR_NULL : HType.INTEGER;
} else if (mask.containsOnlyDouble(compiler)) {
return isNullable ? HType.DOUBLE_OR_NULL : HType.DOUBLE;
- } else if (mask.containsOnlyNum(compiler)) {
+ } else if (mask.containsOnlyNum(compiler)
+ || mask.satisfies(backend.jsNumberClass, compiler)) {
return isNullable ? HType.NUMBER_OR_NULL : HType.NUMBER;
} else if (mask.containsOnlyString(compiler)) {
return isNullable ? HType.STRING_OR_NULL : HType.STRING;
@@ -38,18 +40,17 @@
return isNullable ? HType.UNKNOWN : HType.NON_NULL;
}
- JavaScriptBackend backend = compiler.backend;
if (!isNullable) {
- if (mask.containsOnly(backend.jsIndexableClass)) {
- return HType.INDEXABLE_PRIMITIVE;
- } else if (mask.containsOnly(backend.jsArrayClass)) {
- return HType.READABLE_ARRAY;
- } else if (mask.containsOnly(backend.jsMutableArrayClass)) {
- return HType.MUTABLE_ARRAY;
- } else if (mask.containsOnly(backend.jsFixedArrayClass)) {
+ if (mask.containsOnly(backend.jsFixedArrayClass)) {
return HType.FIXED_ARRAY;
} else if (mask.containsOnly(backend.jsExtendableArrayClass)) {
return HType.EXTENDABLE_ARRAY;
+ } else if (mask.satisfies(backend.jsMutableArrayClass, compiler)) {
+ return HType.MUTABLE_ARRAY;
+ } else if (mask.satisfies(backend.jsArrayClass, compiler)) {
+ return HType.READABLE_ARRAY;
+ } else if (mask.satisfies(backend.jsIndexableClass, compiler)) {
+ return HType.INDEXABLE_PRIMITIVE;
}
}
return new HBoundedType(mask);
@@ -270,6 +271,8 @@
TypeMask union = mask.union(otherMask, compiler);
return new HType.fromMask(union, compiler);
}
+
+ HType simplify(Compiler compiler) => this;
}
/** Used to represent [HType.UNKNOWN] and [HType.CONFLICTING]. */
@@ -561,7 +564,11 @@
bool canBePrimitiveNumber(Compiler compiler) {
JavaScriptBackend backend = compiler.backend;
DartType jsNumberType = backend.jsNumberClass.computeType(compiler);
- return mask.contains(jsNumberType, compiler);
+ DartType jsIntType = backend.jsIntClass.computeType(compiler);
+ DartType jsDoubleType = backend.jsDoubleClass.computeType(compiler);
+ return mask.contains(jsNumberType, compiler)
+ || mask.contains(jsIntType, compiler)
+ || mask.contains(jsDoubleType, compiler);
}
bool canBePrimitiveBoolean(Compiler compiler) {
@@ -588,6 +595,10 @@
TypeMask computeMask(Compiler compiler) => mask;
+ HType simplify(Compiler compiler) {
+ return new HType.fromMask(mask.simplify(compiler), compiler);
+ }
+
bool operator ==(HType other) {
if (other is !HBoundedType) return false;
HBoundedType bounded = other;
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/types/concrete_types_inferrer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698