diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/variables/LocalReadVariableNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/variables/LocalReadVariableNode.java index f67c254ce6760e5525ff1ef194c5455be9f1c515..533db2210151c99af8b2518e8367a45846453b9a 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/variables/LocalReadVariableNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/variables/LocalReadVariableNode.java @@ -51,6 +51,7 @@ public final class LocalReadVariableNode extends Node { private final Object identifier; private final boolean forceResult; + @CompilationFinal private boolean firstExecution = true; @CompilationFinal(dimensions = 1) private boolean[] seenValueKinds; @CompilationFinal private ValueProfile valueProfile; @@ -144,6 +145,13 @@ public final class LocalReadVariableNode extends Node { isPromiseProfile = ConditionProfile.createBinaryProfile(); } if (isPromiseProfile.profile(result instanceof RPromise)) { + if (firstExecution) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + firstExecution = false; + if (identifier instanceof String) { + return ReadVariableNode.evalPromiseSlowPathWithName((String) identifier, frame, (RPromise) result); + } + } if (promiseHelper == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); promiseHelper = insert(new PromiseHelperNode());