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

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: rebase wrt CL 10832351. Created 8 years, 4 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 f68eedea1faed2849d015a57aa7f258300eda6ed..6d5be7f8c2321c4b3933df02ee1da663af175238 100644
--- a/lib/compiler/implementation/ssa/codegen.dart
+++ b/lib/compiler/implementation/ssa/codegen.dart
@@ -25,6 +25,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(() {
compiler.tracer.traceGraph("codegen", graph);
@@ -1937,6 +1959,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 =
@@ -2445,6 +2476,9 @@ class SsaOptimizedCodeGenerator extends SsaCodeGenerator {
// super call. We must make bailout names unique.
String bailoutName = namer.getBailoutName(element);
bailoutTarget = new js.PropertyAccess.field(new js.This(), bailoutName);
+ } else if (element.isField()) {
+ String bailoutName = namer.isolateLazyInitializerBailoutAccess(element);
+ bailoutTarget = new js.VariableUse(bailoutName);
} else {
bailoutTarget = new js.VariableUse(namer.isolateBailoutAccess(element));
}

Powered by Google App Engine
This is Rietveld 408576698