Skip to content

Commit

Permalink
Remove an unneeded function copy
Browse files Browse the repository at this point in the history
  • Loading branch information
k0kubun committed Apr 2, 2023
1 parent 6c55c3e commit 1b475fc
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 25 deletions.
11 changes: 2 additions & 9 deletions array.c
Expand Up @@ -1787,7 +1787,7 @@ ary_ensure_room_for_unshift(VALUE ary, int argc)
* Related: #push, #pop, #shift.
*/

static VALUE
VALUE
rb_ary_unshift_m(int argc, VALUE *argv, VALUE ary)
{
long len = RARRAY_LEN(ary);
Expand All @@ -1804,17 +1804,10 @@ rb_ary_unshift_m(int argc, VALUE *argv, VALUE ary)
return ary;
}

/* non-static for yjit */
VALUE
rb_yjit_rb_ary_unshift_m(int argc, VALUE *argv, VALUE ary)
{
return rb_ary_unshift_m(argc, argv, ary);
}

VALUE
rb_ary_unshift(VALUE ary, VALUE item)
{
return rb_ary_unshift_m(1,&item,ary);
return rb_ary_unshift_m(1, &item, ary);
}

/* faster version - use this if you don't need to treat negative offset */
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby_vm/rjit/insn_compiler.rb
Expand Up @@ -4315,7 +4315,7 @@ def jit_call_iseq(jit, ctx, asm, cme, calling, iseq, frame_type: nil, prev_ep: n
asm.mov(C_ARGS[0], diff)
asm.mov(C_ARGS[1], values_ptr)
asm.mov(C_ARGS[2], array)
asm.call(C.rb_yjit_rb_ary_unshift_m)
asm.call(C.rb_ary_unshift_m)
ctx.stack_pop(diff)

stack_ret = ctx.stack_push
Expand Down
2 changes: 1 addition & 1 deletion rjit_c.c
Expand Up @@ -514,7 +514,7 @@ extern VALUE rb_str_bytesize(VALUE str);
extern const rb_callable_method_entry_t *rb_callable_method_entry_or_negative(VALUE klass, ID mid);
extern VALUE rb_vm_yield_with_cfunc(rb_execution_context_t *ec, const struct rb_captured_block *captured, int argc, const VALUE *argv);
extern VALUE rb_vm_set_ivar_id(VALUE obj, ID id, VALUE val);
extern VALUE rb_yjit_rb_ary_unshift_m(int argc, VALUE *argv, VALUE ary);
extern VALUE rb_ary_unshift_m(int argc, VALUE *argv, VALUE ary);

#include "rjit_c.rbinc"

Expand Down
8 changes: 4 additions & 4 deletions rjit_c.rb
Expand Up @@ -543,6 +543,10 @@ def C.rb_ary_tmp_new_from_values
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_ary_tmp_new_from_values) }
end

def C.rb_ary_unshift_m
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_ary_unshift_m) }
end

def C.rb_backref_get
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_backref_get) }
end
Expand Down Expand Up @@ -731,10 +735,6 @@ def C.rb_vm_yield_with_cfunc
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_vm_yield_with_cfunc) }
end

def C.rb_yjit_rb_ary_unshift_m
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_yjit_rb_ary_unshift_m) }
end

def C.rjit_full_cfunc_return
Primitive.cexpr! %q{ SIZET2NUM((size_t)rjit_full_cfunc_return) }
end
Expand Down
2 changes: 1 addition & 1 deletion tool/rjit/bindgen.rb
Expand Up @@ -565,7 +565,7 @@ def push_target(target)
rb_vm_set_ivar_id
rb_ary_dup
rjit_rb_ary_subseq_length
rb_yjit_rb_ary_unshift_m
rb_ary_unshift_m
],
types: %w[
CALL_DATA
Expand Down
3 changes: 1 addition & 2 deletions yjit.c
Expand Up @@ -845,8 +845,7 @@ rb_yarv_ary_entry_internal(VALUE ary, long offset)
return rb_ary_entry_internal(ary, offset);
}

VALUE
rb_yjit_rb_ary_unshift_m(int argc, VALUE *argv, VALUE ary);
extern VALUE rb_ary_unshift_m(int argc, VALUE *argv, VALUE ary);

VALUE
rb_yjit_rb_ary_subseq_length(VALUE ary, long beg)
Expand Down
2 changes: 1 addition & 1 deletion yjit/bindgen/src/main.rs
Expand Up @@ -136,7 +136,7 @@ fn main() {
.allowlist_function("rb_ary_resurrect")
.allowlist_function("rb_ary_clear")
.allowlist_function("rb_ary_dup")
.allowlist_function("rb_yjit_rb_ary_unshift_m")
.allowlist_function("rb_ary_unshift_m")
.allowlist_function("rb_yjit_rb_ary_subseq_length")

// From internal/array.h
Expand Down
2 changes: 1 addition & 1 deletion yjit/src/codegen.rs
Expand Up @@ -5821,7 +5821,7 @@ fn gen_send_iseq(

asm.comment("prepend stack values to rest array");
let array = asm.ccall(
rb_yjit_rb_ary_unshift_m as *const u8,
rb_ary_unshift_m as *const u8,
vec![Opnd::UImm(diff as u64), values_ptr, array],
);
ctx.stack_pop(diff as usize);
Expand Down
6 changes: 1 addition & 5 deletions yjit/src/cruby_bindings.inc.rs
Expand Up @@ -1296,11 +1296,7 @@ extern "C" {
pub fn rb_yarv_str_eql_internal(str1: VALUE, str2: VALUE) -> VALUE;
pub fn rb_str_neq_internal(str1: VALUE, str2: VALUE) -> VALUE;
pub fn rb_yarv_ary_entry_internal(ary: VALUE, offset: ::std::os::raw::c_long) -> VALUE;
pub fn rb_yjit_rb_ary_unshift_m(
argc: ::std::os::raw::c_int,
argv: *mut VALUE,
ary: VALUE,
) -> VALUE;
pub fn rb_ary_unshift_m(argc: ::std::os::raw::c_int, argv: *mut VALUE, ary: VALUE) -> VALUE;
pub fn rb_yjit_rb_ary_subseq_length(ary: VALUE, beg: ::std::os::raw::c_long) -> VALUE;
pub fn rb_yarv_fix_mod_fix(recv: VALUE, obj: VALUE) -> VALUE;
pub fn rb_yjit_dump_iseq_loc(iseq: *const rb_iseq_t, insn_idx: u32);
Expand Down

0 comments on commit 1b475fc

Please sign in to comment.