Skip to content

Commit 43c4e2d

Browse files
DinoVfacebook-github-bot
authored andcommitted
Assign type version when immortalizing heap
Summary: This causes us to assign version numbers for all types when we are immortalizing the heap. Reviewed By: mpage Differential Revision: D42935864 fbshipit-source-id: 021b36b
1 parent 3f8c658 commit 43c4e2d

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

Cinder/Include/cinder/exports.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ PyAPI_FUNC(PyObject *) Ci_Tuple_Repeat(PyTupleObject *, Py_ssize_t);
9191

9292
#define Ci_Py_TPFLAGS_FROZEN (1UL << 21)
9393

94+
PyAPI_FUNC(int) Ci_Type_AssignVersionTag(PyTypeObject *);
95+
9496
// Implementation in Python/bltinmodule.c
9597
PyObject *
9698
builtin_next(PyObject *self, PyObject *const *args, Py_ssize_t nargs);

Modules/gcmodule.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "pycore_pyerrors.h"
3232
#include "pycore_pystate.h" // _PyThreadState_GET()
3333
#include "pydtrace.h"
34+
#include "cinder/exports.h"
3435

3536
typedef struct _gc_runtime_state GCState;
3637

@@ -2039,6 +2040,9 @@ immortalize_object(PyObject *obj, PyObject * /* unused */ args)
20392040
PyObject_Hash(obj);
20402041
}
20412042

2043+
if (PyType_Check(obj)) {
2044+
Ci_Type_AssignVersionTag((PyTypeObject *)obj);
2045+
}
20422046
if (!_PyImmortal_RecursiveHeapWalk) {
20432047
return 0;
20442048
}

Objects/typeobject.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,11 @@ assign_version_tag(struct type_cache *cache, PyTypeObject *type)
529529
return 1;
530530
}
531531

532+
int
533+
Ci_Type_AssignVersionTag(PyTypeObject *type) {
534+
return assign_version_tag(get_type_cache(), type);
535+
}
536+
532537

533538
static PyMemberDef type_members[] = {
534539
{"__basicsize__", T_PYSSIZET, offsetof(PyTypeObject,tp_basicsize),READONLY},

0 commit comments

Comments
 (0)