use of com.oracle.truffle.llvm.runtime.memory.LLVMThreadingStack in project graal by oracle.
the class LLVMContext method initialize.
@SuppressWarnings("unchecked")
void initialize(ContextExtension[] contextExtens) {
contextState = State.INITIALIZED;
assert this.threadingStack == null;
this.contextExtensions = contextExtens;
if (traceIREnabled()) {
if (!env.getOptions().get(SulongEngineOption.LL_DEBUG)) {
traceIRLog("Trace IR logging is enabled, but \'--llvm.llDebug=true\' is not set");
}
LLVMTracerInstrument.attach(env);
}
this.threadingStack = new LLVMThreadingStack(Thread.currentThread(), parseStackSize(env.getOptions().get(SulongEngineOption.STACK_SIZE)));
String languageHome = language.getLLVMLanguageHome();
if (languageHome != null) {
PlatformCapability<?> sysContextExt = language.getCapability(PlatformCapability.class);
internalLibraryPath = Paths.get(languageHome).resolve(sysContextExt.getSulongLibrariesPath());
internalLibraryPathFile = env.getInternalTruffleFile(internalLibraryPath.toUri());
// add internal library location also to the external library lookup path
addLibraryPath(internalLibraryPath.toString());
}
for (ContextExtension ext : contextExtensions) {
ext.initialize(this);
}
try {
/*
* The default internal libraries are parsed in reverse dependency order, but not
* initialised. (For C: libsulong / For C++: libsulong, libsulong++) The truffle cache
* and the llvm language cache will return the call target of future parsing of these
* libraries.
*/
String[] sulongLibraryNames = language.getCapability(PlatformCapability.class).getSulongDefaultLibraries();
for (int i = sulongLibraryNames.length - 1; i >= 0; i--) {
TruffleFile file = InternalLibraryLocator.INSTANCE.locateLibrary(this, sulongLibraryNames[i], "<default bitcode library>");
Source librarySource = Source.newBuilder("llvm", file).internal(isInternalLibraryFile(file)).build();
sourceCache.put(IDGenerater.INVALID_ID, librarySource);
env.parseInternal(librarySource);
}
setLibsulongAuxFunction(SULONG_INIT_CONTEXT);
setLibsulongAuxFunction(SULONG_DISPOSE_CONTEXT);
setLibsulongAuxFunction(START_METHOD_NAME);
CallTarget builtinsLibrary = env.parseInternal(Source.newBuilder("llvm", env.getInternalTruffleFile(internalLibraryPath.resolve(language.getCapability(PlatformCapability.class).getBuiltinsLibrary()).toUri())).internal(true).build());
builtinsLibrary.call();
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
use of com.oracle.truffle.llvm.runtime.memory.LLVMThreadingStack in project graal by oracle.
the class LLVMForeignCallNode method execute.
@Override
public Object execute(VirtualFrame frame) {
Object result;
LLVMThreadingStack threadingStack = LLVMContext.get(this).getThreadingStack();
LLVMStack stack = getStack.executeWithTarget(threadingStack, Thread.currentThread());
try {
result = doCall(frame, stack);
} catch (ArityException ex) {
throw silenceException(RuntimeException.class, ex);
} catch (TypeOverflowException ex) {
throw silenceException(RuntimeException.class, ex);
}
return prepareValueForEscape.executeWithType(result, returnBaseType);
}
Aggregations