use of com.oracle.truffle.llvm.runtime.pointer.LLVMPointer in project graal by oracle.
the class LLVMPThreadContext method getAndRemoveSpecificUnlessNull.
@TruffleBoundary
public LLVMPointer getAndRemoveSpecificUnlessNull(int keyId) {
final ConcurrentMap<Long, LLVMPointer> value = pThreadKeyStorage.get(keyId);
if (value != null) {
final long threadId = Thread.currentThread().getId();
final LLVMPointer keyMapping = value.get(threadId);
if (keyMapping != null && !keyMapping.isNull()) {
value.remove(threadId);
return keyMapping;
}
}
return null;
}
use of com.oracle.truffle.llvm.runtime.pointer.LLVMPointer in project graal by oracle.
the class LLVMContext method setSymbol.
public void setSymbol(LLVMSymbol symbol, LLVMPointer value) {
CompilerAsserts.neverPartOfCompilation();
LLVMSymbol target = LLVMAlias.resolveAlias(symbol);
BitcodeID bitcodeID = symbol.getBitcodeIDUncached();
int id = bitcodeID.getId();
LLVMPointer[] symbols = symbolDynamicStorage[id];
Assumption[] assumptions = symbolAssumptions[id];
synchronized (symbols) {
try {
int index = target.getSymbolIndexUncached();
symbols[index] = value;
assumptions[index].invalidate();
assumptions[index] = Truffle.getRuntime().createAssumption();
if (target instanceof LLVMFunction) {
((LLVMFunction) target).setValue(value);
}
} catch (LLVMIllegalSymbolIndexException e) {
throw CompilerDirectives.shouldNotReachHere("symbol to be replaced was not found: " + target);
}
}
}
use of com.oracle.truffle.llvm.runtime.pointer.LLVMPointer in project graal by oracle.
the class LLVMContext method checkSymbol.
/**
* This method is only intended to be used during initialization of a Sulong library.
*/
@TruffleBoundary
public boolean checkSymbol(LLVMSymbol symbol) {
assert !symbol.isAlias();
if (symbol.hasValidIndexAndID()) {
BitcodeID bitcodeID = symbol.getBitcodeIDUncached();
int id = bitcodeID.getId();
if (id < symbolDynamicStorage.length && symbolDynamicStorage[id] != null) {
LLVMPointer[] symbols = symbolDynamicStorage[id];
int index = symbol.getSymbolIndexUncached();
return symbols[index] != null;
}
}
throw new LLVMLinkerException(String.format("External %s %s cannot be found.", symbol.getKind(), symbol.getName()));
}
use of com.oracle.truffle.llvm.runtime.pointer.LLVMPointer in project graal by oracle.
the class LLVMResolveForeignClassChainNode method doClassResolvingCached.
/**
* @param ident
* @param clazz
* @param cachedIdent
* @param cachedClazz
*/
@Specialization(guards = { "ident.equals(cachedIdent)", "clazz==cachedClazz" })
public LLVMPointer doClassResolvingCached(LLVMPointer receiver, String ident, LLVMInteropType.Clazz clazz, @Cached(value = "ident", allowUncached = true) String cachedIdent, @Cached(value = "clazz", allowUncached = true) LLVMInteropType.Clazz cachedClazz, @Cached LLVMForeignVirtualSuperElemPtrNode virtualSuperElemPtrNode, @Cached LLVMForeignDirectSuperElemPtrNode directSuperElemPtrNode, @Cached(value = "clazz.getSuperOffsetInformation(ident)", allowUncached = true) Pair<long[], Struct> p, @Cached(value = "p.getLeft()") long[] offsetInformation) {
LLVMPointer curReceiver = receiver;
for (long val : offsetInformation) {
LLVMForeignGetSuperElemPtrNode access = (val & 1) == 1 ? virtualSuperElemPtrNode : directSuperElemPtrNode;
curReceiver = access.execute(curReceiver, val >> 1);
}
return curReceiver.export(p.getRight() == null ? clazz : p.getRight());
}
use of com.oracle.truffle.llvm.runtime.pointer.LLVMPointer 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;
}
Aggregations