Search in sources :

Example 1 with LineNumberTable

use of jdk.vm.ci.meta.LineNumberTable in project graal by oracle.

the class ClassfileBytecode method getLineNumberTable.

@Override
public LineNumberTable getLineNumberTable() {
    if (lineNumberTableBytes == null) {
        return null;
    }
    final int lineNumberTableLength = lineNumberTableBytes.length / LINE_NUMBER_TABLE_ENTRY_SIZE_IN_BYTES;
    DataInputStream stream = new DataInputStream(new ByteArrayInputStream(lineNumberTableBytes));
    int[] bci = new int[lineNumberTableLength];
    int[] line = new int[lineNumberTableLength];
    for (int i = 0; i < lineNumberTableLength; i++) {
        try {
            bci[i] = stream.readUnsignedShort();
            line[i] = stream.readUnsignedShort();
        } catch (IOException e) {
            throw new GraalError(e);
        }
    }
    return new LineNumberTable(line, bci);
}
Also used : GraalError(org.graalvm.compiler.debug.GraalError) ByteArrayInputStream(java.io.ByteArrayInputStream) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream) LineNumberTable(jdk.vm.ci.meta.LineNumberTable)

Example 2 with LineNumberTable

use of jdk.vm.ci.meta.LineNumberTable in project graal by oracle.

the class EncodedLineNumberTable method decode.

public static LineNumberTable decode(byte[] encodedTable) {
    if (encodedTable == null) {
        return null;
    }
    UnsafeArrayTypeReader readBuffer = UnsafeArrayTypeReader.create(encodedTable, 0, ByteArrayReader.supportsUnalignedMemoryAccess());
    int length = readBuffer.getUVInt();
    int[] lineNumbers = new int[length];
    int[] bcis = new int[length];
    int lastLineNumber = 0;
    int lastBci = 0;
    for (int i = 0; i < length; i++) {
        int curLineNumber = lastLineNumber + readBuffer.getSVInt();
        int curBci = lastBci + readBuffer.getSVInt();
        lineNumbers[i] = curLineNumber;
        bcis[i] = curBci;
        lastLineNumber = curLineNumber;
        lastBci = curBci;
    }
    return new LineNumberTable(lineNumbers, bcis);
}
Also used : UnsafeArrayTypeReader(org.graalvm.compiler.core.common.util.UnsafeArrayTypeReader) LineNumberTable(jdk.vm.ci.meta.LineNumberTable)

Aggregations

LineNumberTable (jdk.vm.ci.meta.LineNumberTable)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInputStream (java.io.DataInputStream)1 IOException (java.io.IOException)1 UnsafeArrayTypeReader (org.graalvm.compiler.core.common.util.UnsafeArrayTypeReader)1 GraalError (org.graalvm.compiler.debug.GraalError)1