Skip to content

Commit 252889a

Browse files
committed
opt GIL: PyDateTimeCAPIWrapper
1 parent f9988e1 commit 252889a

File tree

1 file changed

+9
-29
lines changed

1 file changed

+9
-29
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyDateTimeCAPIWrapper.java

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -234,48 +234,28 @@ boolean hasNativeType() {
234234
Object getNativeType(
235235
@CachedLibrary("this") PythonNativeWrapperLibrary lib,
236236
@CachedLibrary(limit = "3") PythonObjectLibrary plib,
237-
@Cached GetSulongTypeNode getSulongTypeNode, @Exclusive @Cached GilNode gil) {
238-
boolean mustRelease = gil.acquire();
239-
try {
240-
return getSulongTypeNode.execute(plib.getLazyPythonClass(lib.getDelegate(this)));
241-
} finally {
242-
gil.release(mustRelease);
243-
}
237+
@Cached GetSulongTypeNode getSulongTypeNode) {
238+
return getSulongTypeNode.execute(plib.getLazyPythonClass(lib.getDelegate(this)));
244239
}
245240

246241
@ExportMessage
247242
boolean isPointer(
248-
@Cached IsPointerNode isPointerNode, @Exclusive @Cached GilNode gil) {
249-
boolean mustRelease = gil.acquire();
250-
try {
251-
return isPointerNode.execute(this);
252-
} finally {
253-
gil.release(mustRelease);
254-
}
243+
@Cached IsPointerNode isPointerNode) {
244+
return isPointerNode.execute(this);
255245
}
256246

257247
@ExportMessage
258248
long asPointer(
259-
@Exclusive @Cached PAsPointerNode pAsPointerNode, @Exclusive @Cached GilNode gil) {
260-
boolean mustRelease = gil.acquire();
261-
try {
262-
return pAsPointerNode.execute(this);
263-
} finally {
264-
gil.release(mustRelease);
265-
}
249+
@Exclusive @Cached PAsPointerNode pAsPointerNode) {
250+
return pAsPointerNode.execute(this);
266251
}
267252

268253
@ExportMessage
269254
void toNative(
270255
@Exclusive @Cached ToPyObjectNode toPyObjectNode,
271-
@Exclusive @Cached InvalidateNativeObjectsAllManagedNode invalidateNode, @Exclusive @Cached GilNode gil) {
272-
boolean mustRelease = gil.acquire();
273-
try {
274-
invalidateNode.execute();
275-
setNativePointer(toPyObjectNode.execute(this));
276-
} finally {
277-
gil.release(mustRelease);
278-
}
256+
@Exclusive @Cached InvalidateNativeObjectsAllManagedNode invalidateNode) {
257+
invalidateNode.execute();
258+
setNativePointer(toPyObjectNode.execute(this));
279259
}
280260

281261
}

0 commit comments

Comments
 (0)