@@ -197,22 +197,22 @@ public static final class PythonObjectReference extends IdReference<PythonNative
197
197
198
198
/**
199
199
* The index in the lookup table, where this reference is stored. This duplicates the native
200
- * field {@link CFields#GraalPyObject__id } in order to save reading the native field if we
201
- * already have the reference object. The value may be {@code -1} in which case it means
202
- * that the reference's referent is a managed object and {@link #pointer} points into the
203
- * handle space.
200
+ * field {@link CFields#GraalPyObject__handle_table_index } in order to save reading the
201
+ * native field if we already have the reference object. The value may be {@code -1} in
202
+ * which case it means that the reference's referent is a managed object and
203
+ * {@link #pointer} points into the handle space.
204
204
*/
205
- private final int idx ;
205
+ private final int handleTableIndex ;
206
206
207
- private PythonObjectReference (HandleContext handleContext , PythonNativeWrapper referent , boolean strong , long pointer , int idx ) {
207
+ private PythonObjectReference (HandleContext handleContext , PythonNativeWrapper referent , boolean strong , long pointer , int handleTableIndex ) {
208
208
super (handleContext , referent );
209
209
this .pointer = pointer ;
210
210
this .strongReference = strong ? referent : null ;
211
211
if (LOGGER .isLoggable (Level .FINE )) {
212
212
LOGGER .fine (PythonUtils .formatJString ("new %s" , toString ()));
213
213
}
214
214
referent .ref = this ;
215
- this .idx = idx ;
215
+ this .handleTableIndex = handleTableIndex ;
216
216
}
217
217
218
218
static PythonObjectReference create (HandleContext handleContext , PythonAbstractObjectNativeWrapper referent , boolean strong , long pointer , int idx ) {
@@ -232,16 +232,16 @@ public void setStrongReference(PythonNativeWrapper wrapper) {
232
232
strongReference = wrapper ;
233
233
}
234
234
235
- public int getId () {
236
- return idx ;
235
+ public int getHandleTableIndex () {
236
+ return handleTableIndex ;
237
237
}
238
238
239
239
@ Override
240
240
@ TruffleBoundary
241
241
public String toString () {
242
242
String type = strongReference != null ? "strong" : "weak" ;
243
243
PythonNativeWrapper referent = get ();
244
- return String .format ("PythonObjectReference<0x%x,%s,%s,id=%d>" , pointer , type , referent != null ? referent : "freed" , idx );
244
+ return String .format ("PythonObjectReference<0x%x,%s,%s,id=%d>" , pointer , type , referent != null ? referent : "freed" , handleTableIndex );
245
245
}
246
246
}
247
247
@@ -365,7 +365,7 @@ public static void pollReferenceQueue() {
365
365
if (entry instanceof PythonObjectReference reference ) {
366
366
LOGGER .fine (() -> PythonUtils .formatJString ("releasing %s" , reference .toString ()));
367
367
if (HandlePointerConverter .pointsToPyHandleSpace (reference .pointer )) {
368
- assert nativeStubLookupGet (context , reference .pointer , reference .idx ) != null : Long .toHexString (reference .pointer );
368
+ assert nativeStubLookupGet (context , reference .pointer , reference .handleTableIndex ) != null : Long .toHexString (reference .pointer );
369
369
nativeStubLookupRemove (context , reference );
370
370
/*
371
371
* We may only free native object stubs if their reference count is
@@ -385,7 +385,7 @@ public static void pollReferenceQueue() {
385
385
* field because there may be referenced from managed in the future
386
386
* and then we would incorrectly reuse the ID.
387
387
*/
388
- CStructAccess .WriteIntNode .writeUncached (reference .pointer , CFields .GraalPyObject__id , 0 );
388
+ CStructAccess .WriteIntNode .writeUncached (reference .pointer , CFields .GraalPyObject__handle_table_index , 0 );
389
389
}
390
390
} else {
391
391
assert nativeLookupGet (context , reference .pointer ) != null : Long .toHexString (reference .pointer );
@@ -550,8 +550,8 @@ private static int resizeNativeStubLookupTable(HandleContext context) {
550
550
}
551
551
552
552
private static int nativeStubLookupPut (HandleContext context , PythonObjectReference value ) {
553
- assert value .idx > 0 ;
554
- final int idx = value .idx - 1 ;
553
+ assert value .handleTableIndex > 0 ;
554
+ final int idx = value .handleTableIndex - 1 ;
555
555
assert context .nativeStubLookup [idx ] == null || context .nativeStubLookup [idx ] == value ;
556
556
context .nativeStubLookup [idx ] = value ;
557
557
if (PythonContext .DEBUG_CAPI ) {
@@ -564,8 +564,8 @@ private static int nativeStubLookupPut(HandleContext context, PythonObjectRefere
564
564
}
565
565
566
566
private static PythonObjectReference nativeStubLookupRemove (HandleContext context , PythonObjectReference ref ) {
567
- assert ref .idx > 0 ;
568
- final int idx = ref .idx - 1 ;
567
+ assert ref .handleTableIndex > 0 ;
568
+ final int idx = ref .handleTableIndex - 1 ;
569
569
PythonObjectReference result = context .nativeStubLookup [idx ];
570
570
context .nativeStubLookup [idx ] = null ;
571
571
context .nativeStubLookupFreeStack .push (idx );
@@ -658,7 +658,7 @@ static long doGeneric(Node inliningTarget, PythonAbstractObjectNativeWrapper wra
658
658
long stubPointer = coerceToLongNode .execute (inliningTarget , nativeObjectStub );
659
659
long taggedPointer = HandlePointerConverter .stubToPointer (stubPointer );
660
660
int idx = nativeStubLookupReserve (handleContext );
661
- writeIntNode .write (stubPointer , CFields .GraalPyObject__id , idx );
661
+ writeIntNode .write (stubPointer , CFields .GraalPyObject__handle_table_index , idx );
662
662
PythonObjectReference ref = PythonObjectReference .create (handleContext , wrapper , immortal , taggedPointer , idx );
663
663
nativeStubLookupPut (handleContext , ref );
664
664
@@ -790,7 +790,7 @@ static PythonNativeWrapper doGeneric(Node inliningTarget, long pointer,
790
790
@ Cached (inline = false ) CStructAccess .ReadI32Node readI32Node ,
791
791
@ Cached InlinedExactClassProfile profile ) {
792
792
HandleContext nativeContext = PythonContext .get (inliningTarget ).nativeContext ;
793
- int idx = readI32Node .read (HandlePointerConverter .pointerToStub (pointer ), CFields .GraalPyObject__id );
793
+ int idx = readI32Node .read (HandlePointerConverter .pointerToStub (pointer ), CFields .GraalPyObject__handle_table_index );
794
794
PythonObjectReference reference = nativeStubLookupGet (nativeContext , pointer , idx );
795
795
PythonNativeWrapper wrapper = profile .profile (inliningTarget , reference .get ());
796
796
assert wrapper != null : "reference was collected: " + Long .toHexString (pointer );
@@ -1065,7 +1065,7 @@ Object doNonWrapper(Object value,
1065
1065
}
1066
1066
assert pythonContext .ownsGil ();
1067
1067
if (isHandleSpaceProfile .profile (inliningTarget , HandlePointerConverter .pointsToPyHandleSpace (pointer ))) {
1068
- int idx = readI32Node .read (HandlePointerConverter .pointerToStub (pointer ), CFields .GraalPyObject__id );
1068
+ int idx = readI32Node .read (HandlePointerConverter .pointerToStub (pointer ), CFields .GraalPyObject__handle_table_index );
1069
1069
PythonObjectReference reference = nativeStubLookupGet (nativeContext , pointer , idx );
1070
1070
if (reference == null ) {
1071
1071
CompilerDirectives .transferToInterpreterAndInvalidate ();
@@ -1232,7 +1232,7 @@ Object doNonWrapper(long pointer, boolean stealing,
1232
1232
}
1233
1233
assert pythonContext .ownsGil ();
1234
1234
if (isHandleSpaceProfile .profile (inliningTarget , HandlePointerConverter .pointsToPyHandleSpace (pointer ))) {
1235
- int idx = readI32Node .read (HandlePointerConverter .pointerToStub (pointer ), CFields .GraalPyObject__id );
1235
+ int idx = readI32Node .read (HandlePointerConverter .pointerToStub (pointer ), CFields .GraalPyObject__handle_table_index );
1236
1236
PythonObjectReference reference = nativeStubLookupGet (nativeContext , pointer , idx );
1237
1237
if (reference == null ) {
1238
1238
CompilerDirectives .transferToInterpreterAndInvalidate ();
@@ -1374,7 +1374,7 @@ static PythonNativeWrapper doNonWrapper(Object obj, boolean strict,
1374
1374
HandleContext nativeContext = pythonContext .nativeContext ;
1375
1375
assert pythonContext .ownsGil ();
1376
1376
if (isHandleSpaceProfile .profile (inliningTarget , HandlePointerConverter .pointsToPyHandleSpace (pointer ))) {
1377
- int idx = readI32Node .read (HandlePointerConverter .pointerToStub (pointer ), CFields .GraalPyObject__id );
1377
+ int idx = readI32Node .read (HandlePointerConverter .pointerToStub (pointer ), CFields .GraalPyObject__handle_table_index );
1378
1378
PythonObjectReference reference = nativeStubLookupGet (nativeContext , pointer , idx );
1379
1379
PythonNativeWrapper wrapper ;
1380
1380
if (reference == null ) {
0 commit comments