Skip to content

Commit

Permalink
Let WakeHighestPriorityNode return ProcessSwitch
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Dec 20, 2023
1 parent 7cddc9f commit ada13e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ protected final PointersObject doWaitExcessSignals(final VirtualFrame frame, fin
} else {
addLastLinkToListNode.execute(node, getActiveProcessNode.execute(node), receiver);
try {
wakeHighestPriorityNode.executeWake(frame, node);
throw wakeHighestPriorityNode.executeWake(frame, node);
} catch (final ProcessSwitch ps) {
/*
* Leave receiver on stack. It has not been removed from the stack yet, so it is
Expand All @@ -397,7 +397,6 @@ protected final PointersObject doWaitExcessSignals(final VirtualFrame frame, fin
getFrameStackPointerIncrementNode().execute(frame);
throw ps;
}
throw CompilerDirectives.shouldNotReachHere();
}
}
}
Expand Down Expand Up @@ -441,13 +440,12 @@ protected static final Object doSuspendActiveProcess(final VirtualFrame frame, @
@Cached final WakeHighestPriorityNode wakeHighestPriorityNode,
@Cached final FrameStackPushNode pushNode) {
try {
wakeHighestPriorityNode.executeWake(frame, node);
throw wakeHighestPriorityNode.executeWake(frame, node);
} catch (final ProcessSwitch ps) {
/* Leave `nil` as result on stack. */
pushNode.execute(frame, NilObject.SINGLETON);
throw ps;
}
throw CompilerDirectives.shouldNotReachHere();
}

@Specialization(guards = {"receiver != getActiveProcessNode.execute(node)"}, limit = "1")
Expand Down Expand Up @@ -480,13 +478,12 @@ protected static final Object doSuspendActiveProcess(final VirtualFrame frame, @
@Cached final WakeHighestPriorityNode wakeHighestPriorityNode,
@Cached final FrameStackPushNode pushNode) {
try {
wakeHighestPriorityNode.executeWake(frame, node);
throw wakeHighestPriorityNode.executeWake(frame, node);
} catch (final ProcessSwitch ps) {
/* Leave `nil` as result on stack. */
pushNode.execute(frame, NilObject.SINGLETON);
throw ps;
}
return NilObject.SINGLETON;
}

@Specialization(guards = {"receiver != getActiveProcessNode.execute(node)"}, limit = "1")
Expand Down Expand Up @@ -939,7 +936,7 @@ protected final Object doYield(final VirtualFrame frame, final PointersObject sc
}
addLastLinkToListNode.execute(node, activeProcess, processList);
try {
wakeHighestPriorityNode.executeWake(frame, node);
throw wakeHighestPriorityNode.executeWake(frame, node);
} catch (final ProcessSwitch ps) {
/*
* Leave receiver on stack. It has not been removed from the stack yet, so it is
Expand All @@ -948,7 +945,6 @@ protected final Object doYield(final VirtualFrame frame, final PointersObject sc
getFrameStackPointerIncrementNode().execute(frame);
throw ps;
}
throw CompilerDirectives.shouldNotReachHere();
}
}

Expand Down Expand Up @@ -1061,13 +1057,12 @@ protected static final Object doEnter(final VirtualFrame frame, final Node node,
@Cached(inline = false) final FrameStackPushNode pushNode) {
addLastLinkToListNode.execute(node, effectiveProcess, mutex);
try {
wakeHighestPriorityNode.executeWake(frame, node);
throw wakeHighestPriorityNode.executeWake(frame, node);
} catch (final ProcessSwitch ps) {
/* Leave `false` as result on stack. */
pushNode.execute(frame, BooleanObject.FALSE);
throw ps;
}
throw CompilerDirectives.shouldNotReachHere();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.Node;

import de.hpi.swa.trufflesqueak.exceptions.ProcessSwitch;
import de.hpi.swa.trufflesqueak.exceptions.SqueakExceptions.SqueakException;
import de.hpi.swa.trufflesqueak.image.SqueakImageContext;
import de.hpi.swa.trufflesqueak.model.ArrayObject;
Expand All @@ -31,10 +32,10 @@
@GenerateCached(false)
public abstract class WakeHighestPriorityNode extends AbstractNode {

public abstract void executeWake(VirtualFrame frame, Node node);
public abstract ProcessSwitch executeWake(VirtualFrame frame, Node node);

@Specialization
protected static final void doWake(final VirtualFrame frame, final Node node,
protected static final ProcessSwitch doWake(final VirtualFrame frame, final Node node,
@Cached final ArrayObjectReadNode arrayReadNode,
@Cached final ArrayObjectSizeNode arraySizeNode,
@Cached final AbstractPointersObjectReadNode pointersReadNode,
Expand Down

1 comment on commit ada13e4

@TruffleSqueak-Bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Performance Report (ada13e4)

Benchmarks ran on graalvm-jdk-21+35.1.

Steady (after 100 iterations)

Benchmark Name Min Geomean Median Mean Max Total (ms) Total (min)
Bounce 557 570 559.89 558 559.88 111977 1.87
CD 485 499 488.9 487 488.89 97780 1.63
DeltaBlue 282 479 416.5 415 414.97 83300 1.39
Havlak 1144 1204 1176.69 1181 1176.62 235337 3.92
Json 409 537 479.3 486 478.55 95860 1.6
List 378 437 384.75 382 384.68 76949 1.28
Mandelbrot 229 237 232.45 234 232.43 46489 0.77
NBody 257 282 262.48 261 262.43 52496 0.87
Permute 155 165 155.93 155 155.92 31186 0.52
Queens 244 256 245.47 245 245.46 49094 0.82
Richards 1208 1222 1212.65 1213 1212.65 242530 4.04
Sieve 177 191 178.04 178 178.03 35608 0.59
Storage 145 152 146.69 146 146.67 29337 0.49
Towers 195 215 196.38 196 196.37 39276 0.65
5865 6446 6136.1 6137 6133.54 1227219 20.45

ada13e4-2-steady.svg

Warmup (first 100 iterations)

ada13e4-3-warmup.svg

Please sign in to comment.