@@ -1172,14 +1172,15 @@ public abstract static class ResolveHandleNode extends Node {
1172
1172
@ Specialization
1173
1173
static PythonNativeWrapper doGeneric (Node inliningTarget , long pointer ,
1174
1174
@ Cached (inline = false ) CStructAccess .ReadI32Node readI32Node ,
1175
- @ Cached InlinedExactClassProfile profile ) {
1175
+ @ Cached InlinedExactClassProfile profile ,
1176
+ @ Cached UpdateRefNode updateRefNode ) {
1176
1177
HandleContext nativeContext = PythonContext .get (inliningTarget ).nativeContext ;
1177
1178
int idx = readI32Node .read (HandlePointerConverter .pointerToStub (pointer ), CFields .GraalPyObject__handle_table_index );
1178
1179
PythonObjectReference reference = nativeStubLookupGet (nativeContext , pointer , idx );
1179
1180
PythonNativeWrapper wrapper = profile .profile (inliningTarget , reference .get ());
1180
1181
assert wrapper != null : "reference was collected: " + Long .toHexString (pointer );
1181
1182
if (wrapper instanceof PythonAbstractObjectNativeWrapper objectNativeWrapper ) {
1182
- objectNativeWrapper .incRef ();
1183
+ updateRefNode . execute ( inliningTarget , objectNativeWrapper , objectNativeWrapper .incRef () );
1183
1184
}
1184
1185
return wrapper ;
1185
1186
}
@@ -1428,8 +1429,9 @@ protected boolean needsTransfer() {
1428
1429
@ Specialization
1429
1430
static Object doWrapper (PythonNativeWrapper value ,
1430
1431
@ Bind ("$node" ) Node inliningTarget ,
1431
- @ Exclusive @ Cached InlinedExactClassProfile wrapperProfile ) {
1432
- return handleWrapper (inliningTarget , wrapperProfile , false , value );
1432
+ @ Exclusive @ Cached InlinedExactClassProfile wrapperProfile ,
1433
+ @ Cached UpdateRefNode updateRefNode ) {
1434
+ return handleWrapper (inliningTarget , wrapperProfile , updateRefNode , false , value );
1433
1435
}
1434
1436
1435
1437
@ Specialization (guards = "!isNativeWrapper(value)" , limit = "3" )
@@ -1444,7 +1446,8 @@ Object doNonWrapper(Object value,
1444
1446
@ Cached InlinedConditionProfile isNativeProfile ,
1445
1447
@ Cached InlinedConditionProfile isNativeWrapperProfile ,
1446
1448
@ Cached InlinedConditionProfile isHandleSpaceProfile ,
1447
- @ Exclusive @ Cached InlinedExactClassProfile wrapperProfile ) {
1449
+ @ Exclusive @ Cached InlinedExactClassProfile wrapperProfile ,
1450
+ @ Cached UpdateRefNode updateRefNode ) {
1448
1451
assert !(value instanceof TruffleString );
1449
1452
assert !(value instanceof PythonAbstractObject );
1450
1453
assert !(value instanceof Number );
@@ -1506,7 +1509,7 @@ Object doNonWrapper(Object value,
1506
1509
return createAbstractNativeObject (nativeContext , value , needsTransfer (), pointer );
1507
1510
}
1508
1511
}
1509
- return handleWrapper (inliningTarget , wrapperProfile , needsTransfer (), wrapper );
1512
+ return handleWrapper (inliningTarget , wrapperProfile , updateRefNode , needsTransfer (), wrapper );
1510
1513
}
1511
1514
1512
1515
/**
@@ -1518,7 +1521,7 @@ Object doNonWrapper(Object value,
1518
1521
* @param wrapper The native wrapper to unwrap.
1519
1522
* @return The Python value contained in the native wrapper.
1520
1523
*/
1521
- static Object handleWrapper (Node node , InlinedExactClassProfile wrapperProfile , boolean transfer , PythonNativeWrapper wrapper ) {
1524
+ static Object handleWrapper (Node node , InlinedExactClassProfile wrapperProfile , UpdateRefNode updateRefNode , boolean transfer , PythonNativeWrapper wrapper ) {
1522
1525
PythonNativeWrapper profiledWrapper = wrapperProfile .profile (node , wrapper );
1523
1526
if (transfer && profiledWrapper instanceof PythonAbstractObjectNativeWrapper objectNativeWrapper ) {
1524
1527
/*
@@ -1532,7 +1535,7 @@ static Object handleWrapper(Node node, InlinedExactClassProfile wrapperProfile,
1532
1535
* MANAGED_REFCNT.
1533
1536
*/
1534
1537
assert objectNativeWrapper .getRefCount () > MANAGED_REFCNT ;
1535
- objectNativeWrapper .decRef ();
1538
+ updateRefNode . execute ( node , objectNativeWrapper , objectNativeWrapper .decRef () );
1536
1539
}
1537
1540
if (profiledWrapper instanceof PrimitiveNativeWrapper primitive ) {
1538
1541
if (primitive .isBool ()) {
@@ -1626,7 +1629,8 @@ Object doNonWrapper(long pointer, boolean stealing,
1626
1629
@ Cached InlinedConditionProfile isNativeProfile ,
1627
1630
@ Cached InlinedConditionProfile isNativeWrapperProfile ,
1628
1631
@ Cached InlinedConditionProfile isHandleSpaceProfile ,
1629
- @ Cached InlinedExactClassProfile wrapperProfile ) {
1632
+ @ Cached InlinedExactClassProfile wrapperProfile ,
1633
+ @ Cached UpdateRefNode updateRefNode ) {
1630
1634
1631
1635
assert PythonContext .get (null ).ownsGil ();
1632
1636
CompilerAsserts .partialEvaluationConstant (stealing );
@@ -1672,7 +1676,7 @@ Object doNonWrapper(long pointer, boolean stealing,
1672
1676
return createAbstractNativeObject (nativeContext , new NativePointer (pointer ), stealing , pointer );
1673
1677
}
1674
1678
}
1675
- return NativeToPythonNode .handleWrapper (inliningTarget , wrapperProfile , stealing , wrapper );
1679
+ return NativeToPythonNode .handleWrapper (inliningTarget , wrapperProfile , updateRefNode , stealing , wrapper );
1676
1680
}
1677
1681
}
1678
1682
0 commit comments