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

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

Issue 1029003002: dart2js: remove first argument from lazy function. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added comment. Created 5 years, 9 months 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 | pkg/dart2js_incremental/lib/library_updater.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart
diff --git a/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart b/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart
index e05d1df1d8847e3dc77fcabd367e338640a928f4..18390375aedae22810435746e0b79d96194b189b 100644
--- a/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart
@@ -854,7 +854,7 @@ class OldEmitter implements Emitter {
needsLazyInitializer = true;
for (VariableElement element in Elements.sortedByPosition(lazyFields)) {
jsAst.Expression init =
- buildLazilyInitializedStaticField(element, isolateProperties);
+ buildLazilyInitializedStaticField(element);
if (init == null) continue;
output.addBuffer(
jsAst.prettyPrint(init, compiler, monitor: compiler.dumpInfoTask));
@@ -864,7 +864,7 @@ class OldEmitter implements Emitter {
}
jsAst.Expression buildLazilyInitializedStaticField(
- VariableElement element, String isolateProperties) {
+ 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
@@ -875,13 +875,22 @@ class OldEmitter implements Emitter {
// 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('#(#,#,#,#,#)',
+ if (isolateProperties != null) {
+ return js('#(#,#,#,#,#)',
+ [js(lazyInitializerName),
+ js.string(element.name),
+ js.string(namer.globalPropertyName(element)),
+ js.string(namer.lazyInitializerName(element)),
+ code,
+ isolateProperties]);
+ }
+
+ return js('#(#,#,#,#)',
[js(lazyInitializerName),
- js(isolateProperties),
- js.string(element.name),
- js.string(namer.globalPropertyName(element)),
- js.string(namer.lazyInitializerName(element)),
- code]);
+ js.string(element.name),
+ js.string(namer.globalPropertyName(element)),
+ js.string(namer.lazyInitializerName(element)),
+ code]);
}
void emitMetadata(Program program, CodeOutput output) {
@@ -998,7 +1007,6 @@ class OldEmitter implements Emitter {
}
void emitInitFunction(CodeOutput output) {
- String isolate = namer.currentIsolate;
jsAst.Expression allClassesAccess =
generateEmbeddedGlobalAccess(embeddedNames.ALL_CLASSES);
jsAst.Expression getTypeFromNameAccess =
@@ -1024,28 +1032,32 @@ class OldEmitter implements Emitter {
#finishedClasses = Object.create(null);
if (#needsLazyInitializer) {
- $lazyInitializerName = function (prototype, staticName, fieldName,
- getterName, lazyValue) {
+ $lazyInitializerName = function (staticName, fieldName, getterName,
+ lazyValue, prototype) {
if (!#lazies) #lazies = Object.create(null);
#lazies[fieldName] = getterName;
+ // 'prototype' will be undefined except if we are doing an update
+ // during incremental compilation. In this case we put the lazy
+ // field directly on the isolate instead of the isolateProperties.
+ prototype = prototype || $isolateProperties;
var sentinelUndefined = {};
var sentinelInProgress = {};
prototype[fieldName] = sentinelUndefined;
prototype[getterName] = function () {
- var result = $isolate[fieldName];
+ var result = this[fieldName];
try {
if (result === sentinelUndefined) {
- $isolate[fieldName] = sentinelInProgress;
+ this[fieldName] = sentinelInProgress;
try {
- result = $isolate[fieldName] = lazyValue();
+ result = this[fieldName] = lazyValue();
} finally {
// Use try-finally, not try-catch/throw as it destroys the
// stack trace.
if (result === sentinelUndefined)
- $isolate[fieldName] = null;
+ this[fieldName] = null;
}
} else {
if (result === sentinelInProgress)
@@ -1054,7 +1066,7 @@ class OldEmitter implements Emitter {
return result;
} finally {
- $isolate[getterName] = function() { return this[fieldName]; };
+ this[getterName] = function() { return this[fieldName]; };
}
}
}
« no previous file with comments | « no previous file | pkg/dart2js_incremental/lib/library_updater.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698