ruby-changes:71880
From: Takashi <ko1@a...>
Date: Fri, 20 May 2022 00:53:11 +0900 (JST)
Subject: [ruby-changes:71880] b8a268e293 (master): YJIT: Add opt_succ (#5919)
https://git.ruby-lang.org/ruby.git/commit/?id=b8a268e293 From b8a268e293f89338c9ad5af8cf8e9e350c112c72 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun <takashikkbn@g...> Date: Thu, 19 May 2022 08:52:52 -0700 Subject: YJIT: Add opt_succ (#5919) --- test/ruby/test_yjit.rb | 4 ++++ yjit/src/codegen.rs | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/test/ruby/test_yjit.rb b/test/ruby/test_yjit.rb index 63d752dde4..bf6345faa6 100644 --- a/test/ruby/test_yjit.rb +++ b/test/ruby/test_yjit.rb @@ -86,6 +86,10 @@ class TestYJIT < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_yjit.rb#L86 assert_compiles(':foo', insns: %i[putobject], result: :foo) end + def test_compile_opt_succ + assert_compiles('1.succ', insns: %i[opt_succ], result: 2) + end + def test_compile_opt_not assert_compiles('!false', insns: %i[opt_not], result: true) assert_compiles('!nil', insns: %i[opt_not], result: true) diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs index 473d464d52..1d62d74de0 100644 --- a/yjit/src/codegen.rs +++ b/yjit/src/codegen.rs @@ -2991,6 +2991,16 @@ fn gen_opt_empty_p( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L2991 gen_opt_send_without_block(jit, ctx, cb, ocb) } +fn gen_opt_succ( + jit: &mut JITState, + ctx: &mut Context, + cb: &mut CodeBlock, + ocb: &mut OutlinedCb, +) -> CodegenStatus { + // Delegate to send, call the method on the recv + gen_opt_send_without_block(jit, ctx, cb, ocb) +} + fn gen_opt_str_freeze( jit: &mut JITState, ctx: &mut Context, @@ -5820,6 +5830,7 @@ fn get_gen_fn(opcode: VALUE) -> Option<InsnGenFn> { https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L5830 OP_OPT_LTLT => Some(gen_opt_ltlt), OP_OPT_NIL_P => Some(gen_opt_nil_p), OP_OPT_EMPTY_P => Some(gen_opt_empty_p), + OP_OPT_SUCC => Some(gen_opt_succ), OP_OPT_NOT => Some(gen_opt_not), OP_OPT_SIZE => Some(gen_opt_size), OP_OPT_LENGTH => Some(gen_opt_length), -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/