diff options
author | Takashi Kokubun <takashikkbn@gmail.com> | 2023-03-04 23:53:21 -0800 |
---|---|---|
committer | Takashi Kokubun <takashikkbn@gmail.com> | 2023-03-05 23:28:59 -0800 |
commit | f0218303e050377da8f4b21a6a2a0bc4c3118cb6 (patch) | |
tree | 7ff8c91c92c1362b3c1be4af85c1790c21d3337f /lib | |
parent | 31babc5ceaa8601075c344399a3bab59bb3dd1dd (diff) |
Optimize String#getbyte
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7448
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ruby_vm/mjit/insn_compiler.rb | 19 |
1 files changed, 19 insertions, 0 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) |