61
61
import com .oracle .truffle .api .CompilerAsserts ;
62
62
import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
63
63
import com .oracle .truffle .api .dsl .Cached ;
64
- import com .oracle .truffle .api .dsl .Cached .Exclusive ;
65
64
import com .oracle .truffle .api .dsl .Cached .Shared ;
66
65
import com .oracle .truffle .api .dsl .CachedLanguage ;
67
66
import com .oracle .truffle .api .interop .ExceptionType ;
@@ -198,17 +197,12 @@ public Object[] getMessageArgs() {
198
197
}
199
198
200
199
@ TruffleBoundary
201
- public String getFormattedMessage (PythonObjectLibrary lib ) {
202
- final Object clazz ;
203
- if (lib == null ) {
204
- clazz = PythonObjectLibrary .getUncached ().getLazyPythonClass (this );
205
- } else {
206
- clazz = lib .getLazyPythonClass (this );
207
- }
200
+ public String getFormattedMessage (PythonObjectLibrary baseExceptionLib , PythonObjectLibrary argsLib ) {
201
+ final Object clazz = baseExceptionLib .getLazyPythonClass (this );
208
202
String typeName = GetNameNode .doSlowPath (clazz );
209
203
if (args == null ) {
210
204
if (messageArgs != null && messageArgs .length > 0 ) {
211
- return typeName + ": " + FORMATTER .format (lib , messageFormat , getMessageArgs ());
205
+ return typeName + ": " + FORMATTER .format (argsLib , messageFormat , getMessageArgs ());
212
206
} else if (hasMessageFormat ) {
213
207
return typeName + ": " + messageFormat ;
214
208
} else {
@@ -287,7 +281,8 @@ boolean isException() {
287
281
@ ExportMessage
288
282
RuntimeException throwException (
289
283
@ Cached PRaiseNode raiseNode ,
290
- @ CachedLanguage PythonLanguage language , @ Exclusive @ Cached GilNode gil ) {
284
+ @ CachedLanguage PythonLanguage language ,
285
+ @ Shared ("gil" ) @ Cached GilNode gil ) {
291
286
boolean mustRelease = gil .acquire ();
292
287
try {
293
288
throw raiseNode .raiseExceptionObject (this , language );
@@ -298,7 +293,8 @@ RuntimeException throwException(
298
293
299
294
@ ExportMessage
300
295
ExceptionType getExceptionType (
301
- @ CachedLibrary ("this" ) PythonObjectLibrary lib , @ Exclusive @ Cached GilNode gil ) {
296
+ @ CachedLibrary ("this" ) PythonObjectLibrary lib ,
297
+ @ Shared ("gil" ) @ Cached GilNode gil ) {
302
298
boolean mustRelease = gil .acquire ();
303
299
try {
304
300
Object clazz = lib .getLazyPythonClass (this );
@@ -332,10 +328,12 @@ boolean hasExceptionMessage() {
332
328
}
333
329
334
330
@ ExportMessage
335
- String getExceptionMessage (@ CachedLibrary ("this" ) PythonObjectLibrary lib , @ Exclusive @ Cached GilNode gil ) {
331
+ String getExceptionMessage (@ CachedLibrary ("this" ) PythonObjectLibrary lib ,
332
+ @ CachedLibrary (limit = "3" ) PythonObjectLibrary argsLib ,
333
+ @ Shared ("gil" ) @ Cached GilNode gil ) {
336
334
boolean mustRelease = gil .acquire ();
337
335
try {
338
- return getFormattedMessage (lib );
336
+ return getFormattedMessage (lib , argsLib );
339
337
} finally {
340
338
gil .release (mustRelease );
341
339
}
@@ -345,7 +343,8 @@ String getExceptionMessage(@CachedLibrary("this") PythonObjectLibrary lib, @Excl
345
343
int getExceptionExitStatus (
346
344
@ CachedLibrary (limit = "2" ) PythonObjectLibrary lib ,
347
345
@ Cached ReadAttributeFromDynamicObjectNode readNode ,
348
- @ Shared ("unsupportedProfile" ) @ Cached BranchProfile unsupportedProfile , @ Exclusive @ Cached GilNode gil ) throws UnsupportedMessageException {
346
+ @ Shared ("unsupportedProfile" ) @ Cached BranchProfile unsupportedProfile ,
347
+ @ Shared ("gil" ) @ Cached GilNode gil ) throws UnsupportedMessageException {
349
348
boolean mustRelease = gil .acquire ();
350
349
try {
351
350
if (getExceptionType (lib , gil ) == ExceptionType .EXIT ) {
@@ -368,7 +367,7 @@ int getExceptionExitStatus(
368
367
}
369
368
370
369
@ ExportMessage
371
- boolean hasExceptionCause (@ Exclusive @ Cached GilNode gil ) {
370
+ boolean hasExceptionCause (@ Shared ( "gil" ) @ Cached GilNode gil ) {
372
371
boolean mustRelease = gil .acquire ();
373
372
try {
374
373
return cause != null || (!suppressContext && context != null );
@@ -379,7 +378,8 @@ boolean hasExceptionCause(@Exclusive @Cached GilNode gil) {
379
378
380
379
@ ExportMessage
381
380
Object getExceptionCause (
382
- @ Shared ("unsupportedProfile" ) @ Cached BranchProfile unsupportedProfile , @ Exclusive @ Cached GilNode gil ) throws UnsupportedMessageException {
381
+ @ Shared ("unsupportedProfile" ) @ Cached BranchProfile unsupportedProfile ,
382
+ @ Shared ("gil" ) @ Cached GilNode gil ) throws UnsupportedMessageException {
383
383
boolean mustRelease = gil .acquire ();
384
384
try {
385
385
if (cause != null ) {
0 commit comments