public abstract class UnsafeArrayTypeWriter extends Object implements TypeWriter
supportsUnalignedMemoryAccess must be set according to the capabilities of the
hardware architecture: the value true allows more efficient memory access on
architectures that support unaligned memory accesses; the value false is the safe
fallback that works on every hardware.| Modifier and Type | Field and Description |
|---|---|
protected org.graalvm.compiler.core.common.util.UnsafeArrayTypeWriter.Chunk |
firstChunk |
static long |
HIGH_WORD_SHIFT |
static long |
MAX_BYTES |
static long |
NUM_HIGH_CODES |
static long |
NUM_LOW_CODES |
protected int |
totalSize |
protected org.graalvm.compiler.core.common.util.UnsafeArrayTypeWriter.Chunk |
writeChunk |
| Modifier | Constructor and Description |
|---|---|
protected |
UnsafeArrayTypeWriter() |
| Modifier and Type | Method and Description |
|---|---|
static UnsafeArrayTypeWriter |
create(boolean supportsUnalignedMemoryAccess) |
static UnsafeArrayTypeWriter |
create(boolean supportsUnalignedMemoryAccess,
boolean bigEndian) |
long |
getBytesWritten()
Returns the number of bytes that have been written, i.e., the byte index of the next byte to
be written.
|
void |
patchS4(long value,
long offset)
Patches a previously written signed 4 byte value at a given offset.
|
void |
putS1(long value)
Writes a signed 1 byte value.
|
void |
putS2(long value)
Writes a signed 2 byte value.
|
protected abstract void |
putS2(long value,
org.graalvm.compiler.core.common.util.UnsafeArrayTypeWriter.Chunk chunk,
long offset) |
void |
putS4(long value)
Writes a signed 4 byte value.
|
protected abstract void |
putS4(long value,
org.graalvm.compiler.core.common.util.UnsafeArrayTypeWriter.Chunk chunk,
long offset) |
void |
putS8(long value)
Writes a signed 8 byte value.
|
protected abstract void |
putS8(long value,
org.graalvm.compiler.core.common.util.UnsafeArrayTypeWriter.Chunk chunk,
long offset) |
void |
putSV(long value)
Writes a signed value in a variable byte size encoding.
|
void |
putU1(long value)
Writes an unsigned 1 byte value.
|
void |
putU2(long value)
Writes an unsigned 2 byte value.
|
void |
putU4(long value)
Writes an unsigned 4 byte value.
|
void |
putUV(long value)
Writes an unsigned value in a variable byte size encoding.
|
byte[] |
toArray() |
byte[] |
toArray(byte[] result)
Copies the buffer into the provided byte[] array of length
UnsafeArrayTypeWriter.getBytesWritten(). |
ByteBuffer |
toByteBuffer(ByteBuffer buffer)
Copies the buffer into the provided ByteBuffer at its current position.
|
protected long |
writeOffset(int writeBytes) |
public static final long HIGH_WORD_SHIFT
public static final long NUM_HIGH_CODES
public static final long NUM_LOW_CODES
public static final long MAX_BYTES
protected final org.graalvm.compiler.core.common.util.UnsafeArrayTypeWriter.Chunk firstChunk
protected org.graalvm.compiler.core.common.util.UnsafeArrayTypeWriter.Chunk writeChunk
protected int totalSize
public static UnsafeArrayTypeWriter create(boolean supportsUnalignedMemoryAccess)
public static UnsafeArrayTypeWriter create(boolean supportsUnalignedMemoryAccess, boolean bigEndian)
public final long getBytesWritten()
TypeWritergetBytesWritten in interface TypeWriterpublic final byte[] toArray(byte[] result)
UnsafeArrayTypeWriter.getBytesWritten().public final ByteBuffer toByteBuffer(ByteBuffer buffer)
public final byte[] toArray()
public final void putS1(long value)
TypeWriterputS1 in interface TypeWriterpublic final void putU1(long value)
TypeWriterputU1 in interface TypeWriterpublic final void putU2(long value)
TypeWriterputU2 in interface TypeWriterpublic final void putU4(long value)
TypeWriterputU4 in interface TypeWriterpublic void putS2(long value)
TypeWriterputS2 in interface TypeWriterpublic void putS4(long value)
TypeWriterputS4 in interface TypeWriterpublic void putS8(long value)
TypeWriterputS8 in interface TypeWriterprotected abstract void putS2(long value,
org.graalvm.compiler.core.common.util.UnsafeArrayTypeWriter.Chunk chunk,
long offset)
protected abstract void putS4(long value,
org.graalvm.compiler.core.common.util.UnsafeArrayTypeWriter.Chunk chunk,
long offset)
protected abstract void putS8(long value,
org.graalvm.compiler.core.common.util.UnsafeArrayTypeWriter.Chunk chunk,
long offset)
protected long writeOffset(int writeBytes)
public void patchS4(long value,
long offset)
TypeWriterpatchS4 in interface TypeWriterpublic void putSV(long value)
TypeWriterputSV in interface TypeWriterpublic void putUV(long value)
TypeWriterputUV in interface TypeWriter