1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Skip opt_case_dispatch

This commit is contained in:
John Hawthorn 2021-06-19 14:02:53 -07:00 committed by Alan Wu
parent fc13ff14a2
commit 96fd8afbf4

View file

@ -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);