diff options
author | John Hawthorn <[email protected]> | 2021-06-19 14:02:53 -0700 |
---|---|---|
committer | Alan Wu <[email protected]> | 2021-10-20 18:19:40 -0400 |
commit | 96fd8afbf4d93b6831ca119fd8c1f07dfa9abd07 (patch) | |
tree | 7a7706fde63c082e0db20a86953b0617ef2e0172 | |
parent | fc13ff14a2a78173dd4a1e93c8f4e3665a4e8555 (diff) |
Skip opt_case_dispatch
-rw-r--r-- | yjit_codegen.c | 17 |
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); |