Unify length field for embedded and heap strings (#7908)

* Unify length field for embedded and heap strings

The length field is of the same type and position in RString for both
embedded and heap allocated strings, so we can unify it.

* Remove RSTRING_EMBED_LEN
This commit is contained in:
Peter Zhu 2023-06-06 10:19:20 -04:00 committed by GitHub
parent fae2f80d06
commit 7577c101ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: git 2023-06-06 14:19:40 +00:00
Merged-By: maximecb <maximecb@ruby-lang.org>
9 changed files with 69 additions and 119 deletions

View file

@ -2994,15 +2994,12 @@ module RubyVM::RJIT
# @param ctx [RubyVM::RJIT::Context]
# @param asm [RubyVM::RJIT::Assembler]
def jit_rb_str_empty_p(jit, ctx, asm, argc, known_recv_class)
# Assume same offset to len embedded or not so we can use one code path to read the length
#assert_equal(C.RString.offsetof(:as, :heap, :len), C.RString.offsetof(:as, :embed, :len))
recv_opnd = ctx.stack_pop(1)
out_opnd = ctx.stack_push(Type::UnknownImm)
asm.comment('get string length')
asm.mov(:rax, recv_opnd)
str_len_opnd = [:rax, C.RString.offsetof(:as, :heap, :len)]
str_len_opnd = [:rax, C.RString.offsetof(:len)]
asm.cmp(str_len_opnd, 0)
asm.mov(:rax, Qfalse)