mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Merge branch 'async' of https://github.com/konsoletyper/teavm into threads
This commit is contained in:
commit
8fa50a0504
|
@ -202,17 +202,19 @@ public class Decompiler {
|
|||
AsyncMethodNode node = new AsyncMethodNode(method.getReference());
|
||||
AsyncProgramSplitter splitter = new AsyncProgramSplitter(asyncMethods);
|
||||
splitter.split(method.getProgram());
|
||||
List<Program> 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) {
|
||||
|
|
|
@ -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<Program> 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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user