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 8cf315a8c7143b774569cac7464c61b6e9301a9a..1df4a7925953472b42c0997d5c5af24b18615c4c 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 |
@@ -158,8 +158,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'); |
@@ -596,9 +598,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) |
@@ -630,17 +633,24 @@ 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; |
Johnni Winther
2014/12/09 11:53:52
Long line
ahe
2014/12/10 14:00:04
Done.
|
+ return Isolate; |
+ } |
+""", |
+ { 'isolatePropertiesName': namer.isolatePropertiesName, |
+ 'needsDefineClass': needsDefineClass, |
+ 'finishClassesProperty': finishClassesProperty, |
+ 'outputContainsConstantList': task.outputContainsConstantList, |
+ 'makeConstListProperty': makeConstListProperty, |
+ 'hasIncrementalSupport': compiler.hasIncrementalSupport, |
+ 'lazyInitializerProperty': lazyInitializerProperty, |
+ }); |
} |
jsAst.Fun get lazyInitializerFunction { |
@@ -931,30 +941,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. |