[前][次][番号順一覧][スレッド一覧]

ruby-changes:69206

From: John <ko1@a...>
Date: Thu, 21 Oct 2021 08:23:36 +0900 (JST)
Subject: [ruby-changes:69206] 96fd8afbf4 (master): Skip opt_case_dispatch

https://git.ruby-lang.org/ruby.git/commit/?id=96fd8afbf4

From 96fd8afbf4d93b6831ca119fd8c1f07dfa9abd07 Mon Sep 17 00:00:00 2001
From: John Hawthorn <john@h...>
Date: Sat, 19 Jun 2021 14:02:53 -0700
Subject: Skip opt_case_dispatch

---
 yjit_codegen.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/yjit_codegen.c b/yjit_codegen.c
index 049c72b6ba..6160169d62 100644
--- a/yjit_codegen.c
+++ b/yjit_codegen.c
@@ -2447,6 +2447,22 @@ gen_opt_regexpmatch2(jitstate_t *jit, ctx_t *ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2447
     return gen_opt_send_without_block(jit, ctx);
 }
 
+static codegen_status_t
+gen_opt_case_dispatch(jitstate_t* jit, ctx_t* ctx)
+{
+    // Normally this instruction would lookup the key in a hash and jump to an
+    // offset based on that.
+    // Instead we can take the fallback case and continue with the next
+    // instruciton.
+    // We'd hope that our jitted code will be sufficiently fast without the
+    // hash lookup, at least for small hashes, but it's worth revisiting this
+    // assumption in the future.
+
+    ctx_stack_pop(ctx, 1);
+
+    return YJIT_KEEP_COMPILING; // continue with the next instruction
+}
+
 void
 gen_branchif_branch(codeblock_t* cb, uint8_t* target0, uint8_t* target1, uint8_t shape)
 {
@@ -4215,6 +4231,7 @@ yjit_init_codegen(void) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L4231
     yjit_reg_op(BIN(opt_getinlinecache), gen_opt_getinlinecache);
     yjit_reg_op(BIN(opt_invokebuiltin_delegate), gen_opt_invokebuiltin_delegate);
     yjit_reg_op(BIN(opt_invokebuiltin_delegate_leave), gen_opt_invokebuiltin_delegate);
+    yjit_reg_op(BIN(opt_case_dispatch), gen_opt_case_dispatch);
     yjit_reg_op(BIN(branchif), gen_branchif);
     yjit_reg_op(BIN(branchunless), gen_branchunless);
     yjit_reg_op(BIN(branchnil), gen_branchnil);
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]