summaryrefslogtreecommitdiff
path: root/zjit/src/asm
AgeCommit message (Collapse)Author
2025-12-16Revert "ZJIT: Allow ccalls above 7 arguments"Alan Wu
This reverts commit 2f151e76b5dc578026706b31f054d5caf5374b05. The SP decrement (push) before the call do not match up with the pops after the call, so registers were restored incorrectly. Code from: ./miniruby --zjit-call-threshold=1 --zjit-dump-disasm -e 'p Time.new(1992, 9, 23, 23, 0, 0, :std)' str x11, [sp, #-0x10]! str x12, [sp, #-0x10]! stur x7, [sp] # last argument mov x0, x20 mov x7, x6 mov x6, x5 mov x5, x4 mov x4, x3 mov x3, x2 mov x2, x1 ldur x1, [x29, #-0x20] mov x16, #0xccfc movk x16, #0x2e7, lsl #16 movk x16, #1, lsl #32 blr x16 ldr x12, [sp], #0x10 # supposed to match str x12, [sp, #-0x10]!, but got last argument ldr x11, [sp], #0x10
2025-12-12ZJIT: Allow ccalls above 7 arguments (#15312)Aiden Fox Ivey
ZJIT: Add stack support for CCalls
2025-12-10ZJIT: Use inline format args (#15482)Alex Rocha
2025-11-21ZJIT: Inline Integer#<< for constant rhs (#15258)Max Bernstein
This is good for protoboeuf and other binary parsing
2025-11-10ZJIT: Deduplicate side exits (#15105)Takashi Kokubun
2025-11-06ZJIT: Restore dropped_bytes after temporary OOM (#15069)Takashi Kokubun
2025-11-04ZJIT: Allow Store with 8-bit Opnd::MemTakashi Kokubun
2025-11-03ZJIT: Implement register spill (#14936)Takashi Kokubun
2025-10-29ZJIT: Introduce a better LIR printer (#14986)Takashi Kokubun
2025-10-28ZJIT: Print unexpected operands on x86_64Takashi Kokubun
2025-10-27ZJIT: Simplify complex type to BranchEncoderAiden Fox Ivey
2025-10-15ZJIT: Centralize the allocation of scratch registers (#14815)Takashi Kokubun
2025-10-13[DOC] Fix typosÉtienne Barrié
Inspired by 42ba82424d908c290a4a34ced8853f0a403b734b, I looked for other occurrences of "the the".
2025-10-03ZJIT: Make sure zjit-test-update works in asm tests (#14708)Takashi Kokubun
2025-09-23ZJIT: Allow testing JIT code on zjit-test (#14639)Takashi Kokubun
* ZJIT: Allow testing JIT code on zjit-test * Resurrect TestingAllocator tests
2025-09-19ZJIT: Fix disasm tests on release build (#14612)Takashi Kokubun
* ZJIT: Fix disasm tests on release build * Rename string() to hexdump()
2025-09-19ZJIT: Test disasm with insta (#14602)Takashi Kokubun
2025-09-08ZJIT: Fix 30k if stmt test (#14446)Aiden Fox Ivey
* ZJIT: Allow label generation above 19 bits * Refactor emit_conditional_jump to use generate_branch * Make branching functionality generic across Label and CodePtr * ZJIT: Add > 19 bit jump test and helper function * Remove an empty line --------- Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2025-09-03ZJIT: Ensure `clippy` passes and silence unnecessary warnings (#14439)Aiden Fox Ivey
2025-09-03ZJIT: Add missing module doc commentsAiden Fox Ivey
2025-09-02ZJIT: Remove unnecessary .into callsAiden Fox Ivey
2025-08-28ZJIT: Add code_region_bytes stat (#14389)Takashi Kokubun
* ZJIT: Add code_region_bytes stat * Share more logic among --zjit and --zjit-stats
2025-08-13ZJIT: Enable or remove comments from YJIT (#14214)Takashi Kokubun
2025-08-07ZJIT: Remove GC offsets overwritten by invalidation (#14102)Takashi Kokubun
ZJIT: Remove GC offsts overwritten by invalidation
2025-08-01ZJIT: A64: Use MOVN for small negative immediatesAlan Wu
Save a couple instructions to load a small negative constant into a register. In fact MOVN is speced to alias as `mov` in the official disassembly.
2025-07-31ZJIT: Remove false comment [ci skip]Alan Wu
2025-07-31ZJIT: Only build the assembler for `target_arch`Alan Wu
Fixes test error from running the ARM assembler on x86, but then trying to disassemble it as x86.
2025-07-31ZJIT: A64: Add add_extended() which can add a register to spAlan Wu
2025-07-28ZJIT: Keep a frame pointer and use it for memory paramsAlan Wu
Previously, ZJIT miscompiled the following because of native SP interference. def a(n1,n2,n3,n4,n5,n6,n7,n8) = [n8] a(0,0,0,0,0,0,0, :ok) Commented problematic disassembly: ; call rb_ary_new_capa mov x0, #1 mov x16, #0x1278 movk x16, #0x4bc, lsl #16 movk x16, #1, lsl #32 blr x16 ; call rb_ary_push mov x1, x0 str x1, [sp, #-0x10]! ; c_push() from alloc_regs() mov x0, x1 ; arg0, the array ldur x1, [sp] ; meant to be arg1=n8, but sp just moved! mov x16, #0x3968 movk x16, #0x4bc, lsl #16 movk x16, #1, lsl #32 blr x16 Since the frame pointer stays constant in the body of the function, static offsets based on it don't run the risk of being invalidated by SP movements. Pass the registers to preserve through Insn::FrameSetup. This allows ARM to use STP and waste no gaps between EC, SP, and CFP. x86 now preserves and restores RBP since we use it as the frame pointer. Since all arches now have a frame pointer, remove offset based SP movement in the epilogue and restore registers using the frame pointer.
2025-07-24ZJIT: Re-enable some A64 assembler testsAlan Wu
Tweak for Condition to build when `cfg!(target = "x86_64")`.
2025-07-11ZJIT: Mark objects baked in JIT code (#13862)Takashi Kokubun
2025-07-10ZJIT: Implement patch points on BOP redefinition (#13850)Takashi Kokubun
Co-authored-by: Max Bernstein <max@bernsteinbear.com>
2025-07-02ZJIT: Reject ISEQs with too-large stack_max (#13770)Takashi Kokubun
2025-06-11ZJIT: x86: Fix panic writing 32-bit number with top bit setAlan Wu
Previously, `asm.mov(m32, imm32)` panicked when `imm32 > 0x80000000`. It attempted to split imm32 into a register before doing the store, but then the register size didn't match the destination size. Instead of splitting, use the `MOV r/m32, imm32` form which works for all 32-bit values. Adjust asserts that assumed that all forms undergo sign extension, which is not true for this case. See: 54edc930f9f0a658da45cfcef46648d1b6f82467 Notes: Merged: https://github.com/ruby/ruby/pull/13576
2025-06-11ZJIT: Restore x86 assembler testsAlan Wu
Notes: Merged: https://github.com/ruby/ruby/pull/13576
2025-06-11ZJIT: Restore most x64 backend testsAlan Wu
Notes: Merged: https://github.com/ruby/ruby/pull/13576
2025-06-04ZJIT: Implement side exits for entry frames (#13469)Takashi Kokubun
Co-authored-by: Max Bernstein <tekknolagi@gmail.com> Co-authored-by: Alan Wu <alansi.xingwu@shopify.com> Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2025-04-18Change mentions of YJIT to ZJIT (https://github.com/Shopify/zjit/pull/113)Aiden Fox Ivey
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Implement JIT-to-JIT calls (https://github.com/Shopify/zjit/pull/109)Takashi Kokubun
* Implement JIT-to-JIT calls * Use a closer dummy address for Arm64 * Revert an obsoleted change * Revert a few more obsoleted changes * Fix outdated comments * Explain PosMarkers for CCall * s/JIT code/machine code/ * Get rid of ParallelMov Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Add miscellaneous Clippy 'corrections' (https://github.com/Shopify/zjit/pull/92)Aiden Fox Ivey
* Remove redundant statements * Remove .clone() since A64 implements Copy * Remove .clone() since InsnId implements Copy . * Dereference since *const rb_call_data implements Copy * Remove unnecessary return statement * Remove unnecessary braces * Use .is_empty() over length checks * Remove unnecessary conversion handling Since i32 can always fit into i64 (the inner type in Opnd::Imm), the conversion is infallibile. * Use slice notation in lieu of Vec https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg * Simplify match statement Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Compile IfFalse, IfTrue, and Jump instructions ↵Takashi Kokubun
(https://github.com/Shopify/zjit/pull/72) * Compile IfFalse instruction * Add a TODO comment * Rename *s_len to num_*s * Run only gen_param() against block.params * Add a few more tests * Wrap label indexes with Label * Compile blocks in reverse post-order * Simplify a nested test * s/get_block/block/ * Return a number instead of an iterator * Clarify the allocator uses disjoint sets of registers * Use Display for Block and Insn * Compile IfTrue and Jump * Avoid resolving Param instructions * Always compile Insn::Param as basic block arguments * Remove an obsoleted variable * Change it back to use find * Use find for params too * Use Display more * Add more tests * nested if * if after if * if elsif else * loop after loop * nested loops * if in loop * loop in if Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Implement FixnumAdd and stub PatchPoint/GuardType ↵Takashi Kokubun
(https://github.com/Shopify/zjit/pull/30) * Implement FixnumAdd and stub PatchPoint/GuardType Co-authored-by: Max Bernstein <max.bernstein@shopify.com> Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> * Clone Target for arm64 * Use $create instead of use create Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> * Fix misindentation from suggested changes * Drop an unneeded variable for mut * Load operand into a register only if necessary --------- Co-authored-by: Max Bernstein <max.bernstein@shopify.com> Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Fix zjit-testTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Resurrect asm comment supportTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Initialize dummy globals for testsTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Generate working putnil-leave using the backendTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Stub YJIT-specific implementations in the backendTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Move CodeBlock to asm moduleTakashi Kokubun
The assembler does expect CodeBlock as the first argument of most assembler functions, so it is a part of the assembler library. Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Generate intructions to be executedTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Add (gutted) asmMaxime Chevalier-Boisvert
Notes: Merged: https://github.com/ruby/ruby/pull/13131