summaryrefslogtreecommitdiffstats
path: root/Tools/cases_generator
Commit message (Collapse)AuthorAgeFilesLines
* gh-98831: register instructions have 0 pushes and pops (#101163)Irit Katriel2023-01-191-0/+1
|
* GH-98831: Implement array support in cases generator (#100912)Guido van Rossum2023-01-173-56/+303
| | | | | | | | You can now write things like this: ``` inst(BUILD_STRING, (pieces[oparg] -- str)) { ... } inst(LIST_APPEND, (list, unused[oparg-1], v -- list, unused[oparg-1])) { ... } ``` Note that array output effects are only partially supported (they must be named `unused` or correspond to an input effect).
* GH-98831: Identify instructions that don't use oparg (#100957)Guido van Rossum2023-01-142-3/+13
| | | | | | | For these the instr_format field uses IX instead of IB. Register instructions use IX, IB, IBBX, IBBB, etc. Also: Include the closing '}' in Block.tokens, for completeness
* GH-98831: Refactor instr format code and change to enum (#100895)Guido van Rossum2023-01-091-51/+53
|
* GH-98831: Add some tests for generate_cases.py (#100763)Guido van Rossum2023-01-061-0/+310
| | | | | | - This doesn't cover everything (far from it) but it's a start. - This uses pytest, which isn't ideal, but was quickest to get started. Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
* GH-98831: Update generate_cases.py: register inst, opcode_metadata.h (#100735)Guido van Rossum2023-01-052-36/+231
| | | | | | | | (These aren't used yet, but may be coming soon, and it's easier to keep this tool the same between branches.) Added a sanity check for all this to compile.c. Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
* GH-98831: Modernize a ton of simpler instructions (#100545)Guido van Rossum2022-12-281-7/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * load_const and load_fast aren't families for now * Don't decref unmoved names * Modernize GET_ANEXT * Modernize GET_AWAITABLE * Modernize ASYNC_GEN_WRAP * Modernize YIELD_VALUE * Modernize POP_EXCEPT (in more than one way) * Modernize PREP_RERAISE_STAR * Modernize LOAD_ASSERTION_ERROR * Modernize LOAD_BUILD_CLASS * Modernize STORE_NAME * Modernize LOAD_NAME * Modernize LOAD_CLASSDEREF * Modernize LOAD_DEREF * Modernize STORE_DEREF * Modernize COPY_FREE_VARS (mark it as done) * Modernize LIST_TO_TUPLE * Modernize LIST_EXTEND * Modernize SET_UPDATE * Modernize SETUP_ANNOTATIONS * Modernize DICT_UPDATE * Modernize DICT_MERGE * Modernize MAP_ADD * Modernize IS_OP * Modernize CONTAINS_OP * Modernize CHECK_EXC_MATCH * Modernize IMPORT_NAME * Modernize IMPORT_STAR * Modernize IMPORT_FROM * Modernize JUMP_FORWARD (mark it as done) * Modernize JUMP_BACKWARD (mark it as done)
* GH-98831: Add DECREF_INPUTS(), expanding to DECREF() each stack input (#100205)Guido van Rossum2022-12-171-1/+5
| | | | | | | | | | | | | | | | | | | The presence of this macro indicates that a particular instruction may be considered for conversion to a register-based format (see https://github.com/faster-cpython/ideas/issues/485). An invariant (currently unchecked) is that `DEOPT_IF()` may only occur *before* `DECREF_INPUTS()`, and `ERROR_IF()` may only occur *after* it. One reason not to check this is that there are a few places where we insert *two* `DECREF_INPUTS()` calls, in different branches of the code. The invariant checking would have to be able to do some flow control analysis to understand this. Note that many instructions, especially specialized ones, can't be converted to use this macro straightforwardly. This is because the generator currently only generates plain `Py_DECREF(variable)` statements, and cannot generate things like `_Py_DECREF_SPECIALIZED()` let alone deal with `_PyList_AppendTakeRef()`.
* GH-100222: Redefine _Py_CODEUNIT as a union to clarify structure of code ↵Mark Shannon2022-12-141-1/+1
| | | | unit. (GH-100223)
* GH-98831: Generate things in the input order (#100123)Guido van Rossum2022-12-081-24/+32
| | | | This makes it easier to see what changed in the generated code when converting an instruction to super or macro.
* GH-98831: Typed stack effects, and more instructions converted (#99764)Guido van Rossum2022-12-082-135/+179
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Stack effects can now have a type, e.g. `inst(X, (left, right -- jump/uint64_t)) { ... }`. Instructions converted to the non-legacy format: * COMPARE_OP * COMPARE_OP_FLOAT_JUMP * COMPARE_OP_INT_JUMP * COMPARE_OP_STR_JUMP * STORE_ATTR * DELETE_ATTR * STORE_GLOBAL * STORE_ATTR_INSTANCE_VALUE * STORE_ATTR_WITH_HINT * STORE_ATTR_SLOT, and complete the store_attr family * Complete the store_subscr family: STORE_SUBSCR{,DICT,LIST_INT} (STORE_SUBSCR was alread half converted, but wasn't using cache effects yet.) * DELETE_SUBSCR * PRINT_EXPR * INTERPRETER_EXIT (a bit weird, ends in return) * RETURN_VALUE * GET_AITER (had to restructure it some) The original had mysterious `SET_TOP(NULL)` before `goto error`. I assume those just account for `obj` having been decref'ed, so I got rid of them in favor of the cleanup implied by `ERROR_IF()`. * LIST_APPEND (a bit unhappy with it) * SET_ADD (also a bit unhappy with it) Various other improvements/refactorings as well.
* GH-98831: Support cache effects in super- and macro instructions (#99601)Guido van Rossum2022-12-033-270/+480
|
* GH-98831: Add `macro` and `op` and their implementation to DSL (#99495)Guido van Rossum2022-11-234-73/+246
| | | | | | | | | | | | | | Newly supported interpreter definition syntax: - `op(NAME, (input_stack_effects -- output_stack_effects)) { ... }` - `macro(NAME) = OP1 + OP2;` Also some other random improvements: - Convert `WITH_EXCEPT_START` to use stack effects - Fix lexer to balk at unrecognized characters, e.g. `@` - Fix moved output names; support object pointers in cache - Introduce `error()` method to print errors - Introduce read_uint16(p) as equivalent to `*p` Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
* GH-98831: Refactor and fix cases generator (#99526)Guido van Rossum2022-11-184-241/+344
| | | | Also complete cache effects for BINARY_SUBSCR family.
* GH-98831: Implement basic cache effects (#99313)Guido van Rossum2022-11-162-72/+154
|
* GH-98686: Get rid of "adaptive" and "quick" instructions (GH-99182)Brandt Bucher2022-11-091-1/+3
|
* GH-98831: Simple input-output stack effects for bytecodes.c (#99120)Guido van Rossum2022-11-082-56/+113
|
* GH-98831: Implement super-instruction generation (#99084)Guido van Rossum2022-11-062-14/+66
| | | Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
* GH-99104: Update headers for bytecodes.c and generate_cases.py (#99112)Guido van Rossum2022-11-051-1/+2
| | | Also tweak the labels near the end of bytecodes.c.
* GH-98831: Auto-generate PREDICTED() macro calls (#99102)Guido van Rossum2022-11-041-0/+7
| | | Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
* GH-98831: Remove redundant extract_cases.py script (GH-99065)Guido van Rossum2022-11-033-338/+0
| | | Debt I owe from PR GH-98830.
* GH-98831: "Generate" the interpreter (#98830)Guido van Rossum2022-11-037-0/+1079
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).