summaryrefslogtreecommitdiff
path: root/yjit.rb
Commit message (Collapse)AuthorAgeFilesLines
* Rename ::YJIT to RubyVM::YJITAlan Wu2021-10-281-4/+4
| | | | | Since the YJIT Ruby module is CRuby specific and not meant for general use, it should live under RubyVM instead of at top level.
* YJIT: move --yjit-stats at_exit call into RubyAlan Wu2021-10-271-1/+6
| | | | | | This change fixes `-v --yjit-stats`. Previously in this situation, YJIT._print_stats wasn't defined as yjit.rb is not evaluated when there is only "-v" and no Ruby code to run.
* Strip out YJIT at build time when unsupported or disabled (#5003)Alan Wu2021-10-251-0/+7
| | | | | | | | | | | | | In an effort to minimize build issues on non x64 platforms, we can decide at build time to not build the bulk of YJIT. This should fix obscure build errors like this one on riscv64: yjit_asm.c:137:(.text+0x3fa): relocation truncated to fit: R_RISCV_PCREL_HI20 against `alloc_exec_mem' We also don't need to bulid YJIT on `--disable-jit-support` builds. One wrinkle to this is that the YJIT Ruby module will not be defined when YJIT is stripped from the build. I think that's a fair change as it's only meant to be used for YJIT development.
* Fix counter names for getblockparamproxy. Print in --yjit-stats.Maxime Chevalier-Boisvert2021-10-201-0/+1
|
* Add counters for version invalidation reasonsAlan Wu2021-10-201-0/+1
| | | | | I noticed that there were two st_table iterators that do exactly the same thing so I merged them into one.
* Add a slowpath for opt_getinlinecacheAlan Wu2021-10-201-0/+1
| | | | | | | | | | | | Before this change, when we encounter a constant cache that is specific to a lexical scope, we unconditionally exit. This change falls back to the interpreter's cache in this situation. This should help constant expressions in `class << self`, which is popular at Shopify due to the style guide. This change relies on the cache being warm while compiling to detect the need for checking the lexical scope for simplicity.
* Rearrange stats printout for consistencyMaxime Chevalier-Boisvert2021-10-201-2/+2
|
* Add counters for tracking invalidationsAlan Wu2021-10-201-0/+3
|
* Add missing percent sign in printoutMaxime Chevalier-Boisvert2021-10-201-1/+1
|
* Fix avg_len_in_yjitAlan Wu2021-10-201-3/+5
| | | | | | | | | We weren't counting completing an entire method in YJIT as exits so the avg_len_in_yjit for ./miniruby --yjit-call-threshold=1 --yjit-stats -e'def foo; end; foo' was infinite.
* Prevent stats being enabled late at run-timeMaxime Chevalier-Boisvert2021-10-201-4/+0
|
* Implement invokesuper using cfp->ep[ME] checkJohn Hawthorn2021-10-201-0/+1
| | | | | This fixes and re-enables invokesuper, replacing the existing guards with a guard on the method entry for the EP.
* Allow to toggle YJIT stats collection from runtimeJean Boussier2021-10-201-0/+8
| | | | | | | | For use cases where you want to collect the metrics for a specific piece of code (typically a web request) you can have the stats turned off by default and then turn them on at runtime before executing the code you care about.
* Add YJIT.enabled?John Hawthorn2021-10-201-0/+4
|
* Update yjit.rbMaxime Chevalier-Boisvert2021-10-201-1/+1
|
* Update yjit.rbMaxime Chevalier-Boisvert2021-10-201-1/+1
| | | Co-authored-by: Rafael França <rafael.franca@shopify.com>
* Dup strings so we can mutate themAaron Patterson2021-10-201-2/+2
| | | | I guess the strings are frozen, so we need to dup before mutating
* Implement expandarrayKevin Deisz2021-10-201-0/+1
|
* Percentages should be out of 100.0%, not 1.0%.Noah Gibbs2021-10-201-1/+1
|
* Convert YJIT stats reporting on exit from C to Ruby.Noah Gibbs2021-10-201-10/+70
|
* Add exit counters and inline/outlined code size to stats hashNoah Gibbs2021-10-201-2/+2
|
* Make jumps dashed and falls solidAaron Patterson2021-10-201-2/+3
|
* Clean graph formattingAaron Patterson2021-10-201-10/+36
|
* Add graphviz outputAaron Patterson2021-10-201-0/+37
| | | | | | | | | This adds a method to blocks to get outgoing ids, then uses the outgoing ids to generate a graphviz graph. Two methods were added to the Block object. One method returns an id for the block, which is just the address of the underlying block. The other method returns a list of outgoing block ids. We can use Block#id in conjunction with Block#outgoing_ids to construct a graph of blocks
* Allow yjit.rb to work with frozen stringsJohn Hawthorn2021-10-201-1/+1
|
* Implement send with blocksAlan Wu2021-10-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | * Implement send with blocks Not that much extra work compared to `opt_send_without_block`. Moved the stack over flow check because it could've exited after changes are made to cfp. * rename oswb counters * Might as well implement sending block to cfuncs * Disable sending blocks to cfuncs for now * Reconstruct interpreter sp before calling into cfuncs In case the callee cfunc calls a method or delegates to a block. This also has the side benefit of letting call sites that sometimes are iseq calls and sometimes cfunc call share the same successor. * only sync with interpreter sp when passing a block Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com> Co-authored-by: Aaron Patterson <aaron.patterson@shopify.com>
* Add setivar exit reasons to --yjit-statsMaxime Chevalier-Boisvert2021-10-201-4/+3
|
* Fix two stats bugs, refactor stats code, add total_insn_count printMaxime Chevalier-Boisvert2021-10-201-3/+3
|
* YJIT: add comments to disassemblyAlan Wu2021-10-201-28/+49
| | | | | | | | Introduce a new macro `ADD_COMMENT(cb, comment)` that records a comment for the current write position in the code block. Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com> Co-authored-by: Aaron Patterson <aaron.patterson@shopify.com>
* Fix caseAaron Patterson2021-10-201-1/+1
|
* Collect statistics about binding allocations / local variable setAaron Patterson2021-10-201-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit collects statistics about how many binding objects are allocated as well as the number of local variables set on bindings. Statistics are output along with other YJIT stats. Here is an example of the output: ``` ***YJIT: Printing runtime counters from yjit.rb*** Number of Bindings Allocated: 195 Number of locals modified through binding: 0 opt_send_without_block exit reasons: ivar_get_method 7515891 (40.4%) se_cc_klass_differ 3081330 (16.6%) iseq_argc_mismatch 1564578 ( 8.4%) se_receiver_not_heap 1557663 ( 8.4%) ic_empty 1407064 ( 7.6%) optimized_method 995823 ( 5.4%) iseq_not_simple 819413 ( 4.4%) alias_method 706972 ( 3.8%) bmethod 685253 ( 3.7%) callsite_not_simple 225983 ( 1.2%) kw_splat 25999 ( 0.1%) ivar_set_method 902 ( 0.0%) cfunc_toomany_args 394 ( 0.0%) refined_method 42 ( 0.0%) cfunc_ruby_array_varg 29 ( 0.0%) invalid_cme 4 ( 0.0%) leave exit reasons: se_finish_frame 4067107 (100.0%) se_interrupt 24 ( 0.0%) getinstancevariable exit reasons: undef 121177 (100.0%) idx_out_of_range 5 ( 0.0%) opt_aref exit reasons: (all relevant counters are zero) compiled_iseq_count: 3944 main_block_code_size: 1.1 MiB side_block_code_size: 0.6 MiB vm_insns_count: 1137268516 yjit_exec_insns_count: 414015644 ratio_in_yjit: 26.7% avg_len_in_yjit: 7.5 total_exit_count: 55491789 most frequent exit op: opt_send_without_block: 18587628 (33.5%) opt_getinlinecache: 11075822 (20.0%) send: 4949300 (8.9%) leave: 4067131 (7.3%) defined: 3975196 (7.2%) setinstancevariable: 3567315 (6.4%) invokesuper: 2982163 (5.4%) getblockparamproxy: 2168852 (3.9%) opt_nil_p: 2104524 (3.8%) opt_aref: 2013858 (3.6%) ``` Running RailsBench allocates 195 binding objects but doesn't set any local variables.
* YJIT: hash specialization for opt_arefAlan Wu2021-10-201-1/+1
| | | | | Make it lazy and add a hash specialization in addition to the array specialization.
* Exit reason breakdown for opt_arefAlan Wu2021-10-201-0/+1
|
* YJIT: lazy polymorphic getinstancevariableAlan Wu2021-10-201-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | Lazily compile out a chain of checks for different known classes and whether `self` embeds its ivars or not. * Remove trailing whitespaces * Get proper addresss in Capstone disassembly * Lowercase address in Capstone disassembly Capstone uses lowercase for jump targets in generated listings. Let's match it. * Use the same successor in getivar guard chains Cuts down on duplication * Address reviews * Fix copypasta error * Add a comment
* Yet Another Ruby JIT!Jose Narvaez2021-10-201-0/+89
Renaming uJIT to YJIT. AKA s/ujit/yjit/g.