mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-104584: Clean up and fix uops tests and fix crash (#106492)
The uops test wasn't testing anything by default, and was failing when run with -Xuops. Made the two executor-related context managers global, so TestUops can use them (notably `with temporary_optimizer(opt)`). Made clear_executor() a little more thorough. Fixed a crash upon finalizing a uop optimizer, by adding a `tp_dealloc` handler.
This commit is contained in:
parent
67a798888d
commit
76fac7bce5
2 changed files with 39 additions and 27 deletions
|
@ -532,7 +532,7 @@ uop_optimize(
|
|||
return trace_length;
|
||||
}
|
||||
OBJECT_STAT_INC(optimization_traces_created);
|
||||
_PyUOpExecutorObject *executor = (_PyUOpExecutorObject *)_PyObject_New(&UOpExecutor_Type);
|
||||
_PyUOpExecutorObject *executor = PyObject_New(_PyUOpExecutorObject, &UOpExecutor_Type);
|
||||
if (executor == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -542,18 +542,24 @@ uop_optimize(
|
|||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
uop_opt_dealloc(PyObject *self) {
|
||||
PyObject_Free(self);
|
||||
}
|
||||
|
||||
static PyTypeObject UOpOptimizer_Type = {
|
||||
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
||||
.tp_name = "uop_optimizer",
|
||||
.tp_basicsize = sizeof(_PyOptimizerObject),
|
||||
.tp_itemsize = 0,
|
||||
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION,
|
||||
.tp_dealloc = uop_opt_dealloc,
|
||||
};
|
||||
|
||||
PyObject *
|
||||
PyUnstable_Optimizer_NewUOpOptimizer(void)
|
||||
{
|
||||
_PyOptimizerObject *opt = (_PyOptimizerObject *)_PyObject_New(&UOpOptimizer_Type);
|
||||
_PyOptimizerObject *opt = PyObject_New(_PyOptimizerObject, &UOpOptimizer_Type);
|
||||
if (opt == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue