220 Commits
Author SHA1 Message Date
Jeong, YunWon 60d6191e45 fix unparse 2026-02-03 14:16:10 +09:00
Jeong, YunWon 527ae55a7a Update faulthandler to match CPython 3.14.2
- Rewrite faulthandler with live frame walking via
  Frame.previous AtomicPtr chain and thread-local
  CURRENT_FRAME (AtomicPtr) instead of frame snapshots
- Add signal-safe traceback dumping (dump_live_frames,
  dump_frame_from_raw) walking the Frame.previous chain
- Add safe_truncate/dump_ascii for UTF-8 safe string
  truncation in signal handlers
- Refactor write_thread_id to accept thread_id parameter
- Add SA_RESTART for user signal registration, SA_NODEFER
  only when chaining
- Save/restore errno in faulthandler_user_signal
- Add signal re-entrancy guard in trigger_signals to
  prevent recursive handler invocation
- Add thread frame tracking (push/pop/cleanup/reinit)
  with force_unlock fallback for post-fork recovery
- Remove expectedFailure markers for now-passing tests
2026-02-03 13:41:58 +09:00
Jeong, YunWon 8273bf3a4a Fix test_asyncio for windows (#6959) 2026-02-02 15:58:16 +09:00
Jeong, YunWon 153b0da60d automark add reasons to reason-less expectedFailures and handles parent better (#6936) 2026-02-01 22:58:07 +09:00
Jeong, YunWon 97861c6809 Rework exception compiler to use CFG-based handler analysis (#6909)
Move exception handler tracking from compile-time fblock metadata to
a post-codegen CFG analysis pass, matching flowgraph.c's pipeline.

Compiler changes (compile.rs):
- Remove fb_handler, fb_stack_depth, fb_preserve_lasti from FBlockInfo
- Remove handler_stack_depth() and current_except_handler() helpers
- Emit SetupFinally/SetupCleanup/SetupWith/PopBlock pseudo instructions
  instead of manually tracking handlers in fblocks
- Add dead blocks after raise/break/continue/return to prevent
  dead code from corrupting the except stack
- Add missing PopTop after CallIntrinsic1 ImportStar
- Fix async comprehension SetupFinally/GetANext emission order
- Fix try-except* handler: move BUILD_LIST/COPY before handler loop
- Rework unwind_fblock for HandlerCleanup, TryExcept, FinallyTry,
  FinallyEnd, and With/AsyncWith to emit proper PopBlock sequences

New CFG analysis passes (ir.rs):
- mark_except_handlers(): mark blocks targeted by SETUP_* instructions
- label_exception_targets(): walk CFG with except stack to set
  per-instruction handler info and convert POP_BLOCK to NOP
- convert_pseudo_ops(): lower remaining pseudo ops after analysis
- Compute handler entry depth from SETUP_* type in max_stackdepth()
  (SETUP_CLEANUP=+2, SETUP_FINALLY/SETUP_WITH=+1)
- Fix SEND jump_effect from -1 to 0 (receiver stays until END_SEND)
- Add underflow guard for handler stack_depth calculation

Instruction metadata (instruction.rs):
- SetupCleanup/SetupFinally/SetupWith now carry target: Arg<Label>
- Add is_block_push()/is_pop_block() to PseudoInstruction/AnyInstruction
- Fix LoadSpecial stack_effect from (2,2) to (1,1)
- Set Setup* stack_effect_info to (0,0) for fall-through consistency

Fixes 3 test_coroutines expectedFailures:
- test_with_8, test_for_assign_raising_stop_async_iteration{,_2}
2026-02-01 17:53:57 +09:00
Shahar Naveh c771427c38 Use stack_effect_info for getting pop&push count (#6913) 2026-01-31 23:45:46 +09:00
Shahar Naveh 743d6b83d3 Split stack_effect into pushed & popped (#6893) 2026-01-31 16:58:14 +09:00
Jeong, YunWon 8e9d591369 Align GetAwaitable to Python 3.14.2 (#6895) 2026-01-30 12:13:39 +09:00
Jeong, YunWon 95abec4c21 More Load instructions including LoadLocals, LoadFastBorrow (#6886)
* fix stdlib_io

* more scpell dict

* LoadLocals

* LoadFastBorrow

* more ops
2026-01-29 19:33:46 +09:00
Jeong YunWon 8c73f3cb30 emit RESUME 2026-01-26 10:40:22 +09:00
Jeong YunWon 9216500355 reimpl smallint 2026-01-26 10:40:22 +09:00
Jeong, YunWon 7eceb145b1 more optimization (#6860) 2026-01-25 10:18:47 +02:00
Jeong YunWon c0bdb9a3e5 align psuedo ops to 3.14.2 2026-01-24 16:09:40 +09:00
Noa f842fbe25d Use std::fmt::from_fn (#6850)
New in 1.93 - replaces our ad-hoc equivalent types.
2026-01-24 09:21:45 +09:00
Jeong, YunWon af7bbfa104 derive Copy where possible (#6844)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Chores**
* Made many lightweight/internal types trivially copyable to simplify
value handling across the codebase.
* Added a workspace lint to surface missing copy implementations as
warnings.
  * Extended buffer support with explicit retain/release hooks.

* **Bug Fixes**
* Improved diagnostics and debug output for thread/lock acquisition
scenarios.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-01-23 15:24:17 +00:00
ShaharNaveh 2c2b13784e Clippy 2026-01-23 16:41:24 +02:00
ShaharNaveh a9364cbc52 Fix warnings 2026-01-23 16:41:19 +02:00
ShaharNaveh 2ee48bc5aa Seperate between scope exit & unconditional jump opcodes 2026-01-23 14:25:03 +02:00
Jeong, YunWon efce325cbf Fix asyncio related compiler/library issues (#6837)
* Fix socket bytes support

* fix unwind_fblock

* fix posix.sendfile

* fix ssl_write

* Fix SSL ZeroReturn

* fix context

* fix generator

* Enable unittest test_async_case again
2026-01-23 19:59:29 +09:00
Jeong, YunWon 40a43f3210 instruction improvements (#6829)
New Features

Direct small-integer loading (0–255) and locals-loading for faster execution
Async-generator wrapping and improved generator resume behavior
Performance

Faster integer loads and streamlined jump/loop handling for better runtime performance
Bug Fixes

More robust StopIteration handling and stricter init return checks
Corrected iterator cleanup for async and sync loops
Improvements

Aligns loop and jump semantics with CPython 3.14 patterns
2026-01-22 17:25:56 +09:00
Jeong, YunWon a7f2351244 Remove BEFORE_WITH,BINARY_SUBSCR (#6822) 2026-01-21 02:58:24 +09:00
Jeong, YunWon 274e8b4b6b Remove JUMP_IF_NOT_EXC_MATCH, SET_EXC_INFO (#6820) 2026-01-21 01:23:43 +09:00
Jeong, YunWon e0cceaf31c Remove ReturnConst/Break/Continue ops (#6816)
* Remove ReturnConst

* Remove break/continue ops
2026-01-21 00:03:43 +09:00
Jeong, YunWon f0c3e7d51f Remove SUBSCRIPT, JUMP_IF_{TRUE,FALSE}_OR_POP (#6810)
* Align ForIter behavior (incomplete)

* Romove JUMP_IF_{TRUE,FALSE}_OR_POP, subscript

* Remove LoadAssetionError

* Update snapshot for ForIter behavior change
2026-01-20 16:21:23 +09:00
Jeong, YunWonandgithub-actions[bot] 82a8f67c71 Replace custom opcodes with CPython standard sequences (#6794)
* Replace custom opcodes with standard sequences

Remove RustPython-specific opcodes (BuildListFromTuples,
BuildMapForCall, BuildSetFromTuples, BuildTupleFromTuples)
and replace their usage with CPython 3.14 standard opcode
sequences:

- BuildListFromTuples → BUILD_LIST + LIST_EXTEND loop
- BuildSetFromTuples → BUILD_SET + SET_UPDATE loop
- BuildTupleFromTuples → BUILD_LIST + LIST_EXTEND + CALL_INTRINSIC_1(ListToTuple)
- BuildMapForCall → DICT_MERGE loop

Implement missing opcodes:
- ListExtend: Extend list with iterable elements
- SetUpdate: Add iterable elements to set
- DictMerge: Merge dict with duplicate key checking

* Auto-generate: generate_opcode_metadata.py

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-01-20 00:34:46 +09:00
Jeong, YunWon 130bb82a43 LoadClosure as pseudo op (#6789) 2026-01-19 02:45:00 +09:00
Jeong, YunWon 0717b53123 Align CallFunctionEx to 3.14 (#6786) 2026-01-19 00:37:18 +09:00
Jeong, YunWon 1ccd99ea20 use ast namespace (#6769) 2026-01-18 17:30:36 +09:00
Jeong, YunWon eb50246b41 fix annotation (#6767) 2026-01-18 15:24:17 +09:00
Jeong, YunWon 6df3753229 Py 3.14 changes fix (#6755)
* marshal v5

* conditional blclk

* fix jit don't use lossy string

* add varname

* symboltable takes responsibility of __debug__
2026-01-18 01:02:40 +09:00
Jeong, YunWon faeed2cdcc clean up 2026-01-17 19:22:18 +09:00
Jeong, YunWon 566b6f438b PEP 649 annotation phase 4 2026-01-17 19:21:11 +09:00
Jeong, YunWon a78b569d92 PEP 649 annotation phase 3 2026-01-17 19:21:11 +09:00
Jeong, YunWon 353a9f6104 PEP 649 annotation phase 2 2026-01-17 19:21:11 +09:00
Jeong, YunWon 0793bd3d08 co_consts 2026-01-17 19:21:11 +09:00
Jeong, YunWon f4363a6b27 PEP 750 tstring (#6744) 2026-01-17 18:41:40 +09:00
Jeong, YunWon a0ace054f3 Fix asyncio compile (#6739) 2026-01-16 09:12:16 +09:00
Shahar Naveh e3890f9b4a Bytecode pseudo opcodes (#6715) 2026-01-15 02:52:25 +09:00
Jeong, YunWon 29bb8b47cd Super instructions (#6694)
* super instructions

* Fix classcell

* ZeroArg
2026-01-11 17:59:32 +09:00
Shahar Naveh 440b8de763 Move Instruction enum to its own file (#6693)
* Move `Instruction` to its own file

* Fix codegen and frame.rs

* Adjust script
2026-01-11 10:04:24 +09:00
Shahar Naveh 6ff7b3ed27 LoadClassDeref -> LoadFromDictOrDeref (#6692) 2026-01-10 23:16:11 +09:00
Shahar Naveh a400386774 Remove _dis module (#6690)
* Remove `_dis` module

* Adjust CodeFlag
2026-01-10 22:11:53 +09:00
Jeong, YunWonandgithub-actions[bot] aa9fc7fede Pseudo ops (#6678)
* better expect

* pseudo instruction

* Fix CallKw narg

* Auto-format: cargo fmt --all

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-01-10 19:49:58 +09:00
Jeong, YunWonandgithub-actions[bot] de0bc732c9 Replace CallMethod/LoadMethod opcodes with plain Call (#6674)
* implementing call the correct way

stack is [Option<PyObjectRef>]

* fix again

* list custom instructions

* Auto-format: cargo fmt --all

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-01-10 08:25:56 +09:00
Shahar Naveh c2bfdf30bd Assign opcode ids (#6637) 2026-01-09 22:52:47 +09:00
a3425b435e Track symbol table cursors to avoid exhaustion (#6670)
* Handle missing symbol table without panic

* Update symbol table error message

* Track symbol table cursors to avoid exhaustion

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: youknowone <69878+youknowone@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-01-09 06:32:12 +09:00
Shahar Naveh ead7e0c39c Make use of Unary opcodes (#6647)
* Make use of `Unary` opcodes

* Add `Reserved140` opcode

* re-add support for UnaryPositive in JIT

* JIT support for `ToBool` instruction
2026-01-05 23:40:41 +09:00
Jeong, YunWon eee360822c Rework compiler about exception handling (#6638)
* asyncgen

* fix coroutine

* rewrite compiler

* tests

* set pyc magic number
2026-01-04 09:15:38 +09:00
Jeong, YunWon b3b97cac7c fix symtable for named_expressions (#6604)
* check duplicated type parameter

* typealias

* fix self.in_comp_inner_loop_target
2025-12-31 15:02:08 +09:00
Ashwin NarenandJeong YunWon 4cf5697e06 Symboltable updates (#5861)
* symboltable updates

* Fix symboltable

---------

Co-authored-by: Jeong YunWon <jeong@youknowone.org>
2025-12-31 11:57:42 +09:00