use of com.oracle.truffle.llvm.runtime.pointer.LLVMNativePointer in project graal by oracle.
the class LLVMVAListNode method createVAList.
@Specialization
public LLVMManagedPointer createVAList(VirtualFrame frame, @Cached("createAllocaNode()") LLVMExpressionNode allocaNode) {
// allocaNode == null indicates that no native stack is supported
LLVMNativePointer vaListNativeStackPtr = allocaNode == null ? LLVMNativePointer.createNull() : LLVMNativePointer.cast(allocaNode.executeGeneric(frame));
Object vaListStorage = LLVMLanguage.get(this).getCapability(PlatformCapability.class).createVAListStorage(getRootNode(), vaListNativeStackPtr);
return LLVMManagedPointer.create(vaListStorage);
}
use of com.oracle.truffle.llvm.runtime.pointer.LLVMNativePointer in project graal by oracle.
the class NativeProfiledMemMove method doInJava.
@Specialization(guards = "length <= MAX_JAVA_LEN")
protected void doInJava(Object target, Object source, long length, @Cached LLVMToNativeNode convertTarget, @Cached LLVMToNativeNode convertSource) {
LLVMMemory memory = getLanguage().getLLVMMemory();
LLVMNativePointer t = convertTarget.executeWithTarget(target);
LLVMNativePointer s = convertSource.executeWithTarget(source);
long targetPointer = t.asNative();
long sourcePointer = s.asNative();
if (CompilerDirectives.injectBranchProbability(CompilerDirectives.LIKELY_PROBABILITY, length > 0 && sourcePointer != targetPointer)) {
// sourcePointer + length <= targetPointer || targetPointer < sourcePointer
if (CompilerDirectives.injectBranchProbability(CompilerDirectives.LIKELY_PROBABILITY, Long.compareUnsigned(targetPointer - sourcePointer, length) >= 0)) {
copyForward(memory, targetPointer, sourcePointer, length);
} else {
copyBackward(memory, targetPointer, sourcePointer, length);
}
}
}
use of com.oracle.truffle.llvm.runtime.pointer.LLVMNativePointer in project graal by oracle.
the class BlockAddressConstant method createNode.
@Override
public LLVMExpressionNode createNode(LLVMParserRuntime runtime, DataLayout dataLayout, GetStackSpaceFactory stackFactory) {
LLVMNativePointer blockAddress = LLVMNativePointer.create(block);
PointerType type = new PointerType(null);
return CommonNodeFactory.createLiteral(blockAddress, type);
}
use of com.oracle.truffle.llvm.runtime.pointer.LLVMNativePointer in project graal by oracle.
the class LLDBMemoryValue method computeAddress.
@Override
@TruffleBoundary
public Object computeAddress(long bitOffset) {
if (pointer.isNull()) {
// special case to prevent dereferencing of an incremented 0x0
return pointer;
}
if (LLVMManagedPointer.isInstance(pointer)) {
return "<managed value>" + (bitOffset == 0 ? "" : " + " + LLDBSupport.toSizeString(bitOffset));
}
if (LLVMNativePointer.isInstance(pointer)) {
LLVMNativePointer nativePointer = LLVMNativePointer.cast(pointer);
long offset = bitOffset;
if (bitOffset != 0) {
nativePointer = nativePointer.increment(offset / Byte.SIZE);
offset = offset % Byte.SIZE;
}
return nativePointer.toString() + (offset == 0 ? "" : " + " + LLDBSupport.toSizeString(offset));
}
throw new IllegalStateException("Unknown Pointer: " + pointer);
}
use of com.oracle.truffle.llvm.runtime.pointer.LLVMNativePointer in project graal by oracle.
the class LLVMStructArrayLiteralNode method writeDouble.
@Specialization
@ExplodeLoop
protected LLVMNativePointer writeDouble(VirtualFrame frame, LLVMNativePointer addr) {
long currentPtr = addr.asNative();
for (int i = 0; i < values.length; i++) {
try {
LLVMNativePointer currentValue = values[i].executeLLVMNativePointer(frame);
memMove.executeWithTarget(LLVMNativePointer.create(currentPtr), currentValue, stride);
currentPtr += stride;
} catch (UnexpectedResultException e) {
throw CompilerDirectives.shouldNotReachHere(e);
}
}
return addr;
}
Aggregations