summaryrefslogtreecommitdiff
path: root/zjit/src
AgeCommit message (Collapse)Author
6 hoursZJIT: Optimize common `invokesuper` cases (#15816)Kevin Menard
* ZJIT: Profile `invokesuper` instructions * ZJIT: Introduce the `InvokeSuperDirect` HIR instruction The new instruction is an optimized version of `InvokeSuper` when we know the `super` target is an ISEQ. * ZJIT: Expand definition of unspecializable to more complex cases * ZJIT: Ensure `invokesuper` optimization works when the inheritance hierarchy is modified * ZJIT: Simplify `invokesuper` specialization to most common case Looking at ruby-bench, most `super` calls don't pass a block, which means we can use the already optimized `SendWithoutBlockDirect`. * ZJIT: Track `super` method entries directly to avoid GC issues Because the method entry isn't typed as a `VALUE`, we set up barriers on its `VALUE` fields. But, that was insufficient as the method entry itself could be collected in certain cases, resulting in dangling objects. Now we track the method entry as a `VALUE` and can more naturally mark it and its children. * ZJIT: Optimize `super` calls with simple argument forms * ZJIT: Report the reason why we can't optimize an `invokesuper` instance * ZJIT: Revise send fallback reasons for `super` calls * ZJIT: Assert `super` calls are `FCALL` and don't need visibily checks
8 hoursZJIT: Add assume_no_singleton_classes to avoid invalidation loops (#15871)Max Bernstein
Make sure we check if we have seen a singleton for this class before assuming we have not. Port the API from YJIT.
11 hoursZJIT: Add Type::has_value method (#15867)Jeff Zhang
Resolves TODO added in #15863 (See https://github.com/ruby/ruby/pull/15863#discussion_r2687769112) Adds a method `Type::has_value` for comparing value specialized types with a `Const`.
29 hoursZJIT: Constant-fold LoadField/GuardBitEquals from known-frozen objectJeff Zhang
Resolves https://github.com/Shopify/ruby/issues/915 When we have `LoadField` with a `Shape` return type, we can fold it similar to the object case. `GuardBitEquals` can be removed when the argument is `Const` and the values are equal. The behaviors for loading instances variables from frozen/dynamic objects are already covered in existing tests so no new tests were added.
33 hoursZJIT: Only print bold text in TTY (#15864)Max Bernstein
This is really irritating when piping to a file or pager.
2 daysZJIT: Check arg limit before pushing SendWithoutBLockDirect insn (#15854)Randy Stauner
This reduces some processing and makes the HIR more accurate.
2 daysZJIT: Optimize Integer#[]Max Bernstein
This is used a lot in optcarrot.
2 daysZJIT: Snapshot FrameState with reordered args before direct sendRandy Stauner
You can see the reordered args in the new Snapshot right before the DirectSend insn: v14:Any = Snapshot FrameState { pc: 0x00, stack: [v6, v11, v13], locals: [] } PatchPoint MethodRedefined(Object@0x00, a@0x00, cme:0x00) PatchPoint NoSingletonClass(Object@0x00) v22:HeapObject[class_exact*:Object@VALUE(0x00)] = GuardType v6, HeapObject[class_exact*:Object@VALUE(0x00)] - v23:BasicObject = SendWithoutBlockDirect v22, :a (0x00), v13, v11 - v16:Any = Snapshot FrameState { pc: 0x00, stack: [v23], locals: [] } + v23:Any = Snapshot FrameState { pc: 0x00, stack: [v6, v13, v11], locals: [] } + v24:BasicObject = SendWithoutBlockDirect v22, :a (0x00), v13, v11 + v16:Any = Snapshot FrameState { pc: 0x00, stack: [v24], locals: [] }
2 daysZJIT: Add snapshot tests for direct sendRandy Stauner
2 daysZJIT: Inline Array#empty?Max Bernstein
2 daysZJIT: Inline Array#lengthMax Bernstein
3 daysZJIT: remove unused rb_RSTRUCT_LEN()Benoit Daloze
6 daysZJIT: Replace GuardShape with LoadField+GuardBitEquals (#15821)Max Bernstein
GuardShape is just load+guard, so use the existing HIR instructions for load+guard. Probably makes future analysis slightly easier.
7 daysZJIT: Add ArrayAset instruction to HIR (#15747)Nozomi Hijikata
Inline `Array#[]=` into `ArrayAset`.
10 daysUpdate bindgenNobuyoshi Nakada
2025-12-26Remove taintedness/trustedness enums/macros deprecated for 4 yearsNobuyoshi Nakada
2025-12-25Update zjit bindingsPeter Zhu
2025-12-24ZJIT: Don't mark control-flow opcodes as invalidating locals (#15694)Max Bernstein
jump, branchif, etc don't invalidate locals in the JIT; they might in the interpreter because they can execute arbitrary code, but the JIT side exits before that happens.
2025-12-18JIT: Move EC offsets to jit_bindgen_constantsJohn Hawthorn
Co-authored-by: Alan Wu <alanwu@ruby-lang.org>
2025-12-16ZJIT: Use rb_zjit_writebarrier_check_immediate() instead of ↵Benoit Daloze
rb_gc_writebarrier() in gen_write_barrier() * To avoid calling rb_gc_writebarrier() with an immediate value in gen_write_barrier(), and avoid the LIR jump issue.
2025-12-16Revert "ZJIT: Do not call rb_gc_writebarrier() with an immediate value in ↵Benoit Daloze
gen_write_barrier()" * This reverts commit 623559faa3dd0927b4034a752226a30ae8821604. * There is an issue with the jump in LIR, see https://github.com/ruby/ruby/pull/15542.
2025-12-16ZJIT: Add a VALUE#write_barrier helper method to deduplicate logicBenoit Daloze
2025-12-16ZJIT: Guard other calls to rb_gc_writebarrier() with a !special_const_p() checkBenoit Daloze
2025-12-16ZJIT: Do not call rb_gc_writebarrier() with an immediate value in ↵Benoit Daloze
gen_write_barrier()
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-16Make tracepoints with set_trace_func or TracePoint.new ractor local (#15468)Luke Gruber
Before this change, GC'ing any Ractor object caused you to lose all enabled tracepoints across all ractors (even main). Now tracepoints are ractor-local and this doesn't happen. Internal events are still global. Fixes [Bug #19112]
2025-12-15ZJIT: Fix test failures from line number of `Primitive` shiftingAlan Wu
This can happen with documentation updates and we don't want those to trip on ZJIT tests. Redact the whole name since names like "_bi342" aren't that helpful anyways.
2025-12-13ZJIT: Nil-fill locals in direct send (#15536)Randy Stauner
Avoid garbage reads from locals in eval. Before the fix the test fails with <"[\"x\", \"x\", \"x\", \"x\"]"> expected but was <"[\"x\", \"x\", \"x\", \"x286326928\"]">.
2025-12-12ZJIT: Don't inline non-parameter localsRandy Stauner
2025-12-12ZJIT: Allow ccalls above 7 arguments (#15312)Aiden Fox Ivey
ZJIT: Add stack support for CCalls
2025-12-12ZJIT: Only optimize `[]` and `[]=` for exact Hash, not Hash subclassesStan Lo
2025-12-12ZJIT: Inline `Hash#[]=`Stan Lo
2025-12-12ZJIT: Add Shape type to HIR (#15528)Max Bernstein
It's just a nicety (they fit fine as CUInt32) but this makes printing look nicer in real execution and also in tests (helps with #15489). Co-authored-by: Randy Stauner <randy@r4s6.net>
2025-12-12ZJIT: Don't specialize calls with kwsplat (#15513)Randy Stauner
2025-12-11ZJIT: Check method visibility when optimizing sends (#15501)Max Bernstein
Fix https://github.com/Shopify/ruby/issues/874
2025-12-10ZJIT: Re-compile ISEQs invalidated by PatchPoint (#15459)Takashi Kokubun
2025-12-10ZJIT: Don't fold LoadField with negative offsets and use byte_addAlan Wu
No point doing the manual size unit conversion for add. Sorry, no new tests since there is no way to generate a LoadField with a negative offset from ruby code AFAICT. Careful with the `as` casts.
2025-12-10ZJIT: Fold LoadField on frozen objects to constants (#15483)Tobias Lütke
* ZJIT: Fold LoadField on frozen objects to constants When accessing instance variables from frozen objects via attr_reader/ attr_accessor, fold the LoadField instruction to a constant at compile time. This enables further optimizations like constant propagation. - Add fold_getinstancevariable_frozen optimization in Function::optimize - Check if receiver type has a known ruby_object() that is frozen - Read the field value at compile time and replace with Const instruction - Add 10 unit tests covering various value types (fixnum, string, symbol, nil, true/false) and negative cases (unfrozen, dynamic receiver) * Run zjit-test-update * Add a test that we don't fold non-BasicObject * Small cleanups --------- Co-authored-by: Max Bernstein <ruby@bernsteinbear.com> Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2025-12-10ZJIT: Use inline format args (#15482)Alex Rocha
2025-12-10ZJIT: Check if shape is too complex before reading ivar by index (#15478)Max Bernstein
This fixes a crash when the new shape after a transition is too complex; we need to check that it's not complex before trying to read by index.
2025-12-09ZJIT: Add dump to file for --zjit-stats (#15414)Aiden Fox Ivey
* ZJIT: Add dump to file for --zjit-stats * ZJIT: Rename --zjit-stats=quiet to --zjit-stats-quiet
2025-12-09ZJIT: Show send fallback reason in HIR dump (#15454)Randy Stauner
This adds comments to the hir dump output like this: v13:BasicObject = SendWithoutBlock v6, :test, v11 # SendFallbackReason: Complex argument passing
2025-12-09ZJIT: Put keyword bits in callee frame rather than c_argsRandy Stauner
2025-12-09ZJIT: Handle caller_kwarg in direct send when all keyword params are requiredRandy Stauner
2025-12-09ZJIT: Test additional arg passing scenariosRandy Stauner
2025-12-09ZJIT: Support opt_newarray_send with PACK_BUFFERMax Bernstein
2025-12-09ZJIT: Clean up opt_newarray_sendMax Bernstein
2025-12-09ZJIT: Add codegen for FixnumDiv (#15452)Abrar Habib
Fixes https://github.com/Shopify/ruby/issues/902 This pull request adds code generation for dividing fixnums. Testing confirms the normal case, flooring, and side-exiting on division by zero.
2025-12-08ZJIT: Avoid redundant SP save in codegen (#15448)Stan Lo
2025-12-05ZJIT: Include local variable names in `Get|SetLocal` insn's print value (#15423)Stan Lo
ZJIT: Print local variable names GetLocal and SetLocal instructions