Skip to content

Commit 97c206c

Browse files
committed
ZJIT: Read (*cd).ci directly instead of calling rb_get_call_data_ci()
1 parent d6ca3fe commit 97c206c

5 files changed

Lines changed: 12 additions & 15 deletions

File tree

zjit/bindgen/src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,6 @@ fn main() {
421421
.allowlist_function("rb_get_iseq_body_param_opt_table")
422422
.allowlist_function("rb_get_cikw_keyword_len")
423423
.allowlist_function("rb_get_cikw_keywords_idx")
424-
.allowlist_function("rb_get_call_data_ci")
425424
.allowlist_function("rb_yarv_str_eql_internal")
426425
.allowlist_function("rb_str_neq_internal")
427426
.allowlist_function("rb_yarv_ary_entry_internal")

zjit/src/cruby.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ pub use rb_get_iseq_body_type as get_iseq_body_type;
193193
pub use rb_get_iseq_body_local_table_size as get_iseq_body_local_table_size;
194194
pub use rb_get_cikw_keyword_len as get_cikw_keyword_len;
195195
pub use rb_get_cikw_keywords_idx as get_cikw_keywords_idx;
196-
pub use rb_get_call_data_ci as get_call_data_ci;
197196
pub use rb_FL_TEST_RAW as FL_TEST_RAW;
198197
pub use rb_RB_TYPE_P as RB_TYPE_P;
199198
pub use rb_vm_ci_argc as vm_ci_argc;
@@ -952,7 +951,7 @@ pub fn ruby_sym_to_rust_string(v: VALUE) -> String {
952951
}
953952

954953
pub fn ruby_call_method_id(cd: *const rb_call_data) -> ID {
955-
let call_info = unsafe { rb_get_call_data_ci(cd) };
954+
let call_info = unsafe { (*cd).ci };
956955
unsafe { rb_vm_ci_mid(call_info) }
957956
}
958957

zjit/src/cruby_bindings.inc.rs

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

zjit/src/hir.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3790,7 +3790,7 @@ impl Function {
37903790
continue;
37913791
}
37923792
};
3793-
let ci = unsafe { get_call_data_ci(cd) }; // info about the call site
3793+
let ci = unsafe { (*cd).ci }; // info about the call site
37943794

37953795
let flags = unsafe { rb_vm_ci_flag(ci) };
37963796

@@ -4152,7 +4152,7 @@ impl Function {
41524152
continue;
41534153
}
41544154

4155-
let ci = unsafe { get_call_data_ci(cd) };
4155+
let ci = unsafe { (*cd).ci };
41564156
let flags = unsafe { rb_vm_ci_flag(ci) };
41574157
assert!(flags & VM_CALL_FCALL != 0);
41584158

@@ -7998,7 +7998,7 @@ fn add_iseq_to_hir(
79987998
// Check if #new resolves to rb_class_new_instance_pass_kw.
79997999
// TODO: Guard on a profiled class and add a patch point for #new redefinition
80008000
let argc = crate::profile::num_arguments_on_stack(cd);
8001-
let ci = unsafe { get_call_data_ci(cd) };
8001+
let ci = unsafe { (*cd).ci };
80028002
let flags = unsafe { rb_vm_ci_flag(ci) };
80038003
assert_eq!(flags & VM_CALL_ARGS_BLOCKARG, 0);
80048004
let val = state.stack_topn(argc)?;
@@ -8469,7 +8469,7 @@ fn add_iseq_to_hir(
84698469
YARVINSN_opt_neq => {
84708470
// NB: opt_neq has two cd; get_arg(0) is for eq and get_arg(1) is for neq
84718471
let cd: *const rb_call_data = get_arg(pc, 1).as_ptr();
8472-
let call_info = unsafe { rb_get_call_data_ci(cd) };
8472+
let call_info = unsafe { (*cd).ci };
84738473
let flags = unsafe { rb_vm_ci_flag(call_info) };
84748474
if let Err(call_type) = unhandled_call_type(flags) {
84758475
// Can't handle the call type; side-exit into the interpreter
@@ -8568,7 +8568,7 @@ fn add_iseq_to_hir(
85688568
YARVINSN_opt_regexpmatch2 |
85698569
YARVINSN_opt_send_without_block => {
85708570
let cd: *const rb_call_data = get_arg(pc, 0).as_ptr();
8571-
let call_info = unsafe { rb_get_call_data_ci(cd) };
8571+
let call_info = unsafe { (*cd).ci };
85728572
let flags = unsafe { rb_vm_ci_flag(call_info) };
85738573
if let Err(call_type) = unhandled_call_type(flags) {
85748574
// Can't handle tailcall; side-exit into the interpreter
@@ -8662,7 +8662,7 @@ fn add_iseq_to_hir(
86628662
YARVINSN_send => {
86638663
let cd: *const rb_call_data = get_arg(pc, 0).as_ptr();
86648664
let blockiseq: IseqPtr = get_arg(pc, 1).as_iseq();
8665-
let call_info = unsafe { rb_get_call_data_ci(cd) };
8665+
let call_info = unsafe { (*cd).ci };
86668666
let flags = unsafe { rb_vm_ci_flag(call_info) };
86678667
if let Err(call_type) = unhandled_call_type(flags) {
86688668
// Can't handle tailcall; side-exit into the interpreter
@@ -8716,7 +8716,7 @@ fn add_iseq_to_hir(
87168716
YARVINSN_sendforward => {
87178717
let cd: *const rb_call_data = get_arg(pc, 0).as_ptr();
87188718
let blockiseq: IseqPtr = get_arg(pc, 1).as_iseq();
8719-
let call_info = unsafe { rb_get_call_data_ci(cd) };
8719+
let call_info = unsafe { (*cd).ci };
87208720
let flags = unsafe { rb_vm_ci_flag(call_info) };
87218721
let forwarding = (flags & VM_CALL_FORWARDING) != 0;
87228722
if let Err(call_type) = unhandled_call_type(flags) {
@@ -8761,7 +8761,7 @@ fn add_iseq_to_hir(
87618761
}
87628762
YARVINSN_invokesuper => {
87638763
let cd: *const rb_call_data = get_arg(pc, 0).as_ptr();
8764-
let call_info = unsafe { rb_get_call_data_ci(cd) };
8764+
let call_info = unsafe { (*cd).ci };
87658765
let flags = unsafe { rb_vm_ci_flag(call_info) };
87668766
if let Err(call_type) = unhandled_call_type(flags) {
87678767
// Can't handle tailcall; side-exit into the interpreter
@@ -8807,7 +8807,7 @@ fn add_iseq_to_hir(
88078807
YARVINSN_invokesuperforward => {
88088808
let cd: *const rb_call_data = get_arg(pc, 0).as_ptr();
88098809
let blockiseq: IseqPtr = get_arg(pc, 1).as_iseq();
8810-
let call_info = unsafe { rb_get_call_data_ci(cd) };
8810+
let call_info = unsafe { (*cd).ci };
88118811
let flags = unsafe { rb_vm_ci_flag(call_info) };
88128812
let forwarding = (flags & VM_CALL_FORWARDING) != 0;
88138813
if let Err(call_type) = unhandled_call_type(flags) {
@@ -8853,7 +8853,7 @@ fn add_iseq_to_hir(
88538853
}
88548854
YARVINSN_invokeblock => {
88558855
let cd: *const rb_call_data = get_arg(pc, 0).as_ptr();
8856-
let call_info = unsafe { rb_get_call_data_ci(cd) };
8856+
let call_info = unsafe { (*cd).ci };
88578857
let flags = unsafe { rb_vm_ci_flag(call_info) };
88588858
if let Err(call_type) = unhandled_call_type(flags) {
88598859
// Can't handle tailcall; side-exit into the interpreter

zjit/src/profile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ pub fn profile_recompile_insn(ec: EcPtr) -> bool {
157157
/// Return the argc as stated in the calldata plus:
158158
/// * 1 if there is an explicit blockarg, since that will be passed on the stack
159159
pub fn num_arguments_on_stack(cd: *const rb_call_data) -> usize {
160-
let ci = unsafe { rb_get_call_data_ci(cd) };
160+
let ci = unsafe { (*cd).ci };
161161
let flags = unsafe { rb_vm_ci_flag(ci) };
162162
let has_blockarg = (flags & VM_CALL_ARGS_BLOCKARG) != 0;
163163
(unsafe { vm_ci_argc(ci) }) as usize + has_blockarg as usize

0 commit comments

Comments
 (0)