aboutsummaryrefslogtreecommitdiffstats
path: root/yjit.rb
Commit message (Collapse)AuthorAgeFilesLines
* YJIT: Delete otherwise-empty defer_compilation() blocksAlan Wu2024-06-131-0/+1
| | | | | | | | | | | | | | | | | | | | | Calls to defer_compilation() leave behind a stub and a `struct Block` that we retain. If the block is empty, it only exits to hold the `struct Branch` that the stub needs. This patch transplants the branch out of the empty block into the newly generated block when the defer_compilation() stub is hit, and deletes the empty block to save memory. To assist the transplantation, `Block::outgoing` is now a `MutableBranchList`, and `Branch::Block` now in a `Cell`. These types don't incur a size cost. On the `lobsters` benchmark, `yjit_alloc_size` is roughly 98% of what it was before the change. Co-authored-by: Kevin Menard <kevin.menard@shopify.com> Co-authored-by: Randy Stauner <randy@r4s6.net> Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>
* YJIT: Align number of `total_exits` for --yjit-statsAlan Wu2024-06-131-1/+1
|
* YJIT: add context cache hits stat (#10979)Maxime Chevalier-Boisvert2024-06-121-1/+2
| | | | | | * YJIT: add context cache hits stat This stat should make more sense when it comes to interpreting the effectiveness of the cache on large deployed apps.
* YJIT: add context cache size stat, lazily allocate cacheMaxime Chevalier-Boisvert2024-06-111-0/+1
| | | | | * YJIT: add context cache size stat * Allocate the context cache in a box so CRuby doesn't pay overhead * Add an extra debug assertion
* YJIT: implement variable-length context encoding scheme (#10888)Maxime Chevalier-Boisvert2024-06-071-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Implement BitVector data structure for variable-length context encoding * Rename method to make intent clearer * Rename write_uint => push_uint to make intent clearer * Implement debug trait for BitVector * Fix bug in BitVector::read_uint_at(), enable more tests * Add one more test for good measure * Start sketching Context::encode() * Progress on variable length context encoding * Add tests. Fix bug. * Encode stack state * Add comments. Try to estimate context encoding size. * More compact encoding for stack size * Commit before rebase * Change Context::encode() to take a BitVector as input * Refactor BitVector::read_uint(), add helper read functions * Implement Context::decode() function. Add test. * Fix bug, add tests * Rename methods * Add Context::encode() and decode() methods using global data * Make encode and decode methods use u32 indices * Refactor YJIT to use variable-length context encoding * Tag functions as allow unused * Add a simple caching mechanism and stats for bytes per context etc * Add comments, fix formatting * Grow vector of bytes by 1.2x instead of 2x * Add debug assert to check round-trip encoding-decoding * Take some rustfmt formatting * Add decoded_from field to Context to reuse previous encodings * Remove olde context stats * Re-add stack_size assert * Disable decoded_from optimization for now
* YJIT: print msg to stderr when RubyVM::YJIT.disasm not available (#10688)Maxime Chevalier-Boisvert2024-04-301-6/+20
| | | | | | | | | | | | | | | | | | * YJIT: print msg to stderr when RubyVM::YJIT.disasm not available Print a more useful error message when people try to use this feature without YJIT dev. Also fix an issue with .gitignore file on macOS * Update yjit.rb Co-authored-by: Randy Stauner <randy@r4s6.net> * Use warn and always return nil if YJIT disasm not available. --------- Co-authored-by: Randy Stauner <randy@r4s6.net>
* YJIT: add iseq_alloc_count to stats (#10398)Maxime Chevalier-Boisvert2024-03-281-0/+1
| | | | | | | | | * YJIT: add iseq_alloc_count to stats * Remove an empty line --------- Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
* YJIT: Lazily push a frame for specialized C funcs (#10080)Takashi Kokubun2024-02-231-0/+4
| | | | | | | | | | | | | | | | | | | | | * YJIT: Lazily push a frame for specialized C funcs Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> * Fix a comment on pc_to_cfunc * Rename rb_yjit_check_pc to rb_yjit_lazy_push_frame * Rename it to jit_prepare_lazy_frame_call * Fix a typo * Optimize String#getbyte as well * Optimize String#byteslice as well --------- Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>
* YJIT: Remove unused countersAlan Wu2024-02-161-1/+0
|
* YJIT: Adjust the padding size of counts automatically (#9912)Takashi Kokubun2024-02-121-9/+10
|
* [DOC] `:stopdoc:` directive must be on its own line (#9916)Nobuyoshi Nakada2024-02-121-1/+4
|
* YJIT: Remove unused variablesNobuyoshi Nakada2024-02-101-2/+0
|
* YJIT: Add top ISEQ call counts to --yjit-stats (#9906)Takashi Kokubun2024-02-091-20/+12
|
* YJIT: Fallback megamorphic opt_case_dispatch (#9894)Takashi Kokubun2024-02-091-2/+3
|
* YJIT: Specialize splatkw on T_HASH (#9764)Takashi Kokubun2024-01-301-0/+1
| | | | | | | | | | | | | * YJIT: Specialize splatkw on T_HASH * Fix a typo Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> * Fix a few more comments --------- Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
* YJIT: Add a counter for invokebuiltin exits (#9696)Takashi Kokubun2024-01-251-0/+1
|
* YJIT: Allow inlining ISEQ calls with a block (#9622)Takashi Kokubun2024-01-231-0/+1
| | | | | * YJIT: Allow inlining ISEQ calls with a block * Leave a TODO comment about u16 inline_block
* YJIT: specialized codegen for integer right shift (#9564)Maxime Chevalier-Boisvert2024-01-171-0/+1
| | | | | | | | | | | | | | * YJIT: specialized codegen for integer right shift Used in optcarrot. May also be used to write pure-Ruby gems. No overflow check or fixnum untagging required. * Update yjit/src/codegen.rs Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com> --------- Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
* YJIT: Optimize Integer#succ (#9519)Takashi Kokubun2024-01-151-0/+1
|
* YJIT: Fallback Integer#<< if a shift amount varies (#9426)Takashi Kokubun2024-01-081-1/+1
| | | | | * YJIT: Fallback Integer#<< if a shift amount varies * YJIT: Do not fallback lshift in the first chain
* YJIT: Let RubyVM::YJIT.enable respect --yjit-stats (#9415)Takashi Kokubun2024-01-051-1/+5
|
* YJIT: Add stats option to RubyVM::YJIT.enable (#9297)Takashi Kokubun2023-12-191-8/+13
|
* YJIT: fix bug in top cfunc logging in `--yjit-stats` (#9056)Maxime Chevalier-Boisvert2023-11-281-1/+3
| | | | | YJIT: correctly handle case where there are no cfunc calls Fix bug in top cfunc logging in `--yjit-stats`
* YJIT: add top C function call counts to `--yjit-stats` (#9047)Maxime Chevalier-Boisvert2023-11-271-0/+29
| | | | | * YJIT: gather call counts for individual cfuncs Co-authored by Takashi Kokubun
* YJIT: record `num_send_cfunc` stat (#9022)Maxime Chevalier-Boisvert2023-11-231-1/+2
| | | | | | | | | * YJIT: record num_send_cfunc stat Also report num_send_known_cfunc as percentage of num_send_cfunc * Rename num_send_known_cfunc => num_send_cfunc_inline Name seems more descriptive of what we do with out custom codegen
* [DOC] RubyVM::YJIT doc improvementsAlan Wu2023-11-101-25/+25
| | | | | | | * Weaken notice about API stability. A few public APIs in here now. * Prune out APIs from the docs that are private in nature * Enable markdown mode and ensure `--` options are quoted so they are rendered as two dashes in the HTML.
* YJIT: refactor format_number (#8869)Mau Magnaguagno2023-11-081-5/+4
| | | Replace enumerators with simpler and faster version that only inserts commas before '.' or end of integer string.
* YJIT: Inline basic Ruby methods (#8855)Takashi Kokubun2023-11-071-0/+3
| | | | | | | * YJIT: Inline basic Ruby methods * YJIT: Fix "InsnOut operand made it past register allocation" checktype should not generate a useless instruction.
* YJIT: skip to_a in format_number (#8815)Mau Magnaguagno2023-11-011-1/+1
| | | String#chars returns an array instead of an enumerator since Ruby 2.0.
* YJIT: Print exit reasons on failure in test_yjit.rbAlan Wu2023-10-191-7/+12
| | | | | | | | | | | For <https://bugs.ruby-lang.org/issues/19921>, I suspect the test is failing due to a timing related interrupt, which on paper could happen with slow-enough GC runs. In any case, it's helpful for debugging to have more information when tests fail. Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
* YJIT: Add RubyVM::YJIT.enable (#8705)Takashi Kokubun2023-10-191-4/+4
|
* YJIT: Add a live ISeq counter Alan Wu2023-10-181-0/+1
| | | | | | | It's an estimator for application size and could be used as a compilation heuristic later. Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
* YJIT: Add a few missing counters for send fallback (#8681)Takashi Kokubun2023-10-171-1/+1
|
* YJIT: port call threshold logic from Rust to C for performance (#8628)Maxime Chevalier-Boisvert2023-10-121-1/+1
| | | | | | | | | | | | | | | | | * Port call threshold logic from Rust to C for performance * Prefix global/field names with yjit_ * Fix linker error * Fix preprocessor condition for rb_yjit_threshold_hit * Fix third linker issue * Exclude yjit_calls_at_interv from RJIT bindgen --------- Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
* YJIT: add heuristic to avoid compiling cold ISEQs (#8522)Maxime Chevalier-Boisvert2023-10-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * YJIT: Add counter to measure how often we compile "cold" ISEQs (#535) Fix counter name in DEFAULT_COUNTERS YJIT: add --yjit-cold-threshold, don't compile cold ISEQs YJIT: increase default cold threshold to 200_000 Remove rb_yjit_call_threshold() Remove conflict markers Fix compilation errors Threshold 1 should compile immediately Debug deadlock issue with test_ractor Fix call threshold issue with tests * Revert exception threshold logic. Document option in yjid.md * (void) for 0 parameter functions in C99 * Rename iseq_entry_cold => cold_iseq_entry * Document --yjit-cold-threshold in ruby.c * Update doc/yjit/yjit.md Co-authored-by: Jean byroot Boussier <jean.boussier+github@shopify.com> * Shorten help string to appease test * Address bug found by Kokubun. Reorder logic. --------- Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> Co-authored-by: Jean byroot Boussier <jean.boussier+github@shopify.com>
* YJIT: Report all insn exit reasons (#8541)Takashi Kokubun2023-09-291-9/+30
|
* YJIT: Add compilation time counter (#8417)Takashi Kokubun2023-09-121-0/+1
| | | | | * YJIT: Add compilation time counter * YJIT: Use Instant instead
* YJIT: add code_region_overhead stat output (#8262)Maxime Chevalier-Boisvert2023-08-221-0/+4
|
* YJIT: Quiet mode when running with `--yjit-stats` (#8251)ywenc2023-08-181-1/+3
| | | Quiet mode for running with --yjit-stats
* YJIT: implement codegen for rb_int_lshift (#8201)Maxime Chevalier-Boisvert2023-08-111-0/+1
| | | | | | | | | | | * YJIT: implement codegen for rb_int_lshift * Update yjit/src/asm/x86_64/mod.rs Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com> --------- Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
* YJIT: Distinguish exit and fallback reasons for invokesuper/invokeblock (#8194)Takashi Kokubun2023-08-091-2/+4
| | | | | YJIT: Distinguish exit and fallback reasons for invokesuper/invokeblock
* YJIT: Count throw instructions for each tag (#8188)Takashi Kokubun2023-08-091-0/+4
| | | | | * YJIT: Count throw instructions for each tag * Show % of each throw type
* YJIT: Count all opt_getconstant_path exit reasons (#8187)Takashi Kokubun2023-08-091-1/+1
|
* YJIT: Distinguish exit and fallback reasons for send (#8159)Takashi Kokubun2023-08-021-1/+2
|
* YJIT: Use dynamic dispatch for megamorphic send (#8125)Takashi Kokubun2023-07-271-1/+3
|
* YJIT: Count the number of dynamic send dispatches (#8122)Takashi Kokubun2023-07-261-0/+1
|
* Implement `opt_aref_with` instruction (#8118)ywenc2023-07-261-0/+1
| | | | | | | | | | | Implement gen_opt_aref_with Vm opt_aref_with is available Test opt_aref_with Stats for opt_aref_with Co-authored-by: jhawthorn <jhawthorn@github.com>
* YJIT: Rename exec_instruction to yjit_insns_count (#8102)Takashi Kokubun2023-07-201-2/+2
|
* YJIT: Avoid undercounting retired_in_yjit (#8038)Takashi Kokubun2023-07-201-1/+1
| | | | | | | * YJIT: Count the number of failed instructions * Rename yjit_insns_count to exec_instructions instead * Hoist out the exec_instruction counter
* YJIT: Make ratio_in_yjit always available (#8064)Takashi Kokubun2023-07-131-15/+8
|