mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-23 23:04:50 -08:00
Changes debug information format for more compact size of bytecode CFG
This commit is contained in:
parent
95f532aca6
commit
497d2424bb
|
@ -93,35 +93,35 @@ class DebugInformationReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
private DebugInformation.CFG readCFG(int index) throws IOException {
|
private DebugInformation.CFG readCFG(int index) throws IOException {
|
||||||
int[] offsets = new int[readUnsignedNumber() + 1];
|
IntegerArray offsets = new IntegerArray(1);
|
||||||
IntegerArray lines = new IntegerArray(1);
|
int[] lines = new int[readUnsignedNumber()];
|
||||||
IntegerArray files = new IntegerArray(1);
|
int[] files = new int[lines.length];
|
||||||
for (int i = 0; i < offsets.length - 1; ++i) {
|
int i = 0;
|
||||||
offsets[i] = lines.size();
|
int line = 0;
|
||||||
|
offsets.add(0);
|
||||||
|
while (i < lines.length) {
|
||||||
|
line += readUnsignedNumber();
|
||||||
int sz = readUnsignedNumber();
|
int sz = readUnsignedNumber();
|
||||||
if (sz == 0) {
|
if (sz == 0) {
|
||||||
continue;
|
lines[i] = -1;
|
||||||
|
files[i++] = -1;
|
||||||
} else if (sz == 1) {
|
} else if (sz == 1) {
|
||||||
lines.add(-1);
|
lines[i] = line + 1;
|
||||||
files.add(-1);
|
files[i++] = index;
|
||||||
} else if (sz == 2) {
|
|
||||||
lines.add(i + 1);
|
|
||||||
files.add(index);
|
|
||||||
} else {
|
|
||||||
sz -= 2;
|
|
||||||
int last = i;
|
|
||||||
for (int j = 0; j < sz; ++j) {
|
|
||||||
last += readNumber();
|
|
||||||
lines.add(last);
|
|
||||||
files.add(index + readNumber());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
sz -= 1;
|
||||||
|
int last = line;
|
||||||
|
for (int j = 0; j < sz; ++j) {
|
||||||
|
last += readNumber();
|
||||||
|
lines[i] = last;
|
||||||
|
files[i++] = index + readNumber();
|
||||||
|
}
|
||||||
|
offsets.add(i);
|
||||||
}
|
}
|
||||||
offsets[offsets.length - 1] = lines.size();
|
|
||||||
DebugInformation.CFG cfg = new DebugInformation.CFG();
|
DebugInformation.CFG cfg = new DebugInformation.CFG();
|
||||||
cfg.offsets = offsets;
|
cfg.offsets = offsets.getAll();
|
||||||
cfg.lines = lines.getAll();
|
cfg.lines = lines;
|
||||||
cfg.files = files.getAll();
|
cfg.files = files;
|
||||||
return cfg;
|
return cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,18 +147,21 @@ class DebugInformationWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeCFG(DebugInformation.CFG mapping, int fileIndex) throws IOException {
|
private void writeCFG(DebugInformation.CFG mapping, int fileIndex) throws IOException {
|
||||||
writeUnsignedNumber(mapping.offsets.length - 1);
|
writeUnsignedNumber(mapping.lines.length);
|
||||||
|
int lastLine = 0;
|
||||||
for (int i = 0; i < mapping.offsets.length - 1; ++i) {
|
for (int i = 0; i < mapping.offsets.length - 1; ++i) {
|
||||||
int start = mapping.offsets[i];
|
int start = mapping.offsets[i];
|
||||||
int sz = mapping.offsets[i + 1] - start;
|
int sz = mapping.offsets[i + 1] - start;
|
||||||
if (sz == 0) {
|
if (sz == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
writeUnsignedNumber(i - lastLine);
|
||||||
|
if (sz == 1 && mapping.lines[start] == -1) {
|
||||||
writeUnsignedNumber(0);
|
writeUnsignedNumber(0);
|
||||||
} else if (sz == 1 && mapping.lines[start] == -1) {
|
|
||||||
writeUnsignedNumber(1);
|
|
||||||
} else if (sz == 1 && mapping.lines[start] == i + 1 && mapping.files[start] == fileIndex) {
|
} else if (sz == 1 && mapping.lines[start] == i + 1 && mapping.files[start] == fileIndex) {
|
||||||
writeUnsignedNumber(2);
|
writeUnsignedNumber(1);
|
||||||
} else {
|
} else {
|
||||||
writeUnsignedNumber(2 + sz);
|
writeUnsignedNumber(1 + sz);
|
||||||
int[] lines = Arrays.copyOfRange(mapping.lines, start, start + sz);
|
int[] lines = Arrays.copyOfRange(mapping.lines, start, start + sz);
|
||||||
int[] files = Arrays.copyOfRange(mapping.files, start, start + sz);
|
int[] files = Arrays.copyOfRange(mapping.files, start, start + sz);
|
||||||
int last = i;
|
int last = i;
|
||||||
|
@ -169,6 +172,7 @@ class DebugInformationWriter {
|
||||||
last = succ;
|
last = succ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
lastLine = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user