mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Wasm: fix issues in DWARF generator
This commit is contained in:
parent
7f38697d50
commit
1399045ff6
|
@ -173,8 +173,8 @@ class DwarfLinesGenerator {
|
|||
instructionsBlob.writeLEB(fileRef);
|
||||
changed = true;
|
||||
}
|
||||
if (advanceTo(address, line)) {
|
||||
changed = true;
|
||||
if (line != this.line || this.address != address) {
|
||||
changed = advanceTo(address, line);
|
||||
}
|
||||
if (changed) {
|
||||
instructionsBlob.writeByte(DW_LNS_COPY);
|
||||
|
@ -186,23 +186,23 @@ class DwarfLinesGenerator {
|
|||
if (!sequenceStarted) {
|
||||
return;
|
||||
}
|
||||
advanceTo(address, line);
|
||||
if (this.address != address) {
|
||||
advanceTo(address, line);
|
||||
}
|
||||
instructionsBlob.writeByte(0);
|
||||
instructionsBlob.writeByte(1);
|
||||
instructionsBlob.writeByte(DW_LNE_END_SEQUENCE);
|
||||
this.line = 1;
|
||||
this.file = 0;
|
||||
this.file = 1;
|
||||
this.address = 0;
|
||||
sequenceStarted = false;
|
||||
}
|
||||
|
||||
private boolean advanceTo(int address, int line) {
|
||||
if (address == this.address && line == this.line) {
|
||||
return false;
|
||||
}
|
||||
int lineIncrement = line - this.line;
|
||||
int addressIncrement = address - this.address;
|
||||
if (!tryEmitSpecial(lineIncrement, addressIncrement)) {
|
||||
var result = !tryEmitSpecial(lineIncrement, addressIncrement);
|
||||
if (result) {
|
||||
if (lineIncrement != 0) {
|
||||
instructionsBlob.writeByte(DW_LNS_ADVANCE_LINE);
|
||||
instructionsBlob.writeSLEB(lineIncrement);
|
||||
|
@ -214,7 +214,7 @@ class DwarfLinesGenerator {
|
|||
}
|
||||
this.line = line;
|
||||
this.address = address;
|
||||
return true;
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean tryEmitSpecial(int lineIncrement, int addressIncrement) {
|
||||
|
|
|
@ -903,21 +903,27 @@ class WasmGenerationVisitor implements StatementVisitor, ExprVisitor {
|
|||
switch (expr.getMethod().getName()) {
|
||||
case "allocStack":
|
||||
generateAllocStack(expr.getArguments().get(0));
|
||||
result.setLocation(expr.getLocation());
|
||||
return;
|
||||
case "releaseStack":
|
||||
generateReleaseStack();
|
||||
result.setLocation(expr.getLocation());
|
||||
return;
|
||||
case "registerGCRoot":
|
||||
generateRegisterGcRoot(expr.getArguments().get(0), expr.getArguments().get(1));
|
||||
result.setLocation(expr.getLocation());
|
||||
return;
|
||||
case "removeGCRoot":
|
||||
generateRemoveGcRoot(expr.getArguments().get(0));
|
||||
result.setLocation(expr.getLocation());
|
||||
return;
|
||||
case "registerCallSite":
|
||||
generateRegisterCallSite(expr.getArguments().get(0));
|
||||
result.setLocation(expr.getLocation());
|
||||
return;
|
||||
case "getExceptionHandlerId":
|
||||
generateGetHandlerId();
|
||||
result.setLocation(expr.getLocation());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -941,6 +947,7 @@ class WasmGenerationVisitor implements StatementVisitor, ExprVisitor {
|
|||
accept(argument);
|
||||
call.getArguments().add(result);
|
||||
}
|
||||
call.setLocation(expr.getLocation());
|
||||
result = call;
|
||||
} else if (expr.getType() == InvocationType.CONSTRUCTOR) {
|
||||
WasmBlock block = new WasmBlock(false);
|
||||
|
|
|
@ -331,8 +331,8 @@ public class WasmBinaryRenderer {
|
|||
if (dwarfGenerator != null && function.getName() != null) {
|
||||
infoWriter.tag(getMethodAbbrev());
|
||||
infoWriter.writeInt(dwarfGenerator.strings.stringRef(function.getName()));
|
||||
infoWriter.writeInt(offset - 4);
|
||||
infoWriter.writeInt(offset + code.getPosition());
|
||||
infoWriter.writeInt(offset);
|
||||
infoWriter.writeInt(offset + code.getPosition() - 1);
|
||||
infoWriter.emptyTag();
|
||||
}
|
||||
|
||||
|
|
|
@ -875,7 +875,8 @@ class WasmBinaryRenderingVisitor implements WasmExpressionVisitor {
|
|||
}
|
||||
|
||||
private void emitLocation(WasmExpression expression) {
|
||||
if (dwarfGenerator == null || expression.getLocation() == null) {
|
||||
if (dwarfGenerator == null || expression.getLocation() == null
|
||||
|| expression.getLocation().getFileName() == null) {
|
||||
return;
|
||||
}
|
||||
dwarfGenerator.lineNumber(writer.getPosition() + addressOffset, expression.getLocation().getFileName(),
|
||||
|
|
Loading…
Reference in New Issue
Block a user