-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
gh-117958: Expose JIT code via access method in experimental UOpExecutor #117959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6838308
7be0d85
21b547e
87f1d74
4b13419
bc9284a
bf5bd37
23bbe83
7019c1c
aa5930a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Added a ``get_jit_code()`` method to access JIT compiled machine code from the UOp Executor when the experimental JIT is enabled. Patch | ||
| by Anthony Shaw. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -394,6 +394,29 @@ executor_traverse(PyObject *o, visitproc visit, void *arg) | |
| return 0; | ||
| } | ||
|
|
||
| static PyObject * | ||
| get_jit_code(PyObject *self, PyObject *Py_UNUSED(ignored)) | ||
| { | ||
| #ifndef _Py_JIT | ||
| PyErr_SetString(PyExc_RuntimeError, "JIT support not enabled."); | ||
| return NULL; | ||
| #else | ||
| _PyExecutorObject *executor = (_PyExecutorObject *)self; | ||
| if (executor->jit_code == NULL || executor->jit_size == 0) { | ||
| Py_RETURN_NONE; | ||
| } | ||
| return PyBytes_FromStringAndSize(executor->jit_code, executor->jit_size); | ||
| #endif | ||
| } | ||
|
|
||
| static PyMethodDef uop_executor_methods[] = { | ||
| { "is_valid", is_valid, METH_NOARGS, NULL }, | ||
| { "get_jit_code", get_jit_code, METH_NOARGS, NULL}, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm happy to merge at this point, but did you consider putting this line inside |
||
| { "get_opcode", get_opcode, METH_NOARGS, NULL }, | ||
| { "get_oparg", get_oparg, METH_NOARGS, NULL }, | ||
| { NULL, NULL }, | ||
| }; | ||
|
|
||
| static int | ||
| executor_is_gc(PyObject *o) | ||
| { | ||
|
|
@@ -411,7 +434,7 @@ PyTypeObject _PyUOpExecutor_Type = { | |
| .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION | Py_TPFLAGS_HAVE_GC, | ||
| .tp_dealloc = (destructor)uop_dealloc, | ||
| .tp_as_sequence = &uop_as_sequence, | ||
| .tp_methods = executor_methods, | ||
| .tp_methods = uop_executor_methods, | ||
| .tp_traverse = executor_traverse, | ||
| .tp_clear = executor_clear, | ||
| .tp_is_gc = executor_is_gc, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.