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);
}
}
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;
}
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);
}
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
}
}
}
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.");
}
}
}
Aggregations