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

YJIT: Fix raw sample stack lengths in exit traces #7728

Merged
merged 1 commit into from Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions yjit.c
Expand Up @@ -186,8 +186,9 @@ rb_yjit_exit_locations_dict(VALUE *yjit_raw_samples, int *yjit_line_samples, int
int line_num = (int)yjit_line_samples[idx];
idx++;

rb_ary_push(raw_samples, SIZET2NUM(num));
rb_ary_push(line_samples, INT2NUM(line_num));
// + 1 as we append an additional sample for the insn
rb_ary_push(raw_samples, SIZET2NUM(num + 1));
rb_ary_push(line_samples, INT2NUM(line_num + 1));

// Loop through the length of samples_len and add data to the
// frames hash. Also push the current value onto the raw_samples
Expand Down
2 changes: 1 addition & 1 deletion yjit.rb
Expand Up @@ -67,7 +67,7 @@ def self.exit_locations
# [ length, line_1, line_2, line_n, ..., dummy value, count
i = 0
while i < raw_samples.length
stack_length = raw_samples[i] + 1
stack_length = raw_samples[i]
i += 1 # consume the stack length

sample_count = raw_samples[i + stack_length]
Expand Down
6 changes: 2 additions & 4 deletions yjit/src/stats.rs
Expand Up @@ -691,10 +691,8 @@ pub extern "C" fn rb_yjit_record_exit_stack(exit_pc: *const VALUE)
// Push the insn value into the yjit_raw_samples Vec.
yjit_raw_samples.push(VALUE(insn as usize));

// Push the current line onto the yjit_line_samples Vec. This
// points to the line in insns.def.
let line = yjit_line_samples.len() - 1;
yjit_line_samples.push(line as i32);
// We don't know the line
yjit_line_samples.push(0);

// Push number of times seen onto the stack, which is 1
// because it's the first time we've seen it.
Expand Down