|
65 | 65 | import com.oracle.graal.python.builtins.PythonBuiltins;
|
66 | 66 | import com.oracle.graal.python.builtins.objects.PNone;
|
67 | 67 | import com.oracle.graal.python.builtins.objects.PythonAbstractObject;
|
68 |
| -import com.oracle.graal.python.builtins.objects.cext.PythonAbstractNativeObject; |
69 |
| -import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.PCallCapiFunction; |
70 | 68 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.ReleaseNativeWrapperNode;
|
71 | 69 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodesFactory.AsCharPointerNodeGen;
|
72 | 70 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodesFactory.ReleaseNativeWrapperNodeGen;
|
|
75 | 73 | import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodesFactory.ExternalFunctionInvokeNodeGen;
|
76 | 74 | import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodesFactory.MaterializePrimitiveNodeGen;
|
77 | 75 | import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodesFactory.ReleaseNativeSequenceStorageNodeGen;
|
78 |
| -import com.oracle.graal.python.builtins.objects.cext.capi.PythonNativeWrapper.PythonAbstractObjectNativeWrapper; |
79 | 76 | import com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor;
|
80 | 77 | import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTiming;
|
81 | 78 | import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions;
|
82 | 79 | import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.NativeToPythonNode;
|
83 | 80 | import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.PythonToNativeNode;
|
84 |
| -import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.ToPythonWrapperNode; |
85 | 81 | import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitionsFactory.PythonToNativeNodeGen;
|
86 | 82 | import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.CheckFunctionResultNode;
|
87 | 83 | import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.ConvertPIntToPrimitiveNode;
|
@@ -2228,46 +2224,28 @@ abstract static class ReleaseNativeSequenceStorageNode extends Node {
|
2228 | 2224 | @Specialization(guards = {"storage.length() == cachedLen", "cachedLen <= 8"}, limit = "1")
|
2229 | 2225 | @ExplodeLoop(kind = LoopExplosionKind.FULL_UNROLL)
|
2230 | 2226 | static void doObjectCachedLen(NativeObjectSequenceStorage storage,
|
| 2227 | + @Bind("this") Node inliningTarget, |
2231 | 2228 | @Cached("storage.length()") int cachedLen,
|
2232 |
| - @Cached(value = "createConditionProfiles(cachedLen)", dimensions = 1) ConditionProfile[] objectWrapperProfiles, |
2233 |
| - @Cached(value = "createConditionProfiles(cachedLen)", dimensions = 1) ConditionProfile[] nativeObjectProfiles, |
2234 | 2229 | @Shared @Cached CStructAccess.ReadPointerNode readNode,
|
2235 |
| - @Shared @Cached ToPythonWrapperNode toPythonWrapperNode, |
2236 |
| - @Shared @Cached PCallCapiFunction callDecrefNode, |
| 2230 | + @Shared @Cached CExtNodes.DecRefPointerNode decRefPointerNode, |
2237 | 2231 | @Shared @Cached CStructAccess.FreeNode freeNode) {
|
2238 | 2232 | for (int i = 0; i < cachedLen; i++) {
|
2239 | 2233 | Object elementPointer = readNode.readArrayElement(storage.getPtr(), i);
|
2240 |
| - PythonNativeWrapper pythonNativeWrapper = toPythonWrapperNode.executeWrapper(elementPointer, false); |
2241 |
| - if (objectWrapperProfiles[i].profile(pythonNativeWrapper instanceof PythonAbstractObjectNativeWrapper)) { |
2242 |
| - ((PythonAbstractObjectNativeWrapper) pythonNativeWrapper).decRef(); |
2243 |
| - } else if (nativeObjectProfiles[i].profile(pythonNativeWrapper == null)) { |
2244 |
| - assert NativeToPythonNode.executeUncached(elementPointer) instanceof PythonAbstractNativeObject; |
2245 |
| - callDecrefNode.call(NativeCAPISymbol.FUN_DECREF, elementPointer); |
2246 |
| - } else { |
2247 |
| - throw CompilerDirectives.shouldNotReachHere("NativeObjectSequenceStorage contains non-object element"); |
2248 |
| - } |
| 2234 | + decRefPointerNode.execute(inliningTarget, elementPointer); |
2249 | 2235 | }
|
2250 | 2236 | // in this case, the runtime still exclusively owns the memory
|
2251 | 2237 | freeNode.free(storage.getPtr());
|
2252 | 2238 | }
|
2253 | 2239 |
|
2254 | 2240 | @Specialization(replaces = "doObjectCachedLen")
|
2255 | 2241 | static void doObjectGeneric(NativeObjectSequenceStorage storage,
|
| 2242 | + @Bind("this") Node inliningTarget, |
2256 | 2243 | @Shared @Cached CStructAccess.ReadPointerNode readNode,
|
2257 |
| - @Shared @Cached ToPythonWrapperNode toPythonWrapperNode, |
2258 |
| - @Shared @Cached PCallCapiFunction callDecrefNode, |
| 2244 | + @Shared @Cached CExtNodes.DecRefPointerNode decRefPointerNode, |
2259 | 2245 | @Shared @Cached CStructAccess.FreeNode freeNode) {
|
2260 | 2246 | for (int i = 0; i < storage.length(); i++) {
|
2261 | 2247 | Object elementPointer = readNode.readArrayElement(storage.getPtr(), i);
|
2262 |
| - PythonNativeWrapper pythonNativeWrapper = toPythonWrapperNode.executeWrapper(elementPointer, false); |
2263 |
| - if (pythonNativeWrapper instanceof PythonAbstractObjectNativeWrapper objectNativeWrapper) { |
2264 |
| - objectNativeWrapper.decRef(); |
2265 |
| - } else if (pythonNativeWrapper == null) { |
2266 |
| - assert NativeToPythonNode.executeUncached(elementPointer) instanceof PythonAbstractNativeObject; |
2267 |
| - callDecrefNode.call(NativeCAPISymbol.FUN_DECREF, elementPointer); |
2268 |
| - } else { |
2269 |
| - throw CompilerDirectives.shouldNotReachHere("NativeObjectSequenceStorage contains non-object element"); |
2270 |
| - } |
| 2248 | + decRefPointerNode.execute(inliningTarget, elementPointer); |
2271 | 2249 | }
|
2272 | 2250 | // in this case, the runtime still exclusively owns the memory
|
2273 | 2251 | freeNode.free(storage.getPtr());
|
|
0 commit comments