Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove function call for String#bytesize #8389

Merged
merged 2 commits into from Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 13 additions & 2 deletions yjit/src/codegen.rs
Expand Up @@ -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
}
Expand Down
1 change: 0 additions & 1 deletion yjit/src/cruby.rs
Expand Up @@ -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
Expand Down