summaryrefslogtreecommitdiff
path: root/zjit/src
AgeCommit message (Collapse)Author
13 hoursRename `imemo_class_fields` -> `imemo_fields`Jean Boussier
Notes: Merged: https://github.com/ruby/ruby/pull/13626
15 hoursZJIT: Add codegen (and FrameState) for GetConstPathAlan Wu
Issue a call to rb_vm_opt_getconstant_path() like the interpreter, but since that allocates the IC, we need to save the PC before calling. Add FrameState to GetConstPath to get access to the PC. Notes: Merged: https://github.com/ruby/ruby/pull/13628
15 hoursZJIT: Parse opt freeze insns to HIRDaniel Colson
* `opt_hash_freeze` * `opt_ary_freeze` * `opt_str_freeze` * `opt_str_uminus` Similar to `opt_neq`, but there are no args for `freeze` Co-authored-by: ywenc <[email protected]> Co-authored-by: Max Bernstein <[email protected]> Notes: Merged: https://github.com/ruby/ruby/pull/13588
27 hoursZJIT: Add codegen for StringCopyDaniel Colson
Prior to this commit we compiled `putstring` and `putchilledstring` to `StringCopy`, but then failed to compile past HIR. This commit adds codegen for `StringCopy` to call `rb_ec_str_ressurrect` as the VM does for these instructions. Notes: Merged: https://github.com/ruby/ruby/pull/13625
31 hoursZJIT: Add support for putspecialobject (#13565)Stan Lo
* ZJIT: Add support for putspecialobject * Address feedback * Update tests * Adjust the indentation of a Ruby test --------- Co-authored-by: Takashi Kokubun <[email protected]> Notes: Merged-By: k0kubun <[email protected]>
4 daysGet rid of FL_EXIVARJean Boussier
Now that the shape_id gives us all the same information, it's no longer needed. Notes: Merged: https://github.com/ruby/ruby/pull/13612
4 daysZJIT: Only write LIR output of HIR instructions with outputMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13602
4 daysZJIT: Add codegen for SideExitMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13602
5 daysZJIT: Write a callee frame on JIT-to-JIT calls (#13579)Takashi Kokubun
Co-authored-by: Max Bernstein <[email protected]> Notes: Merged-By: k0kubun <[email protected]>
5 daysGet rid of `rb_shape_lookup`Jean Boussier
Notes: Merged: https://github.com/ruby/ruby/pull/13596
6 daysTurn `rb_classext_t.fields` into a T_IMEMO/class_fieldsJean Boussier
This behave almost exactly as a T_OBJECT, the layout is entirely compatible. This aims to solve two problems. First, it solves the problem of namspaced classes having a single `shape_id`. Now each namespaced classext has an object that can hold the namespace specific shape. Second, it open the door to later make class instance variable writes atomics, hence be able to read class variables without locking the VM. In the future, in multi-ractor mode, we can do the write on a copy of the `fields_obj` and then atomically swap it. Considerations: - Right now the `RClass` shape_id is always synchronized, but with namespace we should likely mark classes that have multiple namespace with a specific shape flag. Notes: Merged: https://github.com/ruby/ruby/pull/13411
7 daysZJIT: x86: Fix panic writing 32-bit number with top bit setAlan Wu
Previously, `asm.mov(m32, imm32)` panicked when `imm32 > 0x80000000`. It attempted to split imm32 into a register before doing the store, but then the register size didn't match the destination size. Instead of splitting, use the `MOV r/m32, imm32` form which works for all 32-bit values. Adjust asserts that assumed that all forms undergo sign extension, which is not true for this case. See: 54edc930f9f0a658da45cfcef46648d1b6f82467 Notes: Merged: https://github.com/ruby/ruby/pull/13576
7 daysZJIT: Restore x86 assembler testsAlan Wu
Notes: Merged: https://github.com/ruby/ruby/pull/13576
7 daysZJIT: Restore some A64 backend tests to fix unused warningAlan Wu
Notes: Merged: https://github.com/ruby/ruby/pull/13576
7 daysZJIT: Restore most x64 backend testsAlan Wu
Notes: Merged: https://github.com/ruby/ruby/pull/13576
7 daysZJIT: Support get/set on global variablesAaron Patterson
Adds support for code like: ```ruby $foo $foo = x ``` Notes: Merged: https://github.com/ruby/ruby/pull/13569
9 daysZJIT: Parse opt_regexpmatch2 into HIRAlan Wu
Notes: Merged: https://github.com/ruby/ruby/pull/13549
9 daysZJIT: Parse opt_not into HIRAlan Wu
Notes: Merged: https://github.com/ruby/ruby/pull/13549
9 daysZJIT: Parse opt_or into HIRAlan Wu
Notes: Merged: https://github.com/ruby/ruby/pull/13549
9 daysZJIT: Parse opt_and into HIRAlan Wu
Notes: Merged: https://github.com/ruby/ruby/pull/13549
9 daysZJIT: Parse opt_succ into HIRAlan Wu
Notes: Merged: https://github.com/ruby/ruby/pull/13549
9 daysZJIT: Parse opt_empty_p into HIRAlan Wu
Notes: Merged: https://github.com/ruby/ruby/pull/13549
10 daysGet rid of rb_shape_t.heap_idJean Boussier
Notes: Merged: https://github.com/ruby/ruby/pull/13556
12 daysZJIT: Fix build error from commit raceAlan Wu
12 daysZJIT: Fix insn arg index for `defined`, add testsAlan Wu
Notes: Merged: https://github.com/ruby/ruby/pull/13528
12 daysZJIT: Parse definedivar into HIRAlan Wu
Notes: Merged: https://github.com/ruby/ruby/pull/13528
12 daysZJIT: Take a slice instead of Vec in test codeAlan Wu
Shorter code and more efficient. Notes: Merged: https://github.com/ruby/ruby/pull/13528
12 daysZJIT: Add codegen for uncached setinstancevariableMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13527
12 daysZJIT: 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
12 daysZJIT: Panic unimplemented for OOB basic block args (#13533)Shannon Skipper
Notes: Merged-By: k0kubun <[email protected]>
12 daysZJIT: Pass self through basic block params (#13529)Takashi Kokubun
* ZJIT: Pass self through basic block params Co-authored-by: Max Bernstein <[email protected]> * 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 <[email protected]> * Fix test_unknown --------- Co-authored-by: Max Bernstein <[email protected]> Notes: Merged-By: k0kubun <[email protected]>
12 daysRefactor raw accesses to rb_shape_t.capacityJean Boussier
Notes: Merged: https://github.com/ruby/ruby/pull/13524
13 daysGet 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
13 daysZJIT: 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 <[email protected]>
13 daysZJIT: Implement side exits for entry frames (#13469)Takashi Kokubun
Co-authored-by: Max Bernstein <[email protected]> Co-authored-by: Alan Wu <[email protected]> Notes: Merged-By: k0kubun <[email protected]>
14 daysZJIT: Fix incorrect method name in test for Array#sizeStan Lo
Notes: Merged: https://github.com/ruby/ruby/pull/13487 Merged-By: XrXr
14 daysGet 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
14 daysZJIT: 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
14 daysZJIT: 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é <[email protected]> Notes: Merged: https://github.com/ruby/ruby/pull/13441
2025-05-30ZJIT: Fold more fixnum operations (#13465)Tavian Barnes
Notes: Merged-By: k0kubun <[email protected]>
2025-05-30ZJIT: Assert that we're compiling a specific YARV insn to HIR (#13471)Max Bernstein
Notes: Merged-By: k0kubun <[email protected]>
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