diff options
author | Guido van Rossum <guido@python.org> | 2022-11-03 04:31:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-03 04:31:26 (GMT) |
commit | 41bc101dd6726edc5fbd4a934ea057ec712d5498 (patch) | |
tree | 0d184293ab6e1779873b22d9522250bfef473a31 /Misc | |
parent | 2cfcaf5af602b297fc90086de4d8ac980c7891e2 (diff) | |
download | cpython-41bc101dd6726edc5fbd4a934ea057ec712d5498.zip cpython-41bc101dd6726edc5fbd4a934ea057ec712d5498.tar.gz cpython-41bc101dd6726edc5fbd4a934ea057ec712d5498.tar.bz2 |
GH-98831: "Generate" the interpreter (#98830)
The switch cases (really TARGET(opcode) macros) have been moved from ceval.c to generated_cases.c.h. That file is generated from instruction definitions in bytecodes.c (which impersonates a C file so the C code it contains can be edited without custom support in e.g. VS Code).
The code generator lives in Tools/cases_generator (it has a README.md explaining how it works). The DSL used to describe the instructions is a work in progress, described in https://github.com/faster-cpython/ideas/blob/main/3.12/interpreter_definition.md.
This is surely a work-in-progress. An easy next step could be auto-generating super-instructions.
**IMPORTANT: Merge Conflicts**
If you get a merge conflict for instruction implementations in ceval.c, your best bet is to port your changes to bytecodes.c. That file looks almost the same as the original cases, except instead of `TARGET(NAME)` it uses `inst(NAME)`, and the trailing `DISPATCH()` call is omitted (the code generator adds it automatically).
Diffstat (limited to 'Misc')
-rw-r--r-- | Misc/NEWS.d/next/Build/2022-10-28-22-24-26.gh-issue-98831.IXRCRX.rst | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Build/2022-10-28-22-24-26.gh-issue-98831.IXRCRX.rst b/Misc/NEWS.d/next/Build/2022-10-28-22-24-26.gh-issue-98831.IXRCRX.rst new file mode 100644 index 0000000..db84a7f --- /dev/null +++ b/Misc/NEWS.d/next/Build/2022-10-28-22-24-26.gh-issue-98831.IXRCRX.rst @@ -0,0 +1 @@ +We have new tooling, in ``Tools/cases_generator``, to generate the interpreter switch from a list of opcode definitions. |