Skip to content

Commit 7250e4c

Browse files
author
Adam Hrbac
committed
Use shouldNotReachHere for compiler bugs
Previously, we followed CPython and used SystemError where a compiler bug caused an exception to not be on the stack when it should. For graalpy, shouldNotReachHere makes more sense.
1 parent d7e344d commit 7250e4c

File tree

5 files changed

+4
-18
lines changed

5 files changed

+4
-18
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/ErrorMessages.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,6 @@ public abstract class ErrorMessages {
296296
public static final TruffleString EXPECTED_BYTES_P_FOUND = tsLiteral("expected bytes, %p found");
297297
public static final TruffleString EXPECTED_CHARACTER_BUT_STRING_FOUND = tsLiteral("%s expected a character, but string of length %d found");
298298
public static final TruffleString EXPECTED_CONVERSION = tsLiteral("expected conversion");
299-
public static final TruffleString EXPECTED_EXCEPTION_ON_THE_STACK = tsLiteral("expected exception on the stack");
300299
public static final TruffleString EXPECTED_FSPATH_TO_RETURN_STR_OR_BYTES = tsLiteral("expected %p.__fspath__() to return str or bytes, not %p");
301300
public static final TruffleString EXPECTED_OBJ_TYPE_S_GOT_P = tsLiteral("expected object of type %s, got %p");
302301
public static final TruffleString EXPECTED_OBJ_TYPE_P_GOT_P = tsLiteral("expected object of type %p, got %p");

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/EndAsyncForNode.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,8 @@
4040
*/
4141
package com.oracle.graal.python.nodes.bytecode;
4242

43-
import static com.oracle.graal.python.builtins.PythonBuiltinClassType.SystemError;
44-
4543
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
4644
import com.oracle.graal.python.builtins.objects.PNone;
47-
import com.oracle.graal.python.nodes.ErrorMessages;
4845
import com.oracle.graal.python.nodes.PNodeWithContext;
4946
import com.oracle.graal.python.nodes.PRaiseNode;
5047
import com.oracle.graal.python.nodes.object.IsBuiltinClassProfile;
@@ -90,8 +87,7 @@ public void doGeneric(Object exception, boolean rootNodeVisible,
9087
} else if (exception instanceof AbstractTruffleException) {
9188
throw (AbstractTruffleException) exception;
9289
} else {
93-
CompilerDirectives.transferToInterpreterAndInvalidate();
94-
throw raiseNode.raise(SystemError, ErrorMessages.EXPECTED_EXCEPTION_ON_THE_STACK);
90+
throw CompilerDirectives.shouldNotReachHere("Exception not on stack");
9591
}
9692

9793
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ExitAWithNode.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,9 @@
4040
*/
4141
package com.oracle.graal.python.nodes.bytecode;
4242

43-
import static com.oracle.graal.python.builtins.PythonBuiltinClassType.SystemError;
44-
4543
import com.oracle.graal.python.builtins.objects.PNone;
4644
import com.oracle.graal.python.builtins.objects.function.PArguments;
4745
import com.oracle.graal.python.lib.PyObjectIsTrueNode;
48-
import com.oracle.graal.python.nodes.ErrorMessages;
4946
import com.oracle.graal.python.nodes.PNodeWithContext;
5047
import com.oracle.graal.python.nodes.PRaiseNode;
5148
import com.oracle.graal.python.runtime.exception.PException;
@@ -78,8 +75,7 @@ int exit(VirtualFrame virtualFrame, int stackTopIn, boolean rootNodeVisible,
7875
} else if (exception instanceof AbstractTruffleException) {
7976
throw (AbstractTruffleException) exception;
8077
} else {
81-
CompilerDirectives.transferToInterpreterAndInvalidate();
82-
throw raiseNode.raise(SystemError, ErrorMessages.EXPECTED_EXCEPTION_ON_THE_STACK);
78+
throw CompilerDirectives.shouldNotReachHere("Exception not on stack");
8379
}
8480
}
8581
} finally {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ExitWithNode.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,11 @@
4040
*/
4141
package com.oracle.graal.python.nodes.bytecode;
4242

43-
import static com.oracle.graal.python.builtins.PythonBuiltinClassType.SystemError;
44-
4543
import com.oracle.graal.python.builtins.objects.PNone;
4644
import com.oracle.graal.python.builtins.objects.exception.GetExceptionTracebackNode;
4745
import com.oracle.graal.python.builtins.objects.function.PArguments;
4846
import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot;
4947
import com.oracle.graal.python.lib.PyObjectIsTrueNode;
50-
import com.oracle.graal.python.nodes.ErrorMessages;
5148
import com.oracle.graal.python.nodes.PNodeWithContext;
5249
import com.oracle.graal.python.nodes.PRaiseNode;
5350
import com.oracle.graal.python.nodes.call.special.CallQuaternaryMethodNode;
@@ -101,8 +98,7 @@ int exit(VirtualFrame virtualFrame, int stackTopIn, boolean rootNodeVisible,
10198
} else if (exception instanceof AbstractTruffleException) {
10299
throw (AbstractTruffleException) exception;
103100
} else {
104-
CompilerDirectives.transferToInterpreterAndInvalidate();
105-
throw raiseNode.raise(SystemError, ErrorMessages.EXPECTED_EXCEPTION_ON_THE_STACK);
101+
throw CompilerDirectives.shouldNotReachHere("Exception not on stack");
106102
}
107103
}
108104
} finally {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4653,8 +4653,7 @@ private PException bytecodeEndExcHandler(VirtualFrame virtualFrame, int stackTop
46534653
} else if (exception instanceof AbstractTruffleException) {
46544654
throw (AbstractTruffleException) exception;
46554655
} else {
4656-
CompilerDirectives.transferToInterpreterAndInvalidate();
4657-
throw PRaiseNode.raiseUncached(this, SystemError, ErrorMessages.EXPECTED_EXCEPTION_ON_THE_STACK);
4656+
throw CompilerDirectives.shouldNotReachHere("Exception not on stack");
46584657
}
46594658
}
46604659

0 commit comments

Comments
 (0)