@@ -75,44 +75,29 @@ public CArrayWrapper(Object delegate) {
75
75
76
76
@ ExportMessage
77
77
public boolean isPointer (
78
- @ Exclusive @ Cached IsPointerNode pIsPointerNode , @ Exclusive @ Cached GilNode gil ) {
79
- boolean mustRelease = gil .acquire ();
80
- try {
81
- return pIsPointerNode .execute (this );
82
- } finally {
83
- gil .release (mustRelease );
84
- }
78
+ @ Exclusive @ Cached IsPointerNode pIsPointerNode ) {
79
+ return pIsPointerNode .execute (this );
85
80
}
86
81
87
82
@ ExportMessage
88
83
public long asPointer (
89
84
@ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib ,
90
- @ CachedLibrary (limit = "1" ) InteropLibrary interopLibrary , @ Exclusive @ Cached GilNode gil ) throws UnsupportedMessageException {
91
- boolean mustRelease = gil .acquire ();
92
- try {
93
- Object nativePointer = lib .getNativePointer (this );
94
- if (nativePointer instanceof Long ) {
95
- return (long ) nativePointer ;
96
- }
97
- return interopLibrary .asPointer (nativePointer );
98
- } finally {
99
- gil .release (mustRelease );
85
+ @ CachedLibrary (limit = "1" ) InteropLibrary interopLibrary ) throws UnsupportedMessageException {
86
+ Object nativePointer = lib .getNativePointer (this );
87
+ if (nativePointer instanceof Long ) {
88
+ return (long ) nativePointer ;
100
89
}
90
+ return interopLibrary .asPointer (nativePointer );
101
91
}
102
92
103
93
@ ExportMessage
104
94
public void toNative (
105
95
@ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib ,
106
96
@ Exclusive @ Cached AsCharPointerNode asCharPointerNode ,
107
- @ Exclusive @ Cached InvalidateNativeObjectsAllManagedNode invalidateNode , @ Exclusive @ Cached GilNode gil ) {
108
- boolean mustRelease = gil .acquire ();
109
- try {
110
- invalidateNode .execute ();
111
- if (!lib .isNative (this )) {
112
- setNativePointer (asCharPointerNode .execute (lib .getDelegate (this )));
113
- }
114
- } finally {
115
- gil .release (mustRelease );
97
+ @ Exclusive @ Cached InvalidateNativeObjectsAllManagedNode invalidateNode ) {
98
+ invalidateNode .execute ();
99
+ if (!lib .isNative (this )) {
100
+ setNativePointer (asCharPointerNode .execute (lib .getDelegate (this )));
116
101
}
117
102
}
118
103
}
@@ -147,25 +132,20 @@ final boolean hasArrayElements() {
147
132
148
133
@ ExportMessage
149
134
final Object readArrayElement (long index ,
150
- @ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib , @ Exclusive @ Cached GilNode gil ) throws InvalidArrayIndexException {
151
- boolean mustRelease = gil .acquire ();
135
+ @ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib ) throws InvalidArrayIndexException {
152
136
try {
153
- try {
154
- int idx = PInt .intValueExact (index );
155
- String s = (String ) lib .getDelegate (this );
156
- if (idx >= 0 && idx < s .length ()) {
157
- return s .charAt (idx );
158
- } else if (idx == s .length ()) {
159
- return '\0' ;
160
- }
161
- } catch (OverflowException e ) {
162
- // fall through
137
+ int idx = PInt .intValueExact (index );
138
+ String s = (String ) lib .getDelegate (this );
139
+ if (idx >= 0 && idx < s .length ()) {
140
+ return s .charAt (idx );
141
+ } else if (idx == s .length ()) {
142
+ return '\0' ;
163
143
}
164
- CompilerDirectives .transferToInterpreterAndInvalidate ();
165
- throw InvalidArrayIndexException .create (index );
166
- } finally {
167
- gil .release (mustRelease );
144
+ } catch (OverflowException e ) {
145
+ // fall through
168
146
}
147
+ CompilerDirectives .transferToInterpreterAndInvalidate ();
148
+ throw InvalidArrayIndexException .create (index );
169
149
}
170
150
171
151
@ ExportMessage
@@ -176,25 +156,15 @@ final boolean isArrayElementReadable(long identifier,
176
156
177
157
@ ExportMessage
178
158
@ SuppressWarnings ("static-method" )
179
- protected boolean hasNativeType (@ Exclusive @ Cached GilNode gil ) {
180
- boolean mustRelease = gil .acquire ();
181
- try {
182
- return true ;
183
- } finally {
184
- gil .release (mustRelease );
185
- }
159
+ protected boolean hasNativeType () {
160
+ return true ;
186
161
}
187
162
188
163
@ ExportMessage
189
164
protected Object getNativeType (
190
165
@ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib ,
191
- @ Exclusive @ Cached PCallCapiFunction callByteArrayTypeIdNode , @ Exclusive @ Cached GilNode gil ) {
192
- boolean mustRelease = gil .acquire ();
193
- try {
194
- return callByteArrayTypeIdNode .call (FUN_GET_BYTE_ARRAY_TYPE_ID , ((String ) lib .getDelegate (this )).length ());
195
- } finally {
196
- gil .release (mustRelease );
197
- }
166
+ @ Exclusive @ Cached PCallCapiFunction callByteArrayTypeIdNode ) {
167
+ return callByteArrayTypeIdNode .call (FUN_GET_BYTE_ARRAY_TYPE_ID , ((String ) lib .getDelegate (this )).length ());
198
168
}
199
169
}
200
170
0 commit comments