mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Fix bug in liveness analyzer
This commit is contained in:
parent
98247b9927
commit
df8a3b8206
|
@ -15,6 +15,8 @@
|
|||
*/
|
||||
package org.teavm.model.util;
|
||||
|
||||
import com.carrotsearch.hppc.IntOpenHashSet;
|
||||
import com.carrotsearch.hppc.IntSet;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.BitSet;
|
||||
import java.util.Deque;
|
||||
|
@ -51,17 +53,21 @@ public class LivenessAnalyzer {
|
|||
BasicBlock block = program.basicBlockAt(i);
|
||||
for (Instruction insn : block.getInstructions()) {
|
||||
insn.acceptVisitor(usageExtractor);
|
||||
IntSet usedVars = new IntOpenHashSet();
|
||||
for (Variable var : usageExtractor.getUsedVariables()) {
|
||||
Task task = new Task();
|
||||
task.block = i;
|
||||
task.var = var.getIndex();
|
||||
stack.push(task);
|
||||
usedVars.add(var.getIndex());
|
||||
}
|
||||
insn.acceptVisitor(defExtractor);
|
||||
for (Variable var : defExtractor.getDefinedVariables()) {
|
||||
if (!usedVars.contains(var.getIndex())) {
|
||||
definitions[var.getIndex()] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (TryCatchBlock tryCatch : block.getTryCatchBlocks()) {
|
||||
if (tryCatch.getExceptionVariable() != null) {
|
||||
definitions[tryCatch.getExceptionVariable().getIndex()] = i;
|
||||
|
|
Loading…
Reference in New Issue
Block a user