From 4a62b58f821de08e54bcb50f01f18e76963adcb0 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Fri, 2 Apr 2021 19:36:30 +0300 Subject: [PATCH] Bug fixes in optimizer --- core/src/main/java/org/teavm/common/GraphUtils.java | 2 +- core/src/main/java/org/teavm/model/analysis/AliasAnalysis.java | 3 +++ core/src/main/java/org/teavm/model/optimization/Inlining.java | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/teavm/common/GraphUtils.java b/core/src/main/java/org/teavm/common/GraphUtils.java index 744583f3b..f46de92d6 100644 --- a/core/src/main/java/org/teavm/common/GraphUtils.java +++ b/core/src/main/java/org/teavm/common/GraphUtils.java @@ -343,7 +343,7 @@ public final class GraphUtils { stack[top++] = node; for (int successor : graph.outgoingEdges(node)) { if (state[successor] == 0) { - stack[top++] = node; + stack[top++] = successor; } } break; diff --git a/core/src/main/java/org/teavm/model/analysis/AliasAnalysis.java b/core/src/main/java/org/teavm/model/analysis/AliasAnalysis.java index c281b871c..a29e08740 100644 --- a/core/src/main/java/org/teavm/model/analysis/AliasAnalysis.java +++ b/core/src/main/java/org/teavm/model/analysis/AliasAnalysis.java @@ -65,6 +65,9 @@ public class AliasAnalysis { private DfgBuildVisitor prepare(Program program, MethodDescriptor methodDescriptor) { DfgBuildVisitor visitor = new DfgBuildVisitor(program.variableCount()); + visitor.queue.addLast(0); + visitor.queue.addLast(0); + for (int i = 1; i <= methodDescriptor.parameterCount(); ++i) { if (methodDescriptor.parameterType(i - 1) instanceof ValueType.Object) { visitor.queue.addLast(i); diff --git a/core/src/main/java/org/teavm/model/optimization/Inlining.java b/core/src/main/java/org/teavm/model/optimization/Inlining.java index 716a81deb..c360aad73 100644 --- a/core/src/main/java/org/teavm/model/optimization/Inlining.java +++ b/core/src/main/java/org/teavm/model/optimization/Inlining.java @@ -502,7 +502,7 @@ public class Inlining { @Override public ProgramReader getProgram(MethodReference method) { - ClassReader cls = dependencyInfo.getClassSource().get(method.getClassName()); + ClassReader cls = classes.get(method.getClassName()); if (cls == null) { return null; }