summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2023-07-04 16:23:00 (GMT)
committerGitHub <noreply@github.com>2023-07-04 16:23:00 (GMT)
commit318ea2c72e9aed7ac92457c28747eda9424c8327 (patch)
tree76e36a8bfdc7a6702b4fa5f4c7c34944efafc6d6 /Modules
parent80f1c6c49b4cd2bf698eb2bc3d2f3da904880dd2 (diff)
downloadcpython-318ea2c72e9aed7ac92457c28747eda9424c8327.zip
cpython-318ea2c72e9aed7ac92457c28747eda9424c8327.tar.gz
cpython-318ea2c72e9aed7ac92457c28747eda9424c8327.tar.bz2
GH-106360: Support very basic superblock introspection (#106422)
* Add len() and indexing support to uop superblocks.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_testinternalcapi.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/Modules/_testinternalcapi.c b/Modules/_testinternalcapi.c
index 84511d2..52e524a 100644
--- a/Modules/_testinternalcapi.c
+++ b/Modules/_testinternalcapi.c
@@ -858,6 +858,26 @@ get_optimizer(PyObject *self, PyObject *Py_UNUSED(ignored))
return opt;
}
+static PyObject *
+get_executor(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
+{
+
+ if (!_PyArg_CheckPositional("get_executor", nargs, 2, 2)) {
+ return NULL;
+ }
+ PyObject *code = args[0];
+ PyObject *offset = args[1];
+ long ioffset = PyLong_AsLong(offset);
+ if (ioffset == -1 && PyErr_Occurred()) {
+ return NULL;
+ }
+ if (!PyCode_Check(code)) {
+ PyErr_SetString(PyExc_TypeError, "first argument must be a code object");
+ return NULL;
+ }
+ return (PyObject *)PyUnstable_GetExecutor((PyCodeObject *)code, ioffset);
+}
+
static int _pending_callback(void *arg)
{
/* we assume the argument is callable object to which we own a reference */
@@ -1326,6 +1346,7 @@ static PyMethodDef module_functions[] = {
{"iframe_getlasti", iframe_getlasti, METH_O, NULL},
{"get_optimizer", get_optimizer, METH_NOARGS, NULL},
{"set_optimizer", set_optimizer, METH_O, NULL},
+ {"get_executor", _PyCFunction_CAST(get_executor), METH_FASTCALL, NULL},
{"get_counter_optimizer", get_counter_optimizer, METH_NOARGS, NULL},
{"get_uop_optimizer", get_uop_optimizer, METH_NOARGS, NULL},
{"pending_threadfunc", _PyCFunction_CAST(pending_threadfunc),