|
83 | 83 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodesFactory.CreateFunctionNodeGen; |
84 | 84 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodesFactory.FromCharPointerNodeGen; |
85 | 85 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodesFactory.ResolvePointerNodeGen; |
86 | | -import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodesFactory.SubRefCntNodeGen; |
87 | 86 | import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.DefaultCheckFunctionResultNode; |
88 | 87 | import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.PExternalFunctionWrapper; |
89 | 88 | import com.oracle.graal.python.builtins.objects.cext.capi.PythonNativeWrapper.PythonAbstractObjectNativeWrapper; |
@@ -1223,65 +1222,6 @@ static Object doNativeObject(Object object, long value, |
1223 | 1222 | } |
1224 | 1223 | } |
1225 | 1224 |
|
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 | | - |
1285 | 1225 | @GenerateInline |
1286 | 1226 | @GenerateCached(false) |
1287 | 1227 | @GenerateUncached |
@@ -2065,13 +2005,11 @@ abstract static class ReleaseNativeWrapperNode extends Node { |
2065 | 2005 | public abstract void execute(Object pythonObject); |
2066 | 2006 |
|
2067 | 2007 | @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 | + */ |
2075 | 2013 | } |
2076 | 2014 |
|
2077 | 2015 | @Specialization(guards = "!isNativeWrapper(object)") |
|
0 commit comments