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

Unified Diff: lib/compiler/implementation/js_backend/backend.dart

Issue 10855174: Lazy implementation of final variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase and merge. Created 8 years, 3 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 | « lib/compiler/implementation/compiler.dart ('k') | lib/compiler/implementation/js_backend/emitter.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/js_backend/backend.dart
diff --git a/lib/compiler/implementation/js_backend/backend.dart b/lib/compiler/implementation/js_backend/backend.dart
index c96cd0eba00473d7d7754bf000249b85ac1b3e01..213a3ac7e603482d6818c33369879ef62556c33b 100644
--- a/lib/compiler/implementation/js_backend/backend.dart
+++ b/lib/compiler/implementation/js_backend/backend.dart
@@ -327,6 +327,10 @@ class JavaScriptBackend extends Backend {
argumentTypes = new ArgumentTypesRegistry(this);
}
+ Element get cyclicThrowHelper() {
+ return compiler.findHelper(const SourceString("throwCyclicInit"));
+ }
+
JavaScriptItemCompilationContext createItemCompilationContext() {
return new JavaScriptItemCompilationContext();
}
@@ -343,6 +347,19 @@ class JavaScriptBackend extends Backend {
}
void codegen(WorkItem work) {
+ if (work.element.kind.category == ElementCategory.VARIABLE) {
+ Constant initialValue = compiler.constantHandler.compileWorkItem(work);
+ if (initialValue !== null) {
+ return;
+ } else {
+ // If the constant-handler was not able to produce a result we have to
+ // go through the builder (below) to generate the lazy initializer for
+ // the static variable.
+ // We also need to register the use of the cyclic-error helper.
+ compiler.enqueuer.codegen.registerStaticUse(cyclicThrowHelper);
+ }
+ }
+
HGraph graph = builder.build(work);
optimizer.optimize(work, graph);
if (work.allowSpeculativeOptimization
@@ -352,10 +369,9 @@ class JavaScriptBackend extends Backend {
optimizer.prepareForSpeculativeOptimizations(work, graph);
optimizer.optimize(work, graph);
}
- CodeBuffer codeBuffer = generator.generateMethod(work, graph);
+ CodeBuffer codeBuffer = generator.generateCode(work, graph);
compiler.codegenWorld.addGeneratedCode(work, codeBuffer);
- invalidateAfterCodegen.forEach(
- compiler.enqueuer.codegen.eagerRecompile);
+ invalidateAfterCodegen.forEach(compiler.enqueuer.codegen.eagerRecompile);
invalidateAfterCodegen.clear();
}
« no previous file with comments | « lib/compiler/implementation/compiler.dart ('k') | lib/compiler/implementation/js_backend/emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698