-
Notifications
You must be signed in to change notification settings - Fork 5.4k
ZJIT: A64 backend miscomp fixes (and a CI fix) #13904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This comment has been minimized.
This comment has been minimized.
e1fa282
to
8090c2a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know much about Arm but looks reasonable at first glance. Delegating to Kokubun
This is so that e.g. building with `--enable-zjit=dev` will test with the disassembly feature. It makes more sense, saves on build time and reveals that `backend::arm64::tests::sp_movements_are_single_instruction` was in fact failing with the `disasm` feature.
Previously, it issued CMN, which doesn't add to the stack pointer.
The raw bytes didn't disassemble to the disassembly, but we missed this since CI didn't run `make zjit-test` with the disasm feature. Fixes: 1317377 ("ZJIT: A64: Have add/sub to SP be single-instruction")
Previously, my buggy optimization would turn `asm.sub(imm, reg)` into `subs out, reg, imm` since it runs through the addition path which relies on the commutative property. Don't do that because subtraction does not commute. Good thing no one seems to use this form. Also, delete the 2 regs match arm for Add because it's already covered by the fallback arm -- both split_load_operand() and split_shifted_immediate() are no-op when the input is a register. Fixes: 1317377 ("ZJIT: A64: Have add/sub to SP be single-instruction")
The stack canary gets killed in test_yjit.rb:224 for some reason. Needs investigation. Example CI failure: https://github.com/ruby/ruby/actions/runs/16307837724/job/46057558066
755220b
to
cd28885
Compare
@@ -22,7 +22,8 @@ path = "jit.rs" | |||
|
|||
[features] | |||
disasm = ["yjit?/disasm", "zjit?/disasm"] | |||
runtime_checks = [] | |||
# TODO(GH-642) Turning this on trips a btest failure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's hard for other contributors to figure out it refers to Shopify/ruby when you're looking at ruby/ruby, so it might be nice to mention the repository name. It confused me at first too.
I noticed that SP movement still weren't single instruction after my other
PR and that led me to find a few bugs.
Please check commit message for each.
make zjit-test
use the same Cargo features as minirubyWe should now be running the disassembly tests in the backend on CI.
asm.add_into(NATIVE_STACK_POINTER, ...)
Probably the most important one because we use this for side exits.
asm.add(reg, imm)
with Movasm.sub(imm, reg)