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

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

Issue 10584009: Refactor the collection of initializer list types (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Moved data structures to backend 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 | « no previous file | lib/compiler/implementation/enqueue.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/compiler.dart
diff --git a/lib/compiler/implementation/compiler.dart b/lib/compiler/implementation/compiler.dart
index 110d9d70608650a030bc9aa81822086d5f6a87b8..3ade4be683f686366192482aff80cce29607c9a3 100644
--- a/lib/compiler/implementation/compiler.dart
+++ b/lib/compiler/implementation/compiler.dart
@@ -34,8 +34,12 @@ class WorkItem {
class Backend {
final Compiler compiler;
+ final Map<Element, Map<SourceString, HType>> fieldInitializers;
karlklose 2012/06/19 15:07:40 Why not move these datastructures to the JavaScrip
+ final Map<Element, Map<SourceString, bool>> fieldIntegerSetters;
- Backend(this.compiler);
+ Backend(this.compiler)
+ : fieldInitializers = new Map<Element, Map<SourceString, HType>>(),
+ fieldIntegerSetters = new Map<Element, Map<SourceString, bool>>();
void enqueueAllTopLevelFunctions(LibraryElement lib, Enqueuer world) {
lib.forEachExport((Element e) {
@@ -49,6 +53,70 @@ class Backend {
Collection<LibraryElement> libraries);
abstract void assembleProgram();
abstract List<CompilerTask> get tasks();
+
+ void updateFieldInitializers(Type type,
+ SourceString name,
+ HType propagatedType) {
+ Map<SourceString, HType> fields =
+ fieldInitializers.putIfAbsent(
+ type.element, () => new Map<SourceString, HType>());
+ if (!fields.containsKey(name)) {
+ fields[name] = propagatedType;
+ } else {
+ if (fields[name] != propagatedType) fields[name] = HType.UNKNOWN;
+ }
+ }
+
+ bool couldHaveFieldSingleTypeInitializers(Type type,
+ SourceString name,
+ HType requestedType) {
+ if (type == null) return false;
+ // If there is no information on the initializer it might still be
+ // initialized to integers only.
+ if (!fieldInitializers.containsKey(type.element)) return true;
+ Map<SourceString, HType> fields = fieldInitializers[type.element];
+ HType propagatedType = fields[name];
+ if (propagatedType == null) return true;
+ return propagatedType == requestedType;
+ }
+
+ bool hasFieldSingleTypeInitializers(Type type,
+ SourceString name,
+ HType requestedType) {
+ if (type == null) return false;
+ if (!fieldInitializers.containsKey(type.element)) return false;
+ Map<SourceString, HType> fields = fieldInitializers[type.element];
+ HType propagatedType = fields[name];
+ if (propagatedType == null) return false;
+ return propagatedType == requestedType;
+ }
+
+ 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 JavaScriptBackend extends Backend {
« no previous file with comments | « no previous file | lib/compiler/implementation/enqueue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698