summaryrefslogtreecommitdiff
path: root/yjit
Commit message (Collapse)AuthorAgeFilesLines
* YJIT: Move exits in gen_send_iseq to functions and use ? (#7725)Jimmy Miller2023-05-011-211/+260
|
* Generalize cfunc large array splat fix to fix many additional cases raising ↵Jeremy Evans2023-04-252-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SystemStackError Originally, when 2e7bceb34ea858649e1f975a934ce1894d1f06a6 fixed cfuncs to no longer use the VM stack for large array splats, it was thought to have fully fixed Bug #4040, since the issue was fixed for methods defined in Ruby (iseqs) back in Ruby 2.2. After additional research, I determined that same issue affects almost all types of method calls, not just iseq and cfunc calls. There were two main types of remaining issues, important cases (where large array splat should work) and pedantic cases (where large array splat raised SystemStackError instead of ArgumentError). Important cases: ```ruby define_method(:a){|*a|} a(*1380888.times) def b(*a); end send(:b, *1380888.times) :b.to_proc.call(self, *1380888.times) def d; yield(*1380888.times) end d(&method(:b)) def self.method_missing(*a); end not_a_method(*1380888.times) ``` Pedantic cases: ```ruby def a; end a(*1380888.times) def b(_); end b(*1380888.times) def c(_=nil); end c(*1380888.times) c = Class.new do attr_accessor :a alias b a= end.new c.a(*1380888.times) c.b(*1380888.times) c = Struct.new(:a) do alias b a= end.new c.a(*1380888.times) c.b(*1380888.times) ``` This patch fixes all usage of CALLER_SETUP_ARG with splatting a large number of arguments, and required similar fixes to use a temporary hidden array in three other cases where the VM would use the VM stack for handling a large number of arguments. However, it is possible there may be additional cases where splatting a large number of arguments still causes a SystemStackError. This has a measurable performance impact, as it requires additional checks for a large number of arguments in many additional cases. This change is fairly invasive, as there were many different VM functions that needed to be modified to support this. To avoid too much API change, I modified struct rb_calling_info to add a heap_argv member for storing the array, so I would not have to thread it through many functions. This struct is always stack allocated, which helps ensure sure GC doesn't collect it early. Because of how invasive the changes are, and how rarely large arrays are actually splatted in Ruby code, the existing test/spec suites are not great at testing for correct behavior. To try to find and fix all issues, I tested this in CI with VM_ARGC_STACK_MAX to -1, ensuring that a temporary array is used for all array splat method calls. This was very helpful in finding breaking cases, especially ones involving flagged keyword hashes. Fixes [Bug #4040] Co-authored-by: Jimmy Miller <jimmy.miller@shopify.com>
* YJIT: Use general definedivar at the end of chains (#7756)Takashi Kokubun2023-04-241-1/+1
|
* YJIT: invokesuper: Remove cme mid matching checkJohn Hawthorn2023-04-201-7/+0
| | | | | | | | | | This check was introduced to match an assertion in the C YJIT when this was originally introduced. I don't believe it's necessary for correctness of the generated code. Co-authored-by: Adam Hess <HParker@github.com> Co-authored-by: Daniel Colson <danieljamescolson@gmail.com> Co-authored-by: Luan Vieira <luanzeba@github.com>
* YJIT: Merge lower_stack into the split pass (#7748)Takashi Kokubun2023-04-203-71/+55
|
* Fix inaccurate commentMaxime Chevalier-Boisvert2023-04-201-1/+3
|
* YJIT: Merge csel and mov on arm64 (#7747)Takashi Kokubun2023-04-201-94/+91
| | | | | * YJIT: Refactor arm64_split with &mut insn * YJIT: Merge csel and mov on arm64
* YJIT: Avoid splitting mov for small values on arm64 (#7745)Takashi Kokubun2023-04-202-3/+32
| | | | | | | | | | | | | * YJIT: Avoid splitting mov for small values on arm64 * Fix a comment Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> * YJIT: Test the 0xffff boundary --------- Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
* YJIT: Replace Mov with LoadInto on arm64 (#7744)Takashi Kokubun2023-04-191-20/+39
| | | | | * YJIT: Replace Mov with LoadInto on arm64 * YJIT: Add a test for the new pass
* YJIT: Tweak asm comments (#7743)Takashi Kokubun2023-04-191-3/+4
|
* YJIT: Remove Insn::RegTemps (#7741)Takashi Kokubun2023-04-195-97/+83
| | | | | | | | | | | * YJIT: Remove Insn::RegTemps * Update a comment Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com> --------- Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
* Implement opt_newarray_send in YJITAaron Patterson2023-04-181-2/+54
| | | | | This commit implements opt_newarray_send along with min / max / hash for stack allocated arrays
* updating bindgenAaron Patterson2023-04-181-304/+305
|
* YJIT: Fix raw sample stack lengths in exit traces (#7728)John Hawthorn2023-04-181-4/+2
| | | | | | | | | | yjit-trace-exits appends a synthetic sample for the instruction being exited, but we didn't increment the size of the stack. Fixing this count correctly lets us successfully generate a flamegraph from the exits. I also replaced the line number for instructions with 0, as I don't think the previous value had meaning. Co-authored-by: Adam Hess <HParker@github.com>
* YJIT: Fixes failure reported by rails for opt+splat+rest (#7727)Jimmy Miller2023-04-171-1/+1
|
* YJIT: Spill a caller stack as late as possible (#7726)Takashi Kokubun2023-04-172-11/+12
|
* YJIT: Add a counter to all side exits (#7720)Takashi Kokubun2023-04-145-80/+115
|
* YJIT: Remove duplicate `asm.spill_temps()` Alan Wu2023-04-141-1/+0
| | | | | `jit_prepare_routine_call()` calls it, and there is another call above on line 2302. Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
* YJIT: Fix false object collection when setting ivarAlan Wu2023-04-141-0/+5
| | | | | | | | | | | Previously, setinstancevariable could generate code that calls `rb_ensure_iv_list_size()` without first updating `cfp->sp`. This means in the event that a GC start from within said routine the top few objects would not be marked, causing them to be falsly collected. Call `jit_prepare_routine_call()` first. [Bug #19601]
* YJIT: Introduce Target::SideExit (#7712)Takashi Kokubun2023-04-149-291/+374
| | | | | | | * YJIT: Introduce Target::SideExit * YJIT: Obviate Insn::SideExitContext * YJIT: Avoid cloning a Context for each insn
* YJIT: Change to Option<CodegenStatus> (#7717)Jimmy Miller2023-04-141-334/+333
|
* Allow testing a different versionTakashi Kokubun2023-04-131-1/+3
|
* YJIT: Add support for rest with option and splat args (#7698)Jimmy Miller2023-04-132-40/+130
|
* YJIT: Use an enum to represent counters (#7701)Takashi Kokubun2023-04-132-52/+43
|
* YJIT: Move stack_opnd from Context to Assembler (#7700)Takashi Kokubun2023-04-133-99/+93
|
* YJIT: Add a sampling option to exit tracing (#7693)Adam Hess2023-04-132-3/+38
| | | | | | | | | | | Add a sampling option to trace exits Running YJIT with trace exits enabled can make very large metrics files. This allows us to configure a sample rate to make tracing exits possible on larger tests. This also updates the documented YJIT options. Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> Co-authored-by: John Hawthorn <john@hawthorn.email> Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
* YJIT: Fix missing argc check in known cfuncsJohn Hawthorn2023-04-121-1/+3
| | | | | | | | | | | | | | | | | Previously we were missing a compile-time check that the known cfuncs receive the correct number of arguments. We noticied this because in particular when using ARGS_SPLAT, which also wasn't checked, YJIT would crash on code which was otherwise correct (didn't raise exceptions in the VM). This still supports vararg (argc == -1) cfuncs. I added an additional assertion that when we use the specialized codegen for one of these known functions that the argc are popped off the stack correctly, which should help ensure they're implemented correctly (previously the crash was usually observed on a future `leave` insn). [Bug #19595]
* YJIT: Let Assembler own Context (#7691)Takashi Kokubun2023-04-125-951/+809
| | | | | | | | | | | * YJIT: Let Assembler own Context * Update a comment Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com> --------- Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
* YJIT: Fix build on A64Alan Wu2023-04-111-1/+1
| | | | Typo fix for the last commit (1432b37)
* YJIT: Fix a compilation warning in x86_64Takashi Kokubun2023-04-111-0/+1
| | | | This is used only for arm64's cb.jmp_ptr_bytes().
* YJIT: Reduce paddings if --yjit-exec-mem-size <= 128 on arm64 (#7671)Takashi Kokubun2023-04-113-16/+52
| | | | | | | * YJIT: Reduce paddings if --yjit-exec-mem-size <= 128 on arm64 * YJIT: Define jmp_ptr_bytes on CodeBlock
* YJIT: Avoid using a register for unspecified_bits (#7685)Takashi Kokubun2023-04-101-0/+1
| | | Fix [Bug #19586]
* Include `--no-llvm-bc` option in `NM` macro only if usableNobuyoshi Nakada2023-04-081-1/+1
|
* YJIT: Stack temp register allocation for arm64 (#7659)Takashi Kokubun2023-04-066-38/+66
| | | | | | | | | | | | | | | | | * YJIT: Stack temp register allocation for arm64 * Update a comment Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com> * Update comments about assertion * Update a comment Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com> --------- Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
* Update VPATH for socket, & dependenciesMatt Valentine-House2023-04-061-29/+29
| | | | | | | | | | | | | | | | | | The socket extensions rubysocket.h pulls in the "private" include/gc.h, which now depends on vm_core.h. vm_core.h pulls in id.h when tool/update-deps generates the dependencies for the makefiles, it generates the line for id.h to be based on VPATH, which is configured in the extconf.rb for each of the extensions. By default VPATH does not include the actual source directory of the current Ruby so the dependency fails to resolve and linking fails. We need to append the topdir and top_srcdir to VPATH to have the dependancy picked up correctly (and I believe we need both of these to cope with in-tree and out-of-tree builds). I copied this from the approach taken in https://github.com/ruby/ruby/blob/master/ext/objspace/extconf.rb#L3
* YJIT: Add codegen for Integer methods (#7665)Takashi Kokubun2023-04-054-3/+109
| | | | | | | * YJIT: Add codegen for Integer methods * YJIT: Update dependencies * YJIT: Fix Integer#[] for argc=2
* YJIT: Count the number of actually written bytes (#7658)Takashi Kokubun2023-04-052-13/+31
|
* YJIT: Smoke test on Rust 1.58.0Alan Wu2023-04-051-1/+1
| | | | Since warnings might show up on older version but not newer ones.
* YJIT: Eanble `unsafe_op_in_unsafe_fn` on crate::coreAlan Wu2023-04-051-2/+8
| | | | Encourages commenting about soundness of `unsafe` usages.
* Revert "YJIT: Suppress unnecessary `unsafe` block (GH-7634)"Alan Wu2023-04-052-14/+14
| | | | | | | This reverts commit 9e678cdbd054f78576a8f21b3f97cccc395ade22. Without the `unsafe` annotations, the SAFETY comments make less sense. I want to keep the SAFETY comments.
* [Feature #19579] Remove !USE_RVARGC code (#7655)Peter Zhu2023-04-041-1/+0
| | | | | | | | | | | Remove !USE_RVARGC code [Feature #19579] The Variable Width Allocation feature was turned on by default in Ruby 3.2. Since then, we haven't received bug reports or backports to the non-Variable Width Allocation code paths, so we assume that nobody is using it. We also don't plan on maintaining the non-Variable Width Allocation code, so we are going to remove it.
* YJIT: add stats for ratio of versions per block (#7653)Maxime Chevalier-Boisvert2023-04-042-0/+6
|
* Remove an unused counterTakashi Kokubun2023-04-041-1/+0
| | | | I ended up not using it.
* Resurrect yjit-smoke-test before #7651Takashi Kokubun2023-04-041-1/+2
|
* YJIT: Stack temp register allocation (#7651)Takashi Kokubun2023-04-048-145/+519
| | | Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
* YJIT: Add codegen for Array#<< (#7645)Takashi Kokubun2023-04-033-0/+28
|
* Remove an unneeded function copyTakashi Kokubun2023-04-013-7/+3
|
* Remove unused VM_CALL_BLOCKISEQ flagTakashi Kokubun2023-04-011-9/+8
|
* YJIT: Remove unused variable [ci skip]Alan Wu2023-03-311-1/+1
|
* YJIT: Suppress unnecessary `unsafe` block (#7634)Nobuyoshi Nakada2023-03-312-14/+14
|