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

FastR Grid: turn-off recording when running grid code internally

parent 433e338a
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,8 @@
*/
package com.oracle.truffle.r.library.fastrGrid;
import java.util.function.Supplier;
import com.oracle.truffle.r.library.fastrGrid.device.GridDevice;
import com.oracle.truffle.r.runtime.data.RList;
import com.oracle.truffle.r.runtime.data.RNull;
......@@ -29,6 +31,16 @@ public final class GridState {
GridState() {
}
<T> T runWithoutRecording(Supplier<T> code) {
boolean recording = isDisplayListOn();
setIsDisplayListOn(false);
try {
return code.get();
} finally {
setIsDisplayListOn(recording);
}
}
void setDeviceState(GridDeviceState state) {
devState = state;
}
......
......@@ -444,6 +444,11 @@ public final class Unit {
@Child private RGridCodeCall isPureNullCall = new RGridCodeCall("isPureNullUnit");
public boolean execute(Object unit, int index) {
GridState gridState = GridContext.getContext().getGridState();
return gridState.runWithoutRecording(() -> executeImpl(unit, index));
}
private boolean executeImpl(Object unit, int index) {
// Note: converting 0-based java index to 1-based R index
Object result = isPureNullCall.execute(new RArgsValuesAndNames(new Object[]{unit, index + 1}, ArgumentsSignature.empty(2)));
byte resultByte;
......@@ -684,6 +689,11 @@ public final class Unit {
// transcribed from unit.c function evaluateGrobUnit
public double execute(double value, int unitId, Object grob, UnitConversionContext conversionCtx) {
GridState gridState = GridContext.getContext().getGridState();
return gridState.runWithoutRecording(() -> executeImpl(value, unitId, grob, conversionCtx));
}
private double executeImpl(double value, int unitId, Object grob, UnitConversionContext conversionCtx) {
GridContext ctx = GridContext.getContext();
RList currentVP = ctx.getGridState().getViewPort();
getViewPortTransform.execute(currentVP, conversionCtx.device);
......
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