Search in sources :

Example 1 with UnsafeArrayTypeReader

use of org.graalvm.compiler.core.common.util.UnsafeArrayTypeReader in project graal by oracle.

the class DeoptimizationSourcePositionDecoder method decode.

static NodeSourcePosition decode(int deoptId, int[] deoptimizationStartOffsets, byte[] deoptimizationEncodings, Object[] deoptimizationObjectConstants) {
    if (deoptId < 0 || deoptId >= deoptimizationStartOffsets.length) {
        return null;
    }
    int startOffset = deoptimizationStartOffsets[deoptId];
    if (startOffset == NO_SOURCE_POSITION) {
        return null;
    }
    UnsafeArrayTypeReader readBuffer = UnsafeArrayTypeReader.create(deoptimizationEncodings, 0, ByteArrayReader.supportsUnalignedMemoryAccess());
    return decodeSourcePosition(startOffset, deoptimizationObjectConstants, readBuffer);
}
Also used : UnsafeArrayTypeReader(org.graalvm.compiler.core.common.util.UnsafeArrayTypeReader)

Example 2 with UnsafeArrayTypeReader

use of org.graalvm.compiler.core.common.util.UnsafeArrayTypeReader 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)

Example 3 with UnsafeArrayTypeReader

use of org.graalvm.compiler.core.common.util.UnsafeArrayTypeReader in project graal by oracle.

the class EncodedLineNumberTable method getLineNumber.

public static int getLineNumber(int atBci, byte[] encodedTable) {
    if (encodedTable == null) {
        return -1;
    }
    UnsafeArrayTypeReader readBuffer = UnsafeArrayTypeReader.create(encodedTable, 0, ByteArrayReader.supportsUnalignedMemoryAccess());
    int length = readBuffer.getUVInt();
    int lastLineNumber = 0;
    int lastBci = 0;
    for (int i = 0; i < length; i++) {
        int curLineNumber = lastLineNumber + readBuffer.getSVInt();
        int curBci = lastBci + readBuffer.getSVInt();
        if (lastBci <= atBci && atBci < curBci) {
            assert lastLineNumber == decode(encodedTable).getLineNumber(atBci);
            return lastLineNumber;
        }
        lastLineNumber = curLineNumber;
        lastBci = curBci;
    }
    assert lastLineNumber == decode(encodedTable).getLineNumber(atBci);
    return lastLineNumber;
}
Also used : UnsafeArrayTypeReader(org.graalvm.compiler.core.common.util.UnsafeArrayTypeReader)

Example 4 with UnsafeArrayTypeReader

use of org.graalvm.compiler.core.common.util.UnsafeArrayTypeReader in project graal by oracle.

the class TypeWriterTest method test01.

private static void test01(boolean supportsUnalignedMemoryAccess) {
    UnsafeArrayTypeWriter writer = UnsafeArrayTypeWriter.create(supportsUnalignedMemoryAccess);
    putValues(writer);
    byte[] array = new byte[TypeConversion.asU4(writer.getBytesWritten())];
    writer.toArray(array);
    UnsafeArrayTypeReader reader = UnsafeArrayTypeReader.create(array, 0, supportsUnalignedMemoryAccess);
    checkValues(reader);
}
Also used : UnsafeArrayTypeWriter(org.graalvm.compiler.core.common.util.UnsafeArrayTypeWriter) UnsafeArrayTypeReader(org.graalvm.compiler.core.common.util.UnsafeArrayTypeReader)

Example 5 with UnsafeArrayTypeReader

use of org.graalvm.compiler.core.common.util.UnsafeArrayTypeReader in project graal by oracle.

the class FrameInfoDecoder method isFrameInfoMatch.

protected static boolean isFrameInfoMatch(long frameInfoIndex, byte[] frameInfoEncodings, long searchEncodedBci) {
    UnsafeArrayTypeReader readBuffer = UnsafeArrayTypeReader.create(frameInfoEncodings, frameInfoIndex, ByteArrayReader.supportsUnalignedMemoryAccess());
    long actualEncodedBci = readBuffer.getSV();
    assert actualEncodedBci != NO_CALLER_BCI;
    return actualEncodedBci == searchEncodedBci;
}
Also used : UnsafeArrayTypeReader(org.graalvm.compiler.core.common.util.UnsafeArrayTypeReader)

Aggregations

UnsafeArrayTypeReader (org.graalvm.compiler.core.common.util.UnsafeArrayTypeReader)5 LineNumberTable (jdk.vm.ci.meta.LineNumberTable)1 UnsafeArrayTypeWriter (org.graalvm.compiler.core.common.util.UnsafeArrayTypeWriter)1