summaryrefslogtreecommitdiff
path: root/zjit
AgeCommit message (Collapse)Author
2025-04-18Default to BasicObject subclass if unknownMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Add profiling for opt_send_without_blockAlan Wu
Split out from the CCall changes since we discussed during pairing that this is useful to unblock some other changes. No tests since no one consumes this profiling data yet. Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Make disassembly look nicer using InsnPrinterMax Bernstein
This makes the disassembly comments much easier to read because they use the more familiar `v2` rather than `InsnId(2)` and `Fixnum` rather than `Type { bits: ...... }`. Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Use expect-test for HIR testsMax Bernstein
This makes it easier to update cascading test failures while still making output reviewable in the PR. Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Add constant folding pass (https://github.com/Shopify/zjit/pull/74)Max Bernstein
Add a constant folding pass for HIR. This pass uses the types left by `infer_types` to fold away: * `GuardType(val, ty)` where `val` is already `ty` * `FixnumAdd(l, r)` where `l` and `r` are constants * `FixnumLt(l, r)` where `l` and `r` are constants * `FixnumEq(l, r)` where `l` and `r` are constants * `Test(v)`, where `v` is a constant * `IfTrue(v)` and `IfFalse(v)` where `v` is a constant It does this by using the union-find data structure in the IR to avoid a complicated manual find-and-replace process for all the uses. Right now, for branch instructions that it deletes, we remove from the block completely. This is safe only because we have ensured that nothing refers to branch instructions---they produce no values. However, if we want to instead replace them with Nops that get ignored during codegen or removed by a later DCE pass, that works for me as well. Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Don't compute predecessors for infer_types ↵Max Bernstein
(https://github.com/Shopify/zjit/pull/78) We don't need this anymore thanks to the push-driven type union for basic block arguments. Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Assert that ids are initializedAlan Wu
I've been bit by this a couple times. Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18DRY up IDs that have the same content as their nameAlan Wu
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Fix VALUE/isize conversionMax Bernstein
Coming out of VALUE did not work for negative numbers; they came out as huge numbers instead. Add more tests. Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Compile IfFalse, IfTrue, and Jump instructions ↵Takashi Kokubun
(https://github.com/Shopify/zjit/pull/72) * Compile IfFalse instruction * Add a TODO comment * Rename *s_len to num_*s * Run only gen_param() against block.params * Add a few more tests * Wrap label indexes with Label * Compile blocks in reverse post-order * Simplify a nested test * s/get_block/block/ * Return a number instead of an iterator * Clarify the allocator uses disjoint sets of registers * Use Display for Block and Insn * Compile IfTrue and Jump * Avoid resolving Param instructions * Always compile Insn::Param as basic block arguments * Remove an obsoleted variable * Change it back to use find * Use find for params too * Use Display more * Add more tests * nested if * if after if * if elsif else * loop after loop * nested loops * if in loop * loop in if Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18HIR printing: Assign stable address to pointers when first seenAlan Wu
This gives output stability while still showing address equality and inequality. This mapping mechanism is only turned on for FunctionPrinter, so implementation of Display and Debug can share the same code but not go through the mapping process. Outside of `cfg!(test)` we don't want and need to stabilize the addresses. Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Fix another case of single-arm matchMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Make reverse post-order traversal iterativeMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Refactor push_fixnum_insn! further (https://github.com/Shopify/zjit/pull/70)Takashi Kokubun
* Refactor push_fixnum_insn! further * Take one or zero extra argument Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Use a more noticeable invalid pointerMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Test builtin type inferenceMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Fix type checking for strings, arrays, and hashes in the constant poolMax Bernstein
Prism hides the objects from the GC by setting the objects' class fields to 0, so class_of returns 0 (unexpectedly, at least to me). Instead, use builtin_type. Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Print fake/stable addresses in HIR printer in testsMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Convert send (with block) to HIR (https://github.com/Shopify/zjit/pull/67)Max Bernstein
* Convert send (with block) to HIR * Remove newline Co-authored-by: Maxime Chevalier-Boisvert <[email protected]> --------- Co-authored-by: Maxime Chevalier-Boisvert <[email protected]> Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Revert "Pass $state to fallbacks instead of exit_state"Takashi Kokubun
This reverts commit e2eae71d44ced602946d54a083f600848eab79e9. The $state exists for switching Fixnum insn, so guard_two_fixnums and SendWithoutBlock shouldn't need to use $state. The other macro argument pattern doesn't have $state, so it's now inconsistent. Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Pass $state to fallbacks instead of exit_stateTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Resurrect icache invalidation for arm64 ↵Takashi Kokubun
(https://github.com/Shopify/zjit/pull/68) * Resurrect icache invalidation for arm64 * Get rid of cfg(not(test)) Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Refactor Fixnum operations using macrosTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Move a couple of bindgen targets to ZJIT bindgenTakashi Kokubun
We filed https://github.com/Shopify/zjit/pull/65 and https://github.com/Shopify/zjit/pull/64 concurrently. Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Rust tests: Load builtins (core library written in ruby)Alan Wu
Key here is calling rb_call_builtin_inits(), which sticking to public API for robustness is done by calling ruby_options(). Fixes: https://github.com/Shopify/zjit/issues/61 Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Implement dynamic dispatch for opt_send_without_block ↵Takashi Kokubun
(https://github.com/Shopify/zjit/pull/63) * Implement dynamic dispatch for opt_send_without_block * Rename stack methods * Fix typos * More clarification on gen_save_sp() * Update a comment * Update a comment about spills * Rename name to method_name * Test no-arg and 2-arg method calls Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Stop sharing yjit/bindgen with ZJIT (https://github.com/Shopify/zjit/pull/64)Takashi Kokubun
* cp -r yjit/bindgen zjit/ * Rename YJIT variables * Stop mentioning YJIT in zjit.c Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Print Ruby exception in test utilsMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Implement codegen for Test insn (https://github.com/Shopify/zjit/pull/57)Maxime Chevalier-Boisvert
* Implement codegen for Test insn * Update zjit/src/codegen.rs Co-authored-by: Alan Wu <[email protected]> --------- Co-authored-by: Alan Wu <[email protected]> Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Explicitly give function parameters types ↵Max Bernstein
(https://github.com/Shopify/zjit/pull/52) * Explicitly give function parameters types Entrypoint blocks have no predecessors, so they are not otherwise typed. This means we have to explicitly mark them as being Object. * Refactor some tests Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Replace ...User with ...SubclassMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Add union and predicates for testing if immediate ↵Max Bernstein
(https://github.com/Shopify/zjit/pull/54) * Add union and predicates for testing if immediate * Add tests * Improve description for Primitive * Add undef to immediates Also partition Any into (Primitive | Value), where Value is (Object | Undef) * Add BasicObject to hierarchy * Rename Value to RubyValue and Primitive to CValue Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Prefix stack operation names with `stack_`Takashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Put hir_type sources in a sub-folderTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Remove more outdated TODOsMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Remove outdated TODOMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Add a make target to run all ZJIT tests ↵Takashi Kokubun
(https://github.com/Shopify/zjit/pull/49) * Add a make target to run all ZJIT tests * Remove an unused variable * Write up a document about testing * Explain zjit-test-all first * Clarify what's zjit-test-all Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Implement all basic Fixnum instructions ↵Takashi Kokubun
(https://github.com/Shopify/zjit/pull/50) * Implement all basic Fixnum instructions * Use opnd! macro for other instructions as well Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Compile FixnumLt (https://github.com/Shopify/zjit/pull/48)Max Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Add diff_text to pretty-print IR differences in unit test failuresMax Bernstein
This produces errors that look like thread 'hir::tests::test_display_types' panicked at src/hir.rs:1777:9: assertion `left == right` failed: Differences found (-expected, +actual): --- bb0(): v0:NilClassExact = Const Value(nil) v2:TrueClassExact = Const Value(true) v6:CBool[true] = Test v2 - IfFalse v6, bb1(v) + IfFalse v6, bb1(v2) v9:Fixnum[3] = Const Value(3) Return v9 bb1(v12): v14 = Const Value(4) Return v14 --- instead of just left: "bb0():\n v0:NilClassExact = Const Value(nil)\n v2:TrueClassExact = Const Value(true)\n v6:CBool[true] = Test v2\n IfFalse v6, bb1(v2)\n v9:Fixnum[3] = Const Value(3)\n Return v9\nbb1(v12):\n v14 = Const Value(4)\n Return v14\n" right: "bb0():\n v0:NilClassExact = Const Value(nil)\n v2:TrueClassExact = Const Value(true)\n v6:CBool[true] = Test v2\n IfFalse v6, bb1(v)\n v9:Fixnum[3] = Const Value(3)\n Return v9\nbb1(v12):\n v14 = Const Value(4)\n Return v14\n" Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Remove reference to nonexistent functionMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Add intraprocedural flow typing (https://github.com/Shopify/zjit/pull/23)Max Bernstein
* Add RPO * Add basic flow typing * Add more tests, check for type bit equality * Run to fixpoint * Only use/flow types if insn has an output * WIP * WIP 2: merge pred args * It compiles again * Infer more Const instructions * Boot VM * Test displaying types * . * Use type_of more * Extract Param inference into its own function for readability * . * . * Add notion of unions to generated type bit patterns * . * . * Fix hierarchy for user/exact * . * . * . * Give ArraySet a receiver * Use Function::find consistently * s/fd/find/g * Comment * . * Add TODO about recursion * FrameStateId * Use worklist based type inference This requires computing "uses", or at least which blocks to revisit if their params change. * Just use a set * Revert "Just use a set" This reverts commit 54d88be00cbf78ce7e928c66d955c968187a5ec9. * Revert "Use worklist based type inference" This reverts commit e99b24629723c8848fefd5a75caa23e84c2f552e. * . * Store block params separately * Sparse type inference * Get tests passing after rebase * . * Use assert_method_hir * . Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Set a return value before popping registers ↵Takashi Kokubun
(https://github.com/Shopify/zjit/pull/41) Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Fix a comment for subtractionTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Implement Insn::FixnumSub (https://github.com/Shopify/zjit/pull/42)Takashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Move lib.rs functions to appropriate modules ↵Takashi Kokubun
(https://github.com/Shopify/zjit/pull/43) Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Assert everything is compiled in test_zjit ↵Takashi Kokubun
(https://github.com/Shopify/zjit/pull/40) * Assert everything is compiled in test_zjit * Update a comment on rb_zjit_assert_compiles Co-authored-by: Maxime Chevalier-Boisvert <[email protected]> * Add a comment about assert_compiles * Actually use pipe_fd --------- Co-authored-by: Maxime Chevalier-Boisvert <[email protected]> Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Implement Insn::Param using the SP register ↵Takashi Kokubun
(https://github.com/Shopify/zjit/pull/39) Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Load an immediate into a register in the backend ↵Takashi Kokubun
(https://github.com/Shopify/zjit/pull/38) Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Do not assert inside rb_protect() (https://github.com/Shopify/zjit/pull/37)Takashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131