diff --git a/teavm-core/src/main/java/org/teavm/javascript/Decompiler.java b/teavm-core/src/main/java/org/teavm/javascript/Decompiler.java index 6b4a24a19..0f3fb7a5b 100644 --- a/teavm-core/src/main/java/org/teavm/javascript/Decompiler.java +++ b/teavm-core/src/main/java/org/teavm/javascript/Decompiler.java @@ -212,7 +212,7 @@ public class Decompiler { node.getVariables().add(program.variableAt(i).getRegister()); } Optimizer optimizer = new Optimizer(); - optimizer.optimize(node, program); + optimizer.optimize(node, splitter); node.getModifiers().addAll(mapModifiers(method.getModifiers())); int paramCount = Math.min(method.getSignature().length, program.variableCount()); for (int i = 0; i < paramCount; ++i) { diff --git a/teavm-core/src/main/java/org/teavm/javascript/Optimizer.java b/teavm-core/src/main/java/org/teavm/javascript/Optimizer.java index e32c26b37..4c7e18804 100644 --- a/teavm-core/src/main/java/org/teavm/javascript/Optimizer.java +++ b/teavm-core/src/main/java/org/teavm/javascript/Optimizer.java @@ -19,6 +19,7 @@ import org.teavm.javascript.ast.AsyncMethodNode; import org.teavm.javascript.ast.AsyncMethodPart; import org.teavm.javascript.ast.RegularMethodNode; import org.teavm.model.Program; +import org.teavm.model.util.AsyncProgramSplitter; /** * @@ -42,9 +43,11 @@ public class Optimizer { } } - public void optimize(AsyncMethodNode method, Program program) { + public void optimize(AsyncMethodNode method, AsyncProgramSplitter splitter) { ReadWriteStatsBuilder stats = new ReadWriteStatsBuilder(method.getVariables().size()); - stats.analyze(program); + for (int i = 0; i < splitter.size(); ++i) { + stats.analyze(splitter.getProgram(i)); + } for (AsyncMethodPart part : method.getBody()) { OptimizingVisitor optimizer = new OptimizingVisitor(stats.copy()); part.getStatement().acceptVisitor(optimizer);