summaryrefslogtreecommitdiff
path: root/yjit
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2024-02-09 09:12:45 -0800
committerGitHub <noreply@github.com>2024-02-09 12:12:45 -0500
commit717adb564b4dd4a7e34b7b4b734795d7eb272c89 (patch)
tree0d81c6068f39332957ed8e5d2603b7c0fa111091 /yjit
parent80490acfb601557497d5c10841fc5493e691e6da (diff)
YJIT: Fallback megamorphic opt_case_dispatch (#9894)
Diffstat (limited to 'yjit')
-rw-r--r--yjit/src/codegen.rs8
-rw-r--r--yjit/src/stats.rs1
2 files changed, 8 insertions, 1 deletions
diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs
index afcaf54406..1fc0e07fe2 100644
--- a/yjit/src/codegen.rs
+++ b/yjit/src/codegen.rs
@@ -4037,7 +4037,13 @@ fn gen_opt_case_dispatch(
all_fixnum
}
- if comptime_key.fixnum_p() && comptime_key.0 <= u32::MAX.as_usize() && case_hash_all_fixnum_p(case_hash) {
+ // If megamorphic, fallback to compiling branch instructions after opt_case_dispatch
+ let megamorphic = asm.ctx.get_chain_depth() >= CASE_WHEN_MAX_DEPTH;
+ if megamorphic {
+ gen_counter_incr(asm, Counter::num_opt_case_dispatch_megamorphic);
+ }
+
+ if comptime_key.fixnum_p() && comptime_key.0 <= u32::MAX.as_usize() && case_hash_all_fixnum_p(case_hash) && !megamorphic {
if !assume_bop_not_redefined(jit, asm, ocb, INTEGER_REDEFINED_OP_FLAG, BOP_EQQ) {
return None;
}
diff --git a/yjit/src/stats.rs b/yjit/src/stats.rs
index 056bb41931..8214769d9b 100644
--- a/yjit/src/stats.rs
+++ b/yjit/src/stats.rs
@@ -592,6 +592,7 @@ make_counters! {
num_getivar_megamorphic,
num_setivar_megamorphic,
+ num_opt_case_dispatch_megamorphic,
num_throw,
num_throw_break,