diff options
-rw-r--r-- | lib/ruby_vm/rjit/insn_compiler.rb | 18 | ||||
-rw-r--r-- | rjit_c.c | 1 | ||||
-rw-r--r-- | rjit_c.rb | 4 | ||||
-rw-r--r-- | string.c | 2 | ||||
-rwxr-xr-x | tool/rjit/bindgen.rb | 1 | ||||
-rw-r--r-- | yjit.c | 7 |
6 files changed, 24 insertions, 9 deletions
diff --git a/lib/ruby_vm/rjit/insn_compiler.rb b/lib/ruby_vm/rjit/insn_compiler.rb index aa37388a5b..bbfc8c3d0a 100644 --- a/lib/ruby_vm/rjit/insn_compiler.rb +++ b/lib/ruby_vm/rjit/insn_compiler.rb @@ -2769,6 +2769,22 @@ module RubyVM::RJIT # @param jit [RubyVM::RJIT::JITState] # @param ctx [RubyVM::RJIT::Context] # @param asm [RubyVM::RJIT::Assembler] + def jit_rb_str_bytesize(jit, ctx, asm, argc, known_recv_class) + asm.comment('String#bytesize') + + recv = ctx.stack_pop(1) + asm.mov(C_ARGS[0], recv) + asm.call(C.rb_str_bytesize) + + out_opnd = ctx.stack_push + asm.mov(out_opnd, C_RET) + + true + end + + # @param jit [RubyVM::RJIT::JITState] + # @param ctx [RubyVM::RJIT::Context] + # @param asm [RubyVM::RJIT::Assembler] def jit_rb_str_getbyte(jit, ctx, asm, argc, _known_recv_class) return false if argc != 1 asm.comment('rb_str_getbyte') @@ -2852,7 +2868,7 @@ module RubyVM::RJIT register_cfunc_method(String, :empty?, :jit_rb_str_empty_p) register_cfunc_method(String, :to_s, :jit_rb_str_to_s) register_cfunc_method(String, :to_str, :jit_rb_str_to_s) - #register_cfunc_method(String, :bytesize, :jit_rb_str_bytesize) + register_cfunc_method(String, :bytesize, :jit_rb_str_bytesize) #register_cfunc_method(String, :<<, :jit_rb_str_concat) #register_cfunc_method(String, :+@, :jit_rb_str_uplus) @@ -497,6 +497,7 @@ extern void rb_vm_setinstancevariable(const rb_iseq_t *iseq, VALUE obj, ID id, V extern VALUE rb_vm_throw(const rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, rb_num_t throw_state, VALUE throwobj); extern VALUE rb_reg_new_ary(VALUE ary, int opt); extern void rb_vm_setclassvariable(const rb_iseq_t *iseq, const rb_control_frame_t *cfp, ID id, VALUE val, ICVARC ic); +extern VALUE rb_str_bytesize(VALUE str); #include "rjit_c.rbinc" @@ -607,6 +607,10 @@ module RubyVM::RJIT # :nodoc: all Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_reg_nth_match) } end + def C.rb_str_bytesize + Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_str_bytesize) } + end + def C.rb_str_concat_literals Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_str_concat_literals) } end @@ -2186,7 +2186,7 @@ rb_str_length(VALUE str) * */ -static VALUE +VALUE rb_str_bytesize(VALUE str) { return LONG2NUM(RSTRING_LEN(str)); diff --git a/tool/rjit/bindgen.rb b/tool/rjit/bindgen.rb index 3c25edad09..b68123b38a 100755 --- a/tool/rjit/bindgen.rb +++ b/tool/rjit/bindgen.rb @@ -545,6 +545,7 @@ generator = BindingGenerator.new( rb_ary_clear rb_str_intern rb_vm_setclassvariable + rb_str_bytesize ], types: %w[ CALL_DATA @@ -442,13 +442,6 @@ rb_iseq_opcode_at_pc(const rb_iseq_t *iseq, const VALUE *pc) return rb_vm_insn_addr2opcode((const void *)at_pc); } -// used by jit_rb_str_bytesize in codegen.rs -VALUE -rb_str_bytesize(VALUE str) -{ - return LONG2NUM(RSTRING_LEN(str)); -} - unsigned long rb_RSTRING_LEN(VALUE str) { |