Search in sources :

Example 1 with LLVMLoadingPhase

use of com.oracle.truffle.llvm.initialization.LoadModulesNode.LLVMLoadingPhase in project graal by oracle.

the class LoadNativeNode method execute.

@Override
@SuppressWarnings("unchecked")
public Object execute(VirtualFrame frame) {
    Object[] arguments = frame.getArguments();
    Object library = null;
    LLVMLoadingPhase phase;
    if (arguments.length > 0 && (arguments[0] instanceof LLVMLoadingPhase)) {
        phase = (LLVMLoadingPhase) arguments[0];
    } else if (arguments.length == 0 || (arguments.length > 0 && (arguments[0] instanceof LLVMDLOpen.RTLDFlags))) {
        if (path == null) {
            throw new LLVMParserException(this, "Toplevel executable %s does not contain bitcode", path);
        }
        phase = LLVMLoadingPhase.INIT_SYMBOLS;
    } else {
        throw new LLVMParserException(this, "LoadNativeNode is called either with unexpected arguments or as a toplevel");
    }
    if (LLVMLoadingPhase.INIT_SYMBOLS.isActive(phase)) {
        LLVMContext context = LLVMContext.get(this);
        library = parseAndInitialiseNativeLib(context);
    }
    if (LLVMLoadingPhase.BUILD_DEPENDENCY.isActive(phase)) {
        ArrayList<CallTarget> dependencies = (ArrayList<CallTarget>) frame.getArguments()[2];
        dependencies.add(this.getCallTarget());
    }
    return library;
}
Also used : LLVMLoadingPhase(com.oracle.truffle.llvm.initialization.LoadModulesNode.LLVMLoadingPhase) LLVMContext(com.oracle.truffle.llvm.runtime.LLVMContext) CallTarget(com.oracle.truffle.api.CallTarget) LLVMDLOpen(com.oracle.truffle.llvm.runtime.nodes.intrinsics.c.LLVMDLOpen) ArrayList(java.util.ArrayList) LLVMParserException(com.oracle.truffle.llvm.runtime.except.LLVMParserException)

Aggregations

CallTarget (com.oracle.truffle.api.CallTarget)1 LLVMLoadingPhase (com.oracle.truffle.llvm.initialization.LoadModulesNode.LLVMLoadingPhase)1 LLVMContext (com.oracle.truffle.llvm.runtime.LLVMContext)1 LLVMParserException (com.oracle.truffle.llvm.runtime.except.LLVMParserException)1 LLVMDLOpen (com.oracle.truffle.llvm.runtime.nodes.intrinsics.c.LLVMDLOpen)1 ArrayList (java.util.ArrayList)1