Skip to content

Commit fad039d

Browse files
committed
[GR-61997] calculate metaclass during native type initialization
1 parent dcd4e71 commit fad039d

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

graalpython/com.oracle.graal.python.cext/CAPIFunctions.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,7 @@ _PyEval_SetSwitchInterval;void;unsigned long
962962
_PyEval_SetTrace;int;PyThreadState*|Py_tracefunc|PyObject*
963963
_PyEval_SliceIndex;int;PyObject*|Py_ssize_t*
964964
_PyEval_SliceIndexNotNone;int;PyObject*|Py_ssize_t*
965+
PyUnstable_Eval_RequestCodeExtraIndex;Py_ssize_t;freefunc
965966
_PyFrame_IsEntryFrame;int;PyFrameObject*
966967
_PyFunction_Vectorcall;PyObject*;PyObject*|PyObject*const*|size_t|PyObject*
967968
_PyGILState_GetInterpreterStateUnsafe;PyInterpreterState*;void

graalpython/com.oracle.graal.python.cext/src/typeobject.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3117,7 +3117,6 @@ PyType_GetFlags(PyTypeObject *type)
31173117
}
31183118

31193119

3120-
#if 0 // GraalPy change
31213120
int
31223121
PyType_SUPPORTS_WEAKREFS(PyTypeObject *type)
31233122
{
@@ -3161,6 +3160,7 @@ _PyType_CalculateMetaclass(PyTypeObject *metatype, PyObject *bases)
31613160
return winner;
31623161
}
31633162

3163+
#if 0 // GraalPy change
31643164

31653165
// Forward declaration
31663166
static PyObject *
@@ -4279,7 +4279,7 @@ _PyType_FromMetaclass_impl(
42794279
goto finally;
42804280
}
42814281

4282-
#if 0 // GraalPy change [GR-61997]
4282+
#if 0 // GraalPy change
42834283
/* If this is an immutable type, check if all bases are also immutable,
42844284
* and (for now) fire a deprecation warning if not.
42854285
* (This isn't necessary for static types: those can't have heap bases,
@@ -4305,6 +4305,7 @@ _PyType_FromMetaclass_impl(
43054305
}
43064306
}
43074307
}
4308+
#endif // GraalPy change
43084309

43094310
/* Calculate the metaclass */
43104311

@@ -4338,9 +4339,6 @@ _PyType_FromMetaclass_impl(
43384339
goto finally;
43394340
}
43404341
}
4341-
#else // GraalPy change
4342-
metaclass = &PyType_Type;
4343-
#endif // GraalPy change
43444342

43454343
/* Calculate best base, and check that all bases are type objects */
43464344
PyTypeObject *base = best_base(bases); // borrowed ref

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@
166166
import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor._PyFrameEvalFunction;
167167
import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor._PyInterpreterFrame;
168168
import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.destructor;
169+
import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.freefunc;
169170
import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.func_intvoidptr;
170171
import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.func_objcharsizevoidptr;
171172
import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.func_objint;
@@ -760,6 +761,7 @@ public final class CApiFunction {
760761
@CApiBuiltin(name = "PyEval_ReleaseThread", ret = Void, args = {PyThreadState}, call = NotImplemented)
761762
@CApiBuiltin(name = "PyEval_SetProfile", ret = Void, args = {PY_TRACEFUNC, PyObject}, call = NotImplemented)
762763
@CApiBuiltin(name = "PyEval_SetTrace", ret = Void, args = {PY_TRACEFUNC, PyObject}, call = NotImplemented)
764+
@CApiBuiltin(name = "PyUnstable_Eval_RequestCodeExtraIndex", ret = Py_ssize_t, args = {freefunc}, call = NotImplemented)
763765
@CApiBuiltin(name = "PyExceptionClass_Name", ret = ConstCharPtrAsTruffleString, args = {PyObject}, call = NotImplemented)
764766
@CApiBuiltin(name = "PyFile_FromFd", ret = PyObject, args = {Int, ConstCharPtrAsTruffleString, ConstCharPtrAsTruffleString, Int, ConstCharPtrAsTruffleString, ConstCharPtrAsTruffleString,
765767
ConstCharPtrAsTruffleString, Int}, call = NotImplemented)
@@ -916,7 +918,7 @@ public final class CApiFunction {
916918
@CApiBuiltin(name = "PyTruffleFrame_New", ret = PyFrameObjectTransfer, args = {PyThreadState, PyCodeObject, PyObject, PyObject}, call = NotImplemented)
917919
@CApiBuiltin(name = "PyTruffle_SeqIter_New", ret = PyObjectTransfer, args = {PyObject}, call = NotImplemented)
918920
@CApiBuiltin(name = "PyType_ClearCache", ret = UNSIGNED_INT, args = {}, call = NotImplemented)
919-
@CApiBuiltin(name = "PyType_SUPPORTS_WEAKREFS", ret = Int, args = {PyTypeObject}, call = NotImplemented)
921+
@CApiBuiltin(name = "PyType_SUPPORTS_WEAKREFS", ret = Int, args = {PyTypeObject}, call = CImpl)
920922
@CApiBuiltin(name = "PyUnicodeDecodeError_GetEncoding", ret = PyObject, args = {PyObject}, call = NotImplemented)
921923
@CApiBuiltin(name = "PyUnicodeDecodeError_GetEnd", ret = Int, args = {PyObject, PY_SSIZE_T_PTR}, call = NotImplemented)
922924
@CApiBuiltin(name = "PyUnicodeDecodeError_GetObject", ret = PyObject, args = {PyObject}, call = NotImplemented)
@@ -1162,7 +1164,7 @@ public final class CApiFunction {
11621164
@CApiBuiltin(name = "_PyTraceMalloc_GetTraceback", ret = PyObject, args = {UNSIGNED_INT, UINTPTR_T}, call = NotImplemented)
11631165
@CApiBuiltin(name = "_PyTuple_DebugMallocStats", ret = Void, args = {FILE_PTR}, call = NotImplemented)
11641166
@CApiBuiltin(name = "_PyTuple_Resize", ret = Int, args = {PyObjectPtr, Py_ssize_t}, call = NotImplemented)
1165-
@CApiBuiltin(name = "_PyType_CalculateMetaclass", ret = PyTypeObject, args = {PyTypeObject, PyObject}, call = NotImplemented)
1167+
@CApiBuiltin(name = "_PyType_CalculateMetaclass", ret = PyTypeObject, args = {PyTypeObject, PyObject}, call = CImpl)
11661168
@CApiBuiltin(name = "_PyType_GetDocFromInternalDoc", ret = PyObject, args = {ConstCharPtrAsTruffleString, ConstCharPtrAsTruffleString}, call = NotImplemented)
11671169
@CApiBuiltin(name = "_PyType_GetTextSignatureFromInternalDoc", ret = PyObject, args = {ConstCharPtrAsTruffleString, ConstCharPtrAsTruffleString}, call = NotImplemented)
11681170
@CApiBuiltin(name = "_PyType_LookupId", ret = PyObject, args = {PyTypeObject, PY_IDENTIFIER}, call = NotImplemented)

0 commit comments

Comments
 (0)