Skip to content
Snippets Groups Projects
Commit 3493673d authored by Tomas Stupka's avatar Tomas Stupka
Browse files

initialize RGridGraphicsAdapter on each RContext/REngine initialization

parent a51d607d
No related branches found
No related tags found
No related merge requests found
......@@ -168,7 +168,7 @@ final class REngine implements Engine, Engine.Timings {
REnvironment.baseInitialize(baseFrame, globalFrame);
context.getStateRFFI().initializeVariables(context);
RBuiltinPackages.loadBase(context.getLanguage(), baseFrame);
RGraphics.initialize();
RGraphics.initialize(context);
if (FastROptions.LoadProfiles.getBooleanValue()) {
StartupTiming.timestamp("Before Profiles Loaded");
/*
......
......@@ -18,6 +18,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import com.oracle.truffle.r.library.fastrGrid.graphics.RGridGraphicsAdapter;
import com.oracle.truffle.r.runtime.FastROptions;
import com.oracle.truffle.r.runtime.context.RContext;
import com.oracle.truffle.r.runtime.ffi.CallRFFI;
import com.oracle.truffle.r.runtime.ffi.DLL;
import com.oracle.truffle.r.runtime.ffi.NativeCallInfo;
......@@ -30,16 +31,17 @@ import com.oracle.truffle.r.runtime.ffi.NativeCallInfo;
public class RGraphics {
private static final AtomicBoolean initialized = new AtomicBoolean();
public static void initialize() {
if (initialized.compareAndSet(false, true)) {
if (FastROptions.UseInternalGridGraphics.getBooleanValue()) {
public static void initialize(RContext context) {
if (FastROptions.UseInternalGridGraphics.getBooleanValue()) {
if (!context.internalGraphicsInitialized) {
RGridGraphicsAdapter.initialize();
} else if (FastROptions.LoadPackagesNativeCode.getBooleanValue()) {
DLL.DLLInfo dllInfo = DLL.findLibraryContainingSymbol("InitGraphics");
DLL.SymbolHandle symbolHandle = DLL.findSymbol("InitGraphics", dllInfo);
assert symbolHandle != DLL.SYMBOL_NOT_FOUND;
CallRFFI.InvokeVoidCallRootNode.create().getCallTarget().call(new NativeCallInfo("InitGraphics", symbolHandle, dllInfo), new Object[0]);
}
} else if (initialized.compareAndSet(false, true) && FastROptions.LoadPackagesNativeCode.getBooleanValue()) {
DLL.DLLInfo dllInfo = DLL.findLibraryContainingSymbol("InitGraphics");
DLL.SymbolHandle symbolHandle = DLL.findSymbol("InitGraphics", dllInfo);
assert symbolHandle != DLL.SYMBOL_NOT_FOUND;
CallRFFI.InvokeVoidCallRootNode.create().getCallTarget().call(new NativeCallInfo("InitGraphics", symbolHandle, dllInfo), new Object[0]);
}
context.internalGraphicsInitialized = true;
}
}
......@@ -354,6 +354,7 @@ public final class RContext {
// Context specific state required for libraries, the initialization is handled lazily by the
// concrete library.
public Object gridContext = null;
public boolean internalGraphicsInitialized = false;
public final WeakHashMap<String, WeakReference<String>> stringMap = new WeakHashMap<>();
public final WeakHashMap<Source, REnvironment> sourceRefEnvironments = new WeakHashMap<>();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment