Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'upstream/main' into bytecode-enum-named…
…-data
  • Loading branch information
ShaharNaveh committed Mar 3, 2026
commit f9e5530a1b622e0828a9d28c7749b7c912d71ef4
123 changes: 111 additions & 12 deletions crates/vm/src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1453,8 +1453,36 @@ impl ExecutingFrame<'_> {
self.push_value(matched);
Ok(None)
}
Instruction::CompareOp { opname } => self.execute_compare(vm, opname.get(arg)),
Instruction::CompareOp { opname } => {
let op_val = opname.get(arg);
let instr_idx = self.lasti() as usize - 1;
let cache_base = instr_idx + 1;
let counter = self.code.instructions.read_cache_u16(cache_base);
if counter > 0 {
unsafe {
self.code
.instructions
.write_cache_u16(cache_base, counter - 1);
}
} else {
self.specialize_compare_op(vm, op_val, instr_idx, cache_base);
}
self.execute_compare(vm, op_val)
}
Instruction::ContainsOp { invert } => {
let instr_idx = self.lasti() as usize - 1;
let cache_base = instr_idx + 1;
let counter = self.code.instructions.read_cache_u16(cache_base);
if counter > 0 {
unsafe {
self.code
.instructions
.write_cache_u16(cache_base, counter - 1);
}
} else {
self.specialize_contains_op(vm, instr_idx, cache_base);
}

let b = self.pop_value();
let a = self.pop_value();

Expand Down Expand Up @@ -1870,7 +1898,21 @@ impl ExecutingFrame<'_> {
Ok(None)
}
Instruction::LoadAttr { namei } => self.load_attr(vm, namei.get(arg)),
Instruction::LoadSuperAttr { namei } => self.load_super_attr(vm, namei.get(arg)),
Instruction::LoadSuperAttr { namei } => {
let instr_idx = self.lasti() as usize - 1;
let cache_base = instr_idx + 1;
let counter = self.code.instructions.read_cache_u16(cache_base);
if counter > 0 {
unsafe {
self.code
.instructions
.write_cache_u16(cache_base, counter - 1);
}
} else {
self.specialize_load_super_attr(vm, namei.get(arg), instr_idx, cache_base);
}
self.load_super_attr(vm, namei.get(arg))
}
Instruction::LoadBuildClass => {
let build_class = if let Some(builtins_dict) = self.builtins_dict {
builtins_dict
Expand Down Expand Up @@ -2117,6 +2159,18 @@ impl ExecutingFrame<'_> {
}
Instruction::LoadGlobal { namei } => {
let oparg = namei.get(arg);
let instr_idx = self.lasti() as usize - 1;
let cache_base = instr_idx + 1;
let counter = self.code.instructions.read_cache_u16(cache_base);
if counter > 0 {
unsafe {
self.code
.instructions
.write_cache_u16(cache_base, counter - 1);
}
} else {
self.specialize_load_global(vm, oparg, instr_idx, cache_base);
}
let name = &self.code.names[(oparg >> 1) as usize];
let x = self.load_global_or_builtin(name, vm)?;
self.push_value(x);
Expand Down Expand Up @@ -2590,7 +2644,21 @@ impl ExecutingFrame<'_> {
self.execute_set_function_attribute(vm, flag.get(arg))
}
Instruction::SetupAnnotations => self.setup_annotations(vm),
Instruction::StoreAttr { namei } => self.store_attr(vm, namei.get(arg)),
Instruction::StoreAttr { namei } => {
let instr_idx = self.lasti() as usize - 1;
let cache_base = instr_idx + 1;
let counter = self.code.instructions.read_cache_u16(cache_base);
if counter > 0 {
unsafe {
self.code
.instructions
.write_cache_u16(cache_base, counter - 1);
}
} else {
self.specialize_store_attr(vm, idx.get(arg), instr_idx, cache_base);
}
self.store_attr(vm, namei.get(arg))
}
Instruction::StoreDeref { i } => {
let value = self.pop_value();
self.state.cells_frees[i.get(arg) as usize].set(Some(value));
Expand Down Expand Up @@ -2654,7 +2722,21 @@ impl ExecutingFrame<'_> {
container.set_item(&*slice, value, vm)?;
Ok(None)
}
Instruction::StoreSubscr => self.execute_store_subscript(vm),
Instruction::StoreSubscr => {
let instr_idx = self.lasti() as usize - 1;
let cache_base = instr_idx + 1;
let counter = self.code.instructions.read_cache_u16(cache_base);
if counter > 0 {
unsafe {
self.code
.instructions
.write_cache_u16(cache_base, counter - 1);
}
} else {
self.specialize_store_subscr(vm, instr_idx, cache_base);
}
self.execute_store_subscript(vm)
}
Instruction::Swap { i: index } => {
let len = self.state.stack.len();
debug_assert!(len > 0, "stack underflow in SWAP");
Expand Down Expand Up @@ -2694,7 +2776,21 @@ impl ExecutingFrame<'_> {
let args = counts.get(arg);
self.execute_unpack_ex(vm, args.before, args.after)
}
Instruction::UnpackSequence { count } => self.unpack_sequence(count.get(arg), vm),
Instruction::UnpackSequence { count } => {
let instr_idx = self.lasti() as usize - 1;
let cache_base = instr_idx + 1;
let counter = self.code.instructions.read_cache_u16(cache_base);
if counter > 0 {
unsafe {
self.code
.instructions
.write_cache_u16(cache_base, counter - 1);
}
} else {
self.specialize_unpack_sequence(vm, instr_idx, cache_base);
}
self.unpack_sequence(count.get(arg), vm)
}
Instruction::WithExceptStart => {
// Stack: [..., __exit__, lasti, prev_exc, exc]
// Call __exit__(type, value, tb) and push result
Expand Down Expand Up @@ -7019,7 +7115,7 @@ impl ExecutingFrame<'_> {
self.code.instructions.replace_op(
instr_idx,
Instruction::Call {
nargs: Arg::marker(),
argc: Arg::marker(),
},
);
self.code
Expand All @@ -7035,7 +7131,7 @@ impl ExecutingFrame<'_> {
self.code.instructions.replace_op(
instr_idx,
Instruction::CallKw {
nargs: Arg::marker(),
argc: Arg::marker(),
},
);
self.code
Expand All @@ -7051,7 +7147,7 @@ impl ExecutingFrame<'_> {
self.code.instructions.replace_op(
instr_idx,
Instruction::ForIter {
target: Arg::marker(),
delta: Arg::marker(),
},
);
self.code
Expand Down Expand Up @@ -7207,9 +7303,12 @@ impl ExecutingFrame<'_> {
let instr_idx = self.lasti() as usize - 1;
let cache_base = instr_idx + 1;
unsafe {
self.code
.instructions
.replace_op(instr_idx, Instruction::ContainsOp(Arg::marker()));
self.code.instructions.replace_op(
instr_idx,
Instruction::ContainsOp {
invert: Arg::marker(),
},
);
self.code
.instructions
.write_adaptive_counter(cache_base, ADAPTIVE_BACKOFF_VALUE);
Expand Down Expand Up @@ -7255,7 +7354,7 @@ impl ExecutingFrame<'_> {
self.code.instructions.replace_op(
instr_idx,
Instruction::UnpackSequence {
size: Arg::marker(),
count: Arg::marker(),
},
);
self.code
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.