Skip to content

Commit 0a49c06

Browse files
committed
Remove SubRefCntNode
1 parent de315f2 commit 0a49c06

File tree

3 files changed

+8
-85
lines changed

3 files changed

+8
-85
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CtypesModuleBuiltins.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
import com.oracle.graal.python.builtins.objects.cext.capi.CApiContext;
121121
import com.oracle.graal.python.builtins.objects.cext.capi.CApiGuards;
122122
import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.AddRefCntNode;
123-
import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.SubRefCntNode;
123+
import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.PCallCapiFunction;
124124
import com.oracle.graal.python.builtins.objects.cext.capi.NativeCAPISymbol;
125125
import com.oracle.graal.python.builtins.objects.cext.common.CArrayWrappers.CByteArrayWrapper;
126126
import com.oracle.graal.python.builtins.objects.cext.common.LoadCExtException.ApiInitException;
@@ -1740,9 +1740,9 @@ static Object doGeneric(Object arg) {
17401740

17411741
if (pointerObject != null) {
17421742
// that's what this function is for
1743-
SubRefCntNode.executeUncached(pointerObject, 1);
1743+
PCallCapiFunction.callUncached(NativeCAPISymbol.FUN_DECREF, pointerObject);
17441744
// that for returning it
1745-
AddRefCntNode.executeUncached(pointerObject, 1);
1745+
PCallCapiFunction.callUncached(NativeCAPISymbol.FUN_INCREF, pointerObject);
17461746
}
17471747
return arg;
17481748
}

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

Lines changed: 5 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@
8383
import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodesFactory.CreateFunctionNodeGen;
8484
import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodesFactory.FromCharPointerNodeGen;
8585
import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodesFactory.ResolvePointerNodeGen;
86-
import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodesFactory.SubRefCntNodeGen;
8786
import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.DefaultCheckFunctionResultNode;
8887
import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.PExternalFunctionWrapper;
8988
import com.oracle.graal.python.builtins.objects.cext.capi.PythonNativeWrapper.PythonAbstractObjectNativeWrapper;
@@ -1223,65 +1222,6 @@ static Object doNativeObject(Object object, long value,
12231222
}
12241223
}
12251224

1226-
@GenerateInline
1227-
@GenerateCached(false)
1228-
@GenerateUncached
1229-
@ImportStatic(CApiGuards.class)
1230-
public abstract static class SubRefCntNode extends PNodeWithContext {
1231-
private static final TruffleLogger LOGGER = CApiContext.getLogger(SubRefCntNode.class);
1232-
1233-
public static long executeUncached(Object object, long value) {
1234-
return SubRefCntNodeGen.getUncached().execute(null, object, value);
1235-
}
1236-
1237-
public final long dec(Node inliningTarget, Object object) {
1238-
return execute(inliningTarget, object, 1);
1239-
}
1240-
1241-
public abstract long execute(Node inliningTarget, Object object, long value);
1242-
1243-
@Specialization(guards = "value == 1")
1244-
static long doNativeWrapperDecByOne(PythonAbstractObjectNativeWrapper nativeWrapper, @SuppressWarnings("unused") long value) {
1245-
long refCount = nativeWrapper.decRef();
1246-
// TODO(fa): see comment in 'doNativeWrapper'
1247-
// checkRefCountZero(inliningTarget, nativeWrapper, freeNode, negativeProfile,
1248-
// refCount);
1249-
return refCount;
1250-
}
1251-
1252-
@Specialization
1253-
static long doNativeWrapper(Node inliningTarget, PythonAbstractObjectNativeWrapper nativeWrapper, long value,
1254-
@Exclusive @Cached InlinedConditionProfile hasRefProfile) {
1255-
long updatedRefCount = nativeWrapper.getRefCount() - value;
1256-
nativeWrapper.setRefCount(inliningTarget, updatedRefCount, hasRefProfile);
1257-
/*
1258-
* TODO(fa): Investigate if call to 'checkRefCountZero' is beneficial or necessary.
1259-
*
1260-
* I think it is not strictly necessary because 'setRefCount' will make the wrapper's
1261-
* reference weak and as soon as there is no more reference from managed, the object
1262-
* will be free'd. However, if the refcount is 0, we already know that it can be free'd
1263-
* and we could safe the overhead of going through the reference queue and such. OTOH, I
1264-
* think this will rarely happen and would need some special treatment in the reference
1265-
* queue processor.
1266-
*/
1267-
// checkRefCountZero(inliningTarget, nativeWrapper, freeNode, negativeProfile,
1268-
// updatedRefCount);
1269-
return updatedRefCount;
1270-
}
1271-
1272-
/*-
1273-
private static void checkRefCountZero(Node inliningTarget, PythonAbstractObjectNativeWrapper nativeWrapper, PyTruffleObjectFree freeNode, InlinedBranchProfile negativeProfile, long refCount) {
1274-
if (refCount == 0) {
1275-
// 'freeNode' acts as a branch profile
1276-
freeNode.execute(inliningTarget, nativeWrapper);
1277-
} else if (refCount < 0) {
1278-
negativeProfile.enter(inliningTarget);
1279-
LOGGER.severe(() -> "native wrapper has negative ref count: " + nativeWrapper);
1280-
}
1281-
}
1282-
*/
1283-
}
1284-
12851225
@GenerateInline
12861226
@GenerateCached(false)
12871227
@GenerateUncached
@@ -2065,13 +2005,11 @@ abstract static class ReleaseNativeWrapperNode extends Node {
20652005
public abstract void execute(Object pythonObject);
20662006

20672007
@Specialization
2068-
static void doNativeWrapper(PythonAbstractObjectNativeWrapper nativeWrapper,
2069-
@Bind("this") Node inliningTarget,
2070-
@Cached SubRefCntNode subRefCntNode) {
2071-
// in the cached case, refCntNode acts as a branch profile
2072-
// if (subRefCntNode.dec(nativeWrapper) == 0) {
2073-
// traverseNativeWrapperNode.execute(inliningTarget, nativeWrapper.getDelegate());
2074-
// }
2008+
static void doNativeWrapper(@SuppressWarnings("unused") PythonAbstractObjectNativeWrapper nativeWrapper) {
2009+
/*
2010+
* TODO(fa): this is the place where we should decrease the wrapper's refcount by 1 and
2011+
* also make the ref weak
2012+
*/
20752013
}
20762014

20772015
@Specialization(guards = "!isNativeWrapper(object)")

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNodes.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.CreateFunctionNode;
6969
import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.CreateMethodNode;
7070
import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.FromCharPointerNode;
71-
import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.SubRefCntNode;
7271
import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.PExternalFunctionWrapper;
7372
import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.AsNativePrimitiveNode;
7473
import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.ConvertPIntToPrimitiveNode;
@@ -1948,20 +1947,6 @@ static void doConvert(Object[] dest, int destOffset,
19481947
}
19491948
}
19501949

1951-
/**
1952-
* The counter part of {@link HPyGetSetSetterToSulongNode}.
1953-
*/
1954-
@GenerateInline(false)
1955-
public abstract static class HPyLegacyGetSetSetterDecrefNode extends HPyCloseArgHandlesNode {
1956-
1957-
@Specialization
1958-
static void doConvert(Object[] dest, int destOffset,
1959-
@Bind("this") Node inliningTarget,
1960-
@Cached SubRefCntNode subRefCntNode) {
1961-
subRefCntNode.dec(inliningTarget, dest[destOffset + 1]);
1962-
}
1963-
}
1964-
19651950
/**
19661951
* Converts {@code self} to an HPy handle and any other argument to {@code HPy_ssize_t}.
19671952
*/

0 commit comments

Comments
 (0)