| 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));
|
| }
|
|
|