234
234
import com .oracle .graal .python .nodes .object .GetClassNode ;
235
235
import com .oracle .graal .python .nodes .util .CastToJavaIntExactNode ;
236
236
import com .oracle .graal .python .runtime .AsyncHandler ;
237
+ import com .oracle .graal .python .runtime .GilNode ;
237
238
import com .oracle .graal .python .runtime .PythonContext ;
238
239
import com .oracle .graal .python .runtime .PythonOptions ;
239
240
import com .oracle .graal .python .runtime .PythonOptions .HPyBackendMode ;
@@ -2485,7 +2486,8 @@ public GraalHPyHandle createField(Object delegate, int idx) {
2485
2486
return GraalHPyHandle .createField (delegate , idx );
2486
2487
}
2487
2488
2488
- public synchronized GraalHPyHandle createGlobal (Object delegate , int idx ) {
2489
+ public GraalHPyHandle createGlobal (Object delegate , int idx ) {
2490
+ assert !GilNode .getUncached ().acquire (PythonContext .get (null )) : "Gil not held when creating global" ;
2489
2491
final int newIdx ;
2490
2492
if (idx <= 0 ) {
2491
2493
newIdx = allocateHPyGlobal ();
@@ -2500,7 +2502,7 @@ public synchronized GraalHPyHandle createGlobal(Object delegate, int idx) {
2500
2502
return h ;
2501
2503
}
2502
2504
2503
- private synchronized int allocateHPyGlobal () {
2505
+ private int allocateHPyGlobal () {
2504
2506
int handle = 0 ;
2505
2507
for (int i = 1 ; i < hpyGlobalsTable .length ; i ++) {
2506
2508
if (hpyGlobalsTable [i ] == null ) {
@@ -2620,17 +2622,20 @@ private void allocateNativeSpacePointersMirror() {
2620
2622
}
2621
2623
}
2622
2624
2623
- public synchronized GraalHPyHandle getObjectForHPyHandle (int handle ) {
2625
+ public GraalHPyHandle getObjectForHPyHandle (int handle ) {
2626
+ assert !GilNode .getUncached ().acquire (PythonContext .get (null )) : "Gil not held when resolving object from handle" ;
2624
2627
assert !GraalHPyBoxing .isBoxedInt (handle ) && !GraalHPyBoxing .isBoxedDouble (handle ) : "trying to lookup boxed primitive" ;
2625
2628
return hpyHandleTable [handle ];
2626
2629
}
2627
2630
2628
- public synchronized GraalHPyHandle getObjectForHPyGlobal (int handle ) {
2631
+ public GraalHPyHandle getObjectForHPyGlobal (int handle ) {
2632
+ assert !GilNode .getUncached ().acquire (PythonContext .get (null )) : "Gil not held when resolving object from global" ;
2629
2633
assert !GraalHPyBoxing .isBoxedInt (handle ) && !GraalHPyBoxing .isBoxedDouble (handle ) : "trying to lookup boxed primitive" ;
2630
2634
return hpyGlobalsTable [handle ];
2631
2635
}
2632
2636
2633
- synchronized boolean releaseHPyHandleForObject (int handle ) {
2637
+ boolean releaseHPyHandleForObject (int handle ) {
2638
+ assert !GilNode .getUncached ().acquire (PythonContext .get (null )) : "Gil not held when releasing handle" ;
2634
2639
assert handle != 0 : "NULL handle cannot be released" ;
2635
2640
assert hpyHandleTable [handle ] != null : PythonUtils .format ("releasing handle that has already been released: %d" , handle );
2636
2641
if (LOGGER .isLoggable (Level .FINER )) {
0 commit comments