summaryrefslogtreecommitdiff
path: root/bootstraptest
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2022-12-02 11:40:16 -0500
committerGitHub <noreply@github.com>2022-12-02 11:40:16 -0500
commiteb2b717a8bfc18f8ee53ff3d738bcfd3960f8fa4 (patch)
tree7301ebe968a82fab34974e668255eae1aff73d5e /bootstraptest
parentfa77bcf7220a5515323a53a8320132418124f202 (diff)
YJIT: Make case-when optimization respect === redefinition (#6846)
* YJIT: Make case-when optimization respect === redefinition Even when a fixnum key is in the dispatch hash, if there is a case such that its basic operations for === is redefined, we need to fall back to checking each case like the interpreter. Semantically we're always checking each case by calling === in order, it's just that this is not observable when basic operations are intact. When all the keys are fixnums, though, we can do the optimization we're doing right now. Check for this condition. * Update yjit/src/cruby_bindings.inc.rs Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com> Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
Notes
Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
Diffstat (limited to 'bootstraptest')
-rw-r--r--bootstraptest/test_yjit.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb
index 25085f0e8d..349417595f 100644
--- a/bootstraptest/test_yjit.rb
+++ b/bootstraptest/test_yjit.rb
@@ -3436,3 +3436,23 @@ assert_equal '1', %q{
foo(1)
}
+
+# case-when with redefined ===
+assert_equal 'ok', %q{
+ class Symbol
+ def ===(a)
+ true
+ end
+ end
+
+ def cw(arg)
+ case arg
+ when :b
+ :ok
+ when 4
+ :ng
+ end
+ end
+
+ cw(4)
+}