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

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

Issue 739513002: Incremental compilation of removed class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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
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 bf4dffd0328b7c5ba608caf06dc94f8bd4f9b960..29359e7c16871f36c28a6130fdfb7927cf3d6233 100644
--- a/dart/pkg/dart2js_incremental/lib/library_updater.dart
+++ b/dart/pkg/dart2js_incremental/lib/library_updater.dart
@@ -255,6 +255,9 @@ class LibraryUpdater extends JsFeatures {
if (element is PartialFunctionElement) {
removeFunction(element);
return true;
+ } else if (element is PartialClassElement) {
+ removeClass(element);
+ return true;
}
return cannotReuse(element, "Removed element that isn't a function.");
}
@@ -269,6 +272,19 @@ class LibraryUpdater extends JsFeatures {
updates.add(new RemovedFunctionUpdate(compiler, element));
}
+ void removeClass(PartialClassElement element) {
+ logVerbose("Removed class $element.");
+
+ invalidateScopesAffectedBy(element, element.enclosingElement);
+
+ _removedElements.add(element);
+ element.forEachLocalMember((ElementX member) {
+ _removedElements.add(member);
+ });
+
+ updates.add(new RemovedClassUpdate(compiler, element));
+ }
+
void invalidateScopesAffectedBy(
ElementX element,
ScopeContainerElement container) {
@@ -616,54 +632,15 @@ abstract class ReuseFunction {
}
}
-class RemovedFunctionUpdate extends Update with JsFeatures, ReuseFunction {
- final PartialFunctionElement element;
-
- /// Name of property to remove using JavaScript "delete". Null for
- /// non-instance methods.
- String name;
-
- /// Name of super-alias property to remove using JavaScript "delete". Null
- /// for methods that aren't "super aliased", and non-instance methods.
- String superName;
-
- /// For instance methods, access to class object. Otherwise, access to the
- /// method itself.
- jsAst.Node elementAccess;
-
- bool wasStateCaptured = false;
+class RemovalUpdate extends Update {
+ ElementX get element;
- RemovedFunctionUpdate(Compiler compiler, this.element)
+ RemovalUpdate(Compiler compiler)
: super(compiler);
- PartialFunctionElement get before => element;
-
- PartialElement get after => null;
-
bool get isRemoval => true;
- void captureState() {
- if (wasStateCaptured) throw "captureState was called twice.";
-
- if (element.isInstanceMember) {
- elementAccess = namer.elementAccess(element.enclosingClass);
- name = namer.getNameOfMember(element);
- if (backend.isAliasedSuperMember(element)) {
- superName = namer.getNameOfAliasedSuperMember(element);
- }
- } else {
- elementAccess = namer.elementAccess(element);
- }
-
- wasStateCaptured = true;
- }
-
- PartialFunctionElement apply() {
- if (!wasStateCaptured) throw "captureState must be called before apply.";
- removeFromEnclosing();
- reuseElement();
- return null;
- }
+ void writeUpdateJsOn(List<jsAst.Statement> updates);
void removeFromEnclosing() {
// TODO(ahe): Need to recompute duplicated elements logic again. Simplest
@@ -701,6 +678,54 @@ class RemovedFunctionUpdate extends Update with JsFeatures, ReuseFunction {
return copy.toLink(link);
}
+}
+
+class RemovedFunctionUpdate extends RemovalUpdate
+ with JsFeatures, ReuseFunction {
+ final PartialFunctionElement element;
+
+ /// Name of property to remove using JavaScript "delete". Null for
+ /// non-instance methods.
+ String name;
+
+ /// Name of super-alias property to remove using JavaScript "delete". Null
+ /// for methods that aren't "super aliased", and non-instance methods.
+ String superName;
+
+ /// For instance methods, access to class object. Otherwise, access to the
+ /// method itself.
+ jsAst.Node elementAccess;
+
+ bool wasStateCaptured = false;
+
+ RemovedFunctionUpdate(Compiler compiler, this.element)
+ : super(compiler);
+
+ PartialFunctionElement get before => element;
+
+ PartialFunctionElement get after => null;
+
+ void captureState() {
+ if (wasStateCaptured) throw "captureState was called twice.";
+ wasStateCaptured = true;
+
+ if (element.isInstanceMember) {
+ elementAccess = namer.elementAccess(element.enclosingClass);
+ name = namer.getNameOfMember(element);
+ if (backend.isAliasedSuperMember(element)) {
+ superName = namer.getNameOfAliasedSuperMember(element);
+ }
+ } else {
+ elementAccess = namer.elementAccess(element);
+ }
+ }
+
+ PartialFunctionElement apply() {
+ if (!wasStateCaptured) throw "captureState must be called before apply.";
+ removeFromEnclosing();
+ reuseElement();
+ return null;
+ }
void writeUpdateJsOn(List<jsAst.Statement> updates) {
if (elementAccess == null) {
@@ -724,6 +749,65 @@ class RemovedFunctionUpdate extends Update with JsFeatures, ReuseFunction {
}
}
+class RemovedClassUpdate extends RemovalUpdate with JsFeatures {
+ final PartialClassElement element;
+
+ bool wasStateCaptured = false;
+
+ final List<jsAst.Node> accessToStatics = <jsAst.Node>[];
+
+ RemovedClassUpdate(Compiler compiler, this.element)
+ : super(compiler);
+
+ PartialClassElement get before => element;
+
+ PartialClassElement get after => null;
+
+ bool get isRemoval => true;
Johnni Winther 2014/11/19 12:43:53 Not needed. Is already declared in RemovalUpdate.
ahe 2014/11/21 10:47:45 Done.
+
+ void captureState() {
+ if (wasStateCaptured) throw "captureState was called twice.";
+ wasStateCaptured = true;
+
+ accessToStatics.add(namer.elementAccess(element));
+
+ element.forEachLocalMember((ElementX member) {
+ if (!member.isInstanceMember) {
+ accessToStatics.add(namer.elementAccess(member));
+ }
+ });
+ }
+
+ PartialClassElement apply() {
+ if (!wasStateCaptured) {
+ throw new StateError("captureState must be called before apply.");
+ }
+
+ removeFromEnclosing();
+
+ element.forEachLocalMember((ElementX member) {
+ compiler.forgetElement(before);
+ member.reuseElement();
+ });
+
+ compiler.forgetElement(element);
+ element.reuseElement();
+
+ return null;
+ }
+
+ void writeUpdateJsOn(List<jsAst.Statement> updates) {
+ if (accessToStatics.isEmpty) {
+ throw
+ new StateError("captureState must be called before writeUpdateJsOn.");
+ }
+
+ for (jsAst.Node access in accessToStatics) {
+ updates.add(js.statement('delete #', [access]));
+ }
+ }
+}
+
class AddedFunctionUpdate extends Update with JsFeatures {
final PartialFunctionElement element;

Powered by Google App Engine
This is Rietveld 408576698