diff options
author | Takashi Kokubun <takashikkbn@gmail.com> | 2023-03-02 23:15:02 -0800 |
---|---|---|
committer | Takashi Kokubun <takashikkbn@gmail.com> | 2023-03-05 23:28:59 -0800 |
commit | d38069264918e7d0c5aff223414ba45dced92c66 (patch) | |
tree | 740c5fcd1b47834f9d8e8b8fc0cc0e3f5bc158ec /lib/ruby_vm/mjit | |
parent | e4f49236c09240aa9ddbbd6a870119a99e3c78eb (diff) | |
download | ruby-d38069264918e7d0c5aff223414ba45dced92c66.tar.gz |
Optimize Array#<<
Diffstat (limited to 'lib/ruby_vm/mjit')
-rw-r--r-- | lib/ruby_vm/mjit/insn_compiler.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/ruby_vm/mjit/insn_compiler.rb b/lib/ruby_vm/mjit/insn_compiler.rb index 36adfb09d1..625f01b13c 100644 --- a/lib/ruby_vm/mjit/insn_compiler.rb +++ b/lib/ruby_vm/mjit/insn_compiler.rb @@ -1757,6 +1757,27 @@ module RubyVM::MJIT 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) + return false if argc != 1 + asm.comment('rb_ary_push') + + jit_prepare_routine_call(jit, ctx, asm) + + item_opnd = ctx.stack_pop + ary_opnd = ctx.stack_pop + asm.mov(C_ARGS[0], ary_opnd) + asm.mov(C_ARGS[1], item_opnd) + asm.call(C.rb_ary_push) + + ret_opnd = ctx.stack_push + asm.mov(ret_opnd, C_RET) + + true + end + # # Helpers # @@ -1768,6 +1789,8 @@ module RubyVM::MJIT register_cfunc_method(Integer, :==, :jit_rb_int_equal) register_cfunc_method(Integer, :===, :jit_rb_int_equal) register_cfunc_method(Integer, :*, :jit_rb_int_mul) + + register_cfunc_method(Array, :<<, :jit_rb_ary_push) end def register_cfunc_method(klass, mid_sym, func) |