Skip to content
Snippets Groups Projects
Commit f4fd0ce7 authored by Lukas Stadler's avatar Lukas Stadler
Browse files

unwrap promises for stable lookups in FrameSlotChangeMonitor

parent 57460b42
Branches
No related tags found
No related merge requests found
...@@ -46,6 +46,7 @@ import com.oracle.truffle.api.profiles.BranchProfile; ...@@ -46,6 +46,7 @@ import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.r.runtime.RArguments; import com.oracle.truffle.r.runtime.RArguments;
import com.oracle.truffle.r.runtime.RInternalError; import com.oracle.truffle.r.runtime.RInternalError;
import com.oracle.truffle.r.runtime.StableValue; import com.oracle.truffle.r.runtime.StableValue;
import com.oracle.truffle.r.runtime.data.RPromise;
/** /**
* This class maintains information about the current hierarchy of environments in the system. This * This class maintains information about the current hierarchy of environments in the system. This
...@@ -84,6 +85,7 @@ public final class FrameSlotChangeMonitor { ...@@ -84,6 +85,7 @@ public final class FrameSlotChangeMonitor {
private static final class StableValueLookupResult extends LookupResult { private static final class StableValueLookupResult extends LookupResult {
private final StableValue<Object> value; private final StableValue<Object> value;
@CompilationFinal private Object unwrappedValue;
private StableValueLookupResult(String identifier, StableValue<Object> value) { private StableValueLookupResult(String identifier, StableValue<Object> value) {
super(identifier); super(identifier);
...@@ -100,7 +102,20 @@ public final class FrameSlotChangeMonitor { ...@@ -100,7 +102,20 @@ public final class FrameSlotChangeMonitor {
assumption.check(); assumption.check();
StableValue<Object> result = value; StableValue<Object> result = value;
result.getAssumption().check(); result.getAssumption().check();
return result.getValue(); if (unwrappedValue == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
Object resultValue = result.getValue();
if (resultValue instanceof RPromise) {
if (((RPromise) resultValue).isEvaluated()) {
unwrappedValue = ((RPromise) resultValue).getValue();
} else {
return resultValue;
}
} else {
unwrappedValue = resultValue;
}
}
return unwrappedValue;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment