Fix bug in method submit API

This commit is contained in:
Alexey Andreev 2015-10-21 18:45:37 +03:00
parent ce83560279
commit 804b51abf5
2 changed files with 13 additions and 4 deletions

View File

@ -216,7 +216,7 @@ public class DataFlowGraphBuilder implements InstructionReader {
@Override @Override
public void exit(VariableReader valueToReturn) { public void exit(VariableReader valueToReturn) {
if (valueToReturn != null && returnIndex >= 0) { if (valueToReturn != null && returnIndex >= 0) {
connect(valueToReturn.getIndex(), returnIndex); builder.addEdge(valueToReturn.getIndex(), returnIndex);
} }
} }
@ -253,7 +253,7 @@ public class DataFlowGraphBuilder implements InstructionReader {
if (fieldType instanceof ValueType.Primitive) { if (fieldType instanceof ValueType.Primitive) {
return; return;
} }
connect(getFieldNode(field), receiver.getIndex()); builder.addEdge(getFieldNode(field), receiver.getIndex());
} }
@Override @Override
@ -261,7 +261,7 @@ public class DataFlowGraphBuilder implements InstructionReader {
if (fieldType instanceof ValueType.Primitive) { if (fieldType instanceof ValueType.Primitive) {
return; return;
} }
connect(value.getIndex(), getFieldNode(field)); builder.addEdge(value.getIndex(), getFieldNode(field));
} }
@Override @Override

View File

@ -51,6 +51,7 @@ import org.teavm.model.Program;
import org.teavm.model.ValueType; import org.teavm.model.ValueType;
import org.teavm.model.util.ModelUtils; import org.teavm.model.util.ModelUtils;
import org.teavm.model.util.ProgramUtils; import org.teavm.model.util.ProgramUtils;
import org.teavm.optimization.UnreachableBasicBlockEliminator;
/** /**
* *
@ -177,12 +178,20 @@ public class DependencyChecker implements DependencyInfo {
if (!method.hasModifier(ElementModifier.NATIVE)) { if (!method.hasModifier(ElementModifier.NATIVE)) {
throw new IllegalArgumentException("Method is not native: " + methodRef); throw new IllegalArgumentException("Method is not native: " + methodRef);
} }
if (!dep.used) {
return;
}
method.getModifiers().remove(ElementModifier.NATIVE); method.getModifiers().remove(ElementModifier.NATIVE);
method.setProgram(ProgramUtils.copy(program)); method.setProgram(ProgramUtils.copy(program));
new UnreachableBasicBlockEliminator().optimize(method.getProgram());
dep.used = false; dep.used = false;
lock(dep, false); lock(dep, false);
scheduleMethodAnalysis(dep); tasks.add(() -> {
DependencyGraphBuilder graphBuilder = new DependencyGraphBuilder(DependencyChecker.this);
graphBuilder.buildGraph(dep);
dep.used = true;
});
processQueue(); processQueue();
} }