-
Notifications
You must be signed in to change notification settings - Fork 0
MyPyC integration #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
1c0839f
feat(mypyc integration): Refactor instruction tables and memory manag…
prasad-kumkar f785ad3
feat: program structure with basic blocks and improve type hints
prasad-kumkar f6139ba
feat: Improved mapper, implement Cython
prasad-kumkar f22add0
refactor: Update instruction handling and memory management for impro…
prasad-kumkar 337c68f
Refactor recompiler for improved performance and maintainability
prasad-kumkar 72446ae
refactor: exclude recompiler context from build
prasad-kumkar bb7b180
refactor: cleanup logs
prasad-kumkar e671540
refactor: update memory management to use bitarray for efficient page…
prasad-kumkar 0e6170f
Merge branch 'feat/mypyc' of https://github.com/chainscore/tsrkit-pvm…
prasad-kumkar 68d5cf9
refactor: add mypy as a requirement for type checking
prasad-kumkar a4220b0
fix: license on1
prasad-kumkar 01d8acf
fix: license typo
prasad-kumkar 826f6eb
fix: block based execution bug, optimised memory, started work on cython
prasad-kumkar 23bd420
refactor: update type hints for mypyc build
prasad-kumkar b66ef0e
fix: uncomment core and recompiler files for MyPyC compilation
prasad-kumkar c37dd54
Refactor PVM instruction handling and memory management
prasad-kumkar 1b1d9f9
CPVM: More shift towards C; refactor instruction handling and optimiz…
prasad-kumkar b817374
feat: more cythonization, instruction handling and optimize utility f…
prasad-kumkar 1360c49
refactor: cythonise alter_acc
prasad-kumkar aa1e0bc
Refactor Cython instruction tables for performance improvements
prasad-kumkar af5385a
feat:iii_reg missed inline
prasad-kumkar d80ccda
Refactor instruction handling in Cython
prasad-kumkar e53fdf2
fix: accessibility compatibiloty
prasad-kumkar 21e4d69
refactor: simplify memory read/write operations in instruction tables
prasad-kumkar 2070b61
fix: remove mypyc from requirements
harsh-csl 67c11b8
changed log level from info to debug
Kartik213 7ae1bff
feat: prepare tsrkit-pvm for PyPI publishing with multi-platform wheels
prasad-kumkar 6a86522
Merge pull request #2 from Chainscore/feat/publish-package
prasad-kumkar 0665f9f
Merge branch 'main' into feat/mypyc
prasad-kumkar 446a6f7
fix: resolve PyPI packaging build issues
prasad-kumkar 553991d
fix: Windows build failure in cibuildwheel
prasad-kumkar f5fdb17
fix: remove explicit empty parameters causing Windows build failure
prasad-kumkar 78292d6
fix: add packaging>=24.2 dependency for setuptools compatibility
prasad-kumkar 9c1e613
fix: resolve packaging version conflict by letting setuptools handle it
prasad-kumkar 669d079
fix: use setuptools<77.0.0 to avoid packaging version conflicts
prasad-kumkar a5adbe5
fix: correct license field format to PEP 621 specification
prasad-kumkar 1c0e0b6
fix: remove pip upgrade from CIBW_BEFORE_BUILD to fix Windows builds
prasad-kumkar c4cb8cb
fix: replace Unicode symbols with ASCII for Windows compatibility
prasad-kumkar c4bbc5a
fix: add tsrkit-asm dependency and ensure both interpreter and recomp…
prasad-kumkar 30a7652
feat: add runtime mode tests for interpreter and recompiler
prasad-kumkar 9f16bf7
fix: use macos-15-intel for x86_64 Intel builds
prasad-kumkar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| from setuptools import setup, find_packages | ||
|
|
||
| if __name__ == "__main__": | ||
| from mypyc.build import mypycify | ||
| from pathlib import Path | ||
|
|
||
| print("MyPyC compilation requested...") | ||
|
|
||
| # Get current directory | ||
| current_dir = Path(__file__).parent | ||
|
|
||
| # List all Python files to compile | ||
| python_files = [] | ||
|
|
||
| target_files = [ | ||
| "tsrkit_pvm/common/utils.py", | ||
| "tsrkit_pvm/common/status.py", | ||
| "tsrkit_pvm/common/constants.py", | ||
| "tsrkit_pvm/core/code.py", | ||
| "tsrkit_pvm/core/mapper.py", | ||
| "tsrkit_pvm/interpreter/pvm.py", | ||
| "tsrkit_pvm/interpreter/program.py", | ||
| "tsrkit_pvm/interpreter/memory.py", | ||
| "tsrkit_pvm/interpreter/instructions/tables/wo_args.py", | ||
| "tsrkit_pvm/interpreter/instructions/tables/i_imm.py", | ||
| "tsrkit_pvm/interpreter/instructions/tables/i_offset.py", | ||
| "tsrkit_pvm/interpreter/instructions/tables/i_reg_i_ewimm.py", | ||
| "tsrkit_pvm/interpreter/instructions/tables/i_reg_i_imm.py", | ||
| "tsrkit_pvm/interpreter/instructions/tables/i_reg_i_imm_i_offset.py", | ||
| "tsrkit_pvm/interpreter/instructions/tables/ii_imm.py", | ||
| "tsrkit_pvm/interpreter/instructions/tables/ii_reg.py", | ||
| "tsrkit_pvm/interpreter/instructions/tables/ii_reg_i_imm.py", | ||
| "tsrkit_pvm/interpreter/instructions/tables/ii_reg_i_offset.py", | ||
| "tsrkit_pvm/interpreter/instructions/tables/ii_reg_ii_imm.py", | ||
| "tsrkit_pvm/interpreter/instructions/tables/iii_reg.py", | ||
| ] | ||
|
|
||
| # Try MyPyC compilation | ||
| ext_modules = [] | ||
| compiled_count = 0 | ||
| failed_count = 0 | ||
|
|
||
| for py_file in target_files: | ||
| try: | ||
| print(f"Compiling {py_file}...") | ||
| mypycified = mypycify([py_file], opt_level="3") | ||
| if mypycified: | ||
| ext_modules.extend(mypycified) | ||
| compiled_count += 1 | ||
| print(f"✓ Successfully compiled {py_file}") | ||
| else: | ||
| failed_count += 1 | ||
| print(f"✗ Failed to compile {py_file}") | ||
| except Exception as e: | ||
| failed_count += 1 | ||
| print(f"✗ Error compiling {py_file}: {e}") | ||
|
|
||
| print(f"\nCompilation summary: {compiled_count} succeeded, {failed_count} failed") | ||
|
|
||
| setup( | ||
| name="tsrkit_pvm", | ||
| packages=find_packages(), | ||
| ext_modules=ext_modules, | ||
| zip_safe=False, | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,30 @@ | ||
| from typing import Any | ||
| from typing import Any, Union, overload, SupportsIndex | ||
|
|
||
|
|
||
| class ExtendedList(list): | ||
| """List which allows accessing elements out of bound, returns a default value if so""" | ||
|
|
||
| def __init__(self, *args, default=None): | ||
| def __init__(self, *args: Any, default: Any = None) -> None: | ||
| super().__init__(*args) | ||
| self.DEFAULT = default | ||
|
|
||
| def __getitem__(self, index: int | slice): | ||
| if isinstance(index, int): | ||
| if index >= len(self) or index < -len(self): | ||
| return self.DEFAULT | ||
| return super().__getitem__(index) | ||
| elif isinstance(index, slice): | ||
| @overload | ||
| def __getitem__(self, index: SupportsIndex) -> Any: ... | ||
|
|
||
| @overload | ||
| def __getitem__(self, index: slice) -> list[Any]: ... | ||
|
|
||
| def __getitem__(self, index: Union[SupportsIndex, slice]) -> Any: | ||
| if isinstance(index, slice): | ||
| # Handle slice objects properly | ||
| start, stop, step = index.indices(len(self)) | ||
| res = [] | ||
| for i in range(start, stop, step): | ||
| res.append(self.__getitem__(i)) | ||
| return res | ||
| else: | ||
| # Handle int index | ||
| int_index = int(index) | ||
| if int_index >= len(self) or int_index < -len(self): | ||
| return self.DEFAULT | ||
| return super().__getitem__(int_index) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.