YJIT: Fix raw sample stack lengths in exit traces (#7728)
yjit-trace-exits appends a synthetic sample for the instruction being exited, but we didn't increment the size of the stack. Fixing this count correctly lets us successfully generate a flamegraph from the exits. I also replaced the line number for instructions with 0, as I don't think the previous value had meaning. Co-authored-by: Adam Hess <HParker@github.com>
This commit is contained in:
parent
d8a6db7292
commit
2dff1d4fda
Notes:
git
2023-04-18 14:11:18 +00:00
Merged-By: maximecb <maximecb@ruby-lang.org>
5
yjit.c
5
yjit.c
@ -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];
|
int line_num = (int)yjit_line_samples[idx];
|
||||||
idx++;
|
idx++;
|
||||||
|
|
||||||
rb_ary_push(raw_samples, SIZET2NUM(num));
|
// + 1 as we append an additional sample for the insn
|
||||||
rb_ary_push(line_samples, INT2NUM(line_num));
|
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
|
// Loop through the length of samples_len and add data to the
|
||||||
// frames hash. Also push the current value onto the raw_samples
|
// frames hash. Also push the current value onto the raw_samples
|
||||||
|
2
yjit.rb
2
yjit.rb
@ -67,7 +67,7 @@ module RubyVM::YJIT
|
|||||||
# [ length, line_1, line_2, line_n, ..., dummy value, count
|
# [ length, line_1, line_2, line_n, ..., dummy value, count
|
||||||
i = 0
|
i = 0
|
||||||
while i < raw_samples.length
|
while i < raw_samples.length
|
||||||
stack_length = raw_samples[i] + 1
|
stack_length = raw_samples[i]
|
||||||
i += 1 # consume the stack length
|
i += 1 # consume the stack length
|
||||||
|
|
||||||
sample_count = raw_samples[i + stack_length]
|
sample_count = raw_samples[i + stack_length]
|
||||||
|
@ -724,10 +724,8 @@ pub extern "C" fn rb_yjit_record_exit_stack(exit_pc: *const VALUE)
|
|||||||
// Push the insn value into the yjit_raw_samples Vec.
|
// Push the insn value into the yjit_raw_samples Vec.
|
||||||
yjit_raw_samples.push(VALUE(insn as usize));
|
yjit_raw_samples.push(VALUE(insn as usize));
|
||||||
|
|
||||||
// Push the current line onto the yjit_line_samples Vec. This
|
// We don't know the line
|
||||||
// points to the line in insns.def.
|
yjit_line_samples.push(0);
|
||||||
let line = yjit_line_samples.len() - 1;
|
|
||||||
yjit_line_samples.push(line as i32);
|
|
||||||
|
|
||||||
// Push number of times seen onto the stack, which is 1
|
// Push number of times seen onto the stack, which is 1
|
||||||
// because it's the first time we've seen it.
|
// because it's the first time we've seen it.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user