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

Unified Diff: lib/compiler/implementation/universe.dart

Issue 10539156: Track fields which are known to be always set to integer constants (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed second round of comments Created 8 years, 6 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 | « lib/compiler/implementation/ssa/optimize.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/universe.dart
diff --git a/lib/compiler/implementation/universe.dart b/lib/compiler/implementation/universe.dart
index 635cd737cf1c19b9d2425842d930e1644221f751..0c6bc9b6c476aaa31a135686efd2de9264b2e9ea 100644
--- a/lib/compiler/implementation/universe.dart
+++ b/lib/compiler/implementation/universe.dart
@@ -13,6 +13,8 @@ class Universe {
final Map<SourceString, Set<Selector>> invokedSetters;
final Map<SourceString, Set<Selector>> fieldGetters;
final Map<SourceString, Set<Selector>> fieldSetters;
+ final Map<Element, Map<SourceString, bool>> fieldIntegerInitializers;
+ final Map<Element, Map<SourceString, bool>> fieldIntegerSetters;
// TODO(ngeoffray): This should be a Set<Type>.
final Set<Element> isChecks;
final RuntimeTypeInformation rti;
@@ -27,6 +29,10 @@ class Universe {
invokedSetters = new Map<SourceString, Set<Selector>>(),
fieldGetters = new Map<SourceString, Set<Selector>>(),
fieldSetters = new Map<SourceString, Set<Selector>>(),
+ fieldIntegerInitializers =
+ new Map<Element, Map<SourceString, bool>>(),
+ fieldIntegerSetters =
+ new Map<Element, Map<SourceString, bool>>(),
isChecks = new Set<Element>(),
rti = new RuntimeTypeInformation();
@@ -67,6 +73,54 @@ class Universe {
bool hasFieldSetter(Element member, Compiler compiler) {
return hasMatchingSelector(fieldSetters[member.name], member, compiler);
}
+
+ void updateFieldIntegerInitializers(Type type,
+ SourceString name,
+ bool isInteger) {
+ Map<SourceString, bool> fields =
+ fieldIntegerInitializers.putIfAbsent(
+ type.element, () => new Map<SourceString, bool>());
+ if (!fields.containsKey(name)) {
+ fields[name] = isInteger;
+ } else {
+ fields[name] = fields[name] && isInteger;
+ }
+ }
+
+ bool hasFieldOnlyIntegerInitializers(Type type, SourceString name) {
+ if (type == null) return false;
+ if (!fieldIntegerInitializers.containsKey(type.element)) return true;
+ Map<SourceString, bool> fields = fieldIntegerInitializers[type.element];
+ if (!fields.containsKey(name)) return false;
+ return fields[name];
+ }
+
+ void updateFieldIntegerSetters(Type type, SourceString name, bool isInteger) {
+ Map<SourceString, bool> fields =
+ fieldIntegerSetters.putIfAbsent(
+ type.element, () => new Map<SourceString, bool>());
+ if (!fields.containsKey(name)) {
+ fields[name] = isInteger;
+ } else {
+ fields[name] = fields[name] && isInteger;
+ }
+ }
+
+ bool couldHaveFieldOnlyIntegerSetters(Type type, SourceString name) {
+ if (type == null) return false;
+ if (!fieldIntegerSetters.containsKey(type.element)) return true;
+ Map<SourceString, bool> fields = fieldIntegerSetters[type.element];
+ if (!fields.containsKey(name)) return false;
+ return fields[name];
+ }
+
+ bool hasFieldOnlyIntegerSetters(Type type, SourceString name) {
+ if (type == null) return false;
+ if (!fieldIntegerSetters.containsKey(type.element)) return true;
+ Map<SourceString, bool> fields = fieldIntegerSetters[type.element];
+ if (!fields.containsKey(name)) return false;
+ return fields[name];
+ }
}
class SelectorKind {
« no previous file with comments | « lib/compiler/implementation/ssa/optimize.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698