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

Unified Diff: dart/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart

Issue 764023002: Incremental compilation of new lazy statics. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments and also test for needsDefineClass to see if defineClass is needed. Created 6 years 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/pkg/dart2js_incremental/lib/caching_compiler.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart
diff --git a/dart/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart b/dart/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart
index 09e1d7ecfa5a284a5e1021071dd602c91bedcdcc..28dd43342be448bfed90c442ad168a87f55f5b72 100644
--- a/dart/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart
+++ b/dart/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart
@@ -159,8 +159,10 @@ class OldEmitter implements Emitter {
=> '${namer.isolateName}.\$finishIsolateConstructor';
String get isolatePropertiesName
=> '${namer.isolateName}.${namer.isolatePropertiesName}';
+ String get lazyInitializerProperty
+ => r'$lazy';
String get lazyInitializerName
- => '${namer.isolateName}.\$lazy';
+ => '${namer.isolateName}.${lazyInitializerProperty}';
String get initName => 'init';
String get makeConstListProperty
=> namer.getMappedInstanceName('makeConstantList');
@@ -688,9 +690,10 @@ class OldEmitter implements Emitter {
//
// We also copy over old values like the prototype, and the
// isolateProperties themselves.
- return js('''
+ return js(
+ """
function (oldIsolate) {
- var isolateProperties = oldIsolate.#; // isolatePropertiesName
+ var isolateProperties = oldIsolate.#isolatePropertiesName;
function Isolate() {
var hasOwnProperty = Object.prototype.hasOwnProperty;
for (var staticName in isolateProperties)
@@ -722,17 +725,25 @@ class OldEmitter implements Emitter {
}
Isolate.prototype = oldIsolate.prototype;
Isolate.prototype.constructor = Isolate;
- Isolate.# = isolateProperties; // isolatePropertiesName
- if (#) // needsDefineClass.
- Isolate.# = oldIsolate.#; // finishClassesProperty * 2
- if (#) // outputContainsConstantList
- Isolate.# = oldIsolate.#; // makeConstListProperty * 2
- return Isolate;
- }''',
- [namer.isolatePropertiesName, namer.isolatePropertiesName,
- needsDefineClass, finishClassesProperty, finishClassesProperty,
- task.outputContainsConstantList,
- makeConstListProperty, makeConstListProperty ]);
+ Isolate.#isolatePropertiesName = isolateProperties;
+ if (#needsDefineClass)
+ Isolate.#finishClassesProperty = oldIsolate.#finishClassesProperty;
+ if (#outputContainsConstantList)
+ Isolate.#makeConstListProperty = oldIsolate.#makeConstListProperty;
+ if (#hasIncrementalSupport)
+ Isolate.#lazyInitializerProperty =
+ oldIsolate.#lazyInitializerProperty;
+ return Isolate;
+ }
+""",
+ { 'isolatePropertiesName': namer.isolatePropertiesName,
+ 'needsDefineClass': needsDefineClass,
+ 'finishClassesProperty': finishClassesProperty,
+ 'outputContainsConstantList': task.outputContainsConstantList,
+ 'makeConstListProperty': makeConstListProperty,
+ 'hasIncrementalSupport': compiler.hasIncrementalSupport,
+ 'lazyInitializerProperty': lazyInitializerProperty,
+ });
}
jsAst.Fun get lazyInitializerFunction {
@@ -1023,30 +1034,37 @@ class OldEmitter implements Emitter {
if (!lazyFields.isEmpty) {
needsLazyInitializer = true;
for (VariableElement element in Elements.sortedByPosition(lazyFields)) {
- jsAst.Expression code = backend.generatedCode[element];
- // The code is null if we ended up not needing the lazily
- // initialized field after all because of constant folding
- // before code generation.
- if (code == null) continue;
- // The code only computes the initial value. We build the lazy-check
- // here:
- // lazyInitializer(prototype, 'name', fieldName, getterName, initial);
- // The name is used for error reporting. The 'initial' must be a
- // closure that constructs the initial value.
- jsAst.Expression init = js('#(#,#,#,#,#)',
- [js(lazyInitializerName),
- js(isolateProperties),
- js.string(element.name),
- js.string(namer.getNameX(element)),
- js.string(namer.getLazyInitializerName(element)),
- code]);
- buffer.write(jsAst.prettyPrint(init, compiler,
- monitor: compiler.dumpInfoTask));
+ jsAst.Expression init =
+ buildLazilyInitializedStaticField(element, isolateProperties);
+ if (init == null) continue;
+ buffer.write(
+ jsAst.prettyPrint(init, compiler, monitor: compiler.dumpInfoTask));
buffer.write("$N");
}
}
}
+ jsAst.Expression buildLazilyInitializedStaticField(
+ VariableElement element, String isolateProperties) {
+ jsAst.Expression code = backend.generatedCode[element];
+ // The code is null if we ended up not needing the lazily
+ // initialized field after all because of constant folding
+ // before code generation.
+ if (code == null) return null;
+ // The code only computes the initial value. We build the lazy-check
+ // here:
+ // lazyInitializer(prototype, 'name', fieldName, getterName, initial);
+ // The name is used for error reporting. The 'initial' must be a
+ // closure that constructs the initial value.
+ return js('#(#,#,#,#,#)',
+ [js(lazyInitializerName),
+ js(isolateProperties),
+ js.string(element.name),
+ js.string(namer.getNameX(element)),
+ js.string(namer.getLazyInitializerName(element)),
+ code]);
+ }
+
bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant) {
if (constant.isFunction) return true; // Already emitted.
if (constant.isPrimitive) return true; // Inlined.
@@ -1598,7 +1616,8 @@ class OldEmitter implements Emitter {
emitStaticFunctions(task.outputStaticLists[mainOutputUnit]);
// Only output the classesCollector if we actually have any classes.
- if (!(nativeClasses.isEmpty &&
+ if (needsDefineClass ||
+ !(nativeClasses.isEmpty &&
compiler.codegenWorld.staticFunctionsNeedingGetter.isEmpty &&
outputClassLists.values.every((classList) => classList.isEmpty) &&
typedefsNeededForReflection.isEmpty)) {
« no previous file with comments | « no previous file | dart/pkg/dart2js_incremental/lib/caching_compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698