| Index: lib/compiler/implementation/ssa/codegen.dart
|
| diff --git a/lib/compiler/implementation/ssa/codegen.dart b/lib/compiler/implementation/ssa/codegen.dart
|
| index 25fd77484649b5809f2ed359dddce9a330666cef..1af5d646929fc33e2e57871d4c5197c51eed6731 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);
|
| @@ -1880,8 +1902,18 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
|
| }
|
|
|
| void visitStatic(HStatic node) {
|
| - world.registerStaticUse(node.element);
|
| - push(new js.VariableUse(compiler.namer.isolateAccess(node.element)));
|
| + Element element = node.element;
|
| + world.registerStaticUse(element);
|
| + push(new js.VariableUse(compiler.namer.isolateAccess(element)), node);
|
| + }
|
| +
|
| + 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) {
|
| @@ -2393,6 +2425,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));
|
| }
|
|
|