Search in sources :

Example 1 with LLVMNativePointer

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);
}
Also used : LLVMNativePointer(com.oracle.truffle.llvm.runtime.pointer.LLVMNativePointer) PlatformCapability(com.oracle.truffle.llvm.runtime.PlatformCapability) Specialization(com.oracle.truffle.api.dsl.Specialization)

Example 2 with LLVMNativePointer

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);
        }
    }
}
Also used : LLVMMemory(com.oracle.truffle.llvm.runtime.memory.LLVMMemory) LLVMNativePointer(com.oracle.truffle.llvm.runtime.pointer.LLVMNativePointer) Specialization(com.oracle.truffle.api.dsl.Specialization)

Example 3 with LLVMNativePointer

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);
}
Also used : LLVMNativePointer(com.oracle.truffle.llvm.runtime.pointer.LLVMNativePointer) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType)

Example 4 with LLVMNativePointer

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);
}
Also used : LLVMNativePointer(com.oracle.truffle.llvm.runtime.pointer.LLVMNativePointer) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 5 with LLVMNativePointer

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;
}
Also used : LLVMNativePointer(com.oracle.truffle.llvm.runtime.pointer.LLVMNativePointer) UnexpectedResultException(com.oracle.truffle.api.nodes.UnexpectedResultException) Specialization(com.oracle.truffle.api.dsl.Specialization) ExplodeLoop(com.oracle.truffle.api.nodes.ExplodeLoop)

Aggregations

LLVMNativePointer (com.oracle.truffle.llvm.runtime.pointer.LLVMNativePointer)7 Specialization (com.oracle.truffle.api.dsl.Specialization)4 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)2 LLVMMemory (com.oracle.truffle.llvm.runtime.memory.LLVMMemory)2 ExportMessage (com.oracle.truffle.api.library.ExportMessage)1 ExplodeLoop (com.oracle.truffle.api.nodes.ExplodeLoop)1 UnexpectedResultException (com.oracle.truffle.api.nodes.UnexpectedResultException)1 PlatformCapability (com.oracle.truffle.llvm.runtime.PlatformCapability)1 LLVMInternalTruffleObject (com.oracle.truffle.llvm.runtime.interop.LLVMInternalTruffleObject)1 LLVMManagedPointer (com.oracle.truffle.llvm.runtime.pointer.LLVMManagedPointer)1 PointerType (com.oracle.truffle.llvm.runtime.types.PointerType)1