summaryrefslogtreecommitdiff
path: root/zjit/src/lib.rs
AgeCommit message (Collapse)Author
2 daysZJIT: Only print bold text in TTY (#15864)Max Bernstein
This is really irritating when piping to a file or pager.
2025-11-12ZJIT: Add standalone JSON implementation (#15162)Aiden Fox Ivey
I split this off from https://github.com/ruby/ruby/pull/14999 to land the JSON component earlier. Iongraph's viewer is (as mentioned in the article above) a few notches above graphviz for viewing large CFGs. It also allows easily inspecting different compiler optimization passes and multiple functions in the same browser window. Since Spidermonkey is using this format, it may be beneficial to use it for our own JIT development. The requirement for JSON is downstream from that of the Iongraph format. As for writing the implementation myself, ZJIT leans towards having fewer dependencies, so this is the preferred approach.
2025-11-07ZJIT: Carve out IseqPayload into a separate module (#15098)Takashi Kokubun
2025-09-19ZJIT: Test disasm with insta (#14602)Takashi Kokubun
2025-09-03ZJIT: Ensure `clippy` passes and silence unnecessary warnings (#14439)Aiden Fox Ivey
2025-08-05ZJIT: Profile type+shape distributions (#13901)Max Bernstein
ZJIT uses the interpreter to take type profiles of what objects pass through the code. It stores a compressed record of the history per opcode for the opcodes we select. Before this change, we re-used the HIR Type data-structure, a shallow type lattice, to store historical type information. This was quick for bringup but is quite lossy as profiles go: we get one bit per built-in type seen, and if we see a non-built-in type in addition, we end up with BasicObject. Not very helpful. Additionally, it does not give us any notion of cardinality: how many of each type did we see? This change brings with it a much more interesting slice of type history: a histogram. A Distribution holds a record of the top-N (where N is fixed at Ruby compile-time) `(Class, ShapeId)` pairs and their counts. It also holds an *other* count in case we see more than N pairs. Using this distribution, we can make more informed decisions about when we should use type information. We can determine if we are strictly monomorphic, very nearly monomorphic, or something else. Maybe the call-site is polymorphic, so we should have a polymorphic inline cache. Exciting stuff. I also plumb this new distribution into the HIR part of the compilation pipeline.
2025-07-09ZJIT: Mark profiled objects when marking ISEQ (#13784)Takashi Kokubun
2025-07-08ZJIT: Add a BitSet typeMax Bernstein
2025-06-11ZJIT: Restore most x64 backend testsAlan Wu
Notes: Merged: https://github.com/ruby/ruby/pull/13576
2025-04-18Strength reduce to `CCall` for sends landing in simple C methodsAlan Wu
A new optimization pass. Also: - Printing for `Insn::CCall` - Wrap `ID` and add convenience method for printing, replacing calls to rb_id2name() 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 <maxime.chevalierboisvert@shopify.com> * Add a comment about assert_compiles * Actually use pipe_fd --------- Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Load Param off of cfp->ep (https://github.com/Shopify/zjit/pull/31)Takashi Kokubun
* Load Param off of cfp->ep * Test with --zjit-call-threshold=1 as well * Fix get_opnd's debug output * Return Mem operand from gen_param * Test both first and second calls * Spell out the namespace for Opnd returns * Update a comment about gen_param * Explain why we take a lock * Fix a typo Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Implement FixnumAdd and stub PatchPoint/GuardType ↵Takashi Kokubun
(https://github.com/Shopify/zjit/pull/30) * Implement FixnumAdd and stub PatchPoint/GuardType Co-authored-by: Max Bernstein <max.bernstein@shopify.com> Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> * Clone Target for arm64 * Use $create instead of use create Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> * Fix misindentation from suggested changes * Drop an unneeded variable for mut * Load operand into a register only if necessary --------- Co-authored-by: Max Bernstein <max.bernstein@shopify.com> Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Add std docs to crate docsMax Bernstein
This makes it easier to work offline. Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Add compact Type latticeMax Bernstein
This will be used for local type inference and potentially SCCP. Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Add zjit_* instructions to profile the interpreter ↵Takashi Kokubun
(https://github.com/Shopify/zjit/pull/16) * Add zjit_* instructions to profile the interpreter * Rename FixnumPlus to FixnumAdd * Update a comment about Invalidate * Rename Guard to GuardType * Rename Invalidate to PatchPoint * Drop unneeded debug!() * Plan on profiling the types * Use the output of GuardType as type refined outputs Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Rename --zjit-dump-ssa to --zjit-dump-hir ↵Takashi Kokubun
(https://github.com/Shopify/zjit/pull/17) * Rename --zjit-dump-ssa to --zjit-dump-hir * Update comments * Add a comment on iseq_to_hir Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Avoid setting RUST_BACKTRACE environment while panickingAlan Wu
The 2024 edition pointed out that setting env vars in multiple threaded programs is unsafe, due to it being thread unsafe in glibc. Sure don't want to crash while already crashing! Always grab a backtrace with force_backtrace(). Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Fix 2024 edition errorsAlan Wu
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Resurrect asm comment supportTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Add minor commentsMaxime Chevalier-Boisvert
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Rename ir.rs to hir.rs to avoid namespace ambiguity with backendMaxime Chevalier-Boisvert
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Add --zjit-debug and debug! macroTakashi Kokubun
to print debug messages Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Allow dumping SSA in multiple waysTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Rename utils.rs to cast.rsTakashi Kokubun
to avoid making it a place to put anything. Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Let tests share the same ZJITState::init()Takashi Kokubun
to share the initialization of other globals in the future as well Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Initialize dummy globals for testsTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Start compiling the actual IRTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Add a comment to dump the actual structsTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Add --zjit-dump-ssa optionTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Disable stub code execution for nowTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Generate working putnil-leave using the backendTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Rename codegen.rs to state.rsTakashi Kokubun
since it's only about ZJITState at the moment. Because it's no longer called "CodegenGlobals", we don't have any reason to keep it in codegen.rs. Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Fix cargo testTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Stub YJIT-specific implementations in the backendTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Check dump_disasm option before running disasmTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Support --zjit-dump-disasmTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Implement Options as part of ZJITStateTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Don't panic; errMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Implement the disassemblerTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Try to use libcapstoneTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Fix warnings on MacTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Return null on ArmTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Generate intructions to be executedTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Get CodeBlockTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Move RubyOpcodeMaxime Chevalier-Boisvert
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Add BranchEdgeMaxime Chevalier-Boisvert
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Put mod in the right placeTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Set up the panic handlerTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131