Skip to content

Commit 2cf7693

Browse files
XrXrk0kubun
authored andcommitted
Add profiling for opt_send_without_block
Split out from the CCall changes since we discussed during pairing that this is useful to unblock some other changes. No tests since no one consumes this profiling data yet.
1 parent 36d328e commit 2cf7693

File tree

4 files changed

+148
-134
lines changed

4 files changed

+148
-134
lines changed

insns.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,7 @@ opt_send_without_block
890890
(CALL_DATA cd)
891891
(...)
892892
(VALUE val)
893+
// attr bool zjit_profile = true;
893894
// attr bool handles_sp = true;
894895
// attr rb_snum_t sp_inc = sp_inc_of_sendish(cd->ci);
895896
// attr rb_snum_t comptime_sp_inc = sp_inc_of_sendish(ci);

zjit/src/cruby_bindings.inc.rs

Lines changed: 135 additions & 133 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

zjit/src/hir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ pub fn iseq_to_hir(iseq: *const rb_iseq_t) -> Result<Function, ParseError> {
13891389
break; // Don't enqueue the next block as a successor
13901390
}
13911391

1392-
YARVINSN_opt_send_without_block => {
1392+
YARVINSN_opt_send_without_block | YARVINSN_zjit_opt_send_without_block => {
13931393
let cd: *const rb_call_data = get_arg(pc, 0).as_ptr();
13941394
let call_info = unsafe { rb_get_call_data_ci(cd) };
13951395
let argc = unsafe { vm_ci_argc((*cd).ci) };

zjit/src/profile.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ impl Profiler {
2424
}
2525
}
2626

27+
// Get an instruction operand that sits next to the opcode at PC.
28+
fn insn_opnd(&self, idx: usize) -> VALUE {
29+
unsafe { get_cfp_pc(self.cfp).add(1 + idx).read() }
30+
}
31+
2732
// Peek at the nth topmost value on the Ruby stack.
2833
// Returns the topmost value when n == 0.
2934
fn peek_at_stack(&self, n: isize) -> VALUE {
@@ -57,6 +62,12 @@ fn profile_insn(profiler: &mut Profiler, opcode: ruby_vminsn_type) {
5762
YARVINSN_opt_le => profile_operands(profiler, 2),
5863
YARVINSN_opt_gt => profile_operands(profiler, 2),
5964
YARVINSN_opt_ge => profile_operands(profiler, 2),
65+
YARVINSN_opt_send_without_block => {
66+
let cd: *const rb_call_data = profiler.insn_opnd(0).as_ptr();
67+
let argc = unsafe { vm_ci_argc((*cd).ci) };
68+
// Profile all the arguments and self (+1).
69+
profile_operands(profiler, (argc + 1) as usize);
70+
}
6071
_ => {}
6172
}
6273
}

0 commit comments

Comments
 (0)