Skip to content
Snippets Groups Projects
Commit c4d87294 authored by stepan's avatar stepan
Browse files

Remove global GridContext, keep one per RContext

parent faaa8ab3
No related branches found
No related tags found
No related merge requests found
......@@ -50,8 +50,6 @@ import com.oracle.truffle.r.runtime.env.REnvironment;
* Encapsulated the access to the global grid state.
*/
public final class GridContext {
private static final GridContext INSTANCE = new GridContext();
private RInternalCode internalCode;
private final GridState gridState = new GridState();
/**
......@@ -65,7 +63,11 @@ public final class GridContext {
}
public static GridContext getContext() {
return INSTANCE;
RContext rCtx = RContext.getInstance();
if (rCtx.gridContext == null) {
rCtx.gridContext = new GridContext();
}
return (GridContext) rCtx.gridContext;
}
@TruffleBoundary
......
......@@ -24,6 +24,7 @@ import com.oracle.truffle.r.runtime.ROptions.OptionsException;
import com.oracle.truffle.r.runtime.RRuntime;
import com.oracle.truffle.r.runtime.context.RContext;
import com.oracle.truffle.r.runtime.data.RDataFactory;
import com.oracle.truffle.r.runtime.data.RList;
import com.oracle.truffle.r.runtime.data.RNull;
import com.oracle.truffle.r.runtime.data.RPairList;
import com.oracle.truffle.r.runtime.env.REnvironment;
......@@ -81,14 +82,13 @@ public final class RGridGraphicsAdapter {
}
/**
* Fixup .Devices array as someone may have set it to something that is not a pair list nor
* RNull, which breaks dev.cur built-in R function and others. GNUR seems to have active binding
* for it. This is such special case that it doesn't seem necessary for now.
* Fixup .Devices array as someone may have set it to something that is not a (pair) list nor
* RNull, which breaks dev.cur built-in R function and others.
*/
@TruffleBoundary
public static void fixupDevicesVariable() {
Object devices = REnvironment.baseEnv().get(DOT_DEVICES);
if (devices == RNull.instance || !(devices instanceof RPairList)) {
if (!(devices instanceof RPairList || devices instanceof RList)) {
// reset the .Devices and .Device variables to initial values
REnvironment.baseEnv().safePut(DOT_DEVICES, RNull.instance);
addDevice(NULL_DEVICE);
......
......@@ -350,6 +350,10 @@ public final class RContext implements RTruffleObject {
@CompilationFinal private RFFIContext stateRFFI;
// Context specific state required for libraries, the initialization is handled lazily by the
// concrete library.
public Object gridContext = null;
public final WeakHashMap<String, WeakReference<String>> stringMap = new WeakHashMap<>();
public final WeakHashMap<Source, REnvironment> sourceRefEnvironments = new WeakHashMap<>();
public final WeakHashMap<Path, REnvironment> srcfileEnvironments = 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