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

Unified Diff: dart/pkg/dart2js_incremental/lib/library_updater.dart

Issue 742043002: Incremental compilation of removed fields. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r41952 Created 6 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
« no previous file with comments | « no previous file | dart/tests/try/web/incremental_compilation_update_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/pkg/dart2js_incremental/lib/library_updater.dart
diff --git a/dart/pkg/dart2js_incremental/lib/library_updater.dart b/dart/pkg/dart2js_incremental/lib/library_updater.dart
index e3888ad38def5c7c5ff9a8f7ec2f7368866a7581..6ec3330589877a4a850b56c7d3ff76f106cf08b3 100644
--- a/dart/pkg/dart2js_incremental/lib/library_updater.dart
+++ b/dart/pkg/dart2js_incremental/lib/library_updater.dart
@@ -194,7 +194,7 @@ class LibraryUpdater extends JsFeatures {
continue;
}
if (difference.after == null && difference.before is PartialElement) {
- canReuseRemovedElement(difference.before);
+ canReuseRemovedElement(difference.before, element);
continue;
}
Token diffToken = difference.token;
@@ -282,6 +282,8 @@ class LibraryUpdater extends JsFeatures {
}
});
for (FieldElementX field in fields) {
+ // TODO(ahe): This only works when there's one field per
+ // PartialFieldList.
addField(field, container);
}
}
@@ -301,15 +303,21 @@ class LibraryUpdater extends JsFeatures {
updates.add(new AddedFieldUpdate(compiler, element, cls));
}
- bool canReuseRemovedElement(PartialElement element) {
+ bool canReuseRemovedElement(
+ PartialElement element,
+ ScopeContainerElement container) {
if (element is PartialFunctionElement) {
removeFunction(element);
return true;
} else if (element is PartialClassElement) {
removeClass(element);
return true;
+ } else if (element is PartialFieldList) {
+ removeFields(element, container);
+ return true;
}
- return cannotReuse(element, "Removed element that isn't a function.");
+ return cannotReuse(
+ element, "Removing ${element.runtimeType} not supported.");
}
void removeFunction(PartialFunctionElement element) {
@@ -335,6 +343,42 @@ class LibraryUpdater extends JsFeatures {
updates.add(new RemovedClassUpdate(compiler, element));
}
+ void removeFields(
+ PartialFieldList definition,
+ ScopeContainerElement container) {
+ List<FieldElementX> fields = <FieldElementX>[];
+ container.forEachLocalMember((ElementX member) {
+ if (member.declarationSite == definition) {
+ fields.add(member);
+ }
+ });
+ for (FieldElementX field in fields) {
+ // TODO(ahe): This only works when there's one field per
+ // PartialFieldList.
+ removeField(field);
+ }
+ }
+
+ void removeField(FieldElementX element) {
+ logVerbose("Removed field $element.");
+ if (!element.isInstanceMember) {
+ cannotReuse(element, "Not an instance field.");
+ } else {
+ removeInstanceField(element);
+ }
+ }
+
+ void removeInstanceField(FieldElementX element) {
+ PartialClassElement cls = element.enclosingClass;
+
+ _classesWithSchemaChanges.add(cls);
+ invalidateScopesAffectedBy(element, cls);
+
+ _removedElements.add(element);
+
+ updates.add(new RemovedFieldUpdate(compiler, element));
+ }
+
void invalidateScopesAffectedBy(
ElementX element,
/* ScopeContainerElement */ container) {
@@ -872,6 +916,52 @@ class RemovedClassUpdate extends RemovalUpdate with JsFeatures {
}
}
+class RemovedFieldUpdate extends RemovalUpdate with JsFeatures {
+ final FieldElementX element;
+
+ bool wasStateCaptured;
+
+ jsAst.Node elementAccess;
+
+ String getterName;
+
+ String setterName;
+
+ RemovedFieldUpdate(Compiler compiler, this.element)
+ : super(compiler);
+
+ void captureState() {
+ if (wasStateCaptured) throw "captureState was called twice.";
+ wasStateCaptured = true;
+
+ elementAccess = namer.elementAccess(element.enclosingClass);
+ getterName = namer.getterName(element);
+ setterName = namer.setterName(element);
+ }
+
+ FieldElementX apply() {
+ if (!wasStateCaptured) {
+ throw new StateError("captureState must be called before apply.");
+ }
+
+ removeFromEnclosing();
+
+ return element;
+ }
+
+ void writeUpdateJsOn(List<jsAst.Statement> updates) {
+ if (!wasStateCaptured) {
+ throw new StateError(
+ "captureState must be called before writeUpdateJsOn.");
+ }
+
+ updates.add(
+ js.statement('delete #.prototype.#', [elementAccess, getterName]));
+ updates.add(
+ js.statement('delete #.prototype.#', [elementAccess, setterName]));
+ }
+}
+
class AddedFunctionUpdate extends Update with JsFeatures {
final PartialFunctionElement element;
« no previous file with comments | « no previous file | dart/tests/try/web/incremental_compilation_update_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698