mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-10 08:54:11 -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;
|
return false;
|
||||||
}
|
}
|
||||||
MethodReader method = cls.getMethod(STRING_INTERN_METHOD);
|
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 {
|
private void renderRuntimeObjcls() throws IOException {
|
||||||
|
|
|
@ -49,8 +49,10 @@ public class PreOptimizingClassHolderSource implements ClassHolderSource {
|
||||||
return cls;
|
return cls;
|
||||||
}
|
}
|
||||||
for (MethodHolder method : cls.getMethods()) {
|
for (MethodHolder method : cls.getMethods()) {
|
||||||
new GlobalValueNumbering(true).optimize(method.getProgram());
|
if (method.getProgram() != null) {
|
||||||
new UnusedVariableElimination().optimize(method, method.getProgram());
|
new GlobalValueNumbering(true).optimize(method.getProgram());
|
||||||
|
new UnusedVariableElimination().optimize(method, method.getProgram());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return cls;
|
return cls;
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,9 @@ public class ClassRefsRenamer extends AbstractInstructionVisitor {
|
||||||
renamedMethod.setLevel(method.getLevel());
|
renamedMethod.setLevel(method.getLevel());
|
||||||
renamedMethod.setProgram(method.getProgram());
|
renamedMethod.setProgram(method.getProgram());
|
||||||
rename(method.getAnnotations(), renamedMethod.getAnnotations());
|
rename(method.getAnnotations(), renamedMethod.getAnnotations());
|
||||||
rename(renamedMethod.getProgram());
|
if (renamedMethod.getProgram() != null) {
|
||||||
|
rename(renamedMethod.getProgram());
|
||||||
|
}
|
||||||
|
|
||||||
renamedMethod.setTypeParameters(rename(method.getTypeParameters()));
|
renamedMethod.setTypeParameters(rename(method.getTypeParameters()));
|
||||||
GenericValueType genericResultType = method.getGenericResultType();
|
GenericValueType genericResultType = method.getGenericResultType();
|
||||||
|
|
|
@ -79,23 +79,27 @@ public class Parser {
|
||||||
ValueType[] signature = MethodDescriptor.parseSignature(node.desc);
|
ValueType[] signature = MethodDescriptor.parseSignature(node.desc);
|
||||||
MethodHolder method = new MethodHolder(referenceCache.getCached(new MethodDescriptor(node.name, signature)));
|
MethodHolder method = new MethodHolder(referenceCache.getCached(new MethodDescriptor(node.name, signature)));
|
||||||
parseModifiers(node.access, method, DECL_METHOD);
|
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);
|
parseAnnotations(method.getAnnotations(), node.visibleAnnotations, node.invisibleAnnotations);
|
||||||
applyDebugNames(program, phiUpdater, programParser,
|
|
||||||
applySignature(program, method.getDescriptor().getParameterTypes()));
|
if (node.instructions.size() > 0) {
|
||||||
while (program.variableCount() <= method.parameterCount()) {
|
ProgramParser programParser = new ProgramParser(referenceCache);
|
||||||
program.createVariable();
|
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) {
|
if (node.annotationDefault != null) {
|
||||||
method.setAnnotationDefault(parseAnnotationValue(node.annotationDefault));
|
method.setAnnotationDefault(parseAnnotationValue(node.annotationDefault));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user