GH-104584: Assorted fixes for the optimizer API. (GH-105683)

* Add test for long loops

* Clear ENTER_EXECUTOR when deopting code objects.
This commit is contained in:
Mark Shannon 2023-06-19 10:32:20 +01:00 committed by GitHub
parent 4426279a43
commit 581619941e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 298 additions and 204 deletions

View file

@ -840,6 +840,15 @@ set_optimizer(PyObject *self, PyObject *opt)
Py_RETURN_NONE;
}
static PyObject *
get_optimizer(PyObject *self, PyObject *Py_UNUSED(ignored))
{
PyObject *opt = (PyObject *)PyUnstable_GetOptimizer();
if (opt == NULL) {
Py_RETURN_NONE;
}
return opt;
}
static int _pending_callback(void *arg)
{
@ -982,6 +991,7 @@ static PyMethodDef module_functions[] = {
{"iframe_getcode", iframe_getcode, METH_O, NULL},
{"iframe_getline", iframe_getline, METH_O, NULL},
{"iframe_getlasti", iframe_getlasti, METH_O, NULL},
{"get_optimizer", get_optimizer, METH_NOARGS, NULL},
{"set_optimizer", set_optimizer, METH_O, NULL},
{"get_counter_optimizer", get_counter_optimizer, METH_NOARGS, NULL},
{"pending_threadfunc", _PyCFunction_CAST(pending_threadfunc),