}
}
-static inline void
-_Py_DECREF_NO_DEALLOC(PyObject *op)
-{
- if (_Py_IsImmortal(op)) {
- _Py_DECREF_IMMORTAL_STAT_INC();
- return;
- }
- _Py_DECREF_STAT_INC();
-#ifdef Py_REF_DEBUG
- _Py_DEC_REFTOTAL(PyInterpreterState_Get());
-#endif
- op->ob_refcnt--;
-#ifdef Py_DEBUG
- if (op->ob_refcnt <= 0) {
- _Py_FatalRefcountError("Expected a positive remaining refcount");
- }
-#endif
-}
-
#else
// TODO: implement Py_DECREF specializations for Py_GIL_DISABLED build
static inline void
Py_DECREF(op);
}
-static inline void
-_Py_DECREF_NO_DEALLOC(PyObject *op)
-{
- Py_DECREF(op);
-}
-
static inline int
_Py_REF_IS_MERGED(Py_ssize_t ob_ref_shared)
{
uint8_t valid;
uint8_t chain_depth; // Must be big enough for MAX_CHAIN_DEPTH - 1.
bool warm;
+ uint8_t pending_deletion;
int32_t index; // Index of ENTER_EXECUTOR (if code isn't NULL, below).
_PyBloomFilter bloom;
_PyExecutorLinkListNode links;
self.assertNotIn("_POP_TOP_INT", uops)
self.assertIn("_POP_TOP_NOP", uops)
+ def test_143026(self):
+ # https://github.com/python/cpython/issues/143026
+
+ result = script_helper.run_python_until_end('-c', textwrap.dedent("""
+ import gc
+ thresholds = gc.get_threshold()
+ try:
+ gc.set_threshold(1)
+
+ def f1():
+ for i in range(5000):
+ globals()[''] = i
+
+ f1()
+ finally:
+ gc.set_threshold(*thresholds)
+ """), PYTHON_JIT="1")
+ self.assertEqual(result[0].rc, 0, result)
+
+
def global_identity(x):
return x
while (ts) {
_PyExecutorObject *current = (_PyExecutorObject *)ts->current_executor;
if (current != NULL) {
- _Py_DECREF_NO_DEALLOC((PyObject *)current);
+ Py_DECREF((PyObject *)current);
}
ts = ts->next;
}
static void
add_to_pending_deletion_list(_PyExecutorObject *self)
{
+ if (self->vm_data.pending_deletion) {
+ return;
+ }
+ self->vm_data.pending_deletion = 1;
PyInterpreterState *interp = PyInterpreterState_Get();
self->vm_data.links.previous = NULL;
self->vm_data.links.next = interp->executor_deletion_list_head;
uint32_t target = 0;
target = Py_IsNone((PyObject *)old_code)
- ? (int)(target_instr - _Py_INTERPRETER_TRAMPOLINE_INSTRUCTIONS_PTR)
+ ? (uint32_t)(target_instr - _Py_INTERPRETER_TRAMPOLINE_INSTRUCTIONS_PTR)
: INSTR_IP(target_instr, old_code);
// Rewind EXTENDED_ARG so that we see the whole thing.
_Py_ExecutorInit(_PyExecutorObject *executor, const _PyBloomFilter *dependency_set)
{
executor->vm_data.valid = true;
+ executor->vm_data.pending_deletion = 0;
for (int i = 0; i < _Py_BLOOM_FILTER_WORDS; i++) {
executor->vm_data.bloom.bits[i] = dependency_set->bits[i];
}
"_PyUnicode_Equal",
"_PyUnicode_JoinArray",
"_Py_CHECK_EMSCRIPTEN_SIGNALS_PERIODICALLY",
- "_Py_DECREF_NO_DEALLOC",
"_Py_ID",
"_Py_IsImmortal",
"_Py_IsOwnedByCurrentThread",