Search in sources :

Example 1 with LLVMSymbol

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

the class LLSourceMap method getGlobalScope.

private LLVMSourceLocation getGlobalScope(LLVMScope moduleScope) {
    if (globalScope == null) {
        globalScope = LLVMSourceLocation.createLLModule(llSource.getName(), llSource.createSection(0, llSource.getLength()));
    }
    if (!globals.isEmpty()) {
        for (String globalName : globals) {
            assert globalName.startsWith("@");
            final LLVMSymbol actualSymbol = moduleScope.get(globalName.substring(1));
            if (actualSymbol != null && actualSymbol.isGlobalVariable()) {
                globalScope.addGlobal(actualSymbol.asGlobalVariable());
            } else {
                LLVMGlobal global = LLVMGlobal.createUnavailable(globalName);
                globalScope.addGlobal(global);
            }
        }
        globals.clear();
    }
    return globalScope;
}
Also used : LLVMGlobal(com.oracle.truffle.llvm.runtime.global.LLVMGlobal) LLVMSymbol(com.oracle.truffle.llvm.runtime.LLVMSymbol)

Example 2 with LLVMSymbol

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

the class LLVMDLSym method doDefaultHandle.

@Specialization(guards = "isRtldDefault(libraryHandle)")
protected Object doDefaultHandle(@SuppressWarnings("unused") LLVMNativePointer libraryHandle, @SuppressWarnings("unused") LLVMPointer symbolName, @SuppressWarnings("unused") @Cached() LLVMReadStringNode readStr, @Cached WrappedFunctionNode wrapper, @Cached BranchProfile exception) {
    LLVMContext ctx = LLVMContext.get(this);
    String name = readStr.executeWithTarget(symbolName);
    LLVMSymbol symbol = ctx.getGlobalScopeChain().get(name);
    if (symbol == null) {
        Object nativeSymbol = getNativeSymbol(name, ctx);
        if (nativeSymbol == null) {
            ctx.setDLError(2);
            return LLVMNativePointer.createNull();
        }
        return wrapper.execute(nativeSymbol);
    }
    return ctx.getSymbol(symbol, exception);
}
Also used : LLVMContext(com.oracle.truffle.llvm.runtime.LLVMContext) LLVMSymbol(com.oracle.truffle.llvm.runtime.LLVMSymbol) Specialization(com.oracle.truffle.api.dsl.Specialization)

Example 3 with LLVMSymbol

use of com.oracle.truffle.llvm.runtime.LLVMSymbol 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)

Example 4 with LLVMSymbol

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

the class InitializeSymbolsNode method allocGlobals.

private void allocGlobals(LLVMContext context, LLVMPointer roBase, LLVMPointer rwBase) {
    for (int i = 0; i < globals.length; i++) {
        LLVMSymbol allocGlobal = globals[i];
        LLVMGlobal descriptor = fileScope.getGlobalVariable(allocGlobal.getName());
        if (descriptor == null) {
            exception.enter();
            throw new LLVMLinkerException(this, "Global variable %s not found", allocGlobal.getName());
        }
        if (!context.checkSymbol(allocGlobal)) {
            // because of our symbol overriding support, it can happen that the global was
            // already bound before to a different target location
            LLVMPointer ref;
            if (globalOffsets[i] == -1) {
                ref = LLVMManagedPointer.create(new LLVMGlobalContainer());
            } else {
                LLVMPointer base = globalIsReadOnly[i] ? roBase : rwBase;
                ref = base.increment(globalOffsets[i]);
            }
            context.initializeSymbol(globals[i], ref);
            List<LLVMSymbol> list = new ArrayList<>(1);
            list.add(descriptor);
            context.registerSymbolReverseMap(list, ref);
        }
    }
}
Also used : LLVMGlobalContainer(com.oracle.truffle.llvm.runtime.global.LLVMGlobalContainer) LLVMPointer(com.oracle.truffle.llvm.runtime.pointer.LLVMPointer) ArrayList(java.util.ArrayList) LLVMGlobal(com.oracle.truffle.llvm.runtime.global.LLVMGlobal) LLVMLinkerException(com.oracle.truffle.llvm.runtime.except.LLVMLinkerException) LLVMSymbol(com.oracle.truffle.llvm.runtime.LLVMSymbol)

Example 5 with LLVMSymbol

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

the class LLVMParser method defineAlias.

private void defineAlias(String existingName, String newName, boolean newExported) {
    // handle the file scope
    LLVMSymbol aliasTarget = runtime.lookupSymbol(existingName);
    LLVMAlias aliasSymbol = new LLVMAlias(newName, aliasTarget, newExported);
    runtime.getFileScope().register(aliasSymbol);
    registerInPublicFileScope(aliasSymbol);
}
Also used : LLVMAlias(com.oracle.truffle.llvm.runtime.LLVMAlias) LLVMSymbol(com.oracle.truffle.llvm.runtime.LLVMSymbol)

Aggregations

LLVMSymbol (com.oracle.truffle.llvm.runtime.LLVMSymbol)11 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)3 LLVMGlobal (com.oracle.truffle.llvm.runtime.global.LLVMGlobal)3 LLVMPointer (com.oracle.truffle.llvm.runtime.pointer.LLVMPointer)3 Specialization (com.oracle.truffle.api.dsl.Specialization)2 LLVMAlias (com.oracle.truffle.llvm.runtime.LLVMAlias)2 LLVMContext (com.oracle.truffle.llvm.runtime.LLVMContext)2 ArrayList (java.util.ArrayList)2 LLVMElemPtrSymbol (com.oracle.truffle.llvm.runtime.LLVMElemPtrSymbol)1 LLVMFunction (com.oracle.truffle.llvm.runtime.LLVMFunction)1 LLVMFunctionCode (com.oracle.truffle.llvm.runtime.LLVMFunctionCode)1 LLVMScope (com.oracle.truffle.llvm.runtime.LLVMScope)1 LLVMScopeChain (com.oracle.truffle.llvm.runtime.LLVMScopeChain)1 LLVMLinkerException (com.oracle.truffle.llvm.runtime.except.LLVMLinkerException)1 LLVMPolyglotException (com.oracle.truffle.llvm.runtime.except.LLVMPolyglotException)1 LLVMGlobalContainer (com.oracle.truffle.llvm.runtime.global.LLVMGlobalContainer)1 LLVMExpressionNode (com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode)1