60
60
import com .oracle .truffle .api .CompilerAsserts ;
61
61
import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
62
62
import com .oracle .truffle .api .dsl .Cached ;
63
+ import com .oracle .truffle .api .dsl .Cached .Shared ;
63
64
import com .oracle .truffle .api .dsl .CachedLanguage ;
64
65
import com .oracle .truffle .api .interop .ExceptionType ;
65
66
import com .oracle .truffle .api .interop .InteropLibrary ;
68
69
import com .oracle .truffle .api .library .ExportLibrary ;
69
70
import com .oracle .truffle .api .library .ExportMessage ;
70
71
import com .oracle .truffle .api .object .Shape ;
72
+ import com .oracle .truffle .api .profiles .BranchProfile ;
71
73
72
74
@ ExportLibrary (InteropLibrary .class )
73
75
public final class PBaseException extends PythonObject {
@@ -314,7 +316,8 @@ String getExceptionMessage(@CachedLibrary("this") PythonObjectLibrary lib) {
314
316
@ ExportMessage
315
317
int getExceptionExitStatus (
316
318
@ CachedLibrary ("this" ) PythonObjectLibrary lib ,
317
- @ Cached ReadAttributeFromDynamicObjectNode readNode ) throws UnsupportedMessageException {
319
+ @ Cached ReadAttributeFromDynamicObjectNode readNode ,
320
+ @ Shared ("unsupportedProfile" ) @ Cached BranchProfile unsupportedProfile ) throws UnsupportedMessageException {
318
321
if (getExceptionType (lib ) == ExceptionType .EXIT ) {
319
322
try {
320
323
// Avoiding getattr because this message shouldn't have side-effects
@@ -327,6 +330,7 @@ int getExceptionExitStatus(
327
330
return 1 ;
328
331
}
329
332
}
333
+ unsupportedProfile .enter ();
330
334
throw UnsupportedMessageException .create ();
331
335
}
332
336
@@ -336,13 +340,15 @@ boolean hasExceptionCause() {
336
340
}
337
341
338
342
@ ExportMessage
339
- Object getExceptionCause () throws UnsupportedMessageException {
343
+ Object getExceptionCause (
344
+ @ Shared ("unsupportedProfile" ) @ Cached BranchProfile unsupportedProfile ) throws UnsupportedMessageException {
340
345
if (cause != null ) {
341
346
return cause ;
342
347
}
343
348
if (!suppressContext && context != null ) {
344
349
return context ;
345
350
}
351
+ unsupportedProfile .enter ();
346
352
throw UnsupportedMessageException .create ();
347
353
}
348
354
}
0 commit comments