Skip to content
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

reduce check_singals frequency #5281

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
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
38 changes: 27 additions & 11 deletions vm/src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 488,6 @@ impl ExecutingFrame<'_> {
extend_arg: &mut bool,
vm: &VirtualMachine,
) -> FrameResult {
vm.check_signals()?;

flame_guard!(format!(
"Frame::execute_instruction({})",
instruction.display(arg, &self.code.code).to_string()
Expand Down Expand Up @@ -807,6 805,7 @@ impl ExecutingFrame<'_> {
self.unwind_blocks(vm, UnwindReason::Returning { value })
}
bytecode::Instruction::YieldValue => {
vm.check_signals()?;
let value = self.pop_value();
let value = if self.code.flags.contains(bytecode::CodeFlags::IS_COROUTINE) {
PyAsyncGenWrappedValue(value).into_pyobject(vm)
Expand All @@ -815,7 814,10 @@ impl ExecutingFrame<'_> {
};
Ok(Some(ExecutionResult::Yield(value)))
}
bytecode::Instruction::YieldFrom => self.execute_yield_from(vm),
bytecode::Instruction::YieldFrom => {
vm.check_signals()?;
self.execute_yield_from(vm)
}
bytecode::Instruction::SetupAnnotation => self.setup_annotations(vm),
bytecode::Instruction::SetupLoop => {
self.push_block(BlockType::Loop);
Expand Down Expand Up @@ -942,6 944,7 @@ impl ExecutingFrame<'_> {
Ok(None)
}
bytecode::Instruction::WithCleanupFinish => {
vm.check_signals()?;
let block = self.pop_block();
let (reason, prev_exc) = match block.typ {
BlockType::FinallyHandler { reason, prev_exc } => (reason, prev_exc),
Expand All @@ -961,6 964,7 @@ impl ExecutingFrame<'_> {
}
}
bytecode::Instruction::PopBlock => {
vm.check_signals()?;
self.pop_block();
Ok(None)
}
Expand Down Expand Up @@ -1042,6 1046,7 @@ impl ExecutingFrame<'_> {
Ok(None)
}
bytecode::Instruction::EndAsyncFor => {
vm.check_signals()?;
let exc = self.pop_value();
let except_block = self.pop_block(); // pushed by TryExcept unwind
debug_assert_eq!(except_block.level, self.state.stack.len());
Expand Down Expand Up @@ -1097,11 1102,16 @@ impl ExecutingFrame<'_> {
self.execute_method_call(args, vm)
}
bytecode::Instruction::Jump { target } => {
vm.check_signals()?;
self.jump(target.get(arg));
Ok(None)
}
bytecode::Instruction::JumpIfTrue { target } => self.jump_if(vm, target.get(arg), true),
bytecode::Instruction::JumpIfTrue { target } => {
vm.check_signals()?;
self.jump_if(vm, target.get(arg), true)
}
bytecode::Instruction::JumpIfFalse { target } => {
vm.check_signals()?;
self.jump_if(vm, target.get(arg), false)
}
bytecode::Instruction::JumpIfTrueOrPop { target } => {
Expand All @@ -1111,20 1121,26 @@ impl ExecutingFrame<'_> {
self.jump_if_or_pop(vm, target.get(arg), false)
}

bytecode::Instruction::Raise { kind } => self.execute_raise(vm, kind.get(arg)),
bytecode::Instruction::Raise { kind } => {
vm.check_signals()?;
self.execute_raise(vm, kind.get(arg))
}

bytecode::Instruction::Break { target } => self.unwind_blocks(
vm,
UnwindReason::Break {
target: target.get(arg),
},
),
bytecode::Instruction::Continue { target } => self.unwind_blocks(
vm,
UnwindReason::Continue {
target: target.get(arg),
},
),
bytecode::Instruction::Continue { target } => {
vm.check_signals()?;
self.unwind_blocks(
vm,
UnwindReason::Continue {
target: target.get(arg),
},
)
}
bytecode::Instruction::PrintExpr => self.print_expr(vm),
bytecode::Instruction::LoadBuildClass => {
self.push_value(vm.builtins.get_attr(identifier!(vm, __build_class__), vm)?);
Expand Down
Loading