Skip to content
Snippets Groups Projects
Commit 2d7c6bf2 authored by Florian Angerer's avatar Florian Angerer
Browse files

Initialize promise with exec frame if in interpreter.

parent 3740696d
No related branches found
No related tags found
No related merge requests found
......@@ -91,7 +91,10 @@ public final class OptForcedEagerPromiseNode extends PromiseNode {
call = call.getParent();
}
}
return factory.createEagerSuppliedPromise(value, alwaysValidAssumption, call, null, wrapIndex);
if (CompilerDirectives.inInterpreter()) {
return factory.createEagerSuppliedPromise(value, alwaysValidAssumption, call, null, wrapIndex, frame.materialize());
}
return factory.createEagerSuppliedPromise(value, alwaysValidAssumption, call, null, wrapIndex, null);
}
@Override
......
......@@ -25,6 +25,7 @@ package com.oracle.truffle.r.nodes.function.opt;
import com.oracle.truffle.api.Assumption;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.FrameSlot;
import com.oracle.truffle.api.frame.MaterializedFrame;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.InvalidAssumptionException;
import com.oracle.truffle.api.profiles.BranchProfile;
......@@ -99,10 +100,16 @@ public abstract class OptVariablePromiseBaseNode extends PromiseNode implements
promiseCallerProfile.enter();
call = call.getParent();
}
MaterializedFrame execFrame = null;
if (CompilerDirectives.inInterpreter()) {
execFrame = frame.materialize();
}
if (result instanceof RPromise) {
return factory.createPromisedPromise((RPromise) result, notChangedNonLocally, call, this);
return factory.createPromisedPromise((RPromise) result, notChangedNonLocally, call, this, execFrame);
} else {
return factory.createEagerSuppliedPromise(result, notChangedNonLocally, call, this, wrapIndex);
return factory.createEagerSuppliedPromise(result, notChangedNonLocally, call, this, wrapIndex, execFrame);
}
}
......
......@@ -502,18 +502,18 @@ public final class RDataFactory {
}
public static RPromise createEagerPromise(PromiseState state, Closure exprClosure, Object eagerValue, Assumption notChangedNonLocally, RCaller targetFrame, EagerFeedback feedback,
int wrapIndex) {
int wrapIndex, MaterializedFrame execFrame) {
if (FastROptions.noEagerEval()) {
throw RInternalError.shouldNotReachHere();
}
return traceDataCreated(new RPromise.EagerPromise(state, exprClosure, eagerValue, notChangedNonLocally, targetFrame, feedback, wrapIndex));
return traceDataCreated(new RPromise.EagerPromise(state, exprClosure, eagerValue, notChangedNonLocally, targetFrame, feedback, wrapIndex, execFrame));
}
public static RPromise createPromisedPromise(Closure exprClosure, Object eagerValue, Assumption notChangedNonLocally, RCaller targetFrame, EagerFeedback feedback) {
public static RPromise createPromisedPromise(Closure exprClosure, Object eagerValue, Assumption notChangedNonLocally, RCaller targetFrame, EagerFeedback feedback, MaterializedFrame execFrame) {
if (FastROptions.noEagerEval()) {
throw RInternalError.shouldNotReachHere();
}
return traceDataCreated(new RPromise.EagerPromise(PromiseState.Promised, exprClosure, eagerValue, notChangedNonLocally, targetFrame, feedback, -1));
return traceDataCreated(new RPromise.EagerPromise(PromiseState.Promised, exprClosure, eagerValue, notChangedNonLocally, targetFrame, feedback, -1, execFrame));
}
public static Object createLangPairList(int size) {
......
......@@ -26,7 +26,6 @@ import java.util.HashMap;
import com.oracle.truffle.api.Assumption;
import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.CompilerDirectives.ValueType;
......@@ -302,8 +301,8 @@ public class RPromise extends RObject implements RTypedValue {
*/
private boolean deoptimized = false;
EagerPromise(PromiseState state, Closure closure, Object eagerValue, Assumption notChangedNonLocally, RCaller targetFrame, EagerFeedback feedback, int wrapIndex) {
super(state, (MaterializedFrame) null, closure);
EagerPromise(PromiseState state, Closure closure, Object eagerValue, Assumption notChangedNonLocally, RCaller targetFrame, EagerFeedback feedback, int wrapIndex, MaterializedFrame execFrame) {
super(state, execFrame, closure);
assert state != PromiseState.Explicit;
this.eagerValue = eagerValue;
this.notChangedNonLocally = notChangedNonLocally;
......@@ -318,7 +317,6 @@ public class RPromise extends RObject implements RTypedValue {
public boolean deoptimize() {
if (!deoptimized && !isEvaluated() && feedback != null) {
deoptimized = true;
notifyFailure();
materialize();
return false;
}
......@@ -328,8 +326,10 @@ public class RPromise extends RObject implements RTypedValue {
@TruffleBoundary
public void materialize() {
if (execFrame == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
this.execFrame = Utils.getStackFrame(FrameAccess.MATERIALIZE, targetFrame).materialize();
if (feedback != null) {
notifyFailure();
}
}
}
......@@ -409,14 +409,14 @@ public class RPromise extends RObject implements RTypedValue {
* until evaluation
* @return An {@link EagerPromise}
*/
public RPromise createEagerSuppliedPromise(Object eagerValue, Assumption notChangedNonLocally, RCaller targetFrame, EagerFeedback feedback, int wrapIndex) {
public RPromise createEagerSuppliedPromise(Object eagerValue, Assumption notChangedNonLocally, RCaller targetFrame, EagerFeedback feedback, int wrapIndex, MaterializedFrame execFrame) {
return RDataFactory.createEagerPromise(state == PromiseState.Default ? PromiseState.EagerDefault : PromiseState.EagerSupplied, exprClosure, eagerValue, notChangedNonLocally, targetFrame,
feedback, wrapIndex);
feedback, wrapIndex, execFrame);
}
public RPromise createPromisedPromise(RPromise promisedPromise, Assumption notChangedNonLocally, RCaller targetFrame, EagerFeedback feedback) {
public RPromise createPromisedPromise(RPromise promisedPromise, Assumption notChangedNonLocally, RCaller targetFrame, EagerFeedback feedback, MaterializedFrame execFrame) {
assert state == PromiseState.Supplied;
return RDataFactory.createPromisedPromise(exprClosure, promisedPromise, notChangedNonLocally, targetFrame, feedback);
return RDataFactory.createPromisedPromise(exprClosure, promisedPromise, notChangedNonLocally, targetFrame, feedback, execFrame);
}
public Object getExpr() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment