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

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

Issue 735303002: Incremental compilation of added instance fields. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r41892 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 a480c692b9d63046e228a0570907ef3d111c40d2..e268558490df1ce01afe23225909331c6e7e56f1 100644
--- a/dart/pkg/dart2js_incremental/lib/library_updater.dart
+++ b/dart/pkg/dart2js_incremental/lib/library_updater.dart
@@ -28,6 +28,7 @@ import 'package:compiler/src/scanner/scannerlib.dart' show
EOF_TOKEN,
PartialClassElement,
PartialElement,
+ PartialFieldList,
PartialFunctionElement,
Token;
@@ -115,6 +116,9 @@ class LibraryUpdater extends JsFeatures {
final Set<ElementX> _removedElements = new Set<ElementX>();
+ final Set<ClassElementX> _classesWithSchemaChanges =
+ new Set<ClassElementX>();
+
LibraryUpdater(
this.compiler,
this.inputProvider,
@@ -184,7 +188,7 @@ class LibraryUpdater extends JsFeatures {
logTime('Looking at difference: $difference');
if (difference.before == null && difference.after is PartialElement) {
- canReuseAddedElement(difference.after, element);
+ canReuseAddedElement(difference.after, element, newElement);
continue;
}
if (difference.after == null && difference.before is PartialElement) {
@@ -225,15 +229,19 @@ class LibraryUpdater extends JsFeatures {
bool canReuseAddedElement(
PartialElement element,
- ScopeContainerElement container) {
+ ScopeContainerElement container,
+ ScopeContainerElement syntheticContainer) {
if (element is PartialFunctionElement) {
addFunction(element, container);
return true;
} else if (element is PartialClassElement) {
addClass(element, container);
return true;
+ } else if (element is PartialFieldList) {
+ addFields(element, container, syntheticContainer);
+ return true;
}
- return cannotReuse(element, "Added element that isn't a function.");
+ return cannotReuse(element, "Adding ${element.runtimeType} not supported.");
}
void addFunction(
@@ -252,6 +260,36 @@ class LibraryUpdater extends JsFeatures {
updates.add(new AddedClassUpdate(compiler, element, library));
}
+ void addFields(
Johnni Winther 2014/11/21 14:23:05 Add documentation, especially for [syntheticContai
ahe 2014/11/21 15:48:47 Done, added: /// Called when a field in [defini
+ PartialFieldList definition,
+ ScopeContainerElement container,
+ ScopeContainerElement syntheticContainer) {
+ List<FieldElementX> fields = <FieldElementX>[];
+ syntheticContainer.forEachLocalMember((ElementX member) {
+ if (member.declarationSite == definition) {
+ fields.add(member);
+ }
+ });
+ for (FieldElementX field in fields) {
+ addField(field, container);
+ }
+ }
+
+ void addField(FieldElementX element, ScopeContainerElement container) {
+ invalidateScopesAffectedBy(element, container);
+ if (!element.isInstanceMember) {
+ cannotReuse(element, "Not an instance field.");
+ } else {
+ addInstanceField(element, container);
+ }
+ }
+
+ void addInstanceField(FieldElementX element, ClassElementX cls) {
+ _classesWithSchemaChanges.add(cls);
+
+ updates.add(new AddedFieldUpdate(compiler, element, cls));
+ }
+
bool canReuseRemovedElement(PartialElement element) {
if (element is PartialFunctionElement) {
removeFunction(element);
@@ -459,7 +497,8 @@ class LibraryUpdater extends JsFeatures {
compiler.phase = Compiler.PHASE_DONE_RESOLVING;
- Set<PartialClassElement> changedClasses = new Set<PartialClassElement>();
+ Set<PartialClassElement> changedClasses =
+ new Set<PartialClassElement>.from(_classesWithSchemaChanges);
for (Element element in updatedElements) {
if (!element.isClass) {
compiler.enqueuer.codegen.addToWorkList(element);
@@ -883,6 +922,26 @@ class AddedClassUpdate extends Update with JsFeatures {
}
}
+class AddedFieldUpdate extends Update with JsFeatures {
+ final FieldElementX element;
+
+ final ScopeContainerElement container;
+
+ AddedFieldUpdate(Compiler compiler, this.element, this.container)
+ : super(compiler);
+
+ PartialFieldList get before => null;
+
+ PartialFieldList get after => element.declarationSite;
+
+ FieldElementX apply() {
+ FieldElementX copy = element.copyWithEnclosing(container);
+ container.addMember(copy, compiler);
+ return copy;
+ }
+}
+
+
class ClassUpdate extends Update with JsFeatures {
final PartialClassElement before;
« no previous file with comments | « dart/pkg/compiler/lib/src/elements/modelx.dart ('k') | dart/tests/try/web/incremental_compilation_update_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698