Search in sources :

Example 16 with LLVMPointer

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

the class InitializeOverwriteNode method execute.

public void execute(LLVMContext context, LLVMScopeChain localScope, RTLDFlags rtldFlags) {
    LLVMScopeChain globalScope = context.getGlobalScopeChain();
    for (LLVMFunction function : functions) {
        LLVMPointer pointer = allocExternalSymbol.execute(localScope, globalScope, null, null, context, rtldFlags, function);
        // skip allocating fallbacks
        if (pointer == null) {
            continue;
        }
        context.initializeSymbol(function, pointer);
    }
    for (LLVMGlobal global : globals) {
        LLVMPointer pointer = allocExternalSymbol.execute(localScope, globalScope, null, null, context, rtldFlags, global);
        // skip allocating fallbacks
        if (pointer == null) {
            continue;
        }
        context.initializeSymbol(global, pointer);
    }
}
Also used : LLVMFunction(com.oracle.truffle.llvm.runtime.LLVMFunction) LLVMPointer(com.oracle.truffle.llvm.runtime.pointer.LLVMPointer) LLVMScopeChain(com.oracle.truffle.llvm.runtime.LLVMScopeChain) LLVMGlobal(com.oracle.truffle.llvm.runtime.global.LLVMGlobal)

Example 17 with LLVMPointer

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

the class StructLiteralNode method doLLVMPointer.

@ExplodeLoop
@Specialization
protected LLVMPointer doLLVMPointer(VirtualFrame frame, LLVMPointer address) {
    for (int i = 0; i < offsets.length; i++) {
        LLVMPointer currentAddr = address.increment(offsets[i]);
        Object value = values[i] == null ? null : values[i].executeGeneric(frame);
        elementWriteNodes[i].executeWithTarget(currentAddr, value);
    }
    return address;
}
Also used : LLVMPointer(com.oracle.truffle.llvm.runtime.pointer.LLVMPointer) Specialization(com.oracle.truffle.api.dsl.Specialization) ExplodeLoop(com.oracle.truffle.api.nodes.ExplodeLoop)

Example 18 with LLVMPointer

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

the class LLVMDynAccessSymbolNode method doAccess.

@Specialization
LLVMPointer doAccess(LLVMSymbol symbol, @Cached BranchProfile exception) {
    LLVMPointer value = getContext().getSymbol(symbol, exception);
    if (value != null) {
        return value;
    }
    exception.enter();
    throw notFound(symbol);
}
Also used : LLVMPointer(com.oracle.truffle.llvm.runtime.pointer.LLVMPointer) Specialization(com.oracle.truffle.api.dsl.Specialization)

Example 19 with LLVMPointer

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

the class LLVMContext method cleanUpGuestCode.

/**
 * This method is called from {@link LLVMContext#exitContext} only, where the guest code still
 * can be still executed.
 */
private void cleanUpGuestCode(LLVMFunction sulongDisposeContext) {
    // - _exit(), _Exit(), or abort(): no cleanup necessary
    if (cleanupNecessary) {
        try {
            if (sulongDisposeContext == null) {
                throw new IllegalStateException("Context cannot be disposed: " + SULONG_DISPOSE_CONTEXT + " was not found");
            }
            LLVMPointer pointer = getSymbolUncached(sulongDisposeContext);
            if (LLVMManagedPointer.isInstance(pointer)) {
                LLVMFunctionDescriptor functionDescriptor = (LLVMFunctionDescriptor) LLVMManagedPointer.cast(pointer).getObject();
                RootCallTarget disposeContext = functionDescriptor.getFunctionCode().getLLVMIRFunctionSlowPath();
                LLVMStack stack = threadingStack.getStack();
                disposeContext.call(stack);
            } else {
                throw new IllegalStateException("Context cannot be disposed: " + SULONG_DISPOSE_CONTEXT + " is not a function or enclosed inside a LLVMManagedPointer");
            }
        } catch (ControlFlowException | LLVMExitException e) {
        // nothing needs to be done as the behavior is not defined
        }
    }
}
Also used : LLVMPointer(com.oracle.truffle.llvm.runtime.pointer.LLVMPointer) ControlFlowException(com.oracle.truffle.api.nodes.ControlFlowException) RootCallTarget(com.oracle.truffle.api.RootCallTarget) LLVMStack(com.oracle.truffle.llvm.runtime.memory.LLVMStack)

Example 20 with LLVMPointer

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

the class LLVMContext method initializeSymbol.

/**
 * This method is only intended to be used during initialization of a Sulong library.
 */
@TruffleBoundary
public void initializeSymbol(LLVMSymbol symbol, LLVMPointer value) {
    assert !symbol.isAlias();
    BitcodeID bitcodeID = symbol.getBitcodeIDUncached();
    int id = bitcodeID.getId();
    LLVMPointer[] symbols = symbolDynamicStorage[id];
    Assumption[] assumptions = symbolAssumptions[id];
    synchronized (symbols) {
        try {
            int index = symbol.getSymbolIndexUncached();
            if (symbols[index] != null && symbols[index].isSame(value)) {
                return;
            }
            symbols[index] = value;
            assumptions[index] = Truffle.getRuntime().createAssumption();
            if (symbol instanceof LLVMFunction) {
                ((LLVMFunction) symbol).setValue(value);
            }
        } catch (LLVMIllegalSymbolIndexException e) {
            throw new LLVMLinkerException("Writing symbol into symbol table is inconsistent.");
        }
    }
}
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) LLVMLinkerException(com.oracle.truffle.llvm.runtime.except.LLVMLinkerException) TruffleSafepoint(com.oracle.truffle.api.TruffleSafepoint) Assumption(com.oracle.truffle.api.Assumption) 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