Search in sources :

Example 1 with SulongLibrary

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

the class LoadModulesNode method execute.

@Override
public Object execute(VirtualFrame frame) {
    LLVMContext context = getContext();
    synchronized (context) {
        if (!hasInitialised) {
            CompilerDirectives.transferToInterpreterAndInvalidate();
            LLVMFunction mainFunction = findMainFunction();
            if (mainFunction != null) {
                main = new CachedMainFunction(mainFunction);
            } else {
                main = null;
            }
            initContext = this.insert(language.createInitializeContextNode());
            hasInitialised = true;
        }
        LLVMScopeChain firstScopeChain = loadModule(frame, context);
        context.addSourceForCache(bitcodeID, source);
        context.addCalltargetForCache(libraryName, this.getCallTarget());
        // Only the root library (not a dependency) will have a non-null scope.
        if (firstScopeChain != null) {
            SulongLibrary library = new SulongLibrary(this.libraryName, firstScopeChain, main, context, parserRuntime.getLocator(), parserRuntime.getBitcodeID());
            if (main != null) {
                context.setMainLibrary(library);
            }
            return library;
        }
    }
    return null;
}
Also used : LLVMContext(com.oracle.truffle.llvm.runtime.LLVMContext) LLVMFunction(com.oracle.truffle.llvm.runtime.LLVMFunction) LLVMScopeChain(com.oracle.truffle.llvm.runtime.LLVMScopeChain) SulongLibrary(com.oracle.truffle.llvm.runtime.SulongLibrary) CachedMainFunction(com.oracle.truffle.llvm.runtime.SulongLibrary.CachedMainFunction)

Aggregations

LLVMContext (com.oracle.truffle.llvm.runtime.LLVMContext)1 LLVMFunction (com.oracle.truffle.llvm.runtime.LLVMFunction)1 LLVMScopeChain (com.oracle.truffle.llvm.runtime.LLVMScopeChain)1 SulongLibrary (com.oracle.truffle.llvm.runtime.SulongLibrary)1 CachedMainFunction (com.oracle.truffle.llvm.runtime.SulongLibrary.CachedMainFunction)1