mirror of
https://github.com/ruby/ruby.git
synced 2026-08-16 02:15:57 +08:00
YJIT: Use rb_reg_new_from_values() instead of rb_reg_new_ary()
To sync up with ZJIT and insns.def.
This commit is contained in:
parent
01a19896e7
commit
dc0bb7a577
Notes:
git
2026-05-26 17:04:58 +00:00
@ -180,7 +180,7 @@ fn main() {
|
||||
.allowlist_function("rb_reg_match_post")
|
||||
.allowlist_function("rb_reg_match_last")
|
||||
.allowlist_function("rb_reg_nth_match")
|
||||
.allowlist_function("rb_reg_new_ary")
|
||||
.allowlist_function("rb_reg_new_from_values")
|
||||
|
||||
// `ruby_value_type` is a C enum and this stops it from
|
||||
// prefixing all the members with the name of the type
|
||||
|
||||
@ -10180,45 +10180,18 @@ fn gen_toregexp(
|
||||
let opt = jit.get_arg(0).as_i64();
|
||||
let cnt = jit.get_arg(1).as_usize();
|
||||
|
||||
// Save the PC and SP because this allocates an object and could
|
||||
// raise an exception.
|
||||
// Allocates objects and could raise an exception.
|
||||
jit_prepare_non_leaf_call(jit, asm);
|
||||
|
||||
let values_ptr = asm.lea(asm.ctx.sp_opnd(-(cnt as i32)));
|
||||
|
||||
let ary = asm.ccall(
|
||||
rb_ary_tmp_new_from_values as *const u8,
|
||||
vec![
|
||||
Opnd::Imm(0),
|
||||
cnt.into(),
|
||||
values_ptr,
|
||||
]
|
||||
let regexp = asm.ccall(
|
||||
rb_reg_new_from_values as _,
|
||||
vec![cnt.into(), values_ptr, opt.into()],
|
||||
);
|
||||
asm.stack_pop(cnt); // Let ccall spill them
|
||||
|
||||
// Save the array so we can clear it later
|
||||
asm.cpush(ary);
|
||||
asm.cpush(ary); // Alignment
|
||||
|
||||
let val = asm.ccall(
|
||||
rb_reg_new_ary as *const u8,
|
||||
vec![
|
||||
ary,
|
||||
Opnd::Imm(opt),
|
||||
]
|
||||
);
|
||||
|
||||
// The actual regex is in RAX now. Pop the temp array from
|
||||
// rb_ary_tmp_new_from_values into C arg regs so we can clear it
|
||||
let ary = asm.cpop(); // Alignment
|
||||
asm.cpop_into(ary);
|
||||
|
||||
// The value we want to push on the stack is in RAX right now
|
||||
let stack_ret = asm.stack_push(Type::UnknownHeap);
|
||||
asm.mov(stack_ret, val);
|
||||
|
||||
// Clear the temp array.
|
||||
asm.ccall(rb_ary_clear as *const u8, vec![ary]);
|
||||
asm.mov(stack_ret, regexp);
|
||||
|
||||
Some(KeepCompiling)
|
||||
}
|
||||
|
||||
6
yjit/src/cruby_bindings.inc.rs
generated
6
yjit/src/cruby_bindings.inc.rs
generated
@ -1076,7 +1076,11 @@ extern "C" {
|
||||
pub fn rb_obj_info_dump(obj: VALUE);
|
||||
pub fn rb_class_allocate_instance(klass: VALUE) -> VALUE;
|
||||
pub fn rb_obj_equal(obj1: VALUE, obj2: VALUE) -> VALUE;
|
||||
pub fn rb_reg_new_ary(ary: VALUE, options: ::std::os::raw::c_int) -> VALUE;
|
||||
pub fn rb_reg_new_from_values(
|
||||
cnt: ::std::os::raw::c_long,
|
||||
elements: *const VALUE,
|
||||
opt: ::std::os::raw::c_int,
|
||||
) -> VALUE;
|
||||
pub fn rb_ary_tmp_new_from_values(
|
||||
arg1: VALUE,
|
||||
arg2: ::std::os::raw::c_long,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user