mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Improve optimization of unused methods that were inlined on every usage
This commit is contained in:
parent
aefdee2507
commit
2f95045345
|
@ -36,7 +36,7 @@ public class ExpressionSideEffectDecomposer extends RecursiveVisitor {
|
|||
public void visit(ConditionalExpr expr) {
|
||||
ConditionalStatement statement = new ConditionalStatement();
|
||||
statement.setCondition(expr.getCondition());
|
||||
expr.getCondition().acceptVisitor(new ExpressionSideEffectDecomposer(statement.getConsequent()));
|
||||
expr.getConsequent().acceptVisitor(new ExpressionSideEffectDecomposer(statement.getConsequent()));
|
||||
expr.getAlternative().acceptVisitor(new ExpressionSideEffectDecomposer(statement.getAlternative()));
|
||||
target.add(statement);
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ class VirtualCallConsumer implements DependencyConsumer {
|
|||
private final BitSet knownTypes = new BitSet();
|
||||
private DependencyGraphBuilder.ExceptionConsumer exceptionConsumer;
|
||||
private DependencyTypeFilter filter;
|
||||
private boolean isPolymorphic;
|
||||
private MethodDependency monomorphicCall;
|
||||
|
||||
VirtualCallConsumer(DependencyNode node, String filterClass,
|
||||
MethodDescriptor methodDesc, DependencyAnalyzer analyzer, DependencyNode[] parameters,
|
||||
|
@ -67,7 +69,17 @@ class VirtualCallConsumer implements DependencyConsumer {
|
|||
MethodDependency methodDep = analyzer.linkMethod(className, methodDesc);
|
||||
methodDep.addLocation(location);
|
||||
if (!methodDep.isMissing()) {
|
||||
methodDep.use();
|
||||
methodDep.use(false);
|
||||
if (isPolymorphic) {
|
||||
methodDep.external = true;
|
||||
} else if (monomorphicCall == null) {
|
||||
monomorphicCall = methodDep;
|
||||
} else {
|
||||
monomorphicCall.external = true;
|
||||
monomorphicCall = null;
|
||||
methodDep.external = true;
|
||||
isPolymorphic = true;
|
||||
}
|
||||
DependencyNode[] targetParams = methodDep.getVariables();
|
||||
if (parameters[0] != null && targetParams[0] != null) {
|
||||
parameters[0].connect(targetParams[0],
|
||||
|
|
Loading…
Reference in New Issue
Block a user