diff options
-rw-r--r-- | lib/ruby_vm/mjit/insn_compiler.rb | 19 | ||||
-rw-r--r-- | mjit_c.rb | 7 | ||||
-rw-r--r-- | string.c | 2 |
3 files changed, 27 insertions, 1 deletions
diff --git a/lib/ruby_vm/mjit/insn_compiler.rb b/lib/ruby_vm/mjit/insn_compiler.rb index d46998c1f1..83dd8235ff 100644 --- a/lib/ruby_vm/mjit/insn_compiler.rb +++ b/lib/ruby_vm/mjit/insn_compiler.rb @@ -2281,6 +2281,24 @@ module RubyVM::MJIT # @param jit [RubyVM::MJIT::JITState] # @param ctx [RubyVM::MJIT::Context] # @param asm [RubyVM::MJIT::Assembler] + def jit_rb_str_getbyte(jit, ctx, asm, argc, _known_recv_class) + return false if argc != 1 + asm.comment('rb_str_getbyte') + + index_opnd = ctx.stack_pop + str_opnd = ctx.stack_pop + asm.mov(C_ARGS[0], str_opnd) + asm.mov(C_ARGS[1], index_opnd) + asm.call(C.rb_str_getbyte) + + ret_opnd = ctx.stack_push + asm.mov(ret_opnd, C_RET) + true + end + + # @param jit [RubyVM::MJIT::JITState] + # @param ctx [RubyVM::MJIT::Context] + # @param asm [RubyVM::MJIT::Assembler] def jit_rb_ary_push(jit, ctx, asm, argc, _known_recv_class) return false if argc != 1 asm.comment('rb_ary_push') @@ -2364,6 +2382,7 @@ module RubyVM::MJIT register_cfunc_method(Integer, :*, :jit_rb_int_mul) register_cfunc_method(Integer, :/, :jit_rb_int_div) register_cfunc_method(Integer, :[], :jit_rb_int_aref) + register_cfunc_method(String, :getbyte, :jit_rb_str_getbyte) end def register_cfunc_method(klass, mid_sym, func) @@ -420,6 +420,13 @@ module RubyVM::MJIT # :nodoc: all rb_proc_t.new(proc_t_addr) end + def rb_str_getbyte + Primitive.cstmt! %{ + extern VALUE rb_str_getbyte(VALUE str, VALUE index); + return SIZET2NUM((size_t)rb_str_getbyte); + } + end + #======================================================================================== # # Old stuff @@ -6072,7 +6072,7 @@ rb_str_chr(VALUE str) * * Related: String#setbyte. */ -static VALUE +VALUE rb_str_getbyte(VALUE str, VALUE index) { long pos = NUM2LONG(index); |