Merge branch 'master' into better-async

Conflicts:
	teavm-core/src/main/java/org/teavm/javascript/Decompiler.java
	teavm-core/src/main/java/org/teavm/javascript/Optimizer.java
This commit is contained in:
Alexey Andreev 2015-03-12 13:54:19 +04:00
commit 4ab4035522
2 changed files with 6 additions and 3 deletions

View File

@ -212,7 +212,7 @@ public class Decompiler {
node.getVariables().add(program.variableAt(i).getRegister()); node.getVariables().add(program.variableAt(i).getRegister());
} }
Optimizer optimizer = new Optimizer(); Optimizer optimizer = new Optimizer();
optimizer.optimize(node, program); optimizer.optimize(node, splitter);
node.getModifiers().addAll(mapModifiers(method.getModifiers())); node.getModifiers().addAll(mapModifiers(method.getModifiers()));
int paramCount = Math.min(method.getSignature().length, program.variableCount()); int paramCount = Math.min(method.getSignature().length, program.variableCount());
for (int i = 0; i < paramCount; ++i) { for (int i = 0; i < paramCount; ++i) {

View File

@ -19,6 +19,7 @@ import org.teavm.javascript.ast.AsyncMethodNode;
import org.teavm.javascript.ast.AsyncMethodPart; import org.teavm.javascript.ast.AsyncMethodPart;
import org.teavm.javascript.ast.RegularMethodNode; import org.teavm.javascript.ast.RegularMethodNode;
import org.teavm.model.Program; 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()); 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()) { for (AsyncMethodPart part : method.getBody()) {
OptimizingVisitor optimizer = new OptimizingVisitor(stats.copy()); OptimizingVisitor optimizer = new OptimizingVisitor(stats.copy());
part.getStatement().acceptVisitor(optimizer); part.getStatement().acceptVisitor(optimizer);