Skip to content

Commit 69188b9

Browse files
committed
opt GIL: PyUnicodeWrappers
1 parent 0f5fe35 commit 69188b9

File tree

1 file changed

+8
-23
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi

1 file changed

+8
-23
lines changed

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

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -91,39 +91,24 @@ public PString getPString(PythonNativeWrapperLibrary lib) {
9191

9292
@ExportMessage
9393
boolean isPointer(
94-
@Cached IsPointerNode pIsPointerNode, @Exclusive @Cached GilNode gil) {
95-
boolean mustRelease = gil.acquire();
96-
try {
97-
return pIsPointerNode.execute(this);
98-
} finally {
99-
gil.release(mustRelease);
100-
}
94+
@Cached IsPointerNode pIsPointerNode) {
95+
return pIsPointerNode.execute(this);
10196
}
10297

10398
@ExportMessage
10499
long asPointer(
105-
@Cached PAsPointerNode pAsPointerNode, @Exclusive @Cached GilNode gil) {
106-
boolean mustRelease = gil.acquire();
107-
try {
108-
return pAsPointerNode.execute(this);
109-
} finally {
110-
gil.release(mustRelease);
111-
}
100+
@Cached PAsPointerNode pAsPointerNode) {
101+
return pAsPointerNode.execute(this);
112102
}
113103

114104
@ExportMessage
115105
void toNative(
116106
@CachedLibrary("this") PythonNativeWrapperLibrary lib,
117107
@Cached ToPyObjectNode toPyObjectNode,
118-
@Cached InvalidateNativeObjectsAllManagedNode invalidateNode, @Exclusive @Cached GilNode gil) {
119-
boolean mustRelease = gil.acquire();
120-
try {
121-
invalidateNode.execute();
122-
if (!lib.isNative(this)) {
123-
setNativePointer(toPyObjectNode.execute(this));
124-
}
125-
} finally {
126-
gil.release(mustRelease);
108+
@Cached InvalidateNativeObjectsAllManagedNode invalidateNode) {
109+
invalidateNode.execute();
110+
if (!lib.isNative(this)) {
111+
setNativePointer(toPyObjectNode.execute(this));
127112
}
128113
}
129114

0 commit comments

Comments
 (0)