-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
gh-142913: Add test case for interpreter generator w/ overridden opcodes #142911
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
base: main
Are you sure you want to change the base?
Conversation
e25709a to
40d5d70
Compare
85c6f7e to
506d4b6
Compare
80a2701 to
8fec3b0
Compare
abb5095 to
c5caac6
Compare
| Py_XDECREF(resumes); | ||
| return NULL; | ||
| } | ||
| PyObject *loads = PyLong_FromLong(Test_EvalFrame_Loads); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to decref resumes here. IIRC PyDict_SetItemString doesn't steal a reference to the value; we would leak resumes without it.
| } | ||
| PyObject *loads = PyLong_FromLong(Test_EvalFrame_Loads); | ||
| if (loads == NULL || PyDict_SetItemString(res, "loads", loads) < 0) { | ||
| Py_XDECREF(loads); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to decref res here too.
| Py_XDECREF(loads); | ||
| return NULL; | ||
| } | ||
| Test_EvalFrame_Resumes = Test_EvalFrame_Loads = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to decref loads before returning.
The interpreter generator has long supported giving it multiple bytecodes files where the latter files override opcodes defined in the earlier opcodes. This enables PEP 523 hook users to generate an interpreter loop using the existing opcodes and their own set of customizations. But there've been no test cases that validate this actually works.
This adds such a test case and fixes things up so this practically works. static functions used directly in the interpreter loop are moved into ceval.h. APIs which are used but not exported are marked as exported.
The generated test case is updated as mark of
mark regen-casesso it'll stay in sync as the bytecodes change.