summaryrefslogtreecommitdiff
path: root/zjit/src
AgeCommit message (Collapse)Author
2025-10-09ZJIT: Profile opt_aref (#14778)Aiden Fox Ivey
* ZJIT: Profile opt_aref * ZJIT: Add test for opt_aref * ZJIT: Move test and add hash opt test * ZJIT: Update zjit bindgen * ZJIT: Add inspect calls to opt_aref tests
2025-10-08ZJIT: Use type alias for num-profile and call-threshold's types (#14777)Stan Lo
Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
2025-10-06ZJIT: reduce string allocation in the Counter::name() (#14743)Hoa Nguyen
The Counter::name() method creates a new String on every call, each call allocates memory and copies the string. Using %'static str would reduce memory pressure. The change is safe as no breaking changes to the API
2025-10-03ZJIT: Count CCallWithFrame as optimized_send_count (#14722)Takashi Kokubun
2025-10-03ZJIT: Relax the limit of cfunc args by 1Takashi Kokubun
Follow-up on https://github.com/ruby/ruby/pull/14661 Unlike SendWithoutBlockDirect, `args` has every argument given to the C call. So there's no `+ 1` for this HIR.
2025-10-03ZJIT: Add HIR for calling Cfunc with frame (#14661)Stan Lo
* ZJIT: Add HIR for CCallWithFrame * ZJIT: Update stats to count not inlined cfunc calls * ZJIT: Stops optimizing SendWithoutBlock when TracePoint is activated * ZJIT: Fallback to SendWithoutBlock when CCallWithFrame has too many args * ZJIT: Rename cfun -> cfunc
2025-10-03ZJIT: Make sure zjit-test-update works in asm tests (#14708)Takashi Kokubun
2025-10-02ZJIT: Add `NoSingletonClass` patch point (#14680)Stan Lo
* ZJIT: Add NoSingletonClass patch point This patch point makes sure that when the object has a singleton class, the JIT code is invalidated. As of now, this is only needed for C call optimization. In YJIT, the singleton class guard only applies to Array, Hash, and String. But in ZJIT, we may optimize C calls from gems (e.g. `sqlite3`). So the patch point needs to be applied to a broader range of classes. * ZJIT: Only generate NoSingletonClass guard when the type can have singleton class * ZJIT: Update or forget NoSingletonClass patch point when needed
2025-10-02ZJIT: Enable sample rate for side exit tracing (#14696)Aiden Fox Ivey
2025-10-01ZJIT: Allow higher profile num (#14698)Stan Lo
When we investigate guard failure issues, we sometimes need to use profile num around 100k (e.g. `lobsters` in ruby-bench). This change is to allow that.
2025-09-30ZJIT: Add more *_send_count stats (#14689)Takashi Kokubun
2025-09-30ZJIT: Re-apply attr_writer inlining (#14678)Max Bernstein
This re-applies https://github.com/ruby/ruby/pull/14629 / 40bb47665d3ff57e0f2eb5a9fd9e0109617015c9 by reverting https://github.com/ruby/ruby/pull/14673 / d4393772b89dab4f33c118a284d92dc80cd63c39. Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
2025-09-30ZJIT: Decouple stats and side exit tracing (#14688)Aiden Fox Ivey
2025-09-30ZJIT: Rust code refactors (#14687)Stan Lo
2025-09-30ZJIT: Add --zjit-trace-exits (#14640)Aiden Fox Ivey
Add side exit tracing functionality for ZJIT
2025-09-30ZJIT: Unify fallback counters for send-ish insns (#14676)Takashi Kokubun
2025-09-30ZJIT: Revert SetIvar specialization (#14673)Max Bernstein
CI passed on SetIvar but broke some larger Ruby tests. Needs further investigation and testing. * Revert "ZJIT: Fix rebase issue with tests" This reverts commit 37248c51233d827ca56471661175c56e31c3b14f. * Revert "ZJIT: Inline attr_accessor/attr_writer to SetIvar (#14629)" This reverts commit 40bb47665d3ff57e0f2eb5a9fd9e0109617015c9.
2025-09-29ZJIT: Fix rebase issue with testsMax Bernstein
2025-09-29ZJIT: Inline attr_accessor/attr_writer to SetIvar (#14629)Max Bernstein
2025-09-29ZJIT: Count dynamic instance variable lookups (#14615)Max Bernstein
2025-09-29ZJIT: Add stats for cfuncs that are not optimized (#14638)Stan Lo
* ZJIT: Add stats for cfuncs that are not optimized * ZJIT: Add IncrCounterPtr HIR instead From `lobsters` ``` Top-20 Unoptimized C functions (73.0% of total 15,276,688): Kernel#is_a?: 2,052,363 (13.4%) Class#current: 1,892,623 (12.4%) String#to_s: 975,973 ( 6.4%) Hash#key?: 677,623 ( 4.4%) String#empty?: 636,468 ( 4.2%) TrueClass#===: 457,232 ( 3.0%) Hash#[]=: 455,908 ( 3.0%) FalseClass#===: 448,798 ( 2.9%) ActiveSupport::OrderedOptions#_get: 377,468 ( 2.5%) Kernel#kind_of?: 339,551 ( 2.2%) Kernel#dup: 329,371 ( 2.2%) String#==: 324,286 ( 2.1%) String#include?: 297,528 ( 1.9%) Hash#[]: 294,561 ( 1.9%) Array#include?: 287,145 ( 1.9%) Kernel#block_given?: 283,633 ( 1.9%) BasicObject#!=: 278,874 ( 1.8%) Hash#delete: 250,951 ( 1.6%) Set#include?: 246,447 ( 1.6%) NilClass#===: 242,776 ( 1.6%) ``` From `liquid-render` ``` Top-20 Unoptimized C functions (99.8% of total 5,195,549): Hash#key?: 2,459,048 (47.3%) String#to_s: 1,119,758 (21.6%) Set#include?: 799,469 (15.4%) Kernel#is_a?: 214,223 ( 4.1%) Integer#<<: 171,073 ( 3.3%) Integer#/: 127,622 ( 2.5%) CGI::EscapeExt#escapeHTML: 56,971 ( 1.1%) Regexp#===: 50,008 ( 1.0%) String#empty?: 43,990 ( 0.8%) String#===: 36,838 ( 0.7%) String#==: 21,309 ( 0.4%) Time#strftime: 21,251 ( 0.4%) String#strip: 15,271 ( 0.3%) String#scan: 13,753 ( 0.3%) String#+@: 12,603 ( 0.2%) Array#include?: 8,059 ( 0.2%) String#+: 5,295 ( 0.1%) String#dup: 4,606 ( 0.1%) String#-@: 3,213 ( 0.1%) Class#generate: 3,011 ( 0.1%) ```
2025-09-29ZJIT: Remove RefCell from IseqCallAlan Wu
No point taking the panic risks with RefCell when most fields in it are already in a Cell. Put `iseq` in a Cell and we no longer need the wrapping. Saves memory, too.
2025-09-29ZJIT: Incorporate parameter loads into HIR (#14659)Takashi Kokubun
2025-09-29Add and fix dependenciesSatoshi Tagomori
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-25ZJIT: Compile ISEQ with optional arguments (#14653)Takashi Kokubun
2025-09-25ZJIT: Remove dead CMEs from `Invariants`Alan Wu
2025-09-25ZJIT: Reference update `Invariant::cme_patch_points`Alan Wu
2025-09-25ZJIT: Forget about dead ISEQs in `Invariants`Alan Wu
Without this, we crash during reference update.
2025-09-25ZJIT: Standardize to `Iterator::map` in `Invariants::update_references`Alan Wu
The old code was doing a manual HashSet/HashMap rebuild, and there isn't a clear performance advantage over `Iterator::map`. So let's use `map` since it looks clearer and it's easier to see that everything was indeed updated. This also adds assertions the old code did not have by way of as_iseq() and as_cme().
2025-09-24ZJIT: Prefer *const u8 for consts (#14652)Takashi Kokubun
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-24ZJIT: Add Ruby class objects to HIR type lattice automatically (#14647)Max Bernstein
This: * gets us out of the business of manually writing a bunch of `if`s * gets us more type information * cleans up the code * also adds `types::Numeric`
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-23ZJIT: Add stack overflow check to `gen_ccall_variadic` (#14636)Stan Lo
ZJIT: Add stack overflow check to gen_ccall_variadic
2025-09-22ZJIT: Guard receiver class for CCallVariadic (#14630)Takashi Kokubun
2025-09-22ZJIT: Add more type information to DefinedIvar (#14628)Max Bernstein
Add test.
2025-09-22ZJIT: Clean up RangeType (#14627)Max Bernstein
2025-09-22ZJIT: Add polymorphism counters (#14608)Aiden Fox Ivey
* ZJIT: Add polymorphism counters * . * .
2025-09-22ZJIT: Refactor NewRangeFixnum (#14607)André Luiz Tiago Soares
## Context #14409 https://github.com/ruby/ruby/pull/14409#discussion_r2350238583 >You may have noticed that this doesn't produce a New range instruction. For that you probably need to use a local variable (makes it harder for the bytecode compiler to reason about, but the JIT sees through it). If you have time, please rewrite these tests. https://github.com/ruby/ruby/pull/14409#discussion_r2350240389 >There's some code above to do this for you: see arguments_likely_fixnums and coerce something or other ## Changes ### Refactor tests Modify tests force the usage of `NewRangeFixnum` instruction and make tests names more consistent. ### Refactor optimize ranges Didn't found `arguments_likely_fixnums` to be applicable unless we enable profiling for `NewRange` and change the criteria of when the optimization fires. But there were other ways to clean up the code. Simplify the logic and move it to `type_specialize`. Deleted the standalone `optimize_ranges` function.
2025-09-19ZJIT: Fix opt_{hash,ary,str}_{freeze,uminus}Max Bernstein
The stack layout is incompatible with the way we reify the stack for generating fallback SendWithoutBlock: the receiver is an embedded VALUE in the bytecode, not on the stack. Since we don't expect these to be overridden often, instead of fussing about with the stack layout, just hope for the best and PatchPoint/SideExit. Fix https://github.com/Shopify/ruby/issues/760
2025-09-19ZJIT: Expand the list of safe allocatorsMax Bernstein
It's not just the default allocator; other allocators are also leaf.
2025-09-19ZJIT: Wrap commentMax Bernstein
2025-09-19ZJIT: Avoid unnecessary `PopOpnds` and `PushOpnds` codegen (#14614)Stan Lo
* ZJIT: Avoid unnecessary `PopOpnds` codegen If there's no opnds to restore, we don't need to do anything. * ZJIT: Avoid unnecessary sub_into when there's no opnds to allocate
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()
2025-09-19ZJIT: Simplify NewHash HIR and CodegenStan Lo
We can use `Vec<Opnd>` instead of `Vec<(Opnd, Opnd)>` in NewHash HIR as it's the only usage of such type, which requires special handling.
2025-09-19ZJIT: Count method sends where method lookup failsMax Bernstein
2025-09-19ZJIT: Also count fallback sends to ISEQs we can't direct send toMax Bernstein
Make sure these parameter types are counted in the fallback def_types.
2025-09-19ZJIT: Measure reading/writing locals with level > 0 (#14601)Max Bernstein
ZJIT: Measure writing to locals with level > 0