Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c6b6842
fix jit
youknowone Mar 4, 2026
b379239
vm: complete specialized opcode dispatch paths
youknowone Mar 4, 2026
bdeca2b
vm: cache LOAD_GLOBAL with dict entry hints
youknowone Mar 4, 2026
ca3814a
vm: align adaptive specialization counters with CPython backoff
youknowone Mar 4, 2026
f04bf22
vm: apply cooldown counter on specialization success paths
youknowone Mar 4, 2026
02a1495
vm: retain LOAD_GLOBAL specializations on misses
youknowone Mar 4, 2026
13125d8
vm: keep attr and call specializations on guard misses
youknowone Mar 4, 2026
c7007b5
vm: retain store-attr and store-subscr specializations on misses
youknowone Mar 4, 2026
453294d
vm: retain specialization opcodes on generic fallback paths
youknowone Mar 4, 2026
b8f6cc2
vm: align jump-backward specialization defaults with CPython
youknowone Mar 4, 2026
7bfa961
vm: retain exact-args call specializations on misses
youknowone Mar 4, 2026
c852994
vm: retain SEND_GEN specialization on non-coroutine sends
youknowone Mar 4, 2026
1a1bbf5
vm: specialize list.append calls like CPython CALL_LIST_APPEND
youknowone Mar 4, 2026
bdd87f4
vm: set cooldown on LOAD_ATTR_CLASS specialization
youknowone Mar 4, 2026
696e57a
vm: specialize bound method object CALL paths
youknowone Mar 4, 2026
3dc64cc
vm: specialize CALL_KW for bound method objects
youknowone Mar 4, 2026
f220a24
vm: use current-state function version for CALL_KW specialization
youknowone Mar 4, 2026
a66c706
vm: align CALL/CALL_KW pyfunction specialization with CPython
youknowone Mar 4, 2026
59545f5
vm: drop call-site identity caches in generic CALL specializations
youknowone Mar 4, 2026
f8eebec
vm: align builtin type call specializations with CPython guards
youknowone Mar 4, 2026
58bb1ea
vm: align builtin CALL guards with CPython self_or_null semantics
youknowone Mar 4, 2026
157a2c3
vm: require exact list in CALL_LIST_APPEND fast path
youknowone Mar 4, 2026
cae26d4
vm: align CALL builtin/class specialization flow with CPython
youknowone Mar 4, 2026
0d01f7e
vm: tighten len/isinstance CALL specializations to builtin guards
youknowone Mar 4, 2026
22cccae
vm: gate CALL_BUILTIN_CLASS on type vectorcall like CPython
youknowone Mar 4, 2026
30e8a75
vm: run non-py CALL specializations via direct vectorcall
youknowone Mar 4, 2026
da36859
vm: align class-call specialization branching with CPython
youknowone Mar 4, 2026
42d81ff
Fix CI: disable ForIterGen, tighten CALL guards
youknowone Mar 4, 2026
d464119
vm: restore FOR_ITER_GEN specialization and tuple index parity
youknowone Mar 4, 2026
0f044d6
Add datastack-backed FastLocals for non-generator frames
youknowone Mar 4, 2026
cc3fd09
Drop read lock before key_eq in dict get_hint
youknowone Mar 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix jit
  • Loading branch information
youknowone committed Mar 4, 2026
commit c6b6842e71f183c6d47def8e3b894e41685317b3
13 changes: 11 additions & 2 deletions crates/jit/src/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,18 @@ impl<'a, 'b> FunctionCompiler<'a, 'b> {
func_ref: FuncRef,
bytecode: &CodeObject<C>,
) -> Result<(), JitCompileError> {
// JIT should consume a stable instruction stream: de-specialized opcodes
// with zeroed CACHE entries, not runtime-mutated quickened code.
let clean_instructions: bytecode::CodeUnits = bytecode
.instructions
.original_bytes()
.as_slice()
.try_into()
.map_err(|_| JitCompileError::BadBytecode)?;

let mut label_targets = BTreeSet::new();
let mut target_arg_state = OpArgState::default();
for (offset, &raw_instr) in bytecode.instructions.iter().enumerate() {
for (offset, &raw_instr) in clean_instructions.iter().enumerate() {
let (instruction, arg) = target_arg_state.get(raw_instr);
if let Some(target) = Self::instruction_target(offset as u32, instruction, arg)? {
label_targets.insert(target);
Expand All @@ -223,7 +232,7 @@ impl<'a, 'b> FunctionCompiler<'a, 'b> {
// Track whether we have "returned" in the current block
let mut in_unreachable_code = false;

for (offset, &raw_instr) in bytecode.instructions.iter().enumerate() {
for (offset, &raw_instr) in clean_instructions.iter().enumerate() {
let label = Label(offset as u32);
let (instruction, arg) = arg_state.get(raw_instr);

Expand Down
9 changes: 6 additions & 3 deletions crates/vm/src/builtins/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -727,10 +727,12 @@ impl PyFunction {

#[pygetset(setter)]
fn set___code__(&self, code: PyRef<PyCode>, vm: &VirtualMachine) {
#[cfg(feature = "jit")]
let mut jit_guard = self.jitted_code.lock();
self.code.swap_to_temporary_refs(code, vm);
#[cfg(feature = "jit")]
{
*self.jitted_code.lock() = None;
*jit_guard = None;
}
self.func_version.store(0, Relaxed);
}
Expand Down Expand Up @@ -968,15 +970,16 @@ impl PyFunction {
#[cfg(feature = "jit")]
#[pymethod]
fn __jit__(zelf: PyRef<Self>, vm: &VirtualMachine) -> PyResult<()> {
if zelf.jitted_code.lock().is_some() {
let mut jit_guard = zelf.jitted_code.lock();
if jit_guard.is_some() {
return Ok(());
}
let arg_types = jit::get_jit_arg_types(&zelf, vm)?;
let ret_type = jit::jit_ret_type(&zelf, vm)?;
let code: &Py<PyCode> = &zelf.code;
let compiled = rustpython_jit::compile(&code.code, &arg_types, ret_type)
.map_err(|err| jit::new_jit_error(err.to_string(), vm))?;
*zelf.jitted_code.lock() = Some(compiled);
*jit_guard = Some(compiled);
Ok(())
}
}
Expand Down