8000 Merge pull request #214 from jhawthorn/skip_case_dispatch · github/ruby@4959076 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit 4959076

Browse files
authored
Merge pull request #214 from jhawthorn/skip_case_dispatch
Skip over opt_case_dispatch instructions
2 parents 63e9275 + 1cda59e commit 4959076

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

yjit_codegen.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2446,6 +2446,22 @@ gen_opt_regexpmatch2(jitstate_t *jit, ctx_t *ctx)
24462446
return gen_opt_send_without_block(jit, ctx);
24472447
}
24482448

2449+
static codegen_status_t
2450+
gen_opt_case_dispatch(jitstate_t* jit, ctx_t* ctx)
2451+
{
2452+
// Normally this instruction would lookup the key in a hash and jump to an
2453+
// offset based on that.
2454+
// Instead we can take the fallback case and continue with the next
2455+
// instruciton.
2456+
// We'd hope that our jitted code will be sufficiently fast without the
2457+
// hash lookup, at least for small hashes, but it's worth revisiting this
2458+
// assumption in the future.
2459+
2460+
ctx_stack_pop(ctx, 1);
2461+
2462+
return YJIT_KEEP_COMPILING; // continue with the next instruction
2463+
}
2464+
24492465
void
24502466
gen_branchif_branch(codeblock_t* cb, uint8_t* target0, uint8_t* target1, uint8_t shape)
24512467
{
@@ -4214,6 +4230,7 @@ yjit_init_codegen(void)
42144230
yjit_reg_op(BIN(opt_getinlinecache), gen_opt_getinlinecache);
42154231
yjit_reg_op(BIN(opt_invokebuiltin_delegate), gen_opt_invokebuiltin_delegate);
42164232
yjit_reg_op(BIN(opt_invokebuiltin_delegate_leave), gen_opt_invokebuiltin_delegate);
4233+
yjit_reg_op(BIN(opt_case_dispatch), gen_opt_case_dispatch);
42174234
yjit_reg_op(BIN(branchif), gen_branchif);
42184235
yjit_reg_op(BIN(branchunless), gen_branchunless);
42194236
yjit_reg_op(BIN(branchnil), gen_branchnil);

0 commit comments

Comments
 (0)
0