Skip to content

Commit

Permalink
Shield against exceptional states
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslavTulach committed Feb 5, 2025
1 parent e3ee0ea commit f211c19
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeInfo;
import com.oracle.truffle.api.nodes.RootNode;
import com.oracle.truffle.api.profiles.BranchProfile;
import org.enso.interpreter.EnsoLanguage;
import org.enso.interpreter.runtime.EnsoContext;
import org.enso.interpreter.runtime.data.EnsoMultiValue;
Expand Down Expand Up @@ -110,6 +111,9 @@ protected abstract static class ArgNode extends Node {
@Child private AppendWarningNode appendWarningNode;
@Child private HashMapInsertAllNode mapInsertAllNode;

private final BranchProfile errorsTaken = BranchProfile.create();
private final BranchProfile sentinelTaken = BranchProfile.create();

ArgNode(byte flags) {
this.flags = flags;
if (is(CHECK_WARNINGS)) {
Expand All @@ -126,10 +130,12 @@ public final <T> T processArgument(
VirtualFrame frame, Class<T> type, Object value, ArgContext context) {
assert value != null;
if (is(CHECK_ERRORS) && value instanceof DataflowError err) {
errorsTaken.enter();
context.returnValue = err;
return null;
}
if (is(CHECK_PANIC_SENTINEL) && value instanceof PanicSentinel sentinel) {
sentinelTaken.enter();
throw sentinel;
}
if (warnings != null) {
Expand Down

0 comments on commit f211c19

Please sign in to comment.