Search in sources :

Example 1 with LLVMGlobalContainer

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

Aggregations

LLVMSymbol (com.oracle.truffle.llvm.runtime.LLVMSymbol)1 LLVMLinkerException (com.oracle.truffle.llvm.runtime.except.LLVMLinkerException)1 LLVMGlobal (com.oracle.truffle.llvm.runtime.global.LLVMGlobal)1 LLVMGlobalContainer (com.oracle.truffle.llvm.runtime.global.LLVMGlobalContainer)1 LLVMPointer (com.oracle.truffle.llvm.runtime.pointer.LLVMPointer)1 ArrayList (java.util.ArrayList)1