Skip to content

Commit 338a9ed

Browse files
committed
[GR-16266] Do not recheck the assumption in OptForcedEagerPromiseNode.
PullRequest: fastr/2051
2 parents 4113f13 + a11b376 commit 338a9ed

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/opt/OptForcedEagerPromiseNode.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import com.oracle.truffle.api.Assumption;
2626
import com.oracle.truffle.api.CompilerDirectives;
2727
import com.oracle.truffle.api.frame.VirtualFrame;
28-
import com.oracle.truffle.api.nodes.InvalidAssumptionException;
2928
import com.oracle.truffle.api.profiles.BranchProfile;
3029
import com.oracle.truffle.r.nodes.function.ArgumentStatePush;
3130
import com.oracle.truffle.r.nodes.function.PromiseHelperNode;
@@ -137,12 +136,9 @@ public OptForcedEagerPromiseNode(RPromiseFactory factory, int wrapIndex, Assumpt
137136
@Override
138137
public Object execute(final VirtualFrame frame) {
139138
Object value = null;
140-
try {
141-
allArgPromisesCanOptimize.check();
142-
} catch (InvalidAssumptionException e) {
143-
return getFallback().execute(frame);
139+
if (!allArgPromisesCanOptimize.isValid()) {
140+
return rewriteToFallback().execute(frame);
144141
}
145-
146142
RCaller currentCaller = RArguments.getCall(frame);
147143
boolean previousEvalEagerOnly = currentCaller.evaluateOnlyEagerPromises();
148144
try {
@@ -167,8 +163,10 @@ public Object execute(final VirtualFrame frame) {
167163
}
168164
} catch (CannotOptimizePromise ex) {
169165
allArgPromisesCanOptimize.invalidate();
170-
171166
if (previousEvalEagerOnly) {
167+
// no point in continuing executing this node, which checks this assumption as the
168+
// first thing in this method
169+
rewriteToFallback();
172170
throw ex;
173171
}
174172
value = null;
@@ -195,6 +193,10 @@ public RSyntaxNode getPromiseExpr() {
195193
return expr.asRSyntaxNode();
196194
}
197195

196+
private PromiseNode rewriteToFallback() {
197+
return replace(getFallback());
198+
}
199+
198200
private PromiseNode getFallback() {
199201
if (fallback == null) {
200202
CompilerDirectives.transferToInterpreterAndInvalidate();

0 commit comments

Comments
 (0)