Skip to content

Commit 25162be

Browse files
committed
Use CApiTransitions.addNativeRefCount instead of calling PyTruffle_ADDREF
1 parent 4239645 commit 25162be

File tree

1 file changed

+5
-4
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/transitions

1 file changed

+5
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -896,9 +896,10 @@ protected boolean needsTransfer() {
896896

897897
@Specialization
898898
Object doNative(PythonAbstractNativeObject obj,
899-
@Cached PCallCapiFunction callAddRef) {
900-
if (needsTransfer()) {
901-
callAddRef.call(NativeCAPISymbol.FUN_ADDREF, obj.object, 1);
899+
@CachedLibrary(limit = "2") InteropLibrary lib) {
900+
if (needsTransfer() && getContext().isNativeAccessAllowed()) {
901+
long ptr = PythonUtils.coerceToLong(obj.getPtr(), lib);
902+
CApiTransitions.addNativeRefCount(ptr, 1);
902903
}
903904
return obj.getPtr();
904905
}
@@ -938,7 +939,7 @@ static Object doOther(Object obj,
938939
return replacement;
939940
}
940941

941-
assert PythonContext.get(inliningTarget).getEnv().isNativeAccessAllowed();
942+
assert PythonContext.get(inliningTarget).isNativeAccessAllowed();
942943
assert obj != PNone.NO_VALUE;
943944
if (!lib.isPointer(wrapper)) {
944945
lib.toNative(wrapper);

0 commit comments

Comments
 (0)