Skip to content

Commit 5d7bbfc

Browse files
committed
test(jit): strengthen side trace import coverage
1 parent 58be20c commit 5d7bbfc

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

src/vm/jit/deopt.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pub(crate) struct SideTraceImport {
4949
pub(crate) parent_exit: SsaExitId,
5050
pub(crate) stack_depth: usize,
5151
pub(crate) local_count: usize,
52+
pub(crate) dirty_locals: Vec<bool>,
5253
pub(crate) args: Vec<SsaMaterialization>,
5354
}
5455

@@ -103,6 +104,7 @@ pub(crate) fn side_trace_import(
103104
parent_exit,
104105
stack_depth: exit.stack.len(),
105106
local_count: exit.locals.len(),
107+
dirty_locals: exit.dirty_locals.clone(),
106108
args: exit.stack.iter().chain(&exit.locals).cloned().collect(),
107109
})
108110
}
@@ -152,6 +154,7 @@ mod tests {
152154
assert_eq!(import.parent_exit, exit_id);
153155
assert_eq!(import.stack_depth, 1);
154156
assert_eq!(import.local_count, 1);
157+
assert_eq!(import.dirty_locals, vec![true]);
155158
assert_eq!(
156159
import.args,
157160
vec![

tests/jit/jit_tests.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,14 +2184,14 @@ fn trace_jit_reports_exact_parent_exit_profiles() {
21842184
return;
21852185
}
21862186
let source = r#"
2187+
fn choose(i) {
2188+
if i % 2 == 0 => { 3 } else => { 5 }
2189+
}
2190+
21872191
let mut i = 0;
21882192
let mut total = 0;
21892193
while i < 64 {
2190-
if i % 2 == 0 {
2191-
total = total + 3;
2192-
} else {
2193-
total = total + 5;
2194-
}
2194+
total = total + choose(i);
21952195
i = i + 1;
21962196
}
21972197
total;
@@ -2221,6 +2221,13 @@ fn trace_jit_reports_exact_parent_exit_profiles() {
22212221
assert!(profile.exit_id < parent.ssa_exit_count() as u32);
22222222
assert!(profile.executions > 0);
22232223
}
2224+
assert!(
2225+
snapshot.exit_profiles.iter().any(|profile| {
2226+
snapshot.traces[profile.parent_trace_id].frame_key != u64::MAX && profile.executions > 1
2227+
}),
2228+
"expected a repeated exact exit inside a callable frame:\n{}",
2229+
vm.dump_jit_info()
2230+
);
22242231
}
22252232

22262233
#[test]

0 commit comments

Comments
 (0)