summaryrefslogtreecommitdiff
path: root/zjit
AgeCommit message (Collapse)Author
2025-06-06ZJIT: Add codegen for uncached setinstancevariableMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13527
2025-06-06ZJIT: Add codegen for uncached getinstancevariableMax Bernstein
I didn't know `rb_ivar_get` existed until @Xrxr pointed me to it. Thanks, Alan! Notes: Merged: https://github.com/ruby/ruby/pull/13527
2025-06-05ZJIT: Panic unimplemented for OOB basic block args (#13533)Shannon Skipper
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2025-06-05ZJIT: Pass self through basic block params (#13529)Takashi Kokubun
* ZJIT: Pass self through basic block params Co-authored-by: Max Bernstein <tekknolagi@gmail.com> * Add comments for self * Use self_param for ivar * Make self_param a loop local * Fix rest parameter type check * Push self_param first * Add a test case for putself * Use SELF_PARAM_IDX Co-authored-by: Max Bernstein <tekknolagi@gmail.com> * Fix test_unknown --------- Co-authored-by: Max Bernstein <tekknolagi@gmail.com> Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2025-06-05Refactor raw accesses to rb_shape_t.capacityJean Boussier
Notes: Merged: https://github.com/ruby/ruby/pull/13524
2025-06-05Get rid of `rb_shape_t.flags`Jean Boussier
Now all flags are only in the `shape_id_t`, and can all be checked without needing to dereference a pointer. Notes: Merged: https://github.com/ruby/ruby/pull/13515
2025-06-04ZJIT: Add newrange support (#13505)Stan Lo
* Add newrange support to zjit * Add RangeType enum for Range insn's flag * Address other feedback Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
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-06-04ZJIT: Fix incorrect method name in test for Array#sizeStan Lo
Notes: Merged: https://github.com/ruby/ruby/pull/13487 Merged-By: XrXr
2025-06-04Get rid of TOO_COMPLEX shape typeJean Boussier
Instead it's now a `shape_id` flag. This allows to check if an object is complex without having to chase the `rb_shape_t` pointer. Notes: Merged: https://github.com/ruby/ruby/pull/13511
2025-06-04ZJIT: Spill to the stack using arguments instead of FrameStateAlan Wu
The FrameState on the SendWithoutBlock represents the entry state, but for instructions that push to the stack in the middle of the instruction before actually doing the send like opt_aref_with, the FrameState is incorrect. We need to write to the stack using the arguments for the instruction. Notes: Merged: https://github.com/ruby/ruby/pull/13468
2025-06-04ZJIT: Parse opt_aref_with into HIRAlan Wu
Notes: Merged: https://github.com/ruby/ruby/pull/13468
2025-06-03Use all 32bits of `shape_id_t` on all platformsJean Boussier
Followup: https://github.com/ruby/ruby/pull/13341 / [Feature #21353] Even thought `shape_id_t` has been make 32bits, we were still limited to use only the lower 16 bits because they had to fit alongside `attr_index_t` inside a `uintptr_t` in inline caches. By enlarging inline caches we can unlock the full 32bits on all platforms, allowing to use these extra bits for tagging. Notes: Merged: https://github.com/ruby/ruby/pull/13500
2025-06-02shape.c: Implement a lock-free version of get_next_shape_internalJean Boussier
Whenever we run into an inline cache miss when we try to set an ivar, we may need to take the global lock, just to be able to lookup inside `shape->edges`. To solve that, when we're in multi-ractor mode, we can treat the `shape->edges` as immutable. When we need to add a new edge, we first copy the table, and then replace it with CAS. This increases memory allocations, however we expect that creating new transitions becomes increasingly rare over time. ```ruby class A def initialize(bool) @a = 1 if bool @b = 2 else @c = 3 end end def test @d = 4 end end def bench(iterations) i = iterations while i > 0 A.new(true).test A.new(false).test i -= 1 end end if ARGV.first == "ractor" ractors = 8.times.map do Ractor.new do bench(20_000_000 / 8) end end ractors.each(&:take) else bench(20_000_000) end ``` The above benchmark takes 27 seconds in Ractor mode on Ruby 3.4, and only 1.7s with this branch. Co-Authored-By: Étienne Barrié <etienne.barrie@gmail.com> Notes: Merged: https://github.com/ruby/ruby/pull/13441
2025-05-30ZJIT: Fold more fixnum operations (#13465)Tavian Barnes
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2025-05-30ZJIT: Assert that we're compiling a specific YARV insn to HIR (#13471)Max Bernstein
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2025-05-28ZJIT: Add CallableMethodEntry to type lattice (GH-13459)Max Bernstein
This will be useful when we split Send into Lookup+Call. For reasoning about various method types during optimization.
2025-05-28Use flag for RCLASS_IS_INITIALIZEDJohn Hawthorn
Previously we used a flag to set whether a module was uninitialized. When checked whether a class was initialized, we first had to check that it had a non-zero superclass, as well as that it wasn't BasicObject. With the advent of namespaces, RCLASS_SUPER is now an expensive operation, and though we could just check for the prime superclass, we might as well take this opportunity to use a flag so that we can perform the initialized check with as few instructions as possible. It's possible in the future that we could prevent uninitialized classes from being available to the user, but currently there are a few ways to do that. Notes: Merged: https://github.com/ruby/ruby/pull/13443
2025-05-27Refactor `rb_shape_get_iv_index` to take a `shape_id_t`Jean Boussier
Further reduce exposure of `rb_shape_t`. Notes: Merged: https://github.com/ruby/ruby/pull/13450
2025-05-27Get rid of `rb_shape_id(rb_shape_t *)`Jean Boussier
We should avoid conversions from `rb_shape_t *` into `shape_id_t` outside of `shape.c` as the short term goal is to have `shape_id_t` contain tags. Notes: Merged: https://github.com/ruby/ruby/pull/13448
2025-05-23ZJIT: Parse branchnil into HIRMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13432
2025-05-23ZJIT: Parse opt_aref into HIRMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13432
2025-05-23ZJIT: Add fast-paths for Array#length and Array#sizeMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13432
2025-05-23ZJIT: Implement find for DefinedMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13430
2025-05-23ZJIT: Mark SideExit as terminatorMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13430
2025-05-23ZJIT: Side-exit into the interpreter on unknown call typesMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13430
2025-05-23ZJIT: Side-exit into the interpreter on unknown opt_newarray_sendMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13430
2025-05-23ZJIT: Side-exit into the interpreter on unknown opcodesMax Bernstein
No need to bail out of compilation completely; we can compile all the code up until that point. Notes: Merged: https://github.com/ruby/ruby/pull/13430
2025-05-23ZJIT: Parse splatarray, concattoarray, pushtoarray into HIR (#13429)Max Bernstein
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2025-05-23[DOC] ZJIT: `Function::find`: Give advice instead of talking about safetyAlan Wu
Co-Authored-By: Max Bernstein <max.bernstein@shopify.com>
2025-05-22ZJIT: Parse newhash into HIRMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13414
2025-05-22ZJIT: Parse duphash into HIRMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13414
2025-05-22ZJIT: Parse getinstancevariable, setinstancevariable into HIR (#13413)Max Bernstein
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2025-05-22ZJIT: More type level docs in zjit::hir [DOC]Alan Wu
Given `InsnId` is at the top of the file and everywhere, hopefully this will help first time readers. Notes: Merged: https://github.com/ruby/ruby/pull/13399
2025-05-20ZJIT: Allow DCE to remove some CCalls (#13363)Max Bernstein
Allow DCE to remove some CCalls Add `elidable` field that signals that there would be no discernible effect if the call to the method were removed. The default is false. Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2025-05-21ZJIT: Add --allow-multiple-definition for make zjit-testAlan Wu
Notes: Merged: https://github.com/ruby/ruby/pull/13377
2025-05-16ZJIT: Create more ergonomic type profiling API (#13339)Max Bernstein
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2025-05-16ZJIT: Remove unnecessary cloningMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13355
2025-05-15ZJIT: Bail out of recursive compilation if we can't compile calleeMax Bernstein
Right now we just crash if we can't compile an ISEQ for any reason (unimplemented in HIR, unimplemented in codegen, ...) and this fixes that by bailing out. Notes: Merged: https://github.com/ruby/ruby/pull/13356
2025-05-15YJIT: ZJIT: Allow both JITs in the same buildAlan Wu
This commit allows building YJIT and ZJIT simultaneously, a "combo build". Previously, `./configure --enable-yjit --enable-zjit` failed. At runtime, though, only one of the two can be enabled at a time. Add a root Cargo workspace that contains both the yjit and zjit crate. The common Rust build integration mechanisms are factored out into defs/jit.mk. Combo YJIT+ZJIT dev builds are supported; if either JIT uses `--enable-*=dev`, both of them are built in dev mode. The combo build requires Cargo, but building one JIT at a time with only rustc in release build remains supported. Notes: Merged: https://github.com/ruby/ruby/pull/13262
2025-05-14ZJIT: Split long `use` line and add a module doc.Alan Wu
Notes: Merged: https://github.com/ruby/ruby/pull/13276
2025-05-14ZJIT: More tests for parsing param formsAlan Wu
Notes: Merged: https://github.com/ruby/ruby/pull/13276
2025-05-14ZJIT: Infer ArrayExact for the rest parameterAlan Wu
The rest parameter is always a rb_cArray, even when anonymous. (This is different from kw_rest, which can be nil.) Notes: Merged: https://github.com/ruby/ruby/pull/13276
2025-05-14ZJIT: Fix rest parameter not parsed into a BB parameterAlan Wu
Use total parameter size instead of lead parameter size when parsing iseq into hir. Also, copy over IntoUsize for compile-time checked u32->usize cast. Notes: Merged: https://github.com/ruby/ruby/pull/13276
2025-05-14ZJIT: Add IntoUsize, ported from YJITAlan Wu
Notes: Merged: https://github.com/ruby/ruby/pull/13276
2025-05-12ZJIT: Stop padding side exits (#13295)Takashi Kokubun
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2025-05-11Add yjit/zjit bindings for adding namespaceSatoshi Tagomori
2025-05-09ZJIT: Fix a splitting condition for LHSTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13279
2025-05-09Rename `RB_OBJ_SHAPE` -> `rb_obj_shape`Jean Boussier
As well as `RB_OBJ_SHAPE_ID` -> `rb_obj_shape_id` and `RSHAPE` is now a simple alias for `rb_shape_lookup`. I tried to turn all these into `static inline` but I'm having trouble with `RUBY_EXTERN rb_shape_tree_t *rb_shape_tree_ptr;` not being exposed as I'd expect. Notes: Merged: https://github.com/ruby/ruby/pull/13283
2025-05-09Rename `rb_shape_get_shape_id` -> `RB_OBJ_SHAPE_ID`Jean Boussier
And `rb_shape_get_shape` -> `RB_OBJ_SHAPE`. Notes: Merged: https://github.com/ruby/ruby/pull/13283