mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-09 00:14:10 -08:00
Fixes generation of CFG debug information
This commit is contained in:
parent
97e107635b
commit
86003b45ca
|
@ -173,9 +173,7 @@ public class BasicBlock implements BasicBlockReader {
|
||||||
@Override
|
@Override
|
||||||
public void readInstruction(int index, InstructionReader reader) {
|
public void readInstruction(int index, InstructionReader reader) {
|
||||||
Instruction insn = instructions.get(index);
|
Instruction insn = instructions.get(index);
|
||||||
if (insn.getLocation() != null) {
|
reader.location(insn.getLocation());
|
||||||
reader.location(insn.getLocation());
|
|
||||||
}
|
|
||||||
insn.acceptVisitor(new InstructionReadVisitor(reader));
|
insn.acceptVisitor(new InstructionReadVisitor(reader));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ class LocationGraphBuilder {
|
||||||
for (Instruction insn : block.getInstructions()) {
|
for (Instruction insn : block.getInstructions()) {
|
||||||
if (insn.getLocation() != null) {
|
if (insn.getLocation() != null) {
|
||||||
if (!started) {
|
if (!started) {
|
||||||
step.startLocations.add(location);
|
step.startLocations.add(insn.getLocation());
|
||||||
}
|
}
|
||||||
started = true;
|
started = true;
|
||||||
if (blockLocations[step.block] == null) {
|
if (blockLocations[step.block] == null) {
|
||||||
|
|
|
@ -45,9 +45,6 @@ public class ProgramParser implements VariableDebugInformation {
|
||||||
private int minLocal;
|
private int minLocal;
|
||||||
private Program program;
|
private Program program;
|
||||||
private String currentClassName;
|
private String currentClassName;
|
||||||
private int currentLineNumber;
|
|
||||||
private boolean lineNumberChanged;
|
|
||||||
private InstructionLocation lastInsnLocation;
|
|
||||||
private Map<Integer, List<LocalVariableNode>> localVariableMap = new HashMap<>();
|
private Map<Integer, List<LocalVariableNode>> localVariableMap = new HashMap<>();
|
||||||
private Map<Instruction, Map<Integer, String>> variableDebugNames = new HashMap<>();
|
private Map<Instruction, Map<Integer, String>> variableDebugNames = new HashMap<>();
|
||||||
|
|
||||||
|
@ -88,8 +85,6 @@ public class ProgramParser implements VariableDebugInformation {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Program parse(MethodNode method, String className) {
|
public Program parse(MethodNode method, String className) {
|
||||||
currentLineNumber = -1;
|
|
||||||
lineNumberChanged = true;
|
|
||||||
program = new Program();
|
program = new Program();
|
||||||
this.currentClassName = className;
|
this.currentClassName = className;
|
||||||
InsnList instructions = method.instructions;
|
InsnList instructions = method.instructions;
|
||||||
|
@ -103,7 +98,7 @@ public class ProgramParser implements VariableDebugInformation {
|
||||||
insn.setTarget(program.basicBlockAt(1));
|
insn.setTarget(program.basicBlockAt(1));
|
||||||
program.basicBlockAt(0).getInstructions().add(insn);
|
program.basicBlockAt(0).getInstructions().add(insn);
|
||||||
doAnalyze(method);
|
doAnalyze(method);
|
||||||
assemble();
|
assemble(method);
|
||||||
for (int i = 0; i < program.basicBlockCount(); ++i) {
|
for (int i = 0; i < program.basicBlockCount(); ++i) {
|
||||||
BasicBlock block = program.basicBlockAt(i);
|
BasicBlock block = program.basicBlockAt(i);
|
||||||
for (int j = 0; j < block.getTryCatchBlocks().size(); ++j) {
|
for (int j = 0; j < block.getTryCatchBlocks().size(); ++j) {
|
||||||
|
@ -266,9 +261,11 @@ public class ProgramParser implements VariableDebugInformation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assemble() {
|
private void assemble(MethodNode methodNode) {
|
||||||
BasicBlock basicBlock = null;
|
BasicBlock basicBlock = null;
|
||||||
Map<Integer, String> accumulatedDebugNames = new HashMap<>();
|
Map<Integer, String> accumulatedDebugNames = new HashMap<>();
|
||||||
|
Integer lastLineNumber = null;
|
||||||
|
InstructionLocation lastLocation = null;
|
||||||
for (int i = 0; i < basicBlocks.size(); ++i) {
|
for (int i = 0; i < basicBlocks.size(); ++i) {
|
||||||
BasicBlock newBasicBlock = basicBlocks.get(i);
|
BasicBlock newBasicBlock = basicBlocks.get(i);
|
||||||
if (newBasicBlock != null) {
|
if (newBasicBlock != null) {
|
||||||
|
@ -296,7 +293,19 @@ public class ProgramParser implements VariableDebugInformation {
|
||||||
}
|
}
|
||||||
accumulatedDebugNames.putAll(debugNames);
|
accumulatedDebugNames.putAll(debugNames);
|
||||||
}
|
}
|
||||||
|
AbstractInsnNode insnNode = methodNode.instructions.get(i);
|
||||||
|
if (insnNode instanceof LabelNode) {
|
||||||
|
Label label = ((LabelNode)insnNode).getLabel();
|
||||||
|
Integer lineNumber = lineNumbers.get(label);
|
||||||
|
if (lineNumber != null && !lineNumber.equals(lastLineNumber)) {
|
||||||
|
lastLineNumber = lineNumber;
|
||||||
|
lastLocation = new InstructionLocation(fileName, lastLineNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (builtInstructions != null) {
|
if (builtInstructions != null) {
|
||||||
|
for (Instruction insn : builtInstructions) {
|
||||||
|
insn.setLocation(lastLocation);
|
||||||
|
}
|
||||||
basicBlock.getInstructions().addAll(builtInstructions);
|
basicBlock.getInstructions().addAll(builtInstructions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -347,11 +356,6 @@ public class ProgramParser implements VariableDebugInformation {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addInstruction(Instruction insn) {
|
private void addInstruction(Instruction insn) {
|
||||||
if (lineNumberChanged) {
|
|
||||||
lastInsnLocation = new InstructionLocation(fileName, currentLineNumber);
|
|
||||||
lineNumberChanged = false;
|
|
||||||
}
|
|
||||||
insn.setLocation(lastInsnLocation);
|
|
||||||
builder.add(insn);
|
builder.add(insn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,11 +606,6 @@ public class ProgramParser implements VariableDebugInformation {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitLabel(Label label) {
|
public void visitLabel(Label label) {
|
||||||
Integer lineNumber = lineNumbers.get(label);
|
|
||||||
if (lineNumber != null) {
|
|
||||||
currentLineNumber = lineNumber;
|
|
||||||
lineNumberChanged = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void emitBranching(BranchingCondition condition, int value, int target) {
|
private void emitBranching(BranchingCondition condition, int value, int target) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user