aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ruby_vm/mjit
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2023-03-02 23:15:02 -0800
committerTakashi Kokubun <takashikkbn@gmail.com>2023-03-05 23:28:59 -0800
commitd38069264918e7d0c5aff223414ba45dced92c66 (patch)
tree740c5fcd1b47834f9d8e8b8fc0cc0e3f5bc158ec /lib/ruby_vm/mjit
parente4f49236c09240aa9ddbbd6a870119a99e3c78eb (diff)
downloadruby-d38069264918e7d0c5aff223414ba45dced92c66.tar.gz
Optimize Array#<<
Diffstat (limited to 'lib/ruby_vm/mjit')
-rw-r--r--lib/ruby_vm/mjit/insn_compiler.rb23
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)