-
Notifications
You must be signed in to change notification settings - Fork 1.4k
sys._jit #6779
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
sys._jit #6779
Conversation
📝 WalkthroughWalkthroughA new Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@crates/vm/src/stdlib/sys.rs`:
- Around line 7-29: Change the is_available() implementation in the _jit module
(sys_jit::is_available) to reflect the compile-time "jit" Cargo feature instead
of always returning false; replace the constant false return with cfg!(feature =
"jit") so the function reports JIT capability based on build configuration,
while leaving is_enabled() and is_active() as false for now.
| #[pymodule(name = "_jit")] | ||
| mod sys_jit { | ||
| /// Return True if the current Python executable supports JIT compilation, | ||
| /// and False otherwise. | ||
| #[pyfunction] | ||
| const fn is_available() -> bool { | ||
| false // RustPython has no JIT | ||
| } | ||
|
|
||
| /// Return True if JIT compilation is enabled for the current Python process, | ||
| /// and False otherwise. | ||
| #[pyfunction] | ||
| const fn is_enabled() -> bool { | ||
| false // RustPython has no JIT | ||
| } | ||
|
|
||
| /// Return True if the topmost Python frame is currently executing JIT code, | ||
| /// and False otherwise. | ||
| #[pyfunction] | ||
| const fn is_active() -> bool { | ||
| false // RustPython has no JIT | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
echo "=== Checking root Cargo.toml for jit feature ==="
cat Cargo.toml | grep -A 50 "\[features\]" | head -60
echo ""
echo "=== Searching for rustpython-jit dependency ==="
rg 'rustpython-jit' --type toml -B 2 -A 2
echo ""
echo "=== Checking vm/Cargo.toml for jit feature ==="
fd -t f 'Cargo.toml' | xargs grep -l 'jit' 2>/dev/null
echo ""
echo "=== Checking for existing JIT implementation ==="
rg 'feature.*jit' --type rs | head -20
echo ""
echo "=== Looking at sys.rs lines 1580-1590 for integration ==="
sed -n '1575,1595p' crates/vm/src/stdlib/sys.rsRepository: RustPython/RustPython
Length of output: 4150
🏁 Script executed:
#!/bin/bash
echo "=== Searching for cfg! usage in sys.rs ==="
rg 'cfg!' crates/vm/src/stdlib/sys.rs -A 2
echo ""
echo "=== Checking for feature-gated functions in stdlib ==="
rg '#\[cfg\(feature' crates/vm/src/stdlib/ -A 3 | head -40
echo ""
echo "=== Looking for const fn with conditional compilation ==="
rg 'const fn' crates/vm/src/ -A 3 | grep -B 1 -A 2 'cfg'
echo ""
echo "=== Checking rustpython-jit crate structure ==="
ls -la crates/jit/src/ 2>/dev/null || echo "JIT crate not found"
echo ""
echo "=== Searching for feature-gated const values in RustPython ==="
rg '#\[cfg\(' crates/vm/src/ -B 1 -A 3 | grep -A 3 'const' | head -50Repository: RustPython/RustPython
Length of output: 5570
Well-structured JIT stub module following RustPython conventions.
The implementation correctly uses #[pymodule] and #[pyfunction] macros, and the const fn declarations are appropriate for constant return values. The docstrings align with CPython's sys._jit API.
However, given that the jit feature is defined in Cargo.toml and enables rustpython-jit, consider whether is_available() should reflect this at compile time:
#[pyfunction]
const fn is_available() -> bool {
cfg!(feature = "jit")
}This would accurately report JIT capability based on the build configuration, while is_enabled() and is_active() can remain false until runtime JIT activation is implemented.
🤖 Prompt for AI Agents
In `@crates/vm/src/stdlib/sys.rs` around lines 7 - 29, Change the is_available()
implementation in the _jit module (sys_jit::is_available) to reflect the
compile-time "jit" Cargo feature instead of always returning false; replace the
constant false return with cfg!(feature = "jit") so the function reports JIT
capability based on build configuration, while leaving is_enabled() and
is_active() as false for now.
Summary by CodeRabbit
sys._jitsubmodule with three new functions (is_available(),is_enabled(), andis_active()) to check JIT compiler status. This submodule provides standard Python interfaces for checking whether just-in-time compilation support is available, enabled, or currently active in the runtime environment. Note that JIT compilation is not supported, so all functions return false.✏️ Tip: You can customize this high-level summary in your review settings.