Files
RustPython/Lib/test
Jeong, YunWon a04189fa34 Align bytecode codegen structure with CPython 3.14 (#7588)
* Align bytecode codegen structure with CPython 3.14

* Bytecode parity - constant folding, annotation ordering, superinstruction alignment

- Add BoolOp constant folding with short-circuit semantics in compile_expression
- Add constant truthiness evaluation for assert statement optimization
- Disable const collection/boolop folding in starred unpack and assignment contexts
- Move annotation block generation after body with AnnotationsPlaceholder splicing
- Reorder insert_superinstructions to run before push_cold_blocks (matching flowgraph.c)
- Lower LOAD_CLOSURE after superinstructions to avoid false LOAD_FAST_LOAD_FAST
- Add ToBool before PopJumpIf in comparisons and chained compare cleanup blocks
- Unify annotation dict building to always use incremental BuildMap + StoreSubscr
- Add TrueDivide constant folding for integer operands
- Fold constant sets to Frozenset (not Tuple) in try_fold_constant_collection
- Add PyVmBag for frozenset constant materialization in code objects
- Add remove_redundant_const_pop_top_pairs pass and peephole const+branch folding
- Emit Nop for skipped constant expressions and constant-true asserts
- Preserve comprehension local ordering by source-order bound name collection
- Simplify annotation scanning in symboltable (remove simple-name gate)

* Fix CI regressions in marshal and fast-local ops

* impl more

* Align bytecode codegen with CPython structure

* Bytecode parity - comprehension/except scope ordering, load_fast_borrow fixes

- Reorder comprehension symbol-table walk so the outermost iterator
  registers its sub_tables in the enclosing scope before the comp
  scope, and rescan elt/ifs in CPython's order. Codegen peeks past the
  outermost iterator's nested scopes to find the comprehension table.
- For plain try/except, emit handler sub_tables before the else block
  so codegen's linear sub_table cursor stays aligned.
- Rename `collect_simple_annotations` to `collect_annotations` and
  evaluate non-simple annotations during __annotate__ compilation to
  preserve source-order side effects while keeping the simple-name
  index stable.
- Dedupe equivalent code constants in `arg_constant` and add a
  structural equality check on `CodeObject`.
- Disable LOAD_FAST_BORROW for the tail end block when a try has a
  bare `except:` clause, and have `new_block` inherit the flag from
  the current block.
- Remove `cfg!(debug_assertions)` guard around the
  `optimize_load_fast_borrow` start-depth check so mismatches are
  handled (return instead of assert) in release builds.
- Collapse nop-only blocks that precede a return epilogue and hoist
  the prior line number into the next real instruction so the
  line table matches.
- Unmark now-passing `test_consts_in_conditionals`,
  `test_load_fast_unknown_simple`,
  `test_load_fast_known_because_already_loaded`, and PEP 646 f3/f4
  annotation checks.

* Bytecode parity - try/except line tracking, assert 0 shape

- In `compile_try_except`, drop the leading Nop and set the end
  block's source range from the last orelse/body statement so line
  events after the try fall on the right line.
- Recognise constant-false asserts as the direct-raise shape (no
  ToBool/PopJumpIfFalse) and flip the test assertion accordingly.
- Extend `remove_redundant_nops_in_blocks` to also look through a
  trailing nop before a return-epilogue pair (LoadConst/ReturnValue
  or LoadSmallInt/ReturnValue) so the epilogue keeps the correct
  line number.
- Rename `preds` to `predecessor_blocks` in the LOAD_FAST_BORROW
  disable pass and add a test-only `debug_late_cfg_trace` helper.
- Regenerate the `nested_double_async_with` snapshot: the tail
  reference to `stop_exc` now emits LOAD_FAST instead of
  LOAD_FAST_BORROW.

* Bytecode parity - iter folding, break/continue line, cold inlining

- Fold a constant list iterable into a constant tuple in for-loop
  iterable position, matching the CPython optimizer, and strip a
  redundant LIST_TO_TUPLE immediately before GET_ITER in the IR
  peephole pass.
- Emit a Nop at the break/continue source range before unwinding
  so line events land on the break/continue statement instead of
  the following instruction.
- Drop `propagate_disable_load_fast_borrow`; the forward propagation
  was over-zealous and the per-block inheritance in `new_block` plus
  the bare-except marker are enough.
- Relax `inline_small_or_no_lineno_blocks` so small exit blocks at
  the tail of a cold block are always inlined, not just return
  epilogues.
- Add codegen tests covering the LIST_TO_TUPLE/GET_ITER peephole and
  the late-CFG trace helper for a for-loop list-literal iterable.
2026-04-18 09:19:11 +09:00
..
2026-03-01 11:36:46 +09:00
2025-08-24 10:36:07 +03:00
2026-02-18 03:10:40 +09:00
2026-02-10 21:00:40 +09:00
2025-04-30 14:33:52 +09:00
2026-02-02 00:43:07 +09:00
2026-02-04 09:53:02 +09:00
2023-04-20 15:36:28 +09:00
2023-03-02 15:01:12 +09:00
2026-02-05 00:21:34 +09:00
2022-10-18 03:26:29 +09:00
2026-01-21 20:44:26 +09:00
2023-03-01 18:06:50 +09:00
2026-03-01 11:36:46 +09:00
2026-02-02 02:02:12 +09:00
2026-02-13 22:15:52 +09:00
2026-01-25 15:20:05 +09:00
2025-03-31 18:49:08 +09:00
2026-01-19 00:04:06 +09:00
2026-02-14 18:27:31 +02:00
2026-02-13 13:36:33 +02:00
2026-02-13 13:36:33 +02:00
2026-02-13 14:13:30 +09:00
2026-01-18 21:33:37 +09:00
2025-03-26 02:24:01 -05:00
2024-06-24 19:00:54 +09:00
2026-02-18 00:43:49 +09:00
2026-02-11 16:50:23 +09:00
2026-01-30 16:39:33 +02:00
2026-02-13 18:06:47 +09:00
2026-02-08 20:36:35 +09:00
2026-01-17 19:22:00 +09:00
2025-09-01 11:19:00 +03:00
2026-02-10 00:48:22 +09:00
fix
2026-02-12 01:01:35 +09:00
2026-02-06 00:15:18 +09:00
2026-02-13 13:36:33 +02:00
2026-01-30 07:48:29 +09:00
2026-03-03 15:20:36 +01:00
2026-03-12 13:24:29 +01:00
2026-02-11 18:38:10 +09:00
2026-02-03 22:10:31 +09:00
2026-02-06 00:15:18 +09:00
2026-02-01 19:45:06 -05:00
2026-02-13 13:55:05 +09:00
2023-03-02 05:56:34 +09:00
2026-03-06 06:00:08 +09:00
2026-02-13 13:55:05 +09:00
2026-02-14 18:19:57 +02:00
2026-03-23 13:10:51 +09:00
2026-03-21 22:49:09 +09:00
2026-01-25 00:18:55 +09:00
2026-01-25 00:18:55 +09:00
2026-01-26 10:40:22 +09:00
2026-03-03 20:00:50 +09:00
2026-02-06 00:15:18 +09:00
2025-04-28 12:29:21 +09:00
2026-02-03 22:10:31 +09:00
2026-03-12 18:08:56 +09:00
2025-08-31 11:58:21 +03:00
2026-02-06 01:14:55 +09:00
2026-02-13 13:36:33 +02:00
2026-02-27 09:44:41 +01:00
2026-04-14 13:04:50 +02:00
2026-02-04 18:32:45 +09:00
2026-03-03 19:57:50 +09:00
2026-02-28 22:50:51 +09:00
2026-02-06 00:15:18 +09:00
2026-01-25 00:18:55 +09:00
2026-02-27 10:05:21 +01:00
2025-04-21 21:11:42 -07:00
2026-02-04 09:53:02 +09:00
2026-01-31 20:51:53 -05:00
2025-12-12 10:37:40 +09:00
2026-02-15 09:02:24 +09:00
2026-02-03 22:10:31 +09:00
2026-02-05 23:50:08 +09:00
2026-02-14 21:40:04 +09:00
2026-03-01 11:36:46 +09:00
2026-02-14 09:18:09 +09:00
2025-03-26 23:12:21 -05:00
2026-03-01 10:42:37 +09:00
2026-03-21 22:49:09 +09:00
2026-03-23 11:31:30 +09:00
2026-02-11 16:57:51 +09:00
2026-02-27 22:59:41 +09:00
2026-03-21 22:49:09 +09:00
2025-06-22 22:36:13 +09:00
2026-02-27 16:53:55 +09:00
2026-03-08 18:06:23 +09:00
2026-03-03 21:58:46 +09:00
2026-02-02 01:20:23 +09:00
2025-01-17 18:04:25 -08:00
2026-01-25 00:18:55 +09:00
2026-01-25 00:18:55 +09:00
2026-02-13 13:44:28 +09:00
2026-01-25 00:18:55 +09:00
2026-02-06 00:15:18 +09:00
2025-12-20 12:17:11 +09:00
2026-02-13 13:42:22 +09:00
2026-01-25 00:18:55 +09:00
2026-02-15 23:44:23 +09:00
2026-02-27 09:49:35 +01:00
2026-02-14 18:18:53 +02:00
2026-03-05 17:25:59 +09:00
2023-04-20 15:36:28 +09:00