diff --git a/core/src/main/java/org/teavm/model/Variable.java b/core/src/main/java/org/teavm/model/Variable.java index 232cb200b..cb13eda2b 100644 --- a/core/src/main/java/org/teavm/model/Variable.java +++ b/core/src/main/java/org/teavm/model/Variable.java @@ -19,10 +19,6 @@ import java.util.Collections; import java.util.HashSet; import java.util.Set; -/** - * - * @author Alexey Andreev - */ public class Variable implements VariableReader { private Program program; private int index; diff --git a/core/src/main/java/org/teavm/parsing/Parser.java b/core/src/main/java/org/teavm/parsing/Parser.java index 4527cebc9..434666e54 100644 --- a/core/src/main/java/org/teavm/parsing/Parser.java +++ b/core/src/main/java/org/teavm/parsing/Parser.java @@ -98,10 +98,12 @@ public class Parser { debugNames = newDebugNames; } for (Variable definedVar : defExtractor.getDefinedVariables()) { + /* int sourceVar = phiUpdater.getSourceVariable(definedVar.getIndex()); if (sourceVar >= 0) { varMap.put(sourceVar, definedVar.getIndex()); } + */ } for (Map.Entry debugName : debugNames.entrySet()) { int receiver = varMap.getOrDefault(debugName.getKey(), -1); @@ -147,6 +149,7 @@ public class Parser { IntIntMap varMap = new IntIntOpenHashMap(step.varMap); BasicBlock block = program.basicBlockAt(node); + /* for (TryCatchJoint joint : block.getTryCatchJoints()) { int receiver = joint.getReceiver().getIndex(); int sourceVar = phiUpdater.getSourceVariable(receiver); @@ -161,9 +164,11 @@ public class Parser { varMap.put(sourceVar, receiver); } } + */ result[node] = new IntIntOpenHashMap(varMap); + /* for (Instruction insn : block.getInstructions()) { insn.acceptVisitor(defExtractor); for (Variable definedVar : defExtractor.getDefinedVariables()) { @@ -173,6 +178,7 @@ public class Parser { } } } + */ for (int successor : dom.outgoingEdges(node)) { stack[top++] = new Step(successor, new IntIntOpenHashMap(varMap)); diff --git a/samples/async/teavm-samples-async.iml b/samples/async/teavm-samples-async.iml index 9c083f42e..c926e1ae4 100644 --- a/samples/async/teavm-samples-async.iml +++ b/samples/async/teavm-samples-async.iml @@ -25,7 +25,7 @@ - + @@ -38,9 +38,4 @@ - - \ No newline at end of file diff --git a/samples/benchmark/teavm-samples-benchmark.iml b/samples/benchmark/teavm-samples-benchmark.iml index a697a6b71..d928d0f68 100644 --- a/samples/benchmark/teavm-samples-benchmark.iml +++ b/samples/benchmark/teavm-samples-benchmark.iml @@ -35,7 +35,7 @@ - + @@ -63,9 +63,4 @@ - - \ No newline at end of file diff --git a/samples/kotlin/teavm-samples-kotlin.iml b/samples/kotlin/teavm-samples-kotlin.iml index c5711bd66..bc264de3b 100644 --- a/samples/kotlin/teavm-samples-kotlin.iml +++ b/samples/kotlin/teavm-samples-kotlin.iml @@ -29,7 +29,7 @@ - + @@ -42,9 +42,4 @@ - - \ No newline at end of file diff --git a/samples/scala/teavm-samples-scala.iml b/samples/scala/teavm-samples-scala.iml index 699569234..9e12cf33d 100644 --- a/samples/scala/teavm-samples-scala.iml +++ b/samples/scala/teavm-samples-scala.iml @@ -25,7 +25,7 @@ - + @@ -39,9 +39,4 @@ - - \ No newline at end of file diff --git a/samples/storage/teavm-samples-storage.iml b/samples/storage/teavm-samples-storage.iml index 17dde64b4..071b1a57f 100644 --- a/samples/storage/teavm-samples-storage.iml +++ b/samples/storage/teavm-samples-storage.iml @@ -25,7 +25,7 @@ - + @@ -39,9 +39,4 @@ - - \ No newline at end of file diff --git a/samples/video/teavm-samples-video.iml b/samples/video/teavm-samples-video.iml index 5bf84503f..071b1a57f 100644 --- a/samples/video/teavm-samples-video.iml +++ b/samples/video/teavm-samples-video.iml @@ -25,7 +25,7 @@ - + @@ -39,9 +39,4 @@ - - \ No newline at end of file diff --git a/tests/src/test/java/org/teavm/classlib/java/lang/VMTest.java b/tests/src/test/java/org/teavm/classlib/java/lang/VMTest.java index 14476351c..fcf80727f 100644 --- a/tests/src/test/java/org/teavm/classlib/java/lang/VMTest.java +++ b/tests/src/test/java/org/teavm/classlib/java/lang/VMTest.java @@ -16,7 +16,6 @@ package org.teavm.classlib.java.lang; import static org.junit.Assert.*; -import java.lang.annotation.Retention; import org.junit.Test; import org.junit.runner.RunWith; import org.teavm.junit.TeaVMTestRunner; @@ -118,6 +117,21 @@ public class VMTest { assertEquals("SECOND ", ClassWithStaticField.foo(false)); } + @Test + public void variableReadInCatchBlock() { + int n = foo(); + try { + for (int i = 0; i < 10; ++i) { + n += foo(); + } + bar(); + n += foo() * 5; + } catch (RuntimeException e) { + assertEquals(RuntimeException.class, e.getClass()); + assertEquals(n, 22); + } + } + private static class ClassWithStaticField { public final static String CONST1 = "FIRST"; public final static String CONST2 = "SECOND"; diff --git a/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuild.java b/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuild.java index 0a19fbfae..8b1f91175 100644 --- a/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuild.java +++ b/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuild.java @@ -64,8 +64,8 @@ import org.teavm.idea.jps.model.TeaVMJpsConfiguration; import org.teavm.idea.jps.remote.TeaVMBuilderAssistant; import org.teavm.idea.jps.remote.TeaVMElementLocation; import org.teavm.model.CallLocation; -import org.teavm.model.InstructionLocation; import org.teavm.model.MethodReference; +import org.teavm.model.TextLocation; import org.teavm.model.ValueType; import org.teavm.tooling.EmptyTeaVMToolLog; import org.teavm.tooling.TeaVMTool; @@ -243,7 +243,7 @@ class TeaVMBuild { int endOffset = -1; if (callLocation != null) { - InstructionLocation insnLocation = callLocation.getSourceLocation(); + TextLocation insnLocation = callLocation.getSourceLocation(); if (insnLocation != null) { path = insnLocation.getFileName(); line = insnLocation.getLine(); @@ -449,8 +449,6 @@ class TeaVMBuild { return "Discovering classes to compile"; case LINKING: return "Resolving method invocations"; - case DEVIRTUALIZATION: - return "Eliminating virtual calls"; case DECOMPILATION: return "Compiling classes"; case RENDERING: