@@ -141,13 +141,8 @@ public boolean equals(Object obj) {
141
141
@ ExportMessage
142
142
final long getArraySize (
143
143
@ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib ,
144
- @ CachedLibrary (limit = "getCallSiteInlineCacheMaxDepth()" ) PythonObjectLibrary objectLib , @ Exclusive @ Cached GilNode gil ) {
145
- boolean mustRelease = gil .acquire ();
146
- try {
147
- return objectLib .length (lib .getDelegate (this ));
148
- } finally {
149
- gil .release (mustRelease );
150
- }
144
+ @ CachedLibrary (limit = "getCallSiteInlineCacheMaxDepth()" ) PythonObjectLibrary objectLib ) {
145
+ return objectLib .length (lib .getDelegate (this ));
151
146
}
152
147
153
148
@ ExportMessage
@@ -175,14 +170,9 @@ static int getCallSiteInlineCacheMaxDepth() {
175
170
@ ExportMessage
176
171
final boolean isArrayElementReadable (long identifier ,
177
172
@ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib ,
178
- @ CachedLibrary (limit = "getCallSiteInlineCacheMaxDepth()" ) PythonObjectLibrary objectLib , @ Exclusive @ Cached GilNode gil ) {
179
- boolean mustRelease = gil .acquire ();
180
- try {
181
- // also include the implicit null-terminator
182
- return 0 <= identifier && identifier <= getArraySize (lib , objectLib , gil );
183
- } finally {
184
- gil .release (mustRelease );
185
- }
173
+ @ CachedLibrary (limit = "getCallSiteInlineCacheMaxDepth()" ) PythonObjectLibrary objectLib ) {
174
+ // also include the implicit null-terminator
175
+ return 0 <= identifier && identifier <= getArraySize (lib , objectLib );
186
176
}
187
177
188
178
@ ImportStatic ({SpecialMethodNames .class , PySequenceArrayWrapper .class })
@@ -316,13 +306,8 @@ public void removeArrayElement(@SuppressWarnings("unused") long index) throws Un
316
306
@ ExportMessage
317
307
public boolean isArrayElementModifiable (long index ,
318
308
@ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib ,
319
- @ CachedLibrary (limit = "getCallSiteInlineCacheMaxDepth()" ) PythonObjectLibrary objectLib , @ Exclusive @ Cached GilNode gil ) {
320
- boolean mustRelease = gil .acquire ();
321
- try {
322
- return 0 <= index && index <= getArraySize (lib , objectLib , gil );
323
- } finally {
324
- gil .release (mustRelease );
325
- }
309
+ @ CachedLibrary (limit = "getCallSiteInlineCacheMaxDepth()" ) PythonObjectLibrary objectLib ) {
310
+ return 0 <= index && index <= getArraySize (lib , objectLib );
326
311
}
327
312
328
313
@ ExportMessage
@@ -407,15 +392,10 @@ void doGeneric(PythonAbstractObject sequence, Object idx, Object value,
407
392
public void toNative (
408
393
@ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib ,
409
394
@ Exclusive @ Cached ToNativeArrayNode toPyObjectNode ,
410
- @ Exclusive @ Cached InvalidateNativeObjectsAllManagedNode invalidateNode , @ Exclusive @ Cached GilNode gil ) {
411
- boolean mustRelease = gil .acquire ();
412
- try {
413
- invalidateNode .execute ();
414
- if (!lib .isNative (this )) {
415
- setNativePointer (toPyObjectNode .execute (this ));
416
- }
417
- } finally {
418
- gil .release (mustRelease );
395
+ @ Exclusive @ Cached InvalidateNativeObjectsAllManagedNode invalidateNode ) {
396
+ invalidateNode .execute ();
397
+ if (!lib .isNative (this )) {
398
+ setNativePointer (toPyObjectNode .execute (this ));
419
399
}
420
400
}
421
401
@@ -484,29 +464,19 @@ protected static boolean isNative(SequenceStorage s) {
484
464
485
465
@ ExportMessage
486
466
public boolean isPointer (
487
- @ Cached IsPointerNode pIsPointerNode , @ Exclusive @ Cached GilNode gil ) {
488
- boolean mustRelease = gil .acquire ();
489
- try {
490
- return pIsPointerNode .execute (this );
491
- } finally {
492
- gil .release (mustRelease );
493
- }
467
+ @ Cached IsPointerNode pIsPointerNode ) {
468
+ return pIsPointerNode .execute (this );
494
469
}
495
470
496
471
@ ExportMessage
497
472
public long asPointer (
498
473
@ CachedLibrary (limit = "1" ) InteropLibrary interopLibrary ,
499
- @ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib , @ Exclusive @ Cached GilNode gil ) throws UnsupportedMessageException {
500
- boolean mustRelease = gil .acquire ();
501
- try {
502
- Object nativePointer = lib .getNativePointer (this );
503
- if (nativePointer instanceof Long ) {
504
- return (long ) nativePointer ;
505
- }
506
- return interopLibrary .asPointer (nativePointer );
507
- } finally {
508
- gil .release (mustRelease );
474
+ @ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib ) throws UnsupportedMessageException {
475
+ Object nativePointer = lib .getNativePointer (this );
476
+ if (nativePointer instanceof Long ) {
477
+ return (long ) nativePointer ;
509
478
}
479
+ return interopLibrary .asPointer (nativePointer );
510
480
}
511
481
512
482
@ ExportMessage
@@ -518,13 +488,8 @@ protected boolean hasNativeType() {
518
488
@ ExportMessage
519
489
Object getNativeType (
520
490
@ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib ,
521
- @ Exclusive @ Cached GetTypeIDNode getTypeIDNode , @ Exclusive @ Cached GilNode gil ) {
522
- boolean mustRelease = gil .acquire ();
523
- try {
524
- return getTypeIDNode .execute (lib .getDelegate (this ));
525
- } finally {
526
- gil .release (mustRelease );
527
- }
491
+ @ Exclusive @ Cached GetTypeIDNode getTypeIDNode ) {
492
+ return getTypeIDNode .execute (lib .getDelegate (this ));
528
493
}
529
494
530
495
@ GenerateUncached
0 commit comments