38
38
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39
39
* SOFTWARE.
40
40
*/
41
+ // skip GIL
41
42
package com .oracle .graal .python .builtins .objects .cext .hpy ;
42
43
43
44
import static com .oracle .graal .python .builtins .PythonBuiltinClassType .MemoryError ;
132
133
import com .oracle .graal .python .nodes .expression .UnaryArithmetic ;
133
134
import com .oracle .graal .python .runtime .AsyncHandler ;
134
135
import com .oracle .graal .python .runtime .ExecutionContext .CalleeContext ;
135
- import com .oracle .graal .python .runtime .GilNode ;
136
136
import com .oracle .graal .python .runtime .PythonContext ;
137
137
import com .oracle .graal .python .runtime .exception .PException ;
138
138
import com .oracle .graal .python .util .OverflowException ;
144
144
import com .oracle .truffle .api .TruffleLanguage .ContextReference ;
145
145
import com .oracle .truffle .api .TruffleLogger ;
146
146
import com .oracle .truffle .api .dsl .Cached ;
147
- import com .oracle .truffle .api .dsl .Cached .Exclusive ;
148
147
import com .oracle .truffle .api .dsl .GenerateUncached ;
149
148
import com .oracle .truffle .api .dsl .ImportStatic ;
150
149
import com .oracle .truffle .api .dsl .Specialization ;
@@ -541,41 +540,24 @@ public PException getCurrentException() {
541
540
}
542
541
543
542
@ ExportMessage
544
- boolean isPointer (@ Exclusive @ Cached GilNode gil ) {
545
- boolean mustRelease = gil .acquire ();
546
- try {
547
- return nativePointer != null ;
548
- } finally {
549
- gil .release (mustRelease );
550
- }
543
+ boolean isPointer () {
544
+ return nativePointer != null ;
551
545
}
552
546
553
547
@ ExportMessage (limit = "1" )
554
548
@ SuppressWarnings ("static-method" )
555
- long asPointer (
556
- @ CachedLibrary ("this.nativePointer" ) InteropLibrary interopLibrary , @ Exclusive @ Cached GilNode gil ) throws UnsupportedMessageException {
557
- boolean mustRelease = gil .acquire ();
558
- try {
559
- if (isPointer (gil )) {
560
- return interopLibrary .asPointer (nativePointer );
561
- }
562
- CompilerDirectives .transferToInterpreterAndInvalidate ();
563
- throw UnsupportedMessageException .create ();
564
- } finally {
565
- gil .release (mustRelease );
549
+ long asPointer (@ CachedLibrary ("this.nativePointer" ) InteropLibrary interopLibrary ) throws UnsupportedMessageException {
550
+ if (isPointer ()) {
551
+ return interopLibrary .asPointer (nativePointer );
566
552
}
553
+ CompilerDirectives .transferToInterpreterAndInvalidate ();
554
+ throw UnsupportedMessageException .create ();
567
555
}
568
556
569
557
@ ExportMessage
570
- void toNative (
571
- @ Cached PCallHPyFunction callContextToNativeNode , @ Exclusive @ Cached GilNode gil ) {
572
- boolean mustRelease = gil .acquire ();
573
- try {
574
- if (!isPointer (gil )) {
575
- nativePointer = callContextToNativeNode .call (this , GRAAL_HPY_CONTEXT_TO_NATIVE , this );
576
- }
577
- } finally {
578
- gil .release (mustRelease );
558
+ void toNative (@ Cached PCallHPyFunction callContextToNativeNode ) {
559
+ if (!isPointer ()) {
560
+ nativePointer = callContextToNativeNode .call (this , GRAAL_HPY_CONTEXT_TO_NATIVE , this );
579
561
}
580
562
}
581
563
@@ -598,24 +580,14 @@ Object getMembers(@SuppressWarnings("unused") boolean includeInternal) {
598
580
599
581
@ ExportMessage
600
582
@ SuppressWarnings ("static-method" )
601
- boolean isMemberReadable (String key , @ Exclusive @ Cached GilNode gil ) {
602
- boolean mustRelease = gil .acquire ();
603
- try {
604
- return HPyContextMembers .getByName (key ) != null ;
605
- } finally {
606
- gil .release (mustRelease );
607
- }
583
+ boolean isMemberReadable (String key ) {
584
+ return HPyContextMembers .getByName (key ) != null ;
608
585
}
609
586
610
587
@ ExportMessage
611
588
Object readMember (String key ,
612
- @ Cached GraalHPyReadMemberNode readMemberNode , @ Exclusive @ Cached GilNode gil ) {
613
- boolean mustRelease = gil .acquire ();
614
- try {
615
- return readMemberNode .execute (this , key );
616
- } finally {
617
- gil .release (mustRelease );
618
- }
589
+ @ Cached GraalHPyReadMemberNode readMemberNode ) {
590
+ return readMemberNode .execute (this , key );
619
591
}
620
592
621
593
@ ExportMessage
0 commit comments