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

Unified Diff: sdk/lib/_internal/compiler/implementation/inferrer/type_graph_inferrer.dart

Issue 87783003: Add UInt32 and UInt31 types to better infer bit operations. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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: sdk/lib/_internal/compiler/implementation/inferrer/type_graph_inferrer.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/inferrer/type_graph_inferrer.dart (revision 30666)
+++ sdk/lib/_internal/compiler/implementation/inferrer/type_graph_inferrer.dart (working copy)
@@ -16,7 +16,7 @@
import '../util/util.dart' show Spannable, Setlet;
import 'simple_types_inferrer.dart';
import 'ir_type_inferrer.dart';
-import '../dart2jslib.dart' show invariant;
+import '../dart2jslib.dart' show invariant, Constant;
part 'type_graph_nodes.dart';
part 'container_tracer.dart';
@@ -78,6 +78,18 @@
return intTypeCache = getConcreteTypeFor(compiler.typesTask.intType);
}
+ TypeInformation uint32TypeCache;
+ TypeInformation get uint32Type {
+ if (uint32TypeCache != null) return uint32TypeCache;
+ return uint32TypeCache = getConcreteTypeFor(compiler.typesTask.uint32Type);
+ }
+
+ TypeInformation uint31TypeCache;
+ TypeInformation get uint31Type {
+ if (uint31TypeCache != null) return uint31TypeCache;
+ return uint31TypeCache = getConcreteTypeFor(compiler.typesTask.uint31Type);
+ }
+
TypeInformation doubleTypeCache;
TypeInformation get doubleType {
if (doubleTypeCache != null) return doubleTypeCache;
@@ -225,6 +237,7 @@
}
ConcreteTypeInformation getConcreteTypeFor(TypeMask mask) {
+ assert(mask != null);
return concreteTypes.putIfAbsent(mask, () {
return new ConcreteTypeInformation(mask);
});
@@ -466,6 +479,8 @@
compiler.log('Inferred $overallRefineCount types.');
processLoopInformation();
+
+ types.typeInformations.values.forEach((info) => print(info));
}
void analyze(Element element) {
@@ -491,6 +506,15 @@
// If [element] is final and has an initializer, we record
// the inferred type.
if (node.asSendSet() != null) {
+ if (type is! ContainerTypeInformation) {
+ // For non-container types, the constant handler does
+ // constant folding that could give more precise results.
+ Constant value =
+ compiler.constantHandler.getConstantForVariable(element);
+ if (value != null) {
+ type = types.getConcreteTypeFor(value.computeMask(compiler));
+ }
+ }
recordType(element, type);
} else if (!element.isInstanceMember()) {
recordType(element, types.nullType);

Powered by Google App Engine
This is Rietveld 408576698