summaryrefslogtreecommitdiff
path: root/zjit
AgeCommit message (Collapse)Author
2025-07-14ZJIT: Restore SP register after JIT-to-JIT call (#13882)Takashi Kokubun
Co-authored-by: Alan Wu <alansi.xingwu@shopify.com> Co-authored-by: Stan Lo <stan.lo@shopify.com>
2025-07-11ZJIT: Mark objects baked in JIT code (#13862)Takashi Kokubun
2025-07-11ZJIT: Use Vec instead of HashMap for profiling (#13809)Max Bernstein
This is notably faster: no need to hash indices. Before: ``` plum% samply record ~/.rubies/ruby-zjit/bin/ruby --zjit benchmarks/getivar.rb ruby 3.5.0dev (2025-07-10T14:40:49Z master 51252ef8d7) +ZJIT dev +PRISM [arm64-darwin24] itr: time #1: 5311ms #2: 49ms #3: 49ms #4: 48ms ``` After: ``` plum% samply record ~/.rubies/ruby-zjit/bin/ruby --zjit benchmarks/getivar.rb ruby 3.5.0dev (2025-07-10T15:09:06Z mb-benchmark-compile 42ffd3c1ee) +ZJIT dev +PRISM [arm64-darwin24] itr: time #1: 1332ms #2: 49ms #3: 48ms #4: 48ms ```
2025-07-11ZJIT: Improve asm comments for side exits (#13853)Takashi Kokubun
* ZJIT: Improve asm comments for side exits * Use GuardType(Type) and GuardBitEquals(VALUE)
2025-07-11ZJIT: Run validation between compiler passes in debug modeMax Bernstein
2025-07-11ZJIT: Fix missing find!() for SetIvarMax Bernstein
2025-07-11ZJIT: Gracefully handle iseq_name with NULL ISEQMax Bernstein
2025-07-11ZJIT: Don't stringify Function in ValidationErrorMax Bernstein
That's not the validator's responsibility; the caller can choose to later.
2025-07-11Add Set C-APIJeremy Evans
This should be a minimal C-API needed to deal with Set objects. It supports creating the sets, checking whether an element is the set, adding and removing elements, iterating over the elements, clearing a set, and returning the size of the set. Co-authored-by: Nobuyoshi Nakada <nobu.nakada@gmail.com>
2025-07-11ZJIT: A64: Have add/sub to SP be single-instructionAlan Wu
Previously a missed optimization for add followed by mov. While we're at it, have Add and Sub share the same match arm in arm64_split().
2025-07-10ZJIT: Print a message about ZJIT_RB_BUG when unused (#13852)Takashi Kokubun
2025-07-10ZJIT: Mark Snapshot as having an outputMax Bernstein
Other instructions use it as an operand and #13814 especially needs it to have an output for validation.
2025-07-10ZJIT: Validate that each IR instruction appears at most onceMax Bernstein
2025-07-10ZJIT: Implement patch points on BOP redefinition (#13850)Takashi Kokubun
Co-authored-by: Max Bernstein <max@bernsteinbear.com>
2025-07-10ZJIT: Add def-use validator via dataflow analysis (#13814)Ken Jin
This PR adds a validator based on dataflow analysis to ZJIT. It checks that all uses are dominated by a GEN-DEF prior. See issue https://github.com/Shopify/ruby/issues/591 This is especially useful in validating optimizations don't zap away instructions that are actually needed, e.g. DCE. Also included: a slight refactor of the DCE code to its own function, so I can reuse it. Note: the algorithm uses the worklist algorithm rather than the iterative version for faster convergence. Co-Authored-By: Max Bernstein <ruby@bernsteinbear.com>
2025-07-10ZJIT: Avoid optimizing locals on eval (#13840)Takashi Kokubun
* ZJIT: Avoid optimizing locals on eval * Maintain the local state for eval
2025-07-09ZJIT: Mark profiled objects when marking ISEQ (#13784)Takashi Kokubun
2025-07-09ZJIT: Optimize `opt_and` and `opt_or` instructions for FixnumStan Lo
2025-07-09ZJIT: Profile `opt_and` and `opt_or` instructionsStan Lo
2025-07-08ZJIT: Support guarding *Exact types (#13797)Stan Lo
ZJIT already can generate guard type instructions for *Exact types. For example: ``` def test(strings) strings.map do |string| string.bytesize end end test(["foo", "bar"]) ``` ``` HIR: fn block in test: bb0(v0:BasicObject, v1:BasicObject): PatchPoint MethodRedefined(String@0x1014be890, bytesize@0x19f1) v7:StringExact = GuardType v1, StringExact v8:Fixnum = CCall bytesize@0x16fa4cc18, v7 Return v8 ``` But zjit only supported guarding fixnums so this script would panic. This commit adds support for guarding *Exact types.
2025-07-08ZJIT: Use BitSet in HIRMax Bernstein
2025-07-08ZJIT: Add a BitSet typeMax Bernstein
2025-07-08ZJIT: Use nil? optimization to test guard generation against different typesStan Lo
2025-07-08ZJIT: Profile `nil?` callsStan Lo
This allows ZJIT to profile `nil?` calls and create type guards for its receiver. - Add `zjit_profile` to `opt_nil_p` insn - Start profiling `opt_nil_p` calls - Use `runtime_exact_ruby_class` instead of `exact_ruby_class` to determine the profiled receiver class
2025-07-08ZJIT: Make type definition code more consistentStan Lo
2025-07-08ZJIT: More accurately model Class typesStan Lo
2025-07-08ZJIT: Support inference of ModuleExact typeStan Lo
2025-07-07ZJIT: Fix Rust warnings (#13813)Stan Lo
2025-07-07ZJIT: Add opnds macro for Vec<InsnId> to Vec<Opnd> (#13805)Daniel Colson
Along the same lines as the `opnd` macro we already have, but for a `Vec<InsnId>` instead of a single `InsnId`. This gets a few for loops and `jit.get_opnd` calls out of the `gen_` functions.
2025-07-07ZJIT: Add a simple HIR validator (#13780)Ken Jin
This PR adds a simple validator for ZJIT's HIR. See issue https://github.com/Shopify/ruby/issues/591
2025-07-07ZJIT: Avoid double negative in Mem debugDaniel Colson
Prior to this commit the debug output for negative offsets would look like: ``` Mem64[Reg(3) - -8 ``` That makes it look like we're adding instead of subtracting. After this commit we'll print: ``` Mem64[Reg(3) - 8 ```
2025-07-03Support inference of ClassExact typeStan Lo
2025-07-03Add missed runtime_exact_ruby_class case for RegexpStan Lo
2025-07-03ZJIT: Panic on BOP redefinition only when needed (#13782)Takashi Kokubun
2025-07-03ZJIT: Bail out on register spill (#13773)Takashi Kokubun
2025-07-02ZJIT: Reject ISEQs with too-large stack_max (#13770)Takashi Kokubun
2025-07-02ZJIT: Add reason for SideExit (#13768)Max Bernstein
This makes it clearer what is unimplemented when looking at HIR dumps.
2025-07-02ZJIT: Avoid panicing with "Option::unwrap() on None" (#13762)Takashi Kokubun
2025-07-02ZJIT: Support spilling basic block arguments (#13761)Takashi Kokubun
Co-authored-by: Max Bernstein <max@bernsteinbear.com>
2025-07-02ZJIT: Annotate NilClass#nil? and Kernel#nil?Stan Lo
These methods return fixed `true` or `false` so we can be certain about their return types.
2025-07-03ZJIT: `throw` to HIRAlan Wu
2025-07-03ZJIT: Use initialization shorthandAlan Wu
2025-07-02ZJIT: Support `Regexp` type (#13760)Stan Lo
2025-07-01ZJIT: Shorten Debug print for 64-bit VReg (#13763)Takashi Kokubun
2025-07-01ZJIT: Stop tracking EP == BP assumption on JIT entry (#13752)Takashi Kokubun
* ZJIT: Stop tracking EP == BP assumption on JIT entry * Enable test_method.rb as well
2025-06-30ZJIT: Add codegen for IsNilywenc
2025-06-30ZJIT: Add IsNil optimization and tests for optimized hirywenc
2025-06-30ZJIT: Rename Ruby<->Rust functions for clarityMax Bernstein
No need to be so terse.
2025-06-30ZJIT: Pretty-print symbols in HIR dumpMax Bernstein
This lets us better see what is going on, for example in pattern matching code, which has a bunch of dynamic method lookups and `respond_to?` sends.
2025-06-30ZJIT: Mark GetLocal as having no effects (#13750)Max Bernstein
This removes the GetLocal of l3 from: def test l3 = 3 1.times do |l2| _ = l3 1 end end