summaryrefslogtreecommitdiff
path: root/zjit/src/backend
AgeCommit message (Collapse)Author
38 hoursZJIT: Only print bold text in TTY (#15864)Max Bernstein
This is really irritating when piping to a file or pager.
2025-12-18JIT: Move EC offsets to jit_bindgen_constantsJohn Hawthorn
Co-authored-by: Alan Wu <alanwu@ruby-lang.org>
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: Re-compile ISEQs invalidated by PatchPoint (#15459)Takashi Kokubun
2025-12-10ZJIT: Use inline format args (#15482)Alex Rocha
2025-12-03ZJIT: Use the custom iteratorAaron Patterson
This commit uses the custom instruction iterator in arm64 / x86_64 instruction splitting. Once we introduce basic blocks to LIR, the custom iterator will ensure that instructions are added to the correct place.
2025-12-03ZJIT: Add a specialized instruction iterator to the assemblerAaron Patterson
This commit adds a specialized instruction iterator to the assembler with a custom "peek" method. The reason is that we want to add basic blocks to LIR. When we split instructions, we need to add any new instructions to the correct basic block. The custom iterator will maintain the correct basic block inside the assembler, that way when we push any new instructions they will be appended to the correct place.
2025-12-01ZJIT: Split Lea memory reads on x86_64Max Bernstein
2025-11-21ZJIT: Split CSel memory reads on x86_64Max Bernstein
Fix https://github.com/Shopify/ruby/issues/876
2025-11-19ZJIT: Count all calls to C functions from generated code (#15240)Max Bernstein
lobsters: ``` Top-20 calls to C functions from JIT code (79.9% of total 97,004,883): rb_vm_opt_send_without_block: 19,874,212 (20.5%) rb_vm_setinstancevariable: 9,774,841 (10.1%) rb_ivar_get: 9,358,866 ( 9.6%) rb_hash_aref: 6,828,948 ( 7.0%) rb_vm_send: 6,441,551 ( 6.6%) rb_vm_env_write: 5,375,989 ( 5.5%) rb_vm_invokesuper: 3,037,836 ( 3.1%) Module#===: 2,562,446 ( 2.6%) rb_ary_entry: 2,354,546 ( 2.4%) Kernel#is_a?: 1,424,092 ( 1.5%) rb_vm_opt_getconstant_path: 1,344,923 ( 1.4%) Thread.current: 1,300,822 ( 1.3%) rb_zjit_defined_ivar: 1,222,613 ( 1.3%) rb_vm_invokeblock: 1,184,555 ( 1.2%) Hash#[]=: 1,061,969 ( 1.1%) rb_ary_push: 1,024,987 ( 1.1%) rb_ary_new_capa: 904,003 ( 0.9%) rb_str_buf_append: 833,782 ( 0.9%) rb_class_allocate_instance: 822,626 ( 0.8%) Hash#fetch: 755,913 ( 0.8%) ``` railsbench: ``` Top-20 calls to C functions from JIT code (74.8% of total 189,170,268): rb_vm_opt_send_without_block: 29,870,307 (15.8%) rb_vm_setinstancevariable: 17,631,199 ( 9.3%) rb_hash_aref: 16,928,890 ( 8.9%) rb_ivar_get: 14,441,240 ( 7.6%) rb_vm_env_write: 11,571,001 ( 6.1%) rb_vm_send: 11,153,457 ( 5.9%) rb_vm_invokesuper: 7,568,267 ( 4.0%) Module#===: 6,065,923 ( 3.2%) Hash#[]=: 2,842,990 ( 1.5%) rb_ary_entry: 2,766,125 ( 1.5%) rb_ary_push: 2,722,079 ( 1.4%) rb_vm_invokeblock: 2,594,398 ( 1.4%) Thread.current: 2,560,129 ( 1.4%) rb_str_getbyte: 1,965,627 ( 1.0%) Kernel#is_a?: 1,961,815 ( 1.0%) rb_vm_opt_getconstant_path: 1,863,678 ( 1.0%) rb_hash_new_with_size: 1,796,456 ( 0.9%) rb_class_allocate_instance: 1,785,043 ( 0.9%) String#empty?: 1,713,414 ( 0.9%) rb_ary_new_capa: 1,678,834 ( 0.9%) ``` shipit: ``` Top-20 calls to C functions from JIT code (83.4% of total 182,402,821): rb_vm_opt_send_without_block: 45,753,484 (25.1%) rb_ivar_get: 21,020,650 (11.5%) rb_vm_setinstancevariable: 17,528,603 ( 9.6%) rb_hash_aref: 11,892,856 ( 6.5%) rb_vm_send: 11,723,471 ( 6.4%) rb_vm_env_write: 10,434,452 ( 5.7%) Module#===: 4,225,048 ( 2.3%) rb_vm_invokesuper: 3,705,906 ( 2.0%) Thread.current: 3,337,603 ( 1.8%) rb_ary_entry: 3,114,378 ( 1.7%) Hash#[]=: 2,509,912 ( 1.4%) Array#empty?: 2,282,994 ( 1.3%) rb_vm_invokeblock: 2,210,511 ( 1.2%) Hash#fetch: 2,017,960 ( 1.1%) _bi20: 1,975,147 ( 1.1%) rb_zjit_defined_ivar: 1,897,127 ( 1.0%) rb_vm_opt_getconstant_path: 1,813,294 ( 1.0%) rb_ary_new_capa: 1,615,406 ( 0.9%) Kernel#is_a?: 1,567,854 ( 0.9%) rb_class_allocate_instance: 1,560,035 ( 0.9%) ``` Thanks to @eregon for the idea. Co-authored-by: Jacob Denbeaux <jacob.denbeaux@shopify.com> Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
2025-11-14ZJIT: Use Mem.num_bits in Mem split (#15177)Max Bernstein
Fix the ``` write(2, "ruby: ZJIT has panicked. More info to follow...\n", 48) = 48 write(2, "\nthread '<unnamed>' panicked at zjit/src/backend/lir.rs:160:17:\nassertion failed: num_bits <= out_num_bits\n", 107) = 107 ``` based on ``` #25 0x0000aaaaaae8fb14 in zjit::backend::lir::Opnd::mem (num_bits=64, base=..., disp=0) at zjit/src/backend/lir.rs:160 #26 zjit::backend::arm64::{impl#3}::arm64_split::split_memory_address (asm=<optimized out>, opnd=<error reading variable: Cannot access memory at address 0x0>) at zjit/src/backend/arm64/mod.rs:260 #27 zjit::backend::arm64::{impl#3}::arm64_split::split_load_operand (asm=<optimized out>, opnd=...) at zjit/src/backend/arm64/mod.rs:273 ```
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-04ZJIT: Split LShift in arm64_scratch_splitTakashi Kokubun
2025-11-04ZJIT: Use a shared trampoline across all ISEQs (#15042)Takashi Kokubun
2025-11-03ZJIT: Implement register spill (#14936)Takashi Kokubun
2025-10-31ZJIT: Let AssemblerPanicHook write into stderr (#15019)Takashi Kokubun
2025-10-29ZJIT: Limit the default size of LIR dumpTakashi Kokubun
For test_zjit.rb output, it was too long for a single test to print thousands of lines.
2025-10-29ZJIT: Enable comments for --zjit-debug on dev buildsTakashi Kokubun
I wanted to see comments on test_zjit.rb failures.
2025-10-29ZJIT: Rename compile_side_exits to compile_exitsTakashi Kokubun
so that it can be easily specified with `--zjit-dump-lir=`.
2025-10-29ZJIT: Dump Assembler on panic by default for dev buildsTakashi Kokubun
2025-10-29ZJIT: Avoid cloning Assembler repeatedlyTakashi Kokubun
2025-10-29ZJIT: Suffix a label index to duplicated label namesTakashi Kokubun
2025-10-29ZJIT: Print operands with Display on side exitTakashi Kokubun
2025-10-29ZJIT: Refactor operand printerTakashi Kokubun
2025-10-29ZJIT: Introduce a better LIR printer (#14986)Takashi Kokubun
2025-10-28ZJIT: Migrate an arm64 register from emit to splitTakashi Kokubun
2025-10-28ZJIT: Rename SCRATCH_OPND to SCRATCH0_OPND for x86_64Takashi Kokubun
2025-10-28ZJIT: Support ParallelMov into memory (#14975)Takashi Kokubun
2025-10-28ZJIT: Split frame_setup_teardown testsTakashi Kokubun
2025-10-28ZJIT: Move c_stack_slots to AssemblerTakashi Kokubun
2025-10-28ZJIT: Simplify Assembler constructorsTakashi Kokubun
2025-10-28ZJIT: Print unexpected operands on x86_64Takashi Kokubun
2025-10-27ZJIT: Use std::ptr::null instead of castsAiden Fox Ivey
2025-10-27ZJIT: Remove unnecessary #[test] annotationAiden Fox Ivey
2025-10-27ZJIT: Elide unnecessary return statementsAiden Fox Ivey
2025-10-22ZJIT: Fix some dead code in the backend (#14897)Takashi Kokubun
2025-10-22ZJIT: A64: Fix Lea with large displacement and overlapping registerAlan Wu
Previously, when the output register and the base register are the same in `out = Lea(Mem(out, disp))`, we did out = disp out = out + out Which wasn't the desired `out = out + disp`. Fixes a SEGV with `--zjit-call-threshold=2` in `bootstraptest/test_yjit.rb`.
2025-10-15ZJIT: Rewrite arm64_split_with_scratch_reg for clarityAiden Fox Ivey
* The while loop pattern can be rewritten to be more idiomatic, which also allows the iterator to no longer be mutable.
2025-10-15ZJIT: Add trace exit counter (#14831)Aiden Fox Ivey
2025-10-15ZJIT: Centralize the allocation of scratch registers (#14815)Takashi Kokubun
2025-10-03ZJIT: Make sure zjit-test-update works in asm tests (#14708)Takashi Kokubun
2025-09-30ZJIT: Add --zjit-trace-exits (#14640)Aiden Fox Ivey
Add side exit tracing functionality for ZJIT
2025-09-25ZJIT: Remove an obsoleted PC guardTakashi Kokubun
A little follow-up on https://github.com/ruby/ruby/pull/14653 Now that we don't generate a PC-less side exit at the entry block, we shouldn't need this guard that was added by https://github.com/ruby/ruby/pull/14643.
2025-09-24ZJIT: Incorporate bb0-prologue and PC check into HIR (#14643)Takashi Kokubun
* ZJIT: Incorporate bb0-prologue and PC check into HIR * Fix an outdated comment * Use shallow clone for LoadPC and EntryPoint * Reproduce the actual HIR graph to pass validation * Fill out param types for jit_entry_block * Add Type::from_cptr * Add a TODO comment about Const::CPtr printing
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: Remove unnecessary empty linesTakashi Kokubun
2025-09-19ZJIT: Fix disasm tests on release build (#14612)Takashi Kokubun
* ZJIT: Fix disasm tests on release build * Rename string() to hexdump()