Skip to content

Commit

Permalink
Always send aboutToReturn (experiment)
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Dec 22, 2023
1 parent ecebfbb commit 0c6f831
Showing 1 changed file with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import de.hpi.swa.trufflesqueak.model.BooleanObject;
import de.hpi.swa.trufflesqueak.model.CompiledCodeObject;
import de.hpi.swa.trufflesqueak.model.ContextObject;
import de.hpi.swa.trufflesqueak.model.NilObject;
import de.hpi.swa.trufflesqueak.model.FrameMarker;
import de.hpi.swa.trufflesqueak.nodes.HandleNonLocalReturnNodeFactory.AboutToReturnNodeGen;
import de.hpi.swa.trufflesqueak.nodes.HandleNonLocalReturnNodeFactory.NormalReturnNodeGen;
import de.hpi.swa.trufflesqueak.nodes.context.frame.FrameStackReadNode;
Expand All @@ -47,21 +47,32 @@ public static HandleNonLocalReturnNode create(final CompiledCodeObject code) {

@ImportStatic(FrameStackReadNode.class)
public abstract static class AboutToReturnNode extends HandleNonLocalReturnNode {
@Specialization(guards = {"!hasModifiedSender(frame)"})
protected static final ControlFlowException doAboutToReturnVirtualized(final VirtualFrame frame, @SuppressWarnings("unused") final NonLocalReturn nlr,
@Cached("createTemporaryReadNode(frame, 1)") final FrameStackReadNode completeTempReadNode,
@Cached final DispatchVirtualAboutToReturnNode dispatchVirtualAboutToReturnNode) {
dispatchVirtualAboutToReturnNode.execute(frame, completeTempReadNode.executeRead(frame) == NilObject.SINGLETON);
throw CompilerDirectives.shouldNotReachHere();
}
// @Specialization(guards = {"!hasModifiedSender(frame)"})
// protected static final ControlFlowException doAboutToReturnVirtualized(final VirtualFrame
// frame,
// @SuppressWarnings("unused") final NonLocalReturn nlr,
// @Cached("createTemporaryReadNode(frame, 1)") final FrameStackReadNode
// completeTempReadNode,
// @Cached final DispatchVirtualAboutToReturnNode dispatchVirtualAboutToReturnNode) {
// dispatchVirtualAboutToReturnNode.execute(frame, completeTempReadNode.executeRead(frame)
// ==
// NilObject.SINGLETON);
// throw CompilerDirectives.shouldNotReachHere();
// }

@Specialization(guards = {"hasModifiedSender(frame)"})
@Specialization// (guards = {"hasModifiedSender(frame)"})
protected static final ControlFlowException doAboutToReturn(final VirtualFrame frame, final NonLocalReturn nlr,
@Bind("this") final Node node,
@Cached final GetOrCreateContextNode getOrCreateContextNode,
@Cached("createAboutToReturnSend()") final SendSelectorNode sendAboutToReturnNode) {
assert nlr.getTargetContextOrMarker() instanceof ContextObject;
sendAboutToReturnNode.executeSend(frame, new Object[]{getOrCreateContextNode.executeGet(frame, node), nlr.getReturnValue(), nlr.getTargetContextOrMarker()});
// assert nlr.getTargetContextOrMarker() instanceof ContextObject;
final ContextObject context;
if (nlr.getTargetContextOrMarker() instanceof final FrameMarker fm) {
context = fm.getMaterializedContext();
} else {
context = nlr.getTargetContext();
}
sendAboutToReturnNode.executeSend(frame, new Object[]{getOrCreateContextNode.executeGet(frame, node), nlr.getReturnValue(), context});
throw CompilerDirectives.shouldNotReachHere();
}
}
Expand Down

0 comments on commit 0c6f831

Please sign in to comment.