Skip to content

Commit c30080c

Browse files
committed
debuggable
1 parent a7b761a commit c30080c

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

compiler/codegen/src/ir.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,14 @@ impl CodeInfo {
234234
eprintln!("===BLOCK {}===", block.0);
235235
}
236236
let block = &self.blocks[block];
237-
for i in &block.instructions {
238-
let instr = &i.instr;
239-
let effect = instr.stack_effect(i.arg, false);
237+
for ins in &block.instructions {
238+
let instr = &ins.instr;
239+
let effect = instr.stack_effect(ins.arg, false);
240240
if DEBUG {
241-
let display_arg = if i.target == BlockIdx::NULL {
242-
i.arg
241+
let display_arg = if ins.target == BlockIdx::NULL {
242+
ins.arg
243243
} else {
244-
OpArg(i.target.0)
244+
OpArg(ins.target.0)
245245
};
246246
let instr_display = instr.display(display_arg, self);
247247
eprint!("{instr_display}: {depth} {effect:+} => ");
@@ -256,18 +256,18 @@ impl CodeInfo {
256256
// we don't want to worry about Break/Continue, they use unwinding to jump to
257257
// their targets and as such the stack size is taken care of in frame.rs by setting
258258
// it back to the level it was at when SetupLoop was run
259-
if i.target != BlockIdx::NULL
259+
if ins.target != BlockIdx::NULL
260260
&& !matches!(
261261
instr,
262262
Instruction::Continue { .. } | Instruction::Break { .. }
263263
)
264264
{
265-
let effect = instr.stack_effect(i.arg, true);
265+
let effect = instr.stack_effect(ins.arg, true);
266266
let target_depth = depth.checked_add_signed(effect).unwrap();
267267
if target_depth > maxdepth {
268268
maxdepth = target_depth
269269
}
270-
stackdepth_push(&mut stack, &mut start_depths, i.target, target_depth);
270+
stackdepth_push(&mut stack, &mut start_depths, ins.target, target_depth);
271271
}
272272
depth = new_depth;
273273
if instr.unconditional_branch() {

vm/src/frame.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,10 @@ impl ExecutingFrame<'_> {
486486
) -> FrameResult {
487487
vm.check_signals()?;
488488

489-
flame_guard!(format!("Frame::execute_instruction({:?})", instruction));
489+
flame_guard!(format!(
490+
"Frame::execute_instruction({})",
491+
instruction.display(arg, &self.code.code).to_string()
492+
));
490493

491494
#[cfg(feature = "vm-tracing-logging")]
492495
{
@@ -497,7 +500,10 @@ impl ExecutingFrame<'_> {
497500
}
498501
*/
499502
trace!(" {:#?}", self);
500-
trace!(" Executing op code: {:?}", instruction);
503+
trace!(
504+
" Executing op code: {}",
505+
instruction.display(arg, &self.code.code).to_string()
506+
);
501507
trace!("=======");
502508
}
503509

@@ -1926,6 +1932,7 @@ impl ExecutingFrame<'_> {
19261932
}
19271933

19281934
#[inline]
1935+
#[track_caller] // not a real track_caller but pop_value is not very useful
19291936
fn pop_value(&mut self) -> PyObjectRef {
19301937
match self.state.stack.pop() {
19311938
Some(x) => x,
@@ -1959,6 +1966,7 @@ impl ExecutingFrame<'_> {
19591966

19601967
#[cold]
19611968
#[inline(never)]
1969+
#[track_caller]
19621970
fn fatal(&self, msg: &'static str) -> ! {
19631971
dbg!(self);
19641972
panic!("{}", msg)

0 commit comments

Comments
 (0)