зеркало из https://github.com/github/ruby.git
YJIT: Add codegen for Array#<< (#7645)
This commit is contained in:
Родитель
ba4ff2552e
Коммит
38209ffdca
|
@ -136,6 +136,7 @@ fn main() {
|
|||
.allowlist_function("rb_ary_resurrect")
|
||||
.allowlist_function("rb_ary_clear")
|
||||
.allowlist_function("rb_ary_dup")
|
||||
.allowlist_function("rb_ary_push")
|
||||
.allowlist_function("rb_ary_unshift_m")
|
||||
.allowlist_function("rb_yjit_rb_ary_subseq_length")
|
||||
|
||||
|
|
|
@ -4542,6 +4542,31 @@ fn jit_rb_ary_empty_p(
|
|||
return true;
|
||||
}
|
||||
|
||||
fn jit_rb_ary_push(
|
||||
jit: &mut JITState,
|
||||
ctx: &mut Context,
|
||||
asm: &mut Assembler,
|
||||
_ocb: &mut OutlinedCb,
|
||||
_ci: *const rb_callinfo,
|
||||
_cme: *const rb_callable_method_entry_t,
|
||||
_block: Option<IseqPtr>,
|
||||
_argc: i32,
|
||||
_known_recv_class: *const VALUE,
|
||||
) -> bool {
|
||||
asm.comment("Array#<<");
|
||||
|
||||
// rb_ary_push allocates memory for buffer extension
|
||||
jit_prepare_routine_call(jit, ctx, asm);
|
||||
|
||||
let item_opnd = ctx.stack_pop(1);
|
||||
let ary_opnd = ctx.stack_pop(1);
|
||||
let ret = asm.ccall(rb_ary_push as *const u8, vec![ary_opnd, item_opnd]);
|
||||
|
||||
let ret_opnd = ctx.stack_push(Type::TArray);
|
||||
asm.mov(ret_opnd, ret);
|
||||
true
|
||||
}
|
||||
|
||||
fn jit_obj_respond_to(
|
||||
jit: &mut JITState,
|
||||
ctx: &mut Context,
|
||||
|
@ -8071,6 +8096,7 @@ impl CodegenGlobals {
|
|||
|
||||
// rb_ary_empty_p() method in array.c
|
||||
self.yjit_reg_method(rb_cArray, "empty?", jit_rb_ary_empty_p);
|
||||
self.yjit_reg_method(rb_cArray, "<<", jit_rb_ary_push);
|
||||
|
||||
self.yjit_reg_method(rb_mKernel, "respond_to?", jit_obj_respond_to);
|
||||
self.yjit_reg_method(rb_mKernel, "block_given?", jit_rb_f_block_given_p);
|
||||
|
|
|
@ -1094,6 +1094,7 @@ extern "C" {
|
|||
pub fn rb_ary_store(ary: VALUE, key: ::std::os::raw::c_long, val: VALUE);
|
||||
pub fn rb_ary_dup(ary: VALUE) -> VALUE;
|
||||
pub fn rb_ary_resurrect(ary: VALUE) -> VALUE;
|
||||
pub fn rb_ary_push(ary: VALUE, elem: VALUE) -> VALUE;
|
||||
pub fn rb_ary_clear(ary: VALUE) -> VALUE;
|
||||
pub fn rb_hash_new() -> VALUE;
|
||||
pub fn rb_hash_aref(hash: VALUE, key: VALUE) -> VALUE;
|
||||
|
|
Загрузка…
Ссылка в новой задаче