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

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

Issue 1340093002: dart2js cps: Use more precise type inference for direct index access. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Remove unused field 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 a5fa5a8dc9618e51ca53f4b51496735ff404cdbf..a57775db39d660f5fdac94e1fd9c6cc1f143634e 100644
--- a/pkg/compiler/lib/src/cps_ir/type_mask_system.dart
+++ b/pkg/compiler/lib/src/cps_ir/type_mask_system.dart
@@ -295,4 +295,31 @@ class TypeMaskSystem {
TypeMask receiverTypeFor(Selector selector, TypeMask mask) {
return classWorld.allFunctions.receiverType(selector, mask);
}
+
+ /// The result of an index operation on something of [type], or the dynamic
+ /// type if unknown.
+ TypeMask getIndexType(TypeMask type) {
sra1 2015/09/15 15:59:32 Is there a nice way to write this kind of function
sra1 2015/09/15 15:59:32 'getIndexType' suggests to me the argument type of
asgerf 2015/09/15 16:34:07 I don't entirely understand the use of forwarding
+ if (type is ContainerTypeMask) {
karlklose 2015/09/15 08:17:07 We should maybe use a predicate instead of the is
asgerf 2015/09/15 10:46:14 The idea is that TypeMaskSystem should be that int
+ return type.elementType;
+ }
+ if (isDefinitelyString(type)) {
+ return stringType;
+ }
+ if (type.satisfies(backend.typedArrayClass, classWorld)) {
+ if (type.satisfies(backend.typedArrayOfIntClass, classWorld)) {
+ return intType;
+ }
+ return numType;
+ }
+ return dynamicType;
+ }
+
+ /// The length of something of [type], or `null` if unknown.
+ int getContainerLength(TypeMask type) {
+ if (type is ContainerTypeMask) {
+ return type.length;
+ } else {
+ return null;
+ }
+ }
}
« no previous file with comments | « no previous file | pkg/compiler/lib/src/cps_ir/type_propagation.dart » ('j') | pkg/compiler/lib/src/js_backend/backend.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698