Search in sources :

Example 6 with LLVMNativePointer

use of com.oracle.truffle.llvm.runtime.pointer.LLVMNativePointer in project graal by oracle.

the class GraalVMResolveFunction method doNativePointerResolve.

@Specialization(guards = "pointsToLong(pointer)")
protected Object doNativePointerResolve(LLVMPointer pointer) {
    LLVMManagedPointer object = LLVMManagedPointer.cast(pointer);
    Object pointerValue = object.getObject();
    LLVMNativePointer nativePointer = LLVMNativePointer.create((long) pointerValue);
    return LLVMManagedPointer.create(getContext().getFunctionDescriptor(nativePointer));
}
Also used : LLVMNativePointer(com.oracle.truffle.llvm.runtime.pointer.LLVMNativePointer) LLVMManagedPointer(com.oracle.truffle.llvm.runtime.pointer.LLVMManagedPointer) Specialization(com.oracle.truffle.api.dsl.Specialization)

Example 7 with LLVMNativePointer

use of com.oracle.truffle.llvm.runtime.pointer.LLVMNativePointer in project graal by oracle.

the class LLVMGlobalContainer method toNative.

@TruffleBoundary
@ExportMessage
public void toNative(@Cached LLVMToNativeNode toNative) {
    if (address == 0) {
        LLVMMemory memory = LLVMLanguage.get(null).getLLVMMemory();
        LLVMNativePointer pointer = memory.allocateMemory(toNative, 8);
        address = pointer.asNative();
        long value;
        Object global = getFallback();
        if (global instanceof Number) {
            value = ((Number) global).longValue();
        } else {
            value = toNative.executeWithTarget(global).asNative();
        }
        memory.putI64(toNative, pointer, value);
    }
}
Also used : LLVMMemory(com.oracle.truffle.llvm.runtime.memory.LLVMMemory) LLVMNativePointer(com.oracle.truffle.llvm.runtime.pointer.LLVMNativePointer) LLVMInternalTruffleObject(com.oracle.truffle.llvm.runtime.interop.LLVMInternalTruffleObject) ExportMessage(com.oracle.truffle.api.library.ExportMessage) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

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