Search in sources :

Example 6 with LLVMPointer

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

the class LLVMPThreadContext method getAndRemoveSpecificUnlessNull.

@TruffleBoundary
public LLVMPointer getAndRemoveSpecificUnlessNull(int keyId) {
    final ConcurrentMap<Long, LLVMPointer> value = pThreadKeyStorage.get(keyId);
    if (value != null) {
        final long threadId = Thread.currentThread().getId();
        final LLVMPointer keyMapping = value.get(threadId);
        if (keyMapping != null && !keyMapping.isNull()) {
            value.remove(threadId);
            return keyMapping;
        }
    }
    return null;
}
Also used : LLVMPointer(com.oracle.truffle.llvm.runtime.pointer.LLVMPointer) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 7 with LLVMPointer

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

the class LLVMContext method setSymbol.

public void setSymbol(LLVMSymbol symbol, LLVMPointer value) {
    CompilerAsserts.neverPartOfCompilation();
    LLVMSymbol target = LLVMAlias.resolveAlias(symbol);
    BitcodeID bitcodeID = symbol.getBitcodeIDUncached();
    int id = bitcodeID.getId();
    LLVMPointer[] symbols = symbolDynamicStorage[id];
    Assumption[] assumptions = symbolAssumptions[id];
    synchronized (symbols) {
        try {
            int index = target.getSymbolIndexUncached();
            symbols[index] = value;
            assumptions[index].invalidate();
            assumptions[index] = Truffle.getRuntime().createAssumption();
            if (target instanceof LLVMFunction) {
                ((LLVMFunction) target).setValue(value);
            }
        } catch (LLVMIllegalSymbolIndexException e) {
            throw CompilerDirectives.shouldNotReachHere("symbol to be replaced was not found: " + target);
        }
    }
}
Also used : LLVMIllegalSymbolIndexException(com.oracle.truffle.llvm.runtime.except.LLVMIllegalSymbolIndexException) LLVMPointer(com.oracle.truffle.llvm.runtime.pointer.LLVMPointer) BitcodeID(com.oracle.truffle.llvm.runtime.IDGenerater.BitcodeID) TruffleSafepoint(com.oracle.truffle.api.TruffleSafepoint) Assumption(com.oracle.truffle.api.Assumption)

Example 8 with LLVMPointer

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

the class LLVMContext method checkSymbol.

/**
 * This method is only intended to be used during initialization of a Sulong library.
 */
@TruffleBoundary
public boolean checkSymbol(LLVMSymbol symbol) {
    assert !symbol.isAlias();
    if (symbol.hasValidIndexAndID()) {
        BitcodeID bitcodeID = symbol.getBitcodeIDUncached();
        int id = bitcodeID.getId();
        if (id < symbolDynamicStorage.length && symbolDynamicStorage[id] != null) {
            LLVMPointer[] symbols = symbolDynamicStorage[id];
            int index = symbol.getSymbolIndexUncached();
            return symbols[index] != null;
        }
    }
    throw new LLVMLinkerException(String.format("External %s %s cannot be found.", symbol.getKind(), symbol.getName()));
}
Also used : LLVMPointer(com.oracle.truffle.llvm.runtime.pointer.LLVMPointer) BitcodeID(com.oracle.truffle.llvm.runtime.IDGenerater.BitcodeID) LLVMLinkerException(com.oracle.truffle.llvm.runtime.except.LLVMLinkerException) TruffleSafepoint(com.oracle.truffle.api.TruffleSafepoint) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 9 with LLVMPointer

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

the class LLVMResolveForeignClassChainNode method doClassResolvingCached.

/**
 * @param ident
 * @param clazz
 * @param cachedIdent
 * @param cachedClazz
 */
@Specialization(guards = { "ident.equals(cachedIdent)", "clazz==cachedClazz" })
public LLVMPointer doClassResolvingCached(LLVMPointer receiver, String ident, LLVMInteropType.Clazz clazz, @Cached(value = "ident", allowUncached = true) String cachedIdent, @Cached(value = "clazz", allowUncached = true) LLVMInteropType.Clazz cachedClazz, @Cached LLVMForeignVirtualSuperElemPtrNode virtualSuperElemPtrNode, @Cached LLVMForeignDirectSuperElemPtrNode directSuperElemPtrNode, @Cached(value = "clazz.getSuperOffsetInformation(ident)", allowUncached = true) Pair<long[], Struct> p, @Cached(value = "p.getLeft()") long[] offsetInformation) {
    LLVMPointer curReceiver = receiver;
    for (long val : offsetInformation) {
        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) Specialization(com.oracle.truffle.api.dsl.Specialization)

Example 10 with LLVMPointer

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

the class AllocExternalSymbolNode method lookupFromScope.

@TruffleBoundary
private static LLVMPointer lookupFromScope(LLVMScopeChain scope, LLVMSymbol symbol, LLVMContext context) {
    LLVMSymbol resultSymbol = scope.get(symbol.getName());
    if (resultSymbol == null) {
        return null;
    }
    LLVMPointer pointer = context.getSymbolUncached(LLVMAlias.resolveAlias(resultSymbol));
    context.registerSymbol(symbol, pointer);
    return pointer;
}
Also used : LLVMPointer(com.oracle.truffle.llvm.runtime.pointer.LLVMPointer) LLVMSymbol(com.oracle.truffle.llvm.runtime.LLVMSymbol) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

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