use of com.oracle.truffle.llvm.runtime.NativeContextExtension in project graal by oracle.
the class ParserDriver method createNativeTruffleFile.
@TruffleBoundary
private TruffleFile createNativeTruffleFile(String libName, String libPath) {
NativeContextExtension nativeContextExtension = context.getContextExtensionOrNull(NativeContextExtension.class);
if (nativeContextExtension != null) {
TruffleFile file = DefaultLibraryLocator.INSTANCE.locate(context, libName, "<native library>");
if (file == null) {
// Unable to locate the library -> will go to native
LibraryLocator.traceDelegateNative(context, libPath);
file = context.getEnv().getInternalTruffleFile(libPath);
}
return file;
}
return null;
}
use of com.oracle.truffle.llvm.runtime.NativeContextExtension in project graal by oracle.
the class LoadNativeNode method parseAndInitialiseNativeLib.
@TruffleBoundary
private Object parseAndInitialiseNativeLib(LLVMContext context) {
NativeContextExtension nativeContextExtension = context.getContextExtensionOrNull(NativeContextExtension.class);
if (nativeContextExtension != null) {
CallTarget callTarget = nativeContextExtension.parseNativeLibrary(path, context);
Object nfiLibrary = callTarget.call();
nativeContextExtension.addLibraryHandles(nfiLibrary);
return nfiLibrary;
}
return null;
}
use of com.oracle.truffle.llvm.runtime.NativeContextExtension in project graal by oracle.
the class InitializeExternalNode method execute.
/*
* (PLi): Need to be careful of native functions/globals that are not in the nfi context (i.e.
* __xstat). Ideally they will be added to the symbol table as unresolved/undefined
* functions/globals.
*/
public void execute(LLVMContext context, LLVMScopeChain localScope, LLVMDLOpen.RTLDFlags rtldFlags) {
LLVMScopeChain globalScope = context.getGlobalScopeChain();
LLVMIntrinsicProvider intrinsicProvider = getLanguage().getCapability(LLVMIntrinsicProvider.class);
NativeContextExtension nativeContextExtension = getNativeContextExtension(context);
for (int i = 0; i < globals.length; i++) {
LLVMGlobal global = globals[i];
LLVMPointer pointer = allocExternalSymbol.execute(localScope, globalScope, intrinsicProvider, nativeContextExtension, context, rtldFlags, global);
if (pointer == null) {
continue;
}
context.initializeSymbol(globals[i], pointer);
}
for (int i = 0; i < functions.length; i++) {
LLVMFunction function = functions[i];
LLVMPointer pointer = allocExternalSymbol.execute(localScope, globalScope, intrinsicProvider, nativeContextExtension, context, rtldFlags, function);
if (pointer == null) {
continue;
}
context.initializeSymbol(functions[i], pointer);
}
}
use of com.oracle.truffle.llvm.runtime.NativeContextExtension in project graal by oracle.
the class LoadDependencyNode method createNativeTruffleFile.
@TruffleBoundary
private TruffleFile createNativeTruffleFile(String libName, String libPath) {
LLVMContext context = getContext();
NativeContextExtension nativeContextExtension = context.getContextExtensionOrNull(NativeContextExtension.class);
if (nativeContextExtension != null) {
TruffleFile file = DefaultLibraryLocator.INSTANCE.locate(context, libName, "<native library>");
if (file == null) {
// Unable to locate the library -> will go to native
LibraryLocator.traceDelegateNative(context, libPath);
file = context.getEnv().getInternalTruffleFile(libPath);
}
return file;
}
return null;
}
Aggregations