@@ -1772,47 +1772,36 @@ void doPythonNativeWrapper(PythonNativeWrapper obj,
1772
1772
abstract static class ToNativeTypeNode extends Node {
1773
1773
public abstract void execute (PythonNativeWrapper obj );
1774
1774
1775
- static int level = 0 ;
1776
-
1777
1775
@ Specialization
1778
1776
@ TruffleBoundary
1779
1777
void doPythonNativeWrapper (PythonNativeWrapper obj ,
1780
1778
@ CachedLibrary (limit = "3" ) InteropLibrary lib ,
1781
1779
@ Cached PCallCapiFunction callNativeUnary ,
1782
1780
@ 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
+ }
1801
1793
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 );
1812
1803
}
1813
1804
}
1814
- } finally {
1815
- level --;
1816
1805
}
1817
1806
}
1818
1807
}
0 commit comments