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