public final class ConstantReflectionUtil extends Object
ConstantReflectionProvider.| Modifier and Type | Class and Description |
|---|---|
static interface |
ConstantReflectionUtil.ArrayBaseOffsetProvider |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
canFoldReads(CanonicalizerTool tool,
ValueNode array,
ValueNode offset,
JavaKind stride,
int len,
ConstantReflectionUtil.ArrayBaseOffsetProvider arrayBaseOffsetProvider)
Return
true if the array and the starting offset are constants, and we can perform
len in-bounds constant reads starting at byte offset offset. |
static byte[] |
loadByteArrayConstant(ConstantReflectionProvider crp,
JavaConstant targetArg,
int maxLength) |
static char[] |
loadCharArrayConstant(ConstantReflectionProvider crp,
JavaConstant targetArg,
int maxLength) |
static int[] |
loadIntArrayConstant(ConstantReflectionProvider crp,
JavaConstant targetArg,
int maxLength) |
static int |
readTypePunned(ConstantReflectionProvider provider,
JavaConstant array,
JavaKind arrayKind,
JavaKind stride,
int index)
Reads and zero extends 1, 2 or 4 bytes from a constant byte[], char[] or int[] array.
|
static Integer |
startIndex(CanonicalizerTool tool,
ValueNode array,
JavaConstant offset,
JavaKind stride,
ConstantReflectionUtil.ArrayBaseOffsetProvider arrayBaseOffsetProvider)
Compute an element index from a byte offset from the start of the array object.
|
public static byte[] loadByteArrayConstant(ConstantReflectionProvider crp,
JavaConstant targetArg,
int maxLength)
public static char[] loadCharArrayConstant(ConstantReflectionProvider crp,
JavaConstant targetArg,
int maxLength)
public static int[] loadIntArrayConstant(ConstantReflectionProvider crp,
JavaConstant targetArg,
int maxLength)
public static int readTypePunned(ConstantReflectionProvider provider,
JavaConstant array,
JavaKind arrayKind,
JavaKind stride,
int index)
array - a constant java byte[], char[] or int[] array.arrayKind - the array's element kind (JavaKind.Byte for byte[],
JavaKind.Char for char[] and JavaKind.Int for int[]).stride - the element width to read from the array (JavaKind.Byte == 1 byte,
JavaKind.Char == 2 bytes and JavaKind.Int == 4 bytes). The stride
must not be smaller than the array element kind, e.g. reading a byte from an int[]
array is not supported.index - the index to read from, scaled to stride.public static boolean canFoldReads(CanonicalizerTool tool, ValueNode array, ValueNode offset, JavaKind stride, int len, ConstantReflectionUtil.ArrayBaseOffsetProvider arrayBaseOffsetProvider)
true if the array and the starting offset are constants, and we can perform
len in-bounds constant reads starting at byte offset offset. Return
false if not everything constant or if we would try to read out of bounds.public static Integer startIndex(CanonicalizerTool tool, ValueNode array, JavaConstant offset, JavaKind stride, ConstantReflectionUtil.ArrayBaseOffsetProvider arrayBaseOffsetProvider)
null if the given offset is not aligned correctly for the element kind's stride.