mirror of
https://github.com/ruby/ruby.git
synced 2026-01-28 13:04:22 +00:00
Remove function call for String#bytesize (#8389)
* Remove function call for String#bytesize String size is stored in a consistent location, so we can eliminate the function call. * Update yjit/src/codegen.rs Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com> --------- Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com> Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
This commit is contained in:
parent
0c8928721e
commit
0adca625ee
Notes:
git
2023-09-07 13:54:24 +00:00
Merged-By: maximecb <maximecb@ruby-lang.org>
@ -4697,10 +4697,21 @@ fn jit_rb_str_bytesize(
|
||||
asm.comment("String#bytesize");
|
||||
|
||||
let recv = asm.stack_pop(1);
|
||||
let ret_opnd = asm.ccall(rb_str_bytesize as *const u8, vec![recv]);
|
||||
|
||||
asm.comment("get string length");
|
||||
let str_len_opnd = Opnd::mem(
|
||||
std::os::raw::c_long::BITS as u8,
|
||||
asm.load(recv),
|
||||
RUBY_OFFSET_RSTRING_LEN as i32,
|
||||
);
|
||||
|
||||
let len = asm.load(str_len_opnd);
|
||||
let shifted_val = asm.lshift(len, Opnd::UImm(1));
|
||||
let out_val = asm.or(shifted_val, Opnd::UImm(RUBY_FIXNUM_FLAG as u64));
|
||||
|
||||
let out_opnd = asm.stack_push(Type::Fixnum);
|
||||
asm.mov(out_opnd, ret_opnd);
|
||||
|
||||
asm.mov(out_opnd, out_val);
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
@ -135,7 +135,6 @@ extern "C" {
|
||||
ic: ICVARC,
|
||||
) -> VALUE;
|
||||
pub fn rb_vm_ic_hit_p(ic: IC, reg_ep: *const VALUE) -> bool;
|
||||
pub fn rb_str_bytesize(str: VALUE) -> VALUE;
|
||||
}
|
||||
|
||||
// Renames
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user