summaryrefslogtreecommitdiffstats
path: root/Tools/cases_generator/generate_cases.py
Commit message (Collapse)AuthorAgeFilesLines
* GH-111485: Delete the old generator code. (GH-113321)Mark Shannon2023-12-211-848/+0
|
* GH-111485: Generate `TARGET` table for computed goto dispatch. (GH-113319)Mark Shannon2023-12-201-1/+0
|
* GH-111485: Generate instruction and uop metadata (GH-113287)Mark Shannon2023-12-201-1/+0
|
* GH-111485: Sort metadata tables for easier checking of future diffs (GH-113101)Mark Shannon2023-12-141-6/+8
|
* GH-111485: Factor out tier 2 code generation from the rest of the ↵Mark Shannon2023-12-121-8/+0
| | | | interpreter code generator (GH-112968)
* GH-111485: Factor out generation of uop IDs from cases generator. (GH-112877)Mark Shannon2023-12-111-1/+1
|
* GH-111485: Factor out opcode ID generator from the main cases generator. ↵Mark Shannon2023-12-081-44/+3
| | | | (GH-112831)
* GH-111485: Separate out parsing, analysis and code-gen phases of tier 1 code ↵Mark Shannon2023-12-071-1/+0
| | | | generator (GH-112299)
* GH-111485: Sort cases in the case generator output (GH-112315)Mark Shannon2023-11-221-1/+5
|
* gh-112287: Speed up Tier 2 (uop) interpreter a little (#112286)Guido van Rossum2023-11-201-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | This makes the Tier 2 interpreter a little faster. I calculated by about 3%, though I hesitate to claim an exact number. This starts by doubling the trace size limit (to 512), making it more likely that loops fit in a trace. The rest of the approach is to only load `oparg` and `operand` in cases that use them. The code generator know when these are used. For `oparg`, it will conditionally emit ``` oparg = CURRENT_OPARG(); ``` at the top of the case block. (The `oparg` variable may be referenced multiple times by the instructions code block, so it must be in a variable.) For `operand`, it will use `CURRENT_OPERAND()` directly instead of referencing the `operand` variable, which no longer exists. (There is only one place where this will be used.)
* gh-110319: Assert type_version != 0 before using it (#112226)Guido van Rossum2023-11-181-2/+2
| | | | | | - Ensure that `assert(type_version != 0);` always comes *before* using `type_version` Also: - In cases_generator, rename `-v` to from `--verbose` to `--viable`
* A few more cases_generator cleanups (#112220)Guido van Rossum2023-11-171-1/+1
|
* GH-111848: Tidy up tier 2 handling of FOR_ITER specialization by using ↵Mark Shannon2023-11-081-1/+1
| | | | DEOPT_IF instead of jumps. (GH-111849)
* GH-111485: Allow arbitrary annotations on instructions and micro-ops. ↵Mark Shannon2023-11-071-1/+4
| | | | (GH-111697)
* gh-111520: Integrate the Tier 2 interpreter in the Tier 1 interpreter (#111428)Guido van Rossum2023-11-011-0/+20
| | | | | | | | | | | - There is no longer a separate Python/executor.c file. - Conventions in Python/bytecodes.c are slightly different -- don't use `goto error`, you must use `GOTO_ERROR(error)` (same for others like `unused_local_error`). - The `TIER_ONE` and `TIER_TWO` symbols are only valid in the generated (.c.h) files. - In Lib/test/support/__init__.py, `Py_C_RECURSION_LIMIT` is imported from `_testcapi`. - On Windows, in debug mode, stack allocation grows from 8MiB to 12MiB. - **Beware!** This changes the env vars to enable uops and their debugging to `PYTHON_UOPS` and `PYTHON_LLTRACE`.
* GH-111485: Use micro-ops to split specialization code from base action ↵Mark Shannon2023-11-011-10/+10
| | | | (GH-111561)
* GH-111485: Remove some special cases from the code generator and bytecodes.c ↵Mark Shannon2023-10-311-15/+10
| | | | (GH-111540)
* gh-109094: replace frame->prev_instr by frame->instr_ptr (#109095)Irit Katriel2023-10-261-4/+4
|
* GH-109214: Convert _SAVE_CURRENT_IP to _SET_IP in tier 2 trace creation. ↵Mark Shannon2023-10-121-3/+3
| | | | (GH-110755)
* gh-109287: fix overrides in cases generator (#110419)Carl Meyer2023-10-051-17/+0
|
* gh-109979: Auto-generate the target for DEOPT_IF() (#110193)Guido van Rossum2023-10-031-3/+1
| | | | | | | | | | | | | | | | In Python/bytecodes.c, you now write ``` DEOPT_IF(condition); ``` The code generator expands this to ``` DEOPT_IF(condition, opcode); ``` where `opcode` is the name of the unspecialized instruction. This works inside macro expansions too. **CAVEAT:** The entire `DEOPT_IF(condition)` statement must be on a single line. If it isn't, the substitution will fail; an error will be printed by the code generator and the C compiler will report some errors.
* gh-104909: Split some more insts into ops (#109943)Guido van Rossum2023-09-271-0/+11
| | | | | | | | | | | | | | | | | | | | These are the most popular specializations of `LOAD_ATTR` and `STORE_ATTR` that weren't already viable uops: * Split LOAD_ATTR_METHOD_WITH_VALUES * Split LOAD_ATTR_METHOD_NO_DICT * Split LOAD_ATTR_SLOT * Split STORE_ATTR_SLOT * Split STORE_ATTR_INSTANCE_VALUE Also: * Add `-v` flag to code generator which prints a list of non-viable uops (easter-egg: it can print execution counts -- see source) * Double _Py_UOP_MAX_TRACE_LENGTH to 128 I had dropped one of the DEOPT_IF() calls! :-(
* Fix typos in docs and comments (#109619)Heinz-Alexander Fuetterer2023-09-201-1/+1
|
* gh-109287: Desugar inst(X) to op(X); macro(X) = X (#109294)Guido van Rossum2023-09-151-141/+71
| | | This makes the internal representation in the code generator simpler: there's a list of ops, and a list of macros, and there's no special-casing needed for ops that aren't macros. (There's now special-casing for ops that are also macros, but that's simpler.)
* gh-109256: allocate opcode IDs for internal opcodes in their own range (#109269)Irit Katriel2023-09-121-11/+23
|
* gh-109214: Rename SAVE_IP to _SET_IP, and similar (#109285)Guido van Rossum2023-09-111-5/+5
| | | | | | | | * Rename SAVE_IP to _SET_IP * Rename EXIT_TRACE to _EXIT_TRACE * Rename SAVE_CURRENT_IP to _SAVE_CURRENT_IP * Rename INSERT to _INSERT (This is for Ken Jin's abstract interpreter) * Rename IS_NONE to _IS_NONE * Rename JUMP_TO_TOP to _JUMP_TO_TOP
* gh-109039: Branch prediction for Tier 2 interpreter (#109038)Guido van Rossum2023-09-111-4/+14
| | | | | | | | | | | This adds a 16-bit inline cache entry to the conditional branch instructions POP_JUMP_IF_{FALSE,TRUE,NONE,NOT_NONE} and their instrumented variants, which is used to keep track of the branch direction. Each time we encounter these instructions we shift the cache entry left by one and set the bottom bit to whether we jumped. Then when it's time to translate such a branch to Tier 2 uops, we use the bit count from the cache entry to decided whether to continue translating the "didn't jump" branch or the "jumped" branch. The counter is initialized to a pattern of alternating ones and zeros to avoid bias. The .pyc file magic number is updated. There's a new test, some fixes for existing tests, and a few miscellaneous cleanups.
* gh-107557: Remove unnecessary SAVE_IP instructions (#108583)Guido van Rossum2023-08-291-3/+2
| | | | | Also remove NOP instructions. The "stubs" are not optimized in this fashion (their SAVE_IP should always be preserved since it's where to jump next, and they don't contain NOPs by their nature).
* gh-104504: Cases generator: enable mypy's `possibly-undefined` error code ↵Alex Waygood2023-08-251-4/+9
| | | | (#108454)
* gh-106581: Split CALL_BOUND_METHOD_EXACT_ARGS into uops (#108462)Guido van Rossum2023-08-251-1/+1
| | | Instead of using `GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS)` we just add the macro elements of the latter to the macro for the former. This requires lengthening the uops array in struct opcode_macro_expansion. (It also required changes to stacking.py that were merged already.)
* gh-105481: remove regen-opcode. Generated _PyOpcode_Caches in regen-cases. ↵Irit Katriel2023-08-231-0/+12
| | | | (#108367)
* Fix spurious diff if the cases generator is run on Windows (#108319)Alex Waygood2023-08-221-1/+1
|
* gh-108216: Cleanup #include in internal header files (#108228)Victor Stinner2023-08-211-1/+1
| | | | | | | | | | | * Add missing includes. * Remove unused includes. * Update old include/symbol names to newer names. * Mention at least one included symbol. * Sort includes. * Update Tools/cases_generator/generate_cases.py used to generated pycore_opcode_metadata.h. * Update Parser/asdl_c.py used to generate pycore_ast.h. * Cleanup also includes in _testcapimodule.c and _testinternalcapi.c.
* gh-108220: Internal header files require Py_BUILD_CORE to be defined (#108221)Victor Stinner2023-08-211-0/+7
| | | | | | | | | * pycore_intrinsics.h does nothing if included twice (add #ifndef and #define). * Update Tools/cases_generator/generate_cases.py to generate the Py_BUILD_CORE test. * _bz2, _lzma, _opcode and zlib extensions now define the Py_BUILD_CORE_MODULE macro to use internal headers (pycore_code.h, pycore_intrinsics.h and pycore_blocks_output_buffer.h).
* gh-104504: cases generator: Add `--warn-unreachable` to the mypy config ↵Alex Waygood2023-08-201-20/+13
| | | | (#108112)
* gh-104504: Run mypy on cases_generator in CI (and blacken the code) (gh-108090)Dong-hee Na2023-08-181-45/+52
| | | Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* gh-106581: Split `CALL_PY_EXACT_ARGS` into uops (#107760)Guido van Rossum2023-08-161-7/+27
| | | | | | | | | | | | * Split `CALL_PY_EXACT_ARGS` into uops This is only the first step for doing `CALL` in Tier 2. The next step involves tracing into the called code object and back. After that we'll have to do the remaining `CALL` specialization. Finally we'll have to deal with `KW_NAMES`. Note: this moves setting `frame->return_offset` directly in front of `DISPATCH_INLINED()`, to make it easier to move it into `_PUSH_FRAME`.
* gh-105481: generate op IDs from bytecode.c instead of hard coding them in ↵Irit Katriel2023-08-161-6/+200
| | | | opcode.py (#107971)
* gh-107557: Setup abstract interpretation (#107847)Ken Jin2023-08-151-2/+60
| | | | Co-authored-by: Guido van Rossum <gvanrossum@users.noreply.github.com> Co-authored-by: Jules <57632293+juliapoo@users.noreply.github.com>
* gh-105481: reduce repetition in opcode metadata generation code (#107942)Irit Katriel2023-08-141-62/+46
|
* gh-106812: Refactor cases_generator to allow uops with array stack effects ↵Guido van Rossum2023-08-041-112/+33
| | | | | (#107564) Introducing a new file, stacking.py, that takes over several responsibilities related to symbolic evaluation of push/pop operations, with more generality.
* Thoroughly refactor the cases generator (#107151)Guido van Rossum2023-07-241-1143/+144
| | | | | | | | | | | | | | This mostly extracts a whole bunch of stuff out of generate_cases.py into separate files, but there are a few other things going on here. - analysis.py: `Analyzer` etc. - instructions.py: `Instruction` etc. - flags.py: `InstructionFlags`, `variable_used`, `variable_used_unspecialized` - formatting.py: `Formatter` etc. - Rename parser.py to parsing.py, to avoid conflict with stdlib parser.py - Blackify most things - Fix most mypy errors - Remove output filenames from Generator state, add them to `write_instructions()` etc. - Fix unit tests
* gh-105540: Show source files relative to root (#106927)Guido van Rossum2023-07-201-4/+10
| | | This restores a corner case: when the generator is run with working directory set to Tools/cases_generator, the source filenames listed in the generated provenance header should be relative to the repo root directory.
* GH-104584: Miscellaneous fixes for -Xuops (GH-106908)Brandt Bucher2023-07-201-0/+2
|
* gh-105481: Generate the opcode lists in dis from data extracted from ↵Irit Katriel2023-07-181-1/+12
| | | | bytecodes.c (#106758)
* Small fixes to code generator (#106845)Guido van Rossum2023-07-181-5/+5
| | | | These repair nits I found in PR gh-106798 (issue gh-106797) and in PR gh-106716 (issue gh-106706).
* gh-106603: Make uop struct a triple (opcode, oparg, operand) (#106794)Guido van Rossum2023-07-171-11/+4
|
* gh-106581: Add 10 new opcodes by allowing `assert(kwnames == NULL)` (#106707)Guido van Rossum2023-07-171-4/+10
| | | | | | | | | | | | | By turning `assert(kwnames == NULL)` into a macro that is not in the "forbidden" list, many instructions that formerly were skipped because they contained such an assert (but no other mention of `kwnames`) are now supported in Tier 2. This covers 10 instructions in total (all specializations of `CALL` that invoke some C code): - `CALL_NO_KW_TYPE_1` - `CALL_NO_KW_STR_1` - `CALL_NO_KW_TUPLE_1` - `CALL_NO_KW_BUILTIN_O` - `CALL_NO_KW_BUILTIN_FAST` - `CALL_NO_KW_LEN` - `CALL_NO_KW_ISINSTANCE` - `CALL_NO_KW_METHOD_DESCRIPTOR_O` - `CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS` - `CALL_NO_KW_METHOD_DESCRIPTOR_FAST`
* gh-106797: Remove warning logs from Python/generated_cases.c.h (gh-106798)Dong-hee Na2023-07-171-3/+11
|
* gh-105540: Convert `pytest` tests of `cases_generator` to regular tests ↵Nikita Sobolev2023-07-161-16/+16
| | | | (#106713)