Search in sources :

Example 1 with LLVMManagedPointer

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

the class LLVMInteropReadNode method doClazz.

@Specialization(guards = { "type != null", "hasVirtualMethods(type)", "offset == 0" }, replaces = "doClazzCached")
Object doClazz(LLVMInteropType.Clazz type, Object foreign, long offset, ForeignToLLVMType accessType, @Cached LLVMInteropAccessNode access, @Cached ReadLocationNode read) {
    if (type.hasVirtualMethods() && offset == 0) {
        // return an artificially created pointer pointing to vtable and foreign object
        LLVMInteropType.VTableObjectPair vTableObjectPair = LLVMInteropType.VTableObjectPair.create(type.getVTable(), foreign);
        LLVMManagedPointer pointer = LLVMManagedPointer.create(vTableObjectPair);
        return pointer;
    }
    AccessLocation location = access.execute(type, foreign, offset);
    return read.execute(location.identifier, location, accessType);
}
Also used : AccessLocation(com.oracle.truffle.llvm.runtime.interop.access.LLVMInteropAccessNode.AccessLocation) LLVMManagedPointer(com.oracle.truffle.llvm.runtime.pointer.LLVMManagedPointer) Specialization(com.oracle.truffle.api.dsl.Specialization)

Example 2 with LLVMManagedPointer

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

the class LLDBSupport method pointsToObjectAccess.

public static boolean pointsToObjectAccess(LLVMPointer pointer) {
    if (!LLVMManagedPointer.isInstance(pointer)) {
        return false;
    }
    final LLVMManagedPointer managedPointer = LLVMManagedPointer.cast(pointer);
    final Object target = managedPointer.getObject();
    return !LLVMAsForeignLibrary.getFactory().getUncached().isForeign(target);
}
Also used : LLVMManagedPointer(com.oracle.truffle.llvm.runtime.pointer.LLVMManagedPointer)

Example 3 with LLVMManagedPointer

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

the class LLVMDebugObject method toString.

/**
 * A representation of the current value of the referenced variable for the debugger to show.
 *
 * @return a string describing the referenced value
 */
@Override
@TruffleBoundary
public String toString() {
    Object currentValue = getValue();
    if (LLVMManagedPointer.isInstance(currentValue)) {
        final LLVMManagedPointer managedPointer = LLVMManagedPointer.cast(currentValue);
        final Object target = managedPointer.getObject();
        String targetString;
        if (target instanceof LLVMFunctionDescriptor) {
            final LLVMFunctionDescriptor function = (LLVMFunctionDescriptor) target;
            targetString = "LLVM function " + function.getLLVMFunction().getName();
        } else {
            targetString = "<managed pointer>";
        }
        final long targetOffset = managedPointer.getOffset();
        if (targetOffset != 0L) {
            targetString = String.format("%s + %d byte%s", targetString, targetOffset, targetOffset == 1L ? "" : "s");
        }
        currentValue = targetString;
    }
    return Objects.toString(currentValue);
}
Also used : LLVMFunctionDescriptor(com.oracle.truffle.llvm.runtime.LLVMFunctionDescriptor) LLVMManagedPointer(com.oracle.truffle.llvm.runtime.pointer.LLVMManagedPointer) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 4 with LLVMManagedPointer

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

the class LLVMToDebugValueNode method fromGlobal.

@Specialization
protected LLVMDebugValue fromGlobal(LLVMDebugGlobalVariable value, @Cached BranchProfile exception) {
    LLVMGlobal global = value.getDescriptor();
    LLVMPointer target = getContext().getSymbol(global, exception);
    if (LLVMManagedPointer.isInstance(target)) {
        final LLVMManagedPointer managedPointer = LLVMManagedPointer.cast(target);
        if (LLDBSupport.pointsToObjectAccess(LLVMManagedPointer.cast(target))) {
            return new LLDBMemoryValue(managedPointer);
        }
    }
    return new LLDBGlobalConstant(global);
}
Also used : LLVMPointer(com.oracle.truffle.llvm.runtime.pointer.LLVMPointer) LLVMGlobal(com.oracle.truffle.llvm.runtime.global.LLVMGlobal) LLVMManagedPointer(com.oracle.truffle.llvm.runtime.pointer.LLVMManagedPointer) Specialization(com.oracle.truffle.api.dsl.Specialization)

Example 5 with LLVMManagedPointer

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

the class LLVMStructArrayLiteralNode method doVoid.

@Specialization(guards = { "noOffset(addr)" })
@ExplodeLoop
protected Object doVoid(VirtualFrame frame, LLVMManagedPointer addr) {
    LLVMManagedPointer currentPtr = addr;
    for (int i = 0; i < values.length; i++) {
        Object currentValue = values[i].executeGeneric(frame);
        memMove.executeWithTarget(currentPtr, currentValue, stride);
        currentPtr = currentPtr.increment(stride);
    }
    return addr;
}
Also used : LLVMManagedPointer(com.oracle.truffle.llvm.runtime.pointer.LLVMManagedPointer) Specialization(com.oracle.truffle.api.dsl.Specialization) ExplodeLoop(com.oracle.truffle.api.nodes.ExplodeLoop)

Aggregations

LLVMManagedPointer (com.oracle.truffle.llvm.runtime.pointer.LLVMManagedPointer)10 Specialization (com.oracle.truffle.api.dsl.Specialization)6 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)3 LLVMFunctionDescriptor (com.oracle.truffle.llvm.runtime.LLVMFunctionDescriptor)3 LLVMPointer (com.oracle.truffle.llvm.runtime.pointer.LLVMPointer)2 InteropLibrary (com.oracle.truffle.api.interop.InteropLibrary)1 UnknownIdentifierException (com.oracle.truffle.api.interop.UnknownIdentifierException)1 UnsupportedMessageException (com.oracle.truffle.api.interop.UnsupportedMessageException)1 ExplodeLoop (com.oracle.truffle.api.nodes.ExplodeLoop)1 LLVMArgumentBuffer (com.oracle.truffle.llvm.runtime.LLVMArgumentBuffer)1 LLVMContext (com.oracle.truffle.llvm.runtime.LLVMContext)1 LLVMExitException (com.oracle.truffle.llvm.runtime.LLVMExitException)1 DebugExprType (com.oracle.truffle.llvm.runtime.debug.debugexpr.parser.DebugExprType)1 LLVMIllegalSymbolIndexException (com.oracle.truffle.llvm.runtime.except.LLVMIllegalSymbolIndexException)1 LLVMGlobal (com.oracle.truffle.llvm.runtime.global.LLVMGlobal)1 AccessLocation (com.oracle.truffle.llvm.runtime.interop.access.LLVMInteropAccessNode.AccessLocation)1 LLVMStack (com.oracle.truffle.llvm.runtime.memory.LLVMStack)1 LLVMNativePointer (com.oracle.truffle.llvm.runtime.pointer.LLVMNativePointer)1 Type (com.oracle.truffle.llvm.runtime.types.Type)1