Search in sources :

Example 26 with LLVMPointer

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

the class LLVMInteropVtableAccessNode method doPointer.

@Specialization
@GenerateAOT.Exclude
Object doPointer(LLVMPointer vtablePointer, long virtualIndex, Object[] arguments, @Cached LLVMForeignReadNode read, @CachedLibrary(limit = "5") InteropLibrary interop) throws UnsupportedTypeException, ArityException, UnsupportedMessageException {
    LLVMPointer vtableElementPointer = vtablePointer.increment(virtualIndex * LLVMNode.ADDRESS_SIZE_IN_BYTES);
    final LLVMInteropType type = LLVMInteropType.ValueKind.POINTER.type;
    return interop.execute(read.execute(vtableElementPointer, type), arguments);
}
Also used : LLVMPointer(com.oracle.truffle.llvm.runtime.pointer.LLVMPointer) Specialization(com.oracle.truffle.api.dsl.Specialization)

Example 27 with LLVMPointer

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

the class LLVMForeignVirtualSuperElemPtrNode method doResolve.

@Specialization
public LLVMPointer doResolve(LLVMPointer receiver, long offset, @Cached LLVMForeignReadNode read) {
    Object vtablePointer = read.execute(receiver, LLVMInteropType.ValueKind.POINTER.type);
    LLVMPointer parent = LLVMPointer.cast(vtablePointer).increment(-offset);
    Object parentOffset = read.execute(parent, LLVMInteropType.ValueKind.I64.type);
    return receiver.increment((long) parentOffset);
}
Also used : LLVMPointer(com.oracle.truffle.llvm.runtime.pointer.LLVMPointer) Specialization(com.oracle.truffle.api.dsl.Specialization)

Example 28 with LLVMPointer

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

the class LLVMResolveForeignClassChainNode method doClazzResolving.

@Specialization(replaces = "doClassResolvingCached")
public LLVMPointer doClazzResolving(LLVMPointer receiver, String ident, LLVMInteropType.Clazz clazz, @Cached LLVMForeignVirtualSuperElemPtrNode virtualSuperElemPtrNode, @Cached LLVMForeignDirectSuperElemPtrNode directSuperElemPtrNode) throws UnknownIdentifierException {
    LLVMPointer curReceiver = receiver;
    Pair<long[], Struct> p = clazz.getSuperOffsetInformation(ident);
    for (long val : p.getLeft()) {
        LLVMForeignGetSuperElemPtrNode access = (val & 1) == 1 ? virtualSuperElemPtrNode : directSuperElemPtrNode;
        curReceiver = access.execute(curReceiver, val >> 1);
    }
    return curReceiver.export(p.getRight() == null ? clazz : p.getRight());
}
Also used : LLVMPointer(com.oracle.truffle.llvm.runtime.pointer.LLVMPointer) LLVMForeignGetSuperElemPtrNode(com.oracle.truffle.llvm.runtime.interop.export.LLVMForeignGetSuperElemPtrNode) Struct(com.oracle.truffle.llvm.runtime.interop.access.LLVMInteropType.Struct) Specialization(com.oracle.truffle.api.dsl.Specialization)

Example 29 with LLVMPointer

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

the class LLVMAarch64VaListStorage method shift.

/**
 * This is the implementation of the {@code va_arg} instruction.
 */
@SuppressWarnings("static-method")
@ExportMessage
Object shift(Type type, @SuppressWarnings("unused") Frame frame, @CachedLibrary(limit = "1") LLVMManagedReadLibrary readLib, @CachedLibrary(limit = "1") LLVMManagedWriteLibrary writeLib, @Cached BranchProfile regAreaProfile, @Cached("createBinaryProfile()") ConditionProfile isNativizedProfile) {
    int regSaveOffs = 0;
    int regSaveStep = 0;
    boolean lookIntoRegSaveArea = true;
    VarArgArea varArgArea = getVarArgArea(type);
    RegSaveArea regSaveArea = null;
    switch(varArgArea) {
        case GP_AREA:
            regSaveOffs = Aarch64BitVarArgs.GP_OFFSET;
            regSaveStep = Aarch64BitVarArgs.GP_STEP;
            regSaveArea = gpSaveArea;
            break;
        case FP_AREA:
            regSaveOffs = Aarch64BitVarArgs.FP_OFFSET;
            regSaveStep = Aarch64BitVarArgs.FP_STEP;
            regSaveArea = fpSaveArea;
            break;
        case OVERFLOW_AREA:
            lookIntoRegSaveArea = false;
            break;
    }
    if (lookIntoRegSaveArea) {
        regAreaProfile.enter();
        int offs = readLib.readI32(this, regSaveOffs);
        if (offs < 0) {
            // The va shift logic for GP/FP regsave areas is done by updating the gp/fp offset
            // field in va_list
            writeLib.writeI32(this, regSaveOffs, offs + regSaveStep);
            assert regSaveArea != null;
            long n = regSaveArea.offsetToIndex(offs);
            if (n >= 0) {
                int i = (int) ((n << 32) >> 32);
                return regSaveArea.args[i];
            }
        }
    }
    // overflow area
    if (isNativizedProfile.profile(isNativized())) {
        // Synchronize the managed current argument pointer from the native overflow area
        this.overflowArgArea.setOffset(getArgPtrFromNativePtr(this, readLib));
        Object currentArg = this.overflowArgArea.getCurrentArg();
        // Shift the managed current argument pointer
        this.overflowArgArea.shift(1);
        // Update the new native current argument pointer from the managed one
        long shiftOffs = this.overflowArgArea.getOffset();
        LLVMPointer shiftedOverflowAreaPtr = overflowArgAreaBaseNativePtr.increment(shiftOffs);
        writeLib.writePointer(this, Aarch64BitVarArgs.OVERFLOW_ARG_AREA, shiftedOverflowAreaPtr);
        return currentArg;
    } else {
        Object currentArg = this.overflowArgArea.getCurrentArg();
        this.overflowArgArea.shift(1);
        return currentArg;
    }
}
Also used : LLVMPointer(com.oracle.truffle.llvm.runtime.pointer.LLVMPointer) ExportMessage(com.oracle.truffle.api.library.ExportMessage)

Example 30 with LLVMPointer

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

the class LLVMComplex80BitFloatDiv method doDiv.

@Specialization
public Object doDiv(VirtualFrame frame, @Cached("getSizeInBytes()") int sizeInBytes) {
    try {
        LLVM80BitFloat longDoubleA = (LLVM80BitFloat) aNode.executeGeneric(frame);
        LLVM80BitFloat longDoubleB = (LLVM80BitFloat) bNode.executeGeneric(frame);
        LLVM80BitFloat longDoubleC = (LLVM80BitFloat) cNode.executeGeneric(frame);
        LLVM80BitFloat longDoubleD = (LLVM80BitFloat) dNode.executeGeneric(frame);
        double a = longDoubleA.getDoubleValue();
        double b = longDoubleB.getDoubleValue();
        double c = longDoubleC.getDoubleValue();
        double d = longDoubleD.getDoubleValue();
        double denom = c * c + d * d;
        double zReal = (a * c + b * d) / denom;
        double zImag = (b * c - a * d) / denom;
        LLVMPointer allocatedMemory = alloc.executeLLVMPointer(frame);
        storeReal.executeWithTarget(allocatedMemory, LLVM80BitFloat.fromDouble(zReal));
        storeImag.executeWithTarget(allocatedMemory, sizeInBytes, LLVM80BitFloat.fromDouble(zImag));
        return allocatedMemory;
    } catch (UnexpectedResultException | ClassCastException e) {
        throw CompilerDirectives.shouldNotReachHere(e);
    }
}
Also used : UnexpectedResultException(com.oracle.truffle.api.nodes.UnexpectedResultException) LLVMPointer(com.oracle.truffle.llvm.runtime.pointer.LLVMPointer) LLVM80BitFloat(com.oracle.truffle.llvm.runtime.floating.LLVM80BitFloat) Specialization(com.oracle.truffle.api.dsl.Specialization)

Aggregations

LLVMPointer (com.oracle.truffle.llvm.runtime.pointer.LLVMPointer)33 Specialization (com.oracle.truffle.api.dsl.Specialization)12 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)5 LLVMGlobal (com.oracle.truffle.llvm.runtime.global.LLVMGlobal)4 TruffleSafepoint (com.oracle.truffle.api.TruffleSafepoint)3 ExportMessage (com.oracle.truffle.api.library.ExportMessage)3 ExplodeLoop (com.oracle.truffle.api.nodes.ExplodeLoop)3 UnexpectedResultException (com.oracle.truffle.api.nodes.UnexpectedResultException)3 BitcodeID (com.oracle.truffle.llvm.runtime.IDGenerater.BitcodeID)3 LLVMSymbol (com.oracle.truffle.llvm.runtime.LLVMSymbol)3 LLVMIllegalSymbolIndexException (com.oracle.truffle.llvm.runtime.except.LLVMIllegalSymbolIndexException)3 LLVMLinkerException (com.oracle.truffle.llvm.runtime.except.LLVMLinkerException)3 Assumption (com.oracle.truffle.api.Assumption)2 LLVMFunction (com.oracle.truffle.llvm.runtime.LLVMFunction)2 LLVMFunctionDescriptor (com.oracle.truffle.llvm.runtime.LLVMFunctionDescriptor)2 LLVMScopeChain (com.oracle.truffle.llvm.runtime.LLVMScopeChain)2 LLVM80BitFloat (com.oracle.truffle.llvm.runtime.floating.LLVM80BitFloat)2 LLVMForeignGetSuperElemPtrNode (com.oracle.truffle.llvm.runtime.interop.export.LLVMForeignGetSuperElemPtrNode)2 LLVMStack (com.oracle.truffle.llvm.runtime.memory.LLVMStack)2 LLVMManagedPointer (com.oracle.truffle.llvm.runtime.pointer.LLVMManagedPointer)2