use of org.graalvm.word.Pointer in project graal by oracle.
the class AESCryptSubstitutions method crypt.
private static void crypt(Object rcvr, byte[] in, int inOffset, byte[] out, int outOffset, boolean encrypt, boolean withOriginalKey) {
checkArgs(in, inOffset, out, outOffset);
Object realReceiver = PiNode.piCastNonNull(rcvr, AESCryptClass);
Object kObject = RawLoadNode.load(realReceiver, kOffset, JavaKind.Object, LocationIdentity.any());
Pointer kAddr = Word.objectToTrackedPointer(kObject).add(getArrayBaseOffset(JavaKind.Int));
Word inAddr = WordFactory.unsigned(ComputeObjectAddressNode.get(in, getArrayBaseOffset(JavaKind.Byte) + inOffset));
Word outAddr = WordFactory.unsigned(ComputeObjectAddressNode.get(out, getArrayBaseOffset(JavaKind.Byte) + outOffset));
if (encrypt) {
encryptBlockStub(ENCRYPT_BLOCK, inAddr, outAddr, kAddr);
} else {
if (withOriginalKey) {
Object lastKeyObject = RawLoadNode.load(realReceiver, lastKeyOffset, JavaKind.Object, LocationIdentity.any());
Pointer lastKeyAddr = Word.objectToTrackedPointer(lastKeyObject).add(getArrayBaseOffset(JavaKind.Byte));
decryptBlockWithOriginalKeyStub(DECRYPT_BLOCK_WITH_ORIGINAL_KEY, inAddr, outAddr, kAddr, lastKeyAddr);
} else {
decryptBlockStub(DECRYPT_BLOCK, inAddr, outAddr, kAddr);
}
}
}
use of org.graalvm.word.Pointer in project graal by oracle.
the class CRC32Substitutions method update.
/**
* Removed in 9.
*/
@MethodSubstitution(optional = true)
static int update(int crc, int b) {
final Pointer crcTableRawAddress = WordFactory.pointer(GraalHotSpotVMConfigNode.crcTableAddress());
int c = ~crc;
int index = (b ^ c) & 0xFF;
int offset = index << 2;
int result = crcTableRawAddress.readInt(offset);
result = result ^ (c >>> 8);
return ~result;
}
use of org.graalvm.word.Pointer in project graal by oracle.
the class CipherBlockChainingSubstitutions method crypt.
private static void crypt(Object rcvr, byte[] in, int inOffset, int inLength, byte[] out, int outOffset, Object embeddedCipher, boolean encrypt, boolean withOriginalKey) {
AESCryptSubstitutions.checkArgs(in, inOffset, out, outOffset);
Object realReceiver = PiNode.piCastNonNull(rcvr, cipherBlockChainingClass);
Object aesCipher = getAESCryptClass().cast(embeddedCipher);
Object kObject = RawLoadNode.load(aesCipher, AESCryptSubstitutions.kOffset, JavaKind.Object, LocationIdentity.any());
Object rObject = RawLoadNode.load(realReceiver, rOffset, JavaKind.Object, LocationIdentity.any());
Pointer kAddr = Word.objectToTrackedPointer(kObject).add(getArrayBaseOffset(JavaKind.Int));
Pointer rAddr = Word.objectToTrackedPointer(rObject).add(getArrayBaseOffset(JavaKind.Byte));
Word inAddr = WordFactory.unsigned(ComputeObjectAddressNode.get(in, getArrayBaseOffset(JavaKind.Byte) + inOffset));
Word outAddr = WordFactory.unsigned(ComputeObjectAddressNode.get(out, getArrayBaseOffset(JavaKind.Byte) + outOffset));
if (encrypt) {
encryptAESCryptStub(ENCRYPT, inAddr, outAddr, kAddr, rAddr, inLength);
} else {
if (withOriginalKey) {
Object lastKeyObject = RawLoadNode.load(aesCipher, AESCryptSubstitutions.lastKeyOffset, JavaKind.Object, LocationIdentity.any());
Pointer lastKeyAddr = Word.objectToTrackedPointer(lastKeyObject).add(getArrayBaseOffset(JavaKind.Byte));
decryptAESCryptWithOriginalKeyStub(DECRYPT_WITH_ORIGINAL_KEY, inAddr, outAddr, kAddr, rAddr, inLength, lastKeyAddr);
} else {
decryptAESCryptStub(DECRYPT, inAddr, outAddr, kAddr, rAddr, inLength);
}
}
}
use of org.graalvm.word.Pointer in project graal by oracle.
the class AlignedHeapChunkMemoryWalkerAccessFeature method getObjectOffset.
/**
* Return the offset of an object within the objects part of a chunk.
*/
private static UnsignedWord getObjectOffset(AlignedHeader that, Object obj) {
final Pointer objectsStart = getObjectsStart(that);
final Pointer objectPointer = Word.objectToUntrackedPointer(obj);
assert objectsStart.belowOrEqual(objectPointer);
assert objectPointer.belowOrEqual(that.getEnd());
return objectPointer.subtract(objectsStart);
}
use of org.graalvm.word.Pointer in project graal by oracle.
the class AlignedHeapChunkMemoryWalkerAccessFeature method allocateMemory.
/**
* Allocate memory within this AlignedHeapChunk. No initialization of the memory happens here.
*/
static Pointer allocateMemory(AlignedHeader that, UnsignedWord size) {
Pointer result = WordFactory.nullPointer();
final UnsignedWord available = availableObjectMemory(that);
/* Is memory available for the requested size? */
if (size.belowOrEqual(available)) {
/* Returned memory is at the start, */
result = that.getTop();
final Pointer newTop = result.add(size);
setTopCarefully(that, newTop);
}
return result;
}
Aggregations