Skip to content

Commit 4fc6597

Browse files
committed
[GR-28924] Introduce raiseUncached methods
PullRequest: graalpython/1602
2 parents 507e0fa + c4281a3 commit 4fc6597

File tree

6 files changed

+87
-53
lines changed

6 files changed

+87
-53
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CExtNodes.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2862,42 +2862,42 @@ static void setCurrentException(Frame frame, PException e,
28622862
@GenerateUncached
28632863
public abstract static class PRaiseNativeNode extends Node {
28642864

2865-
public final int raiseInt(Frame frame, int errorValue, Object errType, String format, Object... arguments) {
2865+
public final int raiseInt(Frame frame, int errorValue, PythonBuiltinClassType errType, String format, Object... arguments) {
28662866
return executeInt(frame, errorValue, errType, format, arguments);
28672867
}
28682868

2869-
public final Object raise(Frame frame, Object errorValue, Object errType, String format, Object... arguments) {
2869+
public final Object raise(Frame frame, Object errorValue, PythonBuiltinClassType errType, String format, Object... arguments) {
28702870
return execute(frame, errorValue, errType, format, arguments);
28712871
}
28722872

2873-
public final int raiseIntWithoutFrame(int errorValue, Object errType, String format, Object... arguments) {
2873+
public final int raiseIntWithoutFrame(int errorValue, PythonBuiltinClassType errType, String format, Object... arguments) {
28742874
return executeInt(null, errorValue, errType, format, arguments);
28752875
}
28762876

2877-
public abstract Object execute(Frame frame, Object errorValue, Object errType, String format, Object[] arguments);
2877+
public abstract Object execute(Frame frame, Object errorValue, PythonBuiltinClassType errType, String format, Object[] arguments);
28782878

2879-
public abstract int executeInt(Frame frame, int errorValue, Object errType, String format, Object[] arguments);
2879+
public abstract int executeInt(Frame frame, int errorValue, PythonBuiltinClassType errType, String format, Object[] arguments);
28802880

28812881
@Specialization
2882-
static int doInt(Frame frame, int errorValue, Object errType, String format, Object[] arguments,
2882+
static int doInt(Frame frame, int errorValue, PythonBuiltinClassType errType, String format, Object[] arguments,
28832883
@Shared("raiseNode") @Cached PRaiseNode raiseNode,
28842884
@Shared("transformExceptionToNativeNode") @Cached TransformExceptionToNativeNode transformExceptionToNativeNode) {
28852885
raiseNative(frame, errType, format, arguments, raiseNode, transformExceptionToNativeNode);
28862886
return errorValue;
28872887
}
28882888

28892889
@Specialization
2890-
static Object doObject(Frame frame, Object errorValue, Object errType, String format, Object[] arguments,
2890+
static Object doObject(Frame frame, Object errorValue, PythonBuiltinClassType errType, String format, Object[] arguments,
28912891
@Shared("raiseNode") @Cached PRaiseNode raiseNode,
28922892
@Shared("transformExceptionToNativeNode") @Cached TransformExceptionToNativeNode transformExceptionToNativeNode) {
28932893
raiseNative(frame, errType, format, arguments, raiseNode, transformExceptionToNativeNode);
28942894
return errorValue;
28952895
}
28962896

2897-
public static void raiseNative(Frame frame, Object errType, String format, Object[] arguments, PRaiseNode raiseNode,
2897+
public static void raiseNative(Frame frame, PythonBuiltinClassType errType, String format, Object[] arguments, PRaiseNode raiseNode,
28982898
TransformExceptionToNativeNode transformExceptionToNativeNode) {
28992899
try {
2900-
throw raiseNode.execute(errType, PNone.NO_VALUE, format, arguments);
2900+
throw raiseNode.raise(errType, format, arguments);
29012901
} catch (PException p) {
29022902
transformExceptionToNativeNode.execute(frame, p);
29032903
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContextFunctions.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@
135135
import com.oracle.graal.python.runtime.sequence.PSequence;
136136
import com.oracle.graal.python.runtime.sequence.storage.ObjectSequenceStorage;
137137
import com.oracle.graal.python.util.OverflowException;
138-
import com.oracle.graal.python.util.PythonUtils;
139138
import com.oracle.truffle.api.CompilerAsserts;
140139
import com.oracle.truffle.api.CompilerDirectives;
141140
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
@@ -755,7 +754,7 @@ Object execute(Object[] arguments,
755754

756755
// Unfortunately, the HPyRaiseNode is not suitable because it expects a String message.
757756
try {
758-
throw raiseNode.execute(errType, PNone.NO_VALUE, errorMessage, PythonUtils.EMPTY_OBJECT_ARRAY);
757+
throw raiseNode.raise(errType, errorMessage);
759758
} catch (PException p) {
760759
transformExceptionToNativeNode.execute(context, p);
761760
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNodes.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ static int doInt(Frame frame, GraalHPyContext nativeContext, int errorValue, Obj
236236
@Shared("raiseNode") @Cached PRaiseNode raiseNode,
237237
@Shared("transformExceptionToNativeNode") @Cached HPyTransformExceptionToNativeNode transformExceptionToNativeNode) {
238238
try {
239-
throw raiseNode.execute(errType, PNone.NO_VALUE, format, arguments);
239+
// TODO Should properly construct the exception using its constructor
240+
throw raiseNode.execute(raiseNode, errType, PNone.NO_VALUE, format, arguments);
240241
} catch (PException p) {
241242
transformExceptionToNativeNode.execute(frame, nativeContext, p);
242243
}
@@ -248,7 +249,8 @@ static Object doObject(Frame frame, GraalHPyContext nativeContext, Object errorV
248249
@Shared("raiseNode") @Cached PRaiseNode raiseNode,
249250
@Shared("transformExceptionToNativeNode") @Cached HPyTransformExceptionToNativeNode transformExceptionToNativeNode) {
250251
try {
251-
throw raiseNode.execute(errType, PNone.NO_VALUE, format, arguments);
252+
// TODO Should properly construct the exception using its constructor
253+
throw raiseNode.execute(raiseNode, errType, PNone.NO_VALUE, format, arguments);
252254
} catch (PException p) {
253255
transformExceptionToNativeNode.execute(frame, nativeContext, p);
254256
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public PException raise(PythonBuiltinClassType type, String string) {
6666
return getRaiseNode().raise(type, string);
6767
}
6868

69-
public PException raise(Object exceptionType) {
69+
public PException raise(PythonBuiltinClassType exceptionType) {
7070
return getRaiseNode().raise(exceptionType);
7171
}
7272

0 commit comments

Comments
 (0)