summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--yjit_codegen.c17
1 files changed, 17 insertions, 0 deletions
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)
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)
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);