summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2024-12-06 10:46:59 (GMT)
committerGitHub <noreply@github.com>2024-12-06 10:46:59 (GMT)
commit023b7d2141467017abc27de864f3f44677768cb3 (patch)
treefc99a157d5b4dffa4c15a3aa7b47125073d5348b /Objects
parent8b7c194c7bf7e547e4f6317528f0dcb9344c18c7 (diff)
downloadcpython-023b7d2141467017abc27de864f3f44677768cb3.zip
cpython-023b7d2141467017abc27de864f3f44677768cb3.tar.gz
cpython-023b7d2141467017abc27de864f3f44677768cb3.tar.bz2
GH-126491: Lower heap size limit with faster marking (GH-127519)
* Faster marking of reachable objects * Changes calculation of work to do and work done. * Merges transitive closure calculations
Diffstat (limited to 'Objects')
-rw-r--r--Objects/dictobject.c4
-rw-r--r--Objects/genobject.c69
-rw-r--r--Objects/typeobject.c13
3 files changed, 17 insertions, 69 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 1c9f864..de518b8 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -7064,9 +7064,7 @@ int
PyObject_VisitManagedDict(PyObject *obj, visitproc visit, void *arg)
{
PyTypeObject *tp = Py_TYPE(obj);
- if((tp->tp_flags & Py_TPFLAGS_MANAGED_DICT) == 0) {
- return 0;
- }
+ assert(tp->tp_flags & Py_TPFLAGS_MANAGED_DICT);
if (tp->tp_flags & Py_TPFLAGS_INLINE_VALUES) {
PyDictValues *values = _PyObject_InlineValues(obj);
if (values->valid) {
diff --git a/Objects/genobject.c b/Objects/genobject.c
index e87f199..33679af 100644
--- a/Objects/genobject.c
+++ b/Objects/genobject.c
@@ -882,25 +882,7 @@ PyTypeObject PyGen_Type = {
gen_methods, /* tp_methods */
gen_memberlist, /* tp_members */
gen_getsetlist, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
-
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
- 0, /* tp_free */
- 0, /* tp_is_gc */
- 0, /* tp_bases */
- 0, /* tp_mro */
- 0, /* tp_cache */
- 0, /* tp_subclasses */
- 0, /* tp_weaklist */
- 0, /* tp_del */
- 0, /* tp_version_tag */
- _PyGen_Finalize, /* tp_finalize */
+ .tp_finalize = _PyGen_Finalize,
};
static PyObject *
@@ -1242,24 +1224,7 @@ PyTypeObject PyCoro_Type = {
coro_methods, /* tp_methods */
coro_memberlist, /* tp_members */
coro_getsetlist, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
- 0, /* tp_free */
- 0, /* tp_is_gc */
- 0, /* tp_bases */
- 0, /* tp_mro */
- 0, /* tp_cache */
- 0, /* tp_subclasses */
- 0, /* tp_weaklist */
- 0, /* tp_del */
- 0, /* tp_version_tag */
- _PyGen_Finalize, /* tp_finalize */
+ .tp_finalize = _PyGen_Finalize,
};
static void
@@ -1464,7 +1429,6 @@ typedef struct _PyAsyncGenWrappedValue {
(assert(_PyAsyncGenWrappedValue_CheckExact(op)), \
_Py_CAST(_PyAsyncGenWrappedValue*, (op)))
-
static int
async_gen_traverse(PyObject *self, visitproc visit, void *arg)
{
@@ -1673,24 +1637,7 @@ PyTypeObject PyAsyncGen_Type = {
async_gen_methods, /* tp_methods */
async_gen_memberlist, /* tp_members */
async_gen_getsetlist, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
- 0, /* tp_free */
- 0, /* tp_is_gc */
- 0, /* tp_bases */
- 0, /* tp_mro */
- 0, /* tp_cache */
- 0, /* tp_subclasses */
- 0, /* tp_weaklist */
- 0, /* tp_del */
- 0, /* tp_version_tag */
- _PyGen_Finalize, /* tp_finalize */
+ .tp_finalize = _PyGen_Finalize,
};
@@ -1935,16 +1882,6 @@ PyTypeObject _PyAsyncGenASend_Type = {
PyObject_SelfIter, /* tp_iter */
async_gen_asend_iternext, /* tp_iternext */
async_gen_asend_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
.tp_finalize = async_gen_asend_finalize,
};
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 2068d6a..cc95b98 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -2355,6 +2355,16 @@ subtype_traverse(PyObject *self, visitproc visit, void *arg)
return 0;
}
+
+static int
+plain_object_traverse(PyObject *self, visitproc visit, void *arg)
+{
+ PyTypeObject *type = Py_TYPE(self);
+ assert(type->tp_flags & Py_TPFLAGS_MANAGED_DICT);
+ Py_VISIT(type);
+ return PyObject_VisitManagedDict(self, visit, arg);
+}
+
static void
clear_slots(PyTypeObject *type, PyObject *self)
{
@@ -4147,6 +4157,9 @@ type_new_descriptors(const type_new_ctx *ctx, PyTypeObject *type)
assert((type->tp_flags & Py_TPFLAGS_MANAGED_DICT) == 0);
type->tp_flags |= Py_TPFLAGS_MANAGED_DICT;
type->tp_dictoffset = -1;
+ if (type->tp_basicsize == sizeof(PyObject)) {
+ type->tp_traverse = plain_object_traverse;
+ }
}
type->tp_basicsize = slotoffset;