Skip to content

Commit 09bc266

Browse files
committed
Remove recursion debugging in ToNativeTypeNode
1 parent a9b5e08 commit 09bc266

File tree

1 file changed

+21
-32
lines changed

1 file changed

+21
-32
lines changed

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

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,47 +1772,36 @@ void doPythonNativeWrapper(PythonNativeWrapper obj,
17721772
abstract static class ToNativeTypeNode extends Node {
17731773
public abstract void execute(PythonNativeWrapper obj);
17741774

1775-
static int level = 0;
1776-
17771775
@Specialization
17781776
@TruffleBoundary
17791777
void doPythonNativeWrapper(PythonNativeWrapper obj,
17801778
@CachedLibrary(limit = "3") InteropLibrary lib,
17811779
@Cached PCallCapiFunction callNativeUnary,
17821780
@Cached PCallCapiFunction callNativeUnaryPatch) {
1783-
level++;
1784-
if (level > 10) {
1785-
CompilerDirectives.transferToInterpreterAndInvalidate();
1786-
LOGGER.severe("recursion in " + ToNativeTypeNode.class.getName());
1787-
}
1788-
try {
1789-
if (!obj.isNative()) {
1790-
obj.setRefCount(Long.MAX_VALUE / 2); // make this object immortal
1791-
PythonManagedClass clazz = (PythonManagedClass) obj.getDelegate();
1792-
Long ptr = null;
1793-
if (clazz instanceof PythonBuiltinClass) {
1794-
PythonBuiltinClass builtinClass = (PythonBuiltinClass) clazz;
1795-
PythonBuiltinClassType type = builtinClass.getType();
1796-
ptr = PythonContext.get(this).getCApiContext().getTypeStore(type.getName().toJavaStringUncached());
1797-
}
1798-
if (ptr == null) {
1799-
ptr = coerceToLong(callNativeUnary.call(FUN_PYTRUFFLE_ALLOCATE_TYPE, obj, 1), lib);
1800-
}
1781+
if (!obj.isNative()) {
1782+
obj.setRefCount(Long.MAX_VALUE / 2); // make this object immortal
1783+
PythonManagedClass clazz = (PythonManagedClass) obj.getDelegate();
1784+
Long ptr = null;
1785+
if (clazz instanceof PythonBuiltinClass) {
1786+
PythonBuiltinClass builtinClass = (PythonBuiltinClass) clazz;
1787+
PythonBuiltinClassType type = builtinClass.getType();
1788+
ptr = PythonContext.get(this).getCApiContext().getTypeStore(type.getName().toJavaStringUncached());
1789+
}
1790+
if (ptr == null) {
1791+
ptr = coerceToLong(callNativeUnary.call(FUN_PYTRUFFLE_ALLOCATE_TYPE, obj, 1), lib);
1792+
}
18011793

1802-
boolean isType = InlineIsBuiltinClassProfile.profileClassSlowPath(clazz, PythonBuiltinClassType.PythonClass);
1803-
callNativeUnary.call(FUN_PYTRUFFLE_POPULATE_TYPE, ptr, obj, isType ? 1 : 0);
1804-
if (!obj.isNative()) {
1805-
CApiTransitions.firstToNative(obj, ptr);
1806-
if (isType) {
1807-
// PopulateType omits certain fields in this type to avoid circular
1808-
// references
1809-
Object base = ToSulongNode.getUncached().execute(PythonBuiltinClassType.PythonObject);
1810-
callNativeUnaryPatch.call(FUN_PYTRUFFLE_PATCH_TYPE, ptr, base);
1811-
}
1794+
boolean isType = InlineIsBuiltinClassProfile.profileClassSlowPath(clazz, PythonBuiltinClassType.PythonClass);
1795+
callNativeUnary.call(FUN_PYTRUFFLE_POPULATE_TYPE, ptr, obj, isType ? 1 : 0);
1796+
if (!obj.isNative()) {
1797+
CApiTransitions.firstToNative(obj, ptr);
1798+
if (isType) {
1799+
// PopulateType omits certain fields in this type to avoid circular
1800+
// references
1801+
Object base = ToSulongNode.getUncached().execute(PythonBuiltinClassType.PythonObject);
1802+
callNativeUnaryPatch.call(FUN_PYTRUFFLE_PATCH_TYPE, ptr, base);
18121803
}
18131804
}
1814-
} finally {
1815-
level--;
18161805
}
18171806
}
18181807
}

0 commit comments

Comments
 (0)