diff options
| author | Takashi Kokubun <takashikkbn@gmail.com> | 2022-05-19 08:52:52 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-19 11:52:52 -0400 |
| commit | b8a268e293f89338c9ad5af8cf8e9e350c112c72 (patch) | |
| tree | b2eb1d46db88674d010f6e71eb1ee86ebbd79b56 | |
| parent | 3d6fd162a469f9bfa4afc696ef8b8d8536a38507 (diff) | |
YJIT: Add opt_succ (#5919)
Notes
Notes:
Merged-By: maximecb <maximecb@ruby-lang.org>
| -rw-r--r-- | test/ruby/test_yjit.rb | 4 | ||||
| -rw-r--r-- | yjit/src/codegen.rs | 11 |
2 files changed, 15 insertions, 0 deletions
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 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( 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> { 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), |
