| Index: dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
|
| diff --git a/dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart b/dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
|
| index e9bb0f8697c734f888c7c05d660d49bc86cb0c3e..b4922ae8eae40a8a5d408736c2ee454cfa55ba94 100644
|
| --- a/dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
|
| +++ b/dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
|
| @@ -796,6 +796,8 @@ class CodeEmitterTask extends CompilerTask {
|
| js('newIsolate.prototype = isolatePrototype'),
|
| js('isolatePrototype.constructor = newIsolate'),
|
| js('newIsolate.${namer.isolatePropertiesName} = isolateProperties'),
|
| + // TODO(ahe): Only copy makeConstantList when it is used.
|
| + js('newIsolate.makeConstantList = oldIsolate.makeConstantList'),
|
| ]..addAll(copyFinishClasses)
|
| ..addAll([
|
|
|
| @@ -2153,8 +2155,7 @@ class CodeEmitterTask extends CompilerTask {
|
| addedMakeConstantList = true;
|
| emitMakeConstantList(eagerBuffer);
|
| }
|
| - CodeBuffer buffer =
|
| - bufferForElement(constant.computeType(compiler).element, eagerBuffer);
|
| + CodeBuffer buffer = bufferForConstant(constant, eagerBuffer);
|
| jsAst.Expression init = js('$isolateProperties.$name = #',
|
| constantInitializerExpression(constant));
|
| buffer.write(jsAst.prettyPrint(init, compiler));
|
| @@ -3025,6 +3026,35 @@ if (typeof document !== "undefined" && document.readyState !== "complete") {
|
| return deferredBuffer;
|
| }
|
|
|
| + bool firstDeferredConstant = true;
|
| +
|
| + /**
|
| + * Returns the appropriate buffer for [constant]. If [constant] is
|
| + * itself an instance of a deferred type (or built from constants
|
| + * that are instances of deferred types) attempting to use
|
| + * [constant] before the deferred type has been loaded will not
|
| + * work, and [constant] itself must be deferred.
|
| + */
|
| + CodeBuffer bufferForConstant(Constant constant, CodeBuffer eagerBuffer) {
|
| + var queue = new Queue()..add(constant);
|
| + while (!queue.isEmpty) {
|
| + constant = queue.removeFirst();
|
| + if (isDeferred(constant.computeType(compiler).element)) {
|
| + emitDeferredPreambleWhenEmpty(deferredBuffer);
|
| + if (firstDeferredConstant) {
|
| + deferredBuffer.write(
|
| + '${namer.CURRENT_ISOLATE}$_=${_}old${namer.CURRENT_ISOLATE}$N');
|
| + deferredBuffer.write(
|
| + 'old${namer.CURRENT_ISOLATE}$_=${_}${namer.CURRENT_ISOLATE}$N');
|
| + }
|
| + firstDeferredConstant = false;
|
| + return deferredBuffer;
|
| + }
|
| + queue.addAll(constant.getDependencies());
|
| + }
|
| + return eagerBuffer;
|
| + }
|
| +
|
| void emitDeferredCode(CodeBuffer buffer) {
|
| if (buffer.isEmpty) return;
|
|
|
|
|