diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ConditionFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ConditionFunctions.java index 12fffb616a49f19672854e6aa2d57c0c22326559..2f8f4b2f6e33e465ceb65a8110915fdc0ef1392f 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ConditionFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ConditionFunctions.java @@ -36,6 +36,7 @@ import com.oracle.truffle.r.runtime.data.RList; import com.oracle.truffle.r.runtime.data.RNull; import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector; import com.oracle.truffle.r.runtime.env.REnvironment; +import com.oracle.truffle.r.runtime.env.frame.FrameSlotChangeMonitor; /** * Condition handling. Derived from GnUR src/main/errors.c @@ -71,8 +72,8 @@ public class ConditionFunctions { throw error(RError.Message.BAD_HANDLER_DATA); } try { - if (!frame.isObject(handlerFrameSlot) || frame.getObject(handlerFrameSlot) == null) { - frame.setObject(handlerFrameSlot, RErrorHandling.getHandlerStack()); + if (!frame.isObject(handlerFrameSlot) || FrameSlotChangeMonitor.getObject(handlerFrameSlot, frame) == null) { + FrameSlotChangeMonitor.setObject(frame, handlerFrameSlot, RErrorHandling.getHandlerStack()); } } catch (FrameSlotTypeException e) { throw RInternalError.shouldNotReachHere(); @@ -121,7 +122,7 @@ public class ConditionFunctions { } try { if (!frame.isObject(restartFrameSlot) || frame.getObject(restartFrameSlot) == null) { - frame.setObject(restartFrameSlot, RErrorHandling.getRestartStack()); + FrameSlotChangeMonitor.setObject(frame, restartFrameSlot, RErrorHandling.getRestartStack()); } } catch (FrameSlotTypeException e) { throw RInternalError.shouldNotReachHere(); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/OnExit.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/OnExit.java index 3f472f67aa7dc31602afc451a53ba2d9e38f1da6..39096d59aa6f3d7f194d358ba94ad1ab34e0af76 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/OnExit.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/OnExit.java @@ -77,19 +77,19 @@ public abstract class OnExit extends RBuiltinNode.Arg2 { // the empty (RNull.instance) expression is used to clear on.exit if (emptyPromiseProfile.profile(expr.isDefaultArgument())) { assert expr.getRep() instanceof ConstantNode : "only ConstantNode expected for defaulted promise"; - frame.setObject(onExitSlot, RDataFactory.createPairList()); + FrameSlotChangeMonitor.setObject(frame, onExitSlot, RDataFactory.createPairList()); } else { assert !expr.isEvaluated() : "promise cannot already be evaluated"; Object value; try { - value = frame.getObject(onExitSlot); + value = FrameSlotChangeMonitor.getObject(onExitSlot, frame); } catch (FrameSlotTypeException e) { throw RInternalError.shouldNotReachHere(); } RPairList list; if (newProfile.profile(value == null)) { // initialize the list of exit handlers - frame.setObject(onExitSlot, list = RDataFactory.createPairList()); + FrameSlotChangeMonitor.setObject(frame, onExitSlot, list = RDataFactory.createPairList()); } else { list = (RPairList) value; if (addProfile.profile(!add)) { diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/call/RExplicitCallNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/call/RExplicitCallNode.java index b856c58620a7b6e111ee35ca431ca0c57779f4a5..3a4af7be70543373b97334da11591ad97ba1b7ec 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/call/RExplicitCallNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/call/RExplicitCallNode.java @@ -59,7 +59,6 @@ public abstract class RExplicitCallNode extends Node { argsFrameSlot = FrameSlotChangeMonitor.findOrAddFrameSlot(frame.getFrameDescriptor(), argsIdentifier, FrameSlotKind.Object); } try { - frame.setObject(argsFrameSlot, args); FrameSlotChangeMonitor.setObject(frame, argsFrameSlot, args); return call.execute(frame, function); } finally { diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/frame/FrameSlotChangeMonitor.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/frame/FrameSlotChangeMonitor.java index 813377fc39614ef4387f9e30d1512d7dba1db096..58c51106c0554cd81d437790ca30db44ffbd2612 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/frame/FrameSlotChangeMonitor.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/frame/FrameSlotChangeMonitor.java @@ -189,7 +189,7 @@ public final class FrameSlotChangeMonitor { private WeakReference<FrameDescriptor> enclosingFrameDescriptor = new WeakReference<>(null); private Assumption enclosingFrameDescriptorAssumption = Truffle.getRuntime().createAssumption("enclosing frame descriptor"); - private Assumption containsNoActiveBindingAssumption = Truffle.getRuntime().createAssumption("contains no active binding"); + private final Assumption containsNoActiveBindingAssumption = Truffle.getRuntime().createAssumption("contains no active binding"); private FrameDescriptorMetaData(String name, MaterializedFrame singletonFrame) { this.name = name; @@ -940,9 +940,7 @@ public final class FrameSlotChangeMonitor { FrameSlot[] slots = new FrameSlot[frame.getFrameDescriptor().getSlots().size()]; slots = frame.getFrameDescriptor().getSlots().toArray(slots); for (int i = 0; i < slots.length; i++) { - if (!(slots[i].getIdentifier() instanceof RFrameSlot)) { - FrameSlotInfoImpl.handleSearchPathMultiSlot(frame, slots[i], indices, replicate); - } + FrameSlotInfoImpl.handleSearchPathMultiSlot(frame, slots[i], indices, replicate); } } @@ -1000,21 +998,19 @@ public final class FrameSlotChangeMonitor { FrameSlot[] slots = frame.getFrameDescriptor().getSlots().toArray(new FrameSlot[0]); for (int i = 0; i < slots.length; i++) { - if (!(slots[i].getIdentifier() instanceof RFrameSlot)) { - Object value = frame.getValue(slots[i]); - if (value instanceof MultiSlotData) { - MultiSlotData msd = (MultiSlotData) value; - if (indices != null) { - for (int j = 0; j < indices.length; j++) { - assert indices[j] != 0; - msd.set(indices[j], null); - } - } else { - // only safe value of primordial context - Object initialValue = msd.get(0); - msd.setAll(null); - msd.set(0, initialValue); + Object value = frame.getValue(slots[i]); + if (value instanceof MultiSlotData) { + MultiSlotData msd = (MultiSlotData) value; + if (indices != null) { + for (int j = 0; j < indices.length; j++) { + assert indices[j] != 0; + msd.set(indices[j], null); } + } else { + // only safe value of primordial context + Object initialValue = msd.get(0); + msd.setAll(null); + msd.set(0, initialValue); } } }