summaryrefslogtreecommitdiff
path: root/zjit/src/codegen.rs
AgeCommit message (Collapse)Author
2025-09-30ZJIT: Add more *_send_count stats (#14689)Takashi Kokubun
2025-09-30ZJIT: Rust code refactors (#14687)Stan Lo
2025-09-30ZJIT: Unify fallback counters for send-ish insns (#14676)Takashi Kokubun
2025-09-29ZJIT: Count dynamic instance variable lookups (#14615)Max Bernstein
2025-09-29ZJIT: Add stats for cfuncs that are not optimized (#14638)Stan Lo
* ZJIT: Add stats for cfuncs that are not optimized * ZJIT: Add IncrCounterPtr HIR instead From `lobsters` ``` Top-20 Unoptimized C functions (73.0% of total 15,276,688): Kernel#is_a?: 2,052,363 (13.4%) Class#current: 1,892,623 (12.4%) String#to_s: 975,973 ( 6.4%) Hash#key?: 677,623 ( 4.4%) String#empty?: 636,468 ( 4.2%) TrueClass#===: 457,232 ( 3.0%) Hash#[]=: 455,908 ( 3.0%) FalseClass#===: 448,798 ( 2.9%) ActiveSupport::OrderedOptions#_get: 377,468 ( 2.5%) Kernel#kind_of?: 339,551 ( 2.2%) Kernel#dup: 329,371 ( 2.2%) String#==: 324,286 ( 2.1%) String#include?: 297,528 ( 1.9%) Hash#[]: 294,561 ( 1.9%) Array#include?: 287,145 ( 1.9%) Kernel#block_given?: 283,633 ( 1.9%) BasicObject#!=: 278,874 ( 1.8%) Hash#delete: 250,951 ( 1.6%) Set#include?: 246,447 ( 1.6%) NilClass#===: 242,776 ( 1.6%) ``` From `liquid-render` ``` Top-20 Unoptimized C functions (99.8% of total 5,195,549): Hash#key?: 2,459,048 (47.3%) String#to_s: 1,119,758 (21.6%) Set#include?: 799,469 (15.4%) Kernel#is_a?: 214,223 ( 4.1%) Integer#<<: 171,073 ( 3.3%) Integer#/: 127,622 ( 2.5%) CGI::EscapeExt#escapeHTML: 56,971 ( 1.1%) Regexp#===: 50,008 ( 1.0%) String#empty?: 43,990 ( 0.8%) String#===: 36,838 ( 0.7%) String#==: 21,309 ( 0.4%) Time#strftime: 21,251 ( 0.4%) String#strip: 15,271 ( 0.3%) String#scan: 13,753 ( 0.3%) String#+@: 12,603 ( 0.2%) Array#include?: 8,059 ( 0.2%) String#+: 5,295 ( 0.1%) String#dup: 4,606 ( 0.1%) String#-@: 3,213 ( 0.1%) Class#generate: 3,011 ( 0.1%) ```
2025-09-29ZJIT: Remove RefCell from IseqCallAlan Wu
No point taking the panic risks with RefCell when most fields in it are already in a Cell. Put `iseq` in a Cell and we no longer need the wrapping. Saves memory, too.
2025-09-29ZJIT: Incorporate parameter loads into HIR (#14659)Takashi Kokubun
2025-09-25ZJIT: Compile ISEQ with optional arguments (#14653)Takashi Kokubun
2025-09-24ZJIT: Prefer *const u8 for consts (#14652)Takashi Kokubun
2025-09-24ZJIT: Incorporate bb0-prologue and PC check into HIR (#14643)Takashi Kokubun
* ZJIT: Incorporate bb0-prologue and PC check into HIR * Fix an outdated comment * Use shallow clone for LoadPC and EntryPoint * Reproduce the actual HIR graph to pass validation * Fill out param types for jit_entry_block * Add Type::from_cptr * Add a TODO comment about Const::CPtr printing
2025-09-23ZJIT: Allow testing JIT code on zjit-test (#14639)Takashi Kokubun
* ZJIT: Allow testing JIT code on zjit-test * Resurrect TestingAllocator tests
2025-09-23ZJIT: Add stack overflow check to `gen_ccall_variadic` (#14636)Stan Lo
ZJIT: Add stack overflow check to gen_ccall_variadic
2025-09-22ZJIT: Clean up RangeType (#14627)Max Bernstein
2025-09-19ZJIT: Expand the list of safe allocatorsMax Bernstein
It's not just the default allocator; other allocators are also leaf.
2025-09-19ZJIT: Avoid unnecessary `PopOpnds` and `PushOpnds` codegen (#14614)Stan Lo
* ZJIT: Avoid unnecessary `PopOpnds` codegen If there's no opnds to restore, we don't need to do anything. * ZJIT: Avoid unnecessary sub_into when there's no opnds to allocate
2025-09-19ZJIT: Simplify NewHash HIR and CodegenStan Lo
We can use `Vec<Opnd>` instead of `Vec<(Opnd, Opnd)>` in NewHash HIR as it's the only usage of such type, which requires special handling.
2025-09-19ZJIT: Measure reading/writing locals with level > 0 (#14601)Max Bernstein
ZJIT: Measure writing to locals with level > 0
2025-09-18ZJIT: Count writes to the VM frame (#14597)Max Bernstein
This is a) a lot of memory traffic and b) is another good proxy for our ability to strength reduce method calls.
2025-09-18ZJIT: Compile sendforward with dynamic dispatch (#14501)Takashi Kokubun
* ZJIT: Compile sendforward with dynamic dispatch * Reload locals only if it has blockiseq * Add a test case of ... with other args
2025-09-18ZJIT: Support variadic C calls (#14575)Stan Lo
* ZJIT: Support variadic C calls This reduces the `dynamic_send_count` in `liquid-render` by ~21% * ZJIT: Reuse gen_push_frame * ZJIT: Avoid optimizing variadic C call when tracing is enabled
2025-09-17ZJIT: Call instance allocation function directlyMax Bernstein
2025-09-17ZJIT: Const-fold IsMethodCfuncMax Bernstein
2025-09-17ZJIT: Specialize ObjectAlloc with known class pointerMax Bernstein
This has fewer effects (can be elided!) and will eventually get better codegen, too. Fix https://github.com/Shopify/ruby/issues/752
2025-09-17ZJIT: Split Insn::Const from Insn::GetBlockParamProxy (#14583)Takashi Kokubun
* ZJIT: Split Insn::Const from Insn::GetBlockParamProxy * Print [BlockParamProxy] * Link a TODO comment to a Shopify/ruby issue
2025-09-17ZJIT: Add stat for `def_type` of send fallbacks (#14533)Stan Lo
I thought about creating a new HIR like `SendWithoutBlockFailedToOptimize` that can carry very specific reasons later. But it'll mean adding it to every branch matching `SendWithoutBlock` and may make code unnecessarily complicated. So I take the easier path for now: ``` Top-4 send fallback def_types (100.0% of total 21,375,357): cfunc: 20,164,487 (94.3%) optimized: 1,197,897 ( 5.6%) attrset: 12,953 ( 0.1%) alias: 20 ( 0.0%) ```
2025-09-16ZJIT: Debug mechanism to verify leafness for `gen_prepare_call_with_gc` (#14553)André Luiz Tiago Soares
* functional debug mechanism; small refactor * make all tests pass * clean up implementation of debug mechanism for gen_prepare_call_with_gc * revert unnecessary change to gen_object_alloc * make ObjectAlloc non-leaf * fix merge error; reintroduce accidentally deleted counter * remove outdated comment * changes as per review comments * make set_stack_canary more stable * add todo comment to specialize object_alloc * revert whitespace changes * create gen_prepare_leaf_call_with_gc helper * fix spacing
2025-09-12ZJIT: Add specific dynamic send type counters (#14528)Stan Lo
2025-09-11ZJIT: Check for VM stack overflowAlan Wu
Previously, the included test crashed or turned into an infinite loop due to the missing check.
2025-09-10ZJIT: Revert `self_val` removal and rename it to `recv` (#14504)Stan Lo
* Revert "ZJIT: Removed unused self_val from Send" This reverts commit 13c2f8d5c2b41ec78344ae60f9b5ec1564029418. * Revert "ZJIT: Removed unused self_val from InvokeSuper" This reverts commit 877b625922e0f8de4e7ad801dd0306e69b34d263. * ZJIT: Rename self_val in dispatching HIRs to recv * ZJIT: Remove unnecessary constructor param names
2025-09-10ZJIT: Support `invokeblock` insn (#14496)Stan Lo
ZJIT: Support invokeblock insn Basically like other send-ish insns, except that it doesn't pop the receiver.
2025-09-09ZJIT: Implement getblockparamproxy (#14483)Takashi Kokubun
Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
2025-09-09ZJIT: Optimize `ObjToString` with type guards (#14469)André Luiz Tiago Soares
* failing test for ObjToString optimization with GuardType * profile ObjToString receiver and rewrite with guard * adjust integration tests for objtostring type guard optimization * Implement new GuardTypeNot HIR; objtostring sends to_s directly on profiled nonstrings * codegen for GuardTypeNot * typo fixes * better name for tests; fix side exit reason for GuardTypeNot * revert accidental change * make bindgen * Fix is_string to identify subclasses of String; fix codegen for identifying if val is String
2025-09-08ZJIT: Fix backtraces on opt_new (#14461)Takashi Kokubun
2025-09-05ZJIT: Invalidate local variables on EP escape (#14448)Takashi Kokubun
2025-09-04ZJIT: Compile invokesuper with dynamic dispatch (#14444)Takashi Kokubun
Co-authored-by: Max Bernstein <ruby@bernsteinbear.com>
2025-09-04ZJIT: Fix Rust compilation warning (#14443)Stan Lo
This fixes: ``` warning: unused import: `ParseError` --> zjit/src/codegen.rs:20:61 | 20 | use crate::hir::{Const, FrameState, Function, Insn, InsnId, ParseError}; | ^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default ```
2025-09-04ZJIT: Add patchpoint for TracePoint (#14420)Stan Lo
ZJIT: Add patchpoint for TracePoint activation Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com> Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
2025-09-04ZJIT: Support compiling ISEQs for opt_pc = 0 (#14441)Takashi Kokubun
* ZJIT: Support compiling ISEQs for opt_pc = 0 * Test send with optional arguments
2025-09-03ZJIT: Ensure `clippy` passes and silence unnecessary warnings (#14439)Aiden Fox Ivey
2025-09-03ZJIT: Add missing module doc commentsAiden Fox Ivey
2025-09-03ZJIT: Count exits coming from jit_exception (#14428)Takashi Kokubun
2025-09-02ZJIT: Use Copy instead of CloneAiden Fox Ivey
2025-09-02ZJIT: Remove unnecessary return statementsAiden Fox Ivey
2025-09-02ZJIT: Remove unnecessary .into callsAiden Fox Ivey
2025-09-02ZJIT: Use inspect_err on Result values (#14431)Takashi Kokubun
2025-09-02ZJIT: Rename gen_save_pc to gen_prepare_call_with_gc (#14427)Takashi Kokubun
2025-09-02ZJIT: Propagate and count CompileError on exits (#14408)Takashi Kokubun
2025-09-02ZJIT: NewRangeFixnum instruction (#14409)André Luiz Tiago Soares
* Failing optimization tests for NewRangeFixnum * NewRangeFixnum general idea * Use gen_prepare_call_with_gc on gen_new_range_fixnum; add additional hir tests * Remove unused NewRange rewrite trigger when neither range is Fixnum literal * Remove misleading 'profiled' name in range optimization tests * Adjustments as per review comments * Include new_range_fixnum tests * remove non-ASCII character from comments as per PR review * remove non-ASCII character from comments as per PR review
2025-08-29ZJIT: Increment dynamic_send_count for Send tooMax Bernstein
2025-08-29ZJIT: Specialize monomorphic GetIvar (#14388)Max Bernstein
Specialize monomorphic `GetIvar` into: * `GuardType(HeapObject)` * `GuardShape` * `LoadIvarEmbedded` or `LoadIvarExtended` This requires profiling self for `getinstancevariable` (it's not on the operand stack). This also optimizes `GetIvar`s that happen as a result of inlining `attr_reader` and `attr_accessor`. Also move some (newly) shared JIT helpers into jit.c.