|
43 | 43 | import static com.oracle.graal.python.builtins.objects.PNone.NO_VALUE; |
44 | 44 | import static com.oracle.graal.python.builtins.objects.cext.capi.NativeCAPISymbol.FUN_GRAALPY_OBJECT_GC_DEL; |
45 | 45 | import static com.oracle.graal.python.builtins.objects.cext.capi.NativeCAPISymbol.FUN_NO_OP_CLEAR; |
| 46 | +import static com.oracle.graal.python.builtins.objects.cext.capi.NativeCAPISymbol.FUN_NO_OP_TRAVERSE; |
46 | 47 | import static com.oracle.graal.python.builtins.objects.cext.capi.NativeCAPISymbol.FUN_PTR_COMPARE; |
47 | 48 | import static com.oracle.graal.python.builtins.objects.cext.capi.NativeCAPISymbol.FUN_PY_DEALLOC; |
48 | 49 | import static com.oracle.graal.python.builtins.objects.cext.capi.NativeCAPISymbol.FUN_PY_OBJECT_FREE; |
49 | 50 | import static com.oracle.graal.python.builtins.objects.cext.capi.NativeCAPISymbol.FUN_PY_TRUFFLE_MEMORYVIEW_FROM_OBJECT; |
50 | 51 | import static com.oracle.graal.python.builtins.objects.cext.capi.NativeCAPISymbol.FUN_PY_TYPE_GENERIC_ALLOC; |
| 52 | +import static com.oracle.graal.python.builtins.objects.cext.capi.NativeCAPISymbol.FUN_SUBTYPE_TRAVERSE; |
51 | 53 | import static com.oracle.graal.python.builtins.objects.cext.capi.PythonNativeWrapper.PythonAbstractObjectNativeWrapper.IMMORTAL_REFCNT; |
52 | 54 | import static com.oracle.graal.python.builtins.objects.cext.structs.CConstants.PYLONG_BITS_IN_DIGIT; |
53 | 55 | import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyFloatObject__ob_fval; |
|
142 | 144 | import com.oracle.graal.python.builtins.objects.traceback.MaterializeLazyTracebackNode; |
143 | 145 | import com.oracle.graal.python.builtins.objects.type.PythonAbstractClass; |
144 | 146 | import com.oracle.graal.python.builtins.objects.type.PythonBuiltinClass; |
145 | | -import com.oracle.graal.python.builtins.objects.type.PythonClass; |
146 | 147 | import com.oracle.graal.python.builtins.objects.type.PythonManagedClass; |
147 | 148 | import com.oracle.graal.python.builtins.objects.type.TypeFlags; |
148 | 149 | import com.oracle.graal.python.builtins.objects.type.TypeNodes; |
@@ -898,33 +899,33 @@ public static PCallCapiFunction getUncached() { |
898 | 899 | */ |
899 | 900 | @TruffleBoundary |
900 | 901 | public static Object lookupNativeMemberInMRO(PythonManagedClass cls, @SuppressWarnings("unused") CFields nativeMemberName, HiddenAttr managedMemberName) { |
901 | | - if (cls instanceof PythonClass) { |
902 | | - NativeCAPISymbol symbol = null; |
903 | | - // We need to point to PyType_GenericAlloc or PyObject_GC_Del |
904 | | - if (managedMemberName == HiddenAttr.ALLOC) { |
905 | | - symbol = FUN_PY_TYPE_GENERIC_ALLOC; |
906 | | - } else if (managedMemberName == HiddenAttr.FREE) { |
907 | | - /* |
908 | | - * See 'typeobject.c: inherit_slots': A bit of magic to plug in the correct default |
909 | | - * tp_free function when a derived class adds gc, didn't define tp_free, and the |
910 | | - * base uses the default non-gc tp_free. |
911 | | - */ |
912 | | - if ((GetTypeFlagsNode.executeUncached(cls) & TypeFlags.HAVE_GC) != 0) { |
913 | | - symbol = FUN_GRAALPY_OBJECT_GC_DEL; |
914 | | - } else { |
915 | | - symbol = FUN_PY_OBJECT_FREE; |
916 | | - } |
917 | | - } else if (managedMemberName == HiddenAttr.CLEAR) { |
918 | | - // This will need to be subtype_clear when we implement native GC |
919 | | - symbol = FUN_NO_OP_CLEAR; |
| 902 | + NativeCAPISymbol symbol = null; |
| 903 | + // We need to point to PyType_GenericAlloc or PyObject_GC_Del |
| 904 | + if (managedMemberName == HiddenAttr.ALLOC) { |
| 905 | + symbol = FUN_PY_TYPE_GENERIC_ALLOC; |
| 906 | + } else if (managedMemberName == HiddenAttr.FREE) { |
| 907 | + /* |
| 908 | + * See 'typeobject.c: inherit_slots': A bit of magic to plug in the correct default |
| 909 | + * tp_free function when a derived class adds gc, didn't define tp_free, and the base |
| 910 | + * uses the default non-gc tp_free. |
| 911 | + */ |
| 912 | + if ((GetTypeFlagsNode.executeUncached(cls) & TypeFlags.HAVE_GC) != 0) { |
| 913 | + symbol = FUN_GRAALPY_OBJECT_GC_DEL; |
| 914 | + } else { |
| 915 | + symbol = FUN_PY_OBJECT_FREE; |
920 | 916 | } |
921 | | - if (symbol != null) { |
922 | | - Object func = HiddenAttr.ReadNode.executeUncached(cls, managedMemberName, null); |
923 | | - if (func != null) { |
924 | | - return func; |
925 | | - } |
926 | | - return CApiContext.getNativeSymbol(null, symbol); |
| 917 | + } else if (managedMemberName == HiddenAttr.TRAVERSE) { |
| 918 | + symbol = cls instanceof PythonBuiltinClass ? FUN_NO_OP_TRAVERSE : FUN_SUBTYPE_TRAVERSE; |
| 919 | + } else if (managedMemberName == HiddenAttr.CLEAR) { |
| 920 | + // This will need to be subtype_clear when we implement native GC |
| 921 | + symbol = FUN_NO_OP_CLEAR; |
| 922 | + } |
| 923 | + if (symbol != null) { |
| 924 | + Object func = HiddenAttr.ReadNode.executeUncached(cls, managedMemberName, null); |
| 925 | + if (func != null) { |
| 926 | + return func; |
927 | 927 | } |
| 928 | + return CApiContext.getNativeSymbol(null, symbol); |
928 | 929 | } |
929 | 930 | MroSequenceStorage mroStorage = GetMroStorageNode.executeUncached(cls); |
930 | 931 | int n = mroStorage.length(); |
|
0 commit comments