mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Fix <clinit> elimination in case of native methods
This commit is contained in:
parent
862b5e79a1
commit
3b1dae4412
|
@ -180,7 +180,7 @@ public class RuntimeRenderer {
|
|||
return false;
|
||||
}
|
||||
MethodReader method = cls.getMethod(STRING_INTERN_METHOD);
|
||||
return method != null && method.getProgram() != null;
|
||||
return method != null && method.hasModifier(ElementModifier.NATIVE);
|
||||
}
|
||||
|
||||
private void renderRuntimeObjcls() throws IOException {
|
||||
|
|
|
@ -49,8 +49,10 @@ public class PreOptimizingClassHolderSource implements ClassHolderSource {
|
|||
return cls;
|
||||
}
|
||||
for (MethodHolder method : cls.getMethods()) {
|
||||
new GlobalValueNumbering(true).optimize(method.getProgram());
|
||||
new UnusedVariableElimination().optimize(method, method.getProgram());
|
||||
if (method.getProgram() != null) {
|
||||
new GlobalValueNumbering(true).optimize(method.getProgram());
|
||||
new UnusedVariableElimination().optimize(method, method.getProgram());
|
||||
}
|
||||
}
|
||||
return cls;
|
||||
}
|
||||
|
|
|
@ -129,7 +129,9 @@ public class ClassRefsRenamer extends AbstractInstructionVisitor {
|
|||
renamedMethod.setLevel(method.getLevel());
|
||||
renamedMethod.setProgram(method.getProgram());
|
||||
rename(method.getAnnotations(), renamedMethod.getAnnotations());
|
||||
rename(renamedMethod.getProgram());
|
||||
if (renamedMethod.getProgram() != null) {
|
||||
rename(renamedMethod.getProgram());
|
||||
}
|
||||
|
||||
renamedMethod.setTypeParameters(rename(method.getTypeParameters()));
|
||||
GenericValueType genericResultType = method.getGenericResultType();
|
||||
|
|
|
@ -79,23 +79,27 @@ public class Parser {
|
|||
ValueType[] signature = MethodDescriptor.parseSignature(node.desc);
|
||||
MethodHolder method = new MethodHolder(referenceCache.getCached(new MethodDescriptor(node.name, signature)));
|
||||
parseModifiers(node.access, method, DECL_METHOD);
|
||||
|
||||
ProgramParser programParser = new ProgramParser(referenceCache);
|
||||
programParser.setFileName(fileName);
|
||||
Program program = programParser.parse(node);
|
||||
new UnreachableBasicBlockEliminator().optimize(program);
|
||||
PhiUpdater phiUpdater = new PhiUpdater();
|
||||
Variable[] argumentMapping = applySignature(program, method.getParameterTypes());
|
||||
phiUpdater.updatePhis(program, argumentMapping);
|
||||
method.setProgram(program);
|
||||
applyDebugNames(program, phiUpdater, programParser, argumentMapping);
|
||||
|
||||
parseAnnotations(method.getAnnotations(), node.visibleAnnotations, node.invisibleAnnotations);
|
||||
applyDebugNames(program, phiUpdater, programParser,
|
||||
applySignature(program, method.getDescriptor().getParameterTypes()));
|
||||
while (program.variableCount() <= method.parameterCount()) {
|
||||
program.createVariable();
|
||||
|
||||
if (node.instructions.size() > 0) {
|
||||
ProgramParser programParser = new ProgramParser(referenceCache);
|
||||
programParser.setFileName(fileName);
|
||||
Program program = programParser.parse(node);
|
||||
new UnreachableBasicBlockEliminator().optimize(program);
|
||||
PhiUpdater phiUpdater = new PhiUpdater();
|
||||
Variable[] argumentMapping = applySignature(program, method.getParameterTypes());
|
||||
phiUpdater.updatePhis(program, argumentMapping);
|
||||
method.setProgram(program);
|
||||
applyDebugNames(program, phiUpdater, programParser, argumentMapping);
|
||||
|
||||
applyDebugNames(program, phiUpdater, programParser,
|
||||
applySignature(program, method.getDescriptor().getParameterTypes()));
|
||||
|
||||
while (program.variableCount() <= method.parameterCount()) {
|
||||
program.createVariable();
|
||||
}
|
||||
}
|
||||
|
||||
if (node.annotationDefault != null) {
|
||||
method.setAnnotationDefault(parseAnnotationValue(node.annotationDefault));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user