From 8a112394363e5d45337cbe18084e936b6aeefeeb Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Tue, 3 Feb 2015 11:56:17 +0400 Subject: [PATCH] Temporarily switch off expression wielding optimization in async methods. --- .../src/main/java/org/teavm/javascript/Decompiler.java | 4 +++- .../src/main/java/org/teavm/javascript/Optimizer.java | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) 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 c5f4ca06a..b700f9e53 100644 --- a/teavm-core/src/main/java/org/teavm/javascript/Decompiler.java +++ b/teavm-core/src/main/java/org/teavm/javascript/Decompiler.java @@ -202,17 +202,19 @@ public class Decompiler { AsyncMethodNode node = new AsyncMethodNode(method.getReference()); AsyncProgramSplitter splitter = new AsyncProgramSplitter(asyncMethods); splitter.split(method.getProgram()); + List partPrograms = new ArrayList<>(); for (int i = 0; i < splitter.size(); ++i) { AsyncMethodPart part = getRegularMethodStatement(splitter.getProgram(i), splitter.getBlockSuccessors(i)); part.setInputVariable(splitter.getInput(i)); node.getBody().add(part); + partPrograms.add(splitter.getProgram(i)); } Program program = method.getProgram(); for (int i = 0; i < program.variableCount(); ++i) { node.getVariables().add(program.variableAt(i).getRegister()); } Optimizer optimizer = new Optimizer(); - optimizer.optimize(node, method.getProgram()); + optimizer.optimize(node, partPrograms); 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 5396e0964..9e0d53395 100644 --- a/teavm-core/src/main/java/org/teavm/javascript/Optimizer.java +++ b/teavm-core/src/main/java/org/teavm/javascript/Optimizer.java @@ -15,6 +15,7 @@ */ package org.teavm.javascript; +import java.util.List; import org.teavm.javascript.ast.AsyncMethodNode; import org.teavm.javascript.ast.AsyncMethodPart; import org.teavm.javascript.ast.RegularMethodNode; @@ -43,9 +44,11 @@ public class Optimizer { } } - public void optimize(AsyncMethodNode method, Program program) { + public void optimize(AsyncMethodNode method, List programs) { ReadWriteStatsBuilder stats = new ReadWriteStatsBuilder(method.getVariables().size()); - stats.analyze(program); + for (Program program : programs) { + stats.analyze(program); + } OptimizingVisitor optimizer = new OptimizingVisitor(stats); for (AsyncMethodPart part : method.getBody()) { part.getStatement().acceptVisitor(optimizer);