@@ -253,14 +253,22 @@ public static void setCurrentFrameInfo(Object[] arguments, PFrame.Reference info
253
253
}
254
254
255
255
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 ];
257
261
}
258
262
259
263
public static void setException (Frame frame , PException exc ) {
260
264
setException (frame .getArguments (), exc );
261
265
}
262
266
263
267
public static void setException (Object [] arguments , PException exc ) {
268
+ setExceptionUnchecked (arguments , exc );
269
+ }
270
+
271
+ public static void setExceptionUnchecked (Object [] arguments , Object exc ) {
264
272
arguments [INDEX_CURRENT_EXCEPTION ] = exc ;
265
273
}
266
274
@@ -376,7 +384,7 @@ public static PDict getGeneratorFrameLocals(Object[] arguments) {
376
384
377
385
public static ThreadState getThreadState (VirtualFrame frame ) {
378
386
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 ));
380
388
}
381
389
382
390
public static ThreadState getThreadStateOrNull (VirtualFrame frame , ConditionProfile hasFrameProfile ) {
@@ -386,7 +394,7 @@ public static ThreadState getThreadStateOrNull(VirtualFrame frame, ConditionProf
386
394
public static VirtualFrame frameForCall (ThreadState frame ) {
387
395
Object [] args = PArguments .create ();
388
396
PArguments .setCurrentFrameInfo (args , frame .info );
389
- PArguments .setException (args , frame .exc );
397
+ PArguments .setExceptionUnchecked (args , frame .exc );
390
398
return Truffle .getRuntime ().createVirtualFrame (args , EMTPY_FD );
391
399
}
392
400
@@ -396,9 +404,10 @@ public static VirtualFrame frameForCall(ThreadState frame) {
396
404
@ ValueType
397
405
public static final class ThreadState {
398
406
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 ;
400
409
401
- private ThreadState (PFrame .Reference info , PException exc ) {
410
+ private ThreadState (PFrame .Reference info , Object exc ) {
402
411
this .info = info ;
403
412
this .exc = exc ;
404
413
}
0 commit comments