54
54
import com .oracle .graal .python .runtime .sequence .storage .NativeSequenceStorage ;
55
55
import com .oracle .truffle .api .Assumption ;
56
56
import com .oracle .truffle .api .CompilerDirectives ;
57
- import com .oracle .truffle .api .dsl .Bind ;
58
57
import com .oracle .truffle .api .dsl .Cached ;
59
58
import com .oracle .truffle .api .dsl .Cached .Exclusive ;
60
59
import com .oracle .truffle .api .dsl .Cached .Shared ;
@@ -278,44 +277,29 @@ static Object error(@SuppressWarnings("unused") PMemoryView object, String key)
278
277
279
278
@ ExportMessage
280
279
protected boolean isPointer (
281
- @ Exclusive @ Cached CExtNodes .IsPointerNode pIsPointerNode , @ Exclusive @ Cached GilNode gil ) {
282
- boolean mustRelease = gil .acquire ();
283
- try {
284
- return pIsPointerNode .execute (this );
285
- } finally {
286
- gil .release (mustRelease );
287
- }
280
+ @ Exclusive @ Cached CExtNodes .IsPointerNode pIsPointerNode ) {
281
+ return pIsPointerNode .execute (this );
288
282
}
289
283
290
284
@ ExportMessage
291
285
public long asPointer (
292
286
@ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib ,
293
- @ CachedLibrary (limit = "1" ) InteropLibrary interopLibrary , @ Exclusive @ Cached GilNode gil ) throws UnsupportedMessageException {
294
- boolean mustRelease = gil .acquire ();
295
- try {
296
- Object nativePointer = lib .getNativePointer (this );
297
- if (nativePointer instanceof Long ) {
298
- return (long ) nativePointer ;
299
- }
300
- return interopLibrary .asPointer (nativePointer );
301
- } finally {
302
- gil .release (mustRelease );
287
+ @ CachedLibrary (limit = "1" ) InteropLibrary interopLibrary ) throws UnsupportedMessageException {
288
+ Object nativePointer = lib .getNativePointer (this );
289
+ if (nativePointer instanceof Long ) {
290
+ return (long ) nativePointer ;
303
291
}
292
+ return interopLibrary .asPointer (nativePointer );
304
293
}
305
294
306
295
@ ExportMessage
307
296
protected void toNative (
308
297
@ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib ,
309
298
@ Exclusive @ Cached DynamicObjectNativeWrapper .ToPyObjectNode toPyObjectNode ,
310
- @ Exclusive @ Cached InvalidateNativeObjectsAllManagedNode invalidateNode , @ Exclusive @ Cached GilNode gil ) {
311
- boolean mustRelease = gil .acquire ();
312
- try {
313
- invalidateNode .execute ();
314
- if (!lib .isNative (this )) {
315
- setNativePointer (toPyObjectNode .execute (this ));
316
- }
317
- } finally {
318
- gil .release (mustRelease );
299
+ @ Exclusive @ Cached InvalidateNativeObjectsAllManagedNode invalidateNode ) {
300
+ invalidateNode .execute ();
301
+ if (!lib .isNative (this )) {
302
+ setNativePointer (toPyObjectNode .execute (this ));
319
303
}
320
304
}
321
305
@@ -329,25 +313,14 @@ protected boolean hasNativeType() {
329
313
abstract static class GetNativeType {
330
314
@ Specialization (assumptions = "singleNativeContextAssumption()" )
331
315
static Object doByteArray (@ SuppressWarnings ("unused" ) PyMemoryViewBufferWrapper receiver ,
332
- @ Exclusive @ Cached GilNode gil ,
333
- @ Bind ("gil.acquire()" ) boolean mustRelease ,
334
316
@ Exclusive @ Cached (value = "callGetThreadStateTypeIDUncached()" ) Object nativeType ) {
335
- try {
336
- return nativeType ;
337
- } finally {
338
- gil .release (mustRelease );
339
- }
317
+ return nativeType ;
340
318
}
341
319
342
320
@ Specialization (replaces = "doByteArray" )
343
321
static Object doByteArrayMultiCtx (@ SuppressWarnings ("unused" ) PyMemoryViewBufferWrapper receiver ,
344
- @ Exclusive @ Cached CExtNodes .PCallCapiFunction callUnaryNode , @ Exclusive @ Cached GilNode gil ) {
345
- boolean mustRelease = gil .acquire ();
346
- try {
347
- return callUnaryNode .call (FUN_GET_PY_BUFFER_TYPEID );
348
- } finally {
349
- gil .release (mustRelease );
350
- }
322
+ @ Exclusive @ Cached CExtNodes .PCallCapiFunction callUnaryNode ) {
323
+ return callUnaryNode .call (FUN_GET_PY_BUFFER_TYPEID );
351
324
}
352
325
353
326
protected static Object callGetThreadStateTypeIDUncached () {
0 commit comments