From ffc218c5ec3106940ccec1a28db1aa2ccbae6fe5 Mon Sep 17 00:00:00 2001 From: stepan <stepan.sindelar@oracle.com> Date: Wed, 15 Aug 2018 19:52:45 +0200 Subject: [PATCH] Fix: getNumberedFrame with 0 works even in interop context --- .../oracle/truffle/r/nodes/builtin/base/FrameFunctions.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/FrameFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/FrameFunctions.java index a217681484..0be1959463 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/FrameFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/FrameFunctions.java @@ -106,6 +106,7 @@ public class FrameFunctions { public static final class FrameHelper extends RBaseNode { private final ConditionProfile currentFrameProfile = ConditionProfile.createBinaryProfile(); + private final ConditionProfile globalFrameProfile = ConditionProfile.createBinaryProfile(); /** * Determine the frame access mode of a subclass. The rule of thumb is that subclasses that @@ -187,6 +188,11 @@ public class FrameFunctions { protected Frame getNumberedFrame(VirtualFrame frame, int actualFrame, boolean materialize) { if (currentFrameProfile.profile(RArguments.getDepth(frame) == actualFrame)) { return materialize ? frame.materialize() : frame; + } else if (globalFrameProfile.profile(actualFrame == 0)) { + // Note: this is optimization and necessity, because in the case of invocation of R + // function from another "master" language, there will be no actual Truffle frame + // for global environment + return REnvironment.globalEnv().getFrame(); } else { if (RArguments.getDepth(frame) - actualFrame <= ITERATE_LEVELS) { Frame current = frame; -- GitLab