Skip to content

Commit 44c39e7

Browse files
committed
Change ThreadState.exc type to Object
1 parent fb34e77 commit 44c39e7

File tree

1 file changed

+14
-5
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function

1 file changed

+14
-5
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/PArguments.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,14 +253,22 @@ public static void setCurrentFrameInfo(Object[] arguments, PFrame.Reference info
253253
}
254254

255255
public static PException getException(Frame frame) {
256-
return (PException) frame.getArguments()[INDEX_CURRENT_EXCEPTION];
256+
return (PException) getExceptionUnchecked(frame);
257+
}
258+
259+
public static Object getExceptionUnchecked(Frame frame) {
260+
return frame.getArguments()[INDEX_CURRENT_EXCEPTION];
257261
}
258262

259263
public static void setException(Frame frame, PException exc) {
260264
setException(frame.getArguments(), exc);
261265
}
262266

263267
public static void setException(Object[] arguments, PException exc) {
268+
setExceptionUnchecked(arguments, exc);
269+
}
270+
271+
public static void setExceptionUnchecked(Object[] arguments, Object exc) {
264272
arguments[INDEX_CURRENT_EXCEPTION] = exc;
265273
}
266274

@@ -376,7 +384,7 @@ public static PDict getGeneratorFrameLocals(Object[] arguments) {
376384

377385
public static ThreadState getThreadState(VirtualFrame frame) {
378386
assert frame != null : "cannot get thread state without a frame";
379-
return new ThreadState(PArguments.getCurrentFrameInfo(frame), PArguments.getException(frame));
387+
return new ThreadState(PArguments.getCurrentFrameInfo(frame), PArguments.getExceptionUnchecked(frame));
380388
}
381389

382390
public static ThreadState getThreadStateOrNull(VirtualFrame frame, ConditionProfile hasFrameProfile) {
@@ -386,7 +394,7 @@ public static ThreadState getThreadStateOrNull(VirtualFrame frame, ConditionProf
386394
public static VirtualFrame frameForCall(ThreadState frame) {
387395
Object[] args = PArguments.create();
388396
PArguments.setCurrentFrameInfo(args, frame.info);
389-
PArguments.setException(args, frame.exc);
397+
PArguments.setExceptionUnchecked(args, frame.exc);
390398
return Truffle.getRuntime().createVirtualFrame(args, EMTPY_FD);
391399
}
392400

@@ -396,9 +404,10 @@ public static VirtualFrame frameForCall(ThreadState frame) {
396404
@ValueType
397405
public static final class ThreadState {
398406
private final PFrame.Reference info;
399-
private final PException exc;
407+
// The type is object because it is Object in the frame and casting it slows things down
408+
private final Object exc;
400409

401-
private ThreadState(PFrame.Reference info, PException exc) {
410+
private ThreadState(PFrame.Reference info, Object exc) {
402411
this.info = info;
403412
this.exc = exc;
404413
}

0 commit comments

Comments
 (0)