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

Unified Diff: lib/compiler/implementation/ssa/codegen.dart

Issue 10855174: Lazy implementation of final variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove lazy bailout initializers. 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
Index: lib/compiler/implementation/ssa/codegen.dart
diff --git a/lib/compiler/implementation/ssa/codegen.dart b/lib/compiler/implementation/ssa/codegen.dart
index 1d7476de0790f123a4ff512622b8b527f6fa353a..783fc1e6520f4c3f16f3989604f18a13eda89c37 100644
--- a/lib/compiler/implementation/ssa/codegen.dart
+++ b/lib/compiler/implementation/ssa/codegen.dart
@@ -27,6 +27,28 @@ class SsaCodeGeneratorTask extends CompilerTask {
return js.prettyPrint(node, compiler, positionElement);
}
+ CodeBuffer generateCode(WorkItem work, HGraph graph) {
+ if (work.element.isField()) {
+ return generateLazyInitializer(work, graph);
+ } else {
+ return generateMethod(work, graph);
+ }
+ }
+
+ CodeBuffer generateLazyInitializer(work, graph) {
+ return measure(() {
+ compiler.tracer.traceGraph("codegen", graph);
+ List<js.Parameter> parameters = <js.Parameter>[];
+ SsaOptimizedCodeGenerator codegen = new SsaOptimizedCodeGenerator(
+ backend, work, parameters, new Map<Element, String>());
+ codegen.visitGraph(graph);
+ js.Block body = codegen.body;
+ Element element = work.element;
+ js.Fun fun = new js.Fun(parameters, body);
+ return prettyPrint(fun, element);
+ });
+ }
+
CodeBuffer generateMethod(WorkItem work, HGraph graph) {
return measure(() {
JavaScriptItemCompilationContext context = work.compilationContext;
@@ -1964,6 +1986,15 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
push(new js.VariableUse(compiler.namer.isolateAccess(node.element)));
}
+ void visitLazyStatic(HLazyStatic node) {
+ Element element = node.element;
+ world.registerStaticUse(element);
+ String lazyGetter = compiler.namer.isolateLazyInitializerAccess(element);
+ js.VariableUse target = new js.VariableUse(lazyGetter);
+ js.Call call = new js.Call(target, <js.Expression>[]);
+ push(call, node);
+ }
+
void visitStaticStore(HStaticStore node) {
world.registerStaticUse(node.element);
js.VariableUse variableUse =
@@ -2438,6 +2469,7 @@ class SsaOptimizedCodeGenerator extends SsaCodeGenerator {
String bailoutName = namer.getBailoutName(element);
bailoutTarget = new js.PropertyAccess.field(new js.This(), bailoutName);
} else {
+ assert(!element.isField());
bailoutTarget = new js.VariableUse(namer.isolateBailoutAccess(element));
}
js.Call call = new js.Call(bailoutTarget, arguments);

Powered by Google App Engine
This is Rietveld 408576698