Commit Graph

46 Commits

Author SHA1 Message Date
Jeong, YunWon
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, YunWon
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, YunWon
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
Copilot
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 Naren
4cf5697e06 Symboltable updates (#5861)
* symboltable updates

* Fix symboltable

---------

Co-authored-by: Jeong YunWon <jeong@youknowone.org>
2025-12-31 11:57:42 +09:00
Jeong, YunWon
e79a1a1a66 Fix traceback (#6569)
* Fix traceback

* Update traceback from CPython 3.13.11

* unmark test_traceback

* fix code

* fix debug range

* fix tests
2025-12-30 16:58:53 +09:00
Terry Tianlin Luan
1464d5ca43 Adding + Fixing Clippy rules to better align with #[no_std] (#6570)
* * Added alloc_instead_of_core, std_instead_of_alloc, and std_instead_of_core clippy rules
* Manually changed part of the code to use core/alloc

* use clippy --fix to fix issues in stdlib

* * Used clippy --fix to fix issues in vm
* Imported Range in vm/src/anystr.rs

* * Used clippy --fix to fix issues in common
2025-12-30 13:10:14 +09:00
Jeong, YunWon
5b20c458af Implement more except* (#6545)
* clean build documentation

* SetExcInfo

* fix EG subclass

* test_except_star
2025-12-27 23:03:23 +09:00
Shahar Naveh
b704f42158 Reduce usage JumpIfTrueOrPop & JumpIfFalseOrPop opcdes. Refactor compile_compare (#6524)
* Remove `JumpIfTrueOrPop` & `JumpIfFalseOrPop` opcdes

* Use correct instruction name

* Extract `compile_cmpop` to its own method

* Better alignment with CPython code

* Restore `PopJumpIf` instructions

* Revert PopJumpIfFalse for comparisons
2025-12-27 00:16:16 +09:00
Jeong, YunWon
4a6e8fb29e Add except* support (#6530) 2025-12-26 21:54:23 +09:00
Shahar Naveh
bcdf37bef1 Align opcode names in dis (#6526)
* opcodes dis repr like cpython. POP-> POP_TOP

* Adjust frame.rs

* Fix codegen

* snapshots

* Add doc for `PopTop`

* fix jit
2025-12-25 22:17:31 +09:00
Shahar Naveh
569bee103f Use ruff_python_ast::visitor::Visitor for detecting await (#6466) 2025-12-22 12:43:58 +09:00
Shahar Naveh
75dcf8042e Tidy codegen::ir::BlockIdx api (#6413)
* Tidy `codegen::ir::BlockIdx` api

* Update crates/codegen/src/ir.rs

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-12-12 20:05:31 +09:00
Jeong, YunWon
bfd873a8b8 a few unreachable->unimplemented, clippy (#6405)
* unreachable -> unimplemented

* Fix clippy on 1.92
2025-12-12 01:13:28 +09:00
Jeong, YunWon
98fff96f1c __doc__ handing in the right way (#6390) 2025-12-10 20:04:09 +09:00
Shahar Naveh
2b90e826ec Use rust idioms for accessing a Vec in codegen/src/compile.rs (#6326)
* Use rust idioms for accessing a `Vec`

* clippy

* Remove `unsafe`
2025-12-04 09:17:04 +09:00
Shahar Naveh
f49c18578a Move PrintExpr to IntristicFunction1 (#6324) 2025-12-03 21:17:36 +09:00
Shahar Naveh
305fb489e7 Remove ImportNameless bytecode (#6325) 2025-12-03 07:07:33 +09:00
Shahar Naveh
26d5307520 Align f-string related bytecodes with 3.13 (#6321)
* Align `f-string` related bytecodes with 3.13

* Resolve name collision

* Adjust for ruff return value
2025-12-03 07:05:16 +09:00
Shahar Naveh
9130dd8068 Unify BINARY_OP bytecodes (#6317)
* Unify BINARY_OP bytecodes

* Add missing op to `as_inplace`

* Fix doc example

* Fix jit

* Fix doc

* Use correct opname

* Fix dis fmt

* Inplace ops support in JIT
2025-12-02 09:00:26 +09:00
Shahar Naveh
4051becc9e Ensure BuildSlice oparg to be either 2 or 3 (#6313)
* Force `BuildSlice` oparg to be either 2 or 3

* `compile_slice` to return `BuildSliceArgCount`
2025-11-30 09:05:29 +09:00
Shahar Naveh
7d8f0b989c Split TestOperator instruction (#6306)
* Split `TestOperator` inatruction

* Update snapshot

* Set as have label
2025-11-29 09:02:52 +09:00
Shahar Naveh
fef9de22c4 Remove Rotate* & Duplicate* instructions (#6303)
* Remove `Instruction::Duplicate2?`

* Remove `Instruction::Rotate*` instructions

* Fix jit

* Update snapshot
2025-11-29 00:46:27 +09:00
Shahar Naveh
f7ddcd2795 Break after annotation future found (#6284) 2025-11-19 01:00:41 +09:00
Shahar Naveh
7f45ba4c9c Move compiler/codegen -> crates/codegen (#6260) 2025-11-15 18:25:46 +09:00