Skip to content

Commit 696ed2a

Browse files
committed
[GR-36983] Ignore checking refcount for managed arrays
PullRequest: graalpython/2153
2 parents 30d152c + 1457425 commit 696ed2a

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -45,6 +45,7 @@
4545
import com.oracle.graal.python.PythonLanguage;
4646
import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.ClearNativeWrapperNode;
4747
import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.PCallCapiFunction;
48+
import com.oracle.graal.python.builtins.objects.cext.common.CArrayWrappers.CArrayWrapper;
4849
import com.oracle.graal.python.runtime.GilNode;
4950
import com.oracle.truffle.api.CompilerDirectives;
5051
import com.oracle.truffle.api.TruffleLogger;
@@ -92,7 +93,7 @@ public abstract static class FreeNode extends Node {
9293

9394
public abstract int execute(Object pointerObject);
9495

95-
@Specialization(limit = "3")
96+
@Specialization(guards = "!isCArrayWrapper(nativeWrapper)", limit = "3")
9697
static int doNativeWrapper(PythonNativeWrapper nativeWrapper,
9798
@CachedLibrary("nativeWrapper") PythonNativeWrapperLibrary lib,
9899
@Cached ClearNativeWrapperNode clearNativeWrapperNode,
@@ -110,11 +111,22 @@ static int doNativeWrapper(PythonNativeWrapper nativeWrapper,
110111
return 1;
111112
}
112113

114+
@Specialization
115+
static int arrayWrapper(@SuppressWarnings("unused") CArrayWrapper object) {
116+
// It's a pointer to a managed object but doesn't need special handling, so we just
117+
// ignore it.
118+
return 1;
119+
}
120+
113121
@Specialization(guards = "!isNativeWrapper(object)")
114122
static int doOther(@SuppressWarnings("unused") Object object) {
115123
// It's a pointer to a managed object but none of our wrappers, so we just ignore it.
116124
return 0;
117125
}
126+
127+
protected static boolean isCArrayWrapper(Object obj) {
128+
return obj instanceof CArrayWrapper;
129+
}
118130
}
119131

120132
@GenerateUncached

0 commit comments

Comments
 (0)