From 0deb7ac4e6380f04fdc699ea4f70751e9e0b5055 Mon Sep 17 00:00:00 2001 From: konsoletyper Date: Mon, 31 Mar 2014 15:26:20 +0400 Subject: [PATCH] Includes catch instruction into interference analysis --- .../org/teavm/model/util/InterferenceGraphBuilder.java | 10 ++++++++++ .../java/org/teavm/model/util/LivenessAnalyzer.java | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/teavm-core/src/main/java/org/teavm/model/util/InterferenceGraphBuilder.java b/teavm-core/src/main/java/org/teavm/model/util/InterferenceGraphBuilder.java index 9b38bada5..e39480eaf 100644 --- a/teavm-core/src/main/java/org/teavm/model/util/InterferenceGraphBuilder.java +++ b/teavm-core/src/main/java/org/teavm/model/util/InterferenceGraphBuilder.java @@ -50,6 +50,16 @@ class InterferenceGraphBuilder { for (Incoming outgoing : outgoings.get(i)) { live.add(nodes.get(outgoing.getValue().getIndex())); } + for (TryCatchBlock tryCatch : block.getTryCatchBlocks()) { + if (tryCatch.getExceptionVariable() != null) { + nodes.get(tryCatch.getExceptionVariable().getIndex()).connectAll(live); + } + } + for (TryCatchBlock tryCatch : block.getTryCatchBlocks()) { + if (tryCatch.getExceptionVariable() != null) { + live.remove(tryCatch.getExceptionVariable()); + } + } for (int j = block.getInstructions().size() - 1; j >= 0; --j) { Instruction insn = block.getInstructions().get(j); insn.acceptVisitor(useExtractor); diff --git a/teavm-core/src/main/java/org/teavm/model/util/LivenessAnalyzer.java b/teavm-core/src/main/java/org/teavm/model/util/LivenessAnalyzer.java index f94bf4000..d0bac2296 100644 --- a/teavm-core/src/main/java/org/teavm/model/util/LivenessAnalyzer.java +++ b/teavm-core/src/main/java/org/teavm/model/util/LivenessAnalyzer.java @@ -66,6 +66,11 @@ public class LivenessAnalyzer { definitions[var.getIndex()] = i; } } + for (TryCatchBlock tryCatch : block.getTryCatchBlocks()) { + if (tryCatch.getExceptionVariable() != null) { + definitions[tryCatch.getExceptionVariable().getIndex()] = i; + } + } for (Phi phi : block.getPhis()) { definitions[phi.getReceiver().getIndex()] = i; for (Incoming incoming : phi.getIncomings()) {