diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Xtfrm.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Xtfrm.java index a6f492fda37610985d91e463e67177c96dd1f5f5..9f9e6abd16c18a21579e3b689fcfb7c15cc3cae9 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Xtfrm.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Xtfrm.java @@ -64,7 +64,7 @@ public abstract class Xtfrm extends RBuiltinNode.Arg1 { REnvironment env = RArguments.getEnvironment(frame); if (createProfile.profile(env == null)) { - env = REnvironment.createEnclosingEnvironments(frame.materialize()); + env = REnvironment.frameToEnvironment(frame.materialize()); } RFunction func = (RFunction) getNode.execute(frame, "xtfrm.default", env, RType.Function.getName(), true); return RContext.getEngine().evalFunction(func, null, null, true, null, x); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/EnvironmentNodes.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/EnvironmentNodes.java index 5d6db966d17c912b1a435b364e729497ee889351..ef47ee3c2416d3e4aa7988a97c554a6ec26c3a41 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/EnvironmentNodes.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/EnvironmentNodes.java @@ -146,7 +146,7 @@ public final class EnvironmentNodes { } REnvironment env = RArguments.getEnvironment(enclosing); if (createProfile.profile(env == null)) { - return REnvironment.createEnclosingEnvironments(enclosing.materialize()); + return REnvironment.frameToEnvironment(enclosing.materialize()); } return env; } diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/REnvironment.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/REnvironment.java index ecfce5c1599cbf35bb9781ea96fa3c7f44c1d6d5..95ba65c09f037c09c94225a2b5e28f182cf65221 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/REnvironment.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/REnvironment.java @@ -660,27 +660,8 @@ public abstract class REnvironment extends RAttributeStorage { MaterializedFrame f = frame instanceof VirtualEvalFrame ? ((VirtualEvalFrame) frame).getOriginalFrame() : frame; REnvironment env = RArguments.getEnvironment(f); if (env == null) { - if (RArguments.getFunction(f) == null) { - throw RInternalError.shouldNotReachHere(); - } - env = createEnclosingEnvironments(f); - } - return env; - } - - /** - * This chain can be followed back to whichever "base" (i.e. non-function) environment the - * outermost function was defined in, e.g. "global" or "base". The purpose of this method is to - * create an analogous lexical parent chain of {@link Function} instances with the correct - * {@link MaterializedFrame}. - */ - @TruffleBoundary - public static REnvironment createEnclosingEnvironments(MaterializedFrame frame) { - MaterializedFrame f = frame instanceof VirtualEvalFrame ? ((VirtualEvalFrame) frame).getOriginalFrame() : frame; - REnvironment env = RArguments.getEnvironment(f); - if (env == null) { - // parent is the env of the enclosing frame - env = REnvironment.Function.create(f); + assert RArguments.getFunction(f) != null; + RArguments.setEnvironment(f, env = new REnvironment.Function(f)); } return env; } @@ -1068,14 +1049,6 @@ public abstract class REnvironment extends RAttributeStorage { // function environments are not named super(UNNAMED, frame); } - - private static Function create(MaterializedFrame frame) { - Function result = (Function) RArguments.getEnvironment(frame); - if (result == null) { - result = new Function(frame); - } - return result; - } } /**