summaryrefslogtreecommitdiff
path: root/yjit/src/codegen.rs
AgeCommit message (Collapse)Author
2024-02-15Update a comment on spill_temps()Takashi Kokubun
2024-02-15Remove duplicated spill_temps()Takashi Kokubun
2024-02-15Spill fewer temps on iv writesAaron Patterson
Not all IV writes require calling a C function. If we don't need to execute a write barrier (IOW the written value is an immediate), and we don't need to expand the object to accommodate a new IV, we won't need to make a C call and we can avoid spilling temps.
2024-02-15YJIT: Pass nil to anonymous kwrest when empty (#9972)Alan Wu
This is the same optimization as e4272fd29 ("Avoid allocation when passing no keywords to anonymous kwrest methods") but for YJIT. For anonymous kwrest parameters, nil is just as good as an empty hash. On the usage side, update `splatkw` to handle `nil` with a leaner path.
2024-02-14YJIT: Replace perf_fn! with a simpler macro (#9971)Takashi Kokubun
2024-02-14YJIT: Use i32 over isize for ctx.sp_opnd() (#9968)Alan Wu
It eventually casts it to i32 anyways, and a lot of callers already have an i32, so using isize was just adding unnecessary casts.
2024-02-14YJIT: Extract keyword handling to make gen_send_iseq() shorterAlan Wu
This should make it easier to grok the order of operations.
2024-02-14Update yjit/src/codegen.rsAaron Patterson
Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2024-02-14Consider rb_str_getbyte as leaf sometimesAaron Patterson
If YJIT knows the parameter to rb_str_getbyte is a fixnum, then I think we can consider the function to be a leaf
2024-02-14YJIT: Add --yjit-perf=codegen option (#9957)Takashi Kokubun
2024-02-14YJIT: Simplify Kernel#send guards and admit more cases (#9956)Alan Wu
Previously, our compile time check rejected dynamic symbols (e.g. what String#to_sym could return) even though we could handle them just fine. The runtime guards for the type of method name was also overly restrictive and didn't accept dynamic symbols. Fold the type check into the rb_get_symbol_id() and take advantage of the guard already checking for 0. This also avoids generating the same call twice in case the same method name is presented as different types.
2024-02-13byteslice can return nil so we have to push an "unknown" valueAaron Patterson
2024-02-13YJIT: Fixup kwrest stack baseAlan Wu
I was a little rushed and didn't notice that it was still using the final stack size even though we don't grow the stack before kwrest handling anymore. Oh well, we got a new test out of it. Fix: cbdabd5890
2024-02-13Specialize String#byteslice(a, b) (#9939)Aaron Patterson
* Specialize String#byteslice(a, b) This adds a specialization for String#byteslice when there are two parameters. This makes our protobuf parser go from 5.84x slower to 5.33x slower ``` Comparison: decode upstream (53738 bytes): 7228.5 i/s decode protobuff (53738 bytes): 1236.8 i/s - 5.84x slower Comparison: decode upstream (53738 bytes): 7024.8 i/s decode protobuff (53738 bytes): 1318.5 i/s - 5.33x slower ``` * Update yjit/src/codegen.rs --------- Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
2024-02-12YJIT: Fix kwrest calls setting SP with uninit valuesAlan Wu
We did stack_push() and then saved the SP without writing to the slots of the new values first, which caused the GC to mark uninitialized values. Should fix crashes like https://github.com/ruby/ruby/actions/runs/7877298133/job/21493179294
2024-02-12YJIT: Add support for `**kwrest` parametersAlan Wu
Now that `...` uses `**kwrest` instead of regular splat and ruby2keywords, we need to support these type of methods to support `...` well.
2024-02-12Allow `foo(**nil, &block_arg)`Alan Wu
Previously, `**nil` by itself worked, but if you add a block argument, it raised a conversion error. The presence of the block argument shouldn't change how keyword splat works. See: <https://bugs.ruby-lang.org/issues/20064>
2024-02-12YJIT: Prefer an overloaded cme if available (#9913)Takashi Kokubun
YJIT: Prefer an overloaded cme if applicable
2024-02-12YJIT: Fix insufficient type guards (#9911)Takashi Kokubun
2024-02-09YJIT: Add top ISEQ call counts to --yjit-stats (#9906)Takashi Kokubun
2024-02-09YJIT: Fallback megamorphic opt_case_dispatch (#9894)Takashi Kokubun
2024-02-09YJIT: Refactor recv_known_class to Option (#9895)Takashi Kokubun
2024-02-08YJIT: Remove unnecessary casts for chain_depth (#9893)Takashi Kokubun
2024-02-08YJIT: Allow tracing a counted exit (#9890)Takashi Kokubun
* YJIT: Allow tracing a counted exit * Avoid clobbering caller-saved registers
2024-02-08YJIT: Use jit_prepare_call_with_gc as much as possible (#9874)Takashi Kokubun
* YJIT: Use jit_prepare_call_with_gc as much as possible * Stop assuming vm_defined doesn't make a call
2024-02-08YJIT: Skip pushing a frame for Hash#empty? (#9875)Takashi Kokubun
2024-02-06YJIT: Allow popping before falling backAlan Wu
Popping but not generating any code before returning `None` was allowed before fallbacks were introduced so this is restoring that support in the same way. The included test used to trip an assert due to popping too much.
2024-02-05YJIT: No need to reject splat+zsuperAlan Wu
There is nothing special about argument handling when it comes to zsuper if you look around in the VM. Everything passes removing these fallback reasons. It was ~16% on `railsbench`.
2024-01-31YJIT: Float arithmetics are actually leafTakashi Kokubun
with these guards in YJIT. The previous commit was to fix "conflict" between two PRs, but I actually wanted to use it here, which is why I filed the other one.
2024-01-31YJIT: s/jit_prepare_routine_call/jit_prepare_non_leaf_call/Takashi Kokubun
2024-01-31YJIT: Add codegen for Float arithmetics (#9774)Takashi Kokubun
* YJIT: Add codegen for Float arithmetics * Add Flonum and Fixnum tests
2024-01-31YJIT: Add jit_prepare_for_gc function (#9775)Takashi Kokubun
* YJIT: Add jit_prepare_for_gc function * s/jit_prepare_routine_call/jit_prepare_non_leaf_call/ * s/jit_prepare_for_gc/jit_prepare_call_with_gc/ * Use jit_prepare_call_with_gc for leaf builtin
2024-01-30YJIT: Specialize splatkw on T_HASH (#9764)Takashi Kokubun
* 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>
2024-01-30YJIT: add specialized codegen for fixnum XOR (#9763)Maxime Chevalier-Boisvert
2024-01-29YJIT: add asm comment when we clear local types (#9713)Maxime Chevalier-Boisvert
Small PR to add a comment when we clear local variable types, so we can be aware that it's happening when looking at the disasm.
2024-01-26YJIT: Fix exits on splatkw instruction (#9711)Takashi Kokubun
2024-01-25YJIT: Support concattoarray and pushtoarray (#9708)Takashi Kokubun
2024-01-25YJIT: Add a counter for invokebuiltin exits (#9696)Takashi Kokubun
2024-01-24YJIT: Avoid leaks by skipping objects with a singleton classAlan Wu
For receiver with a singleton class, there are multiple vectors YJIT can end up retaining the object. There is a path in jit_guard_known_klass() that bakes the receiver into the code, and the object could also be kept alive indirectly through a path starting at the CME object baked into the code. To avoid these leaks, avoid compiling calls on objects with a singleton class. See: https://github.com/Shopify/ruby/issues/552 [Bug #20209]
2024-01-24YJIT: fix small bug causing jit_rb_int_rshift to side-exit (#9684)Maxime Chevalier-Boisvert
YJIT: fix bug causing jit_rb_int_rshift to side-exit The nqueens benchmark was showing zero performance improvement because we immediately side-exited as soon as the shift amount changed. If the amount changes, we want to fall back to the C function call, not side-exit.
2024-01-23YJIT: Reuse get_array_{ptr,len}Alan Wu
2024-01-23YJIT: Fix ruby2_keywords splat+rest and drop bogus checksAlan Wu
YJIT didn't guard for ruby2_keywords hash in case of splat calls that land in methods with a rest parameter, creating incorrect results. The compile-time checks didn't correspond to any actual effects of ruby2_keywords, so it was masking this bug and YJIT was needlessly refusing to compile some code. About 16% of fallback reasons in `lobsters` was due to the ISeq check. We already handle the tagging part with exit_if_supplying_kw_and_has_no_kw() and should now have a dynamic guard for all splat cases. Note for backporting: You also need 7f51959ff1. [Bug #20195]
2024-01-23YJIT: Allow inlining ISEQ calls with a block (#9622)Takashi Kokubun
* YJIT: Allow inlining ISEQ calls with a block * Leave a TODO comment about u16 inline_block
2024-01-23YJIT: Move guard up for a case of splat+restAlan Wu
Previously, YJIT put the guard for having enough items to extract from splat array at a place where the side exit is invalid, so if the guard fails, YJIT could raise something other than ArgumentError. Move the guard up to a place before any stack manipulation. [Bug #20204]
2024-01-22YJIT: Drop extra arguments passed by yield (#9596)Alan Wu
Support dropping extra arguments passed by `yield` in blocks. For example `10.times { work }` drops the count argument. This is common enough that it's about 3% of fallback reasons in `lobsters`. Only support simple cases where the surplus arguments are at the top of the stack, that way they just need to be popped, which takes no work.
2024-01-19YJIT: Optimize defined?(yield) (#9599)Takashi Kokubun
* YJIT: Optimize defined?(yield) * Remove an irrelevant comment * s/get/gen/
2024-01-18YJIT: Properly reject keyword splat with `yield`Alan Wu
We don't have support for keyword splat anywhere, but we tried to compile these anyways in case of `invokeblock`. This led to bad things happening such as passing the wrong value and passing a hash into rb_yjit_array_len(), which raised in the middle of compilation. [Bug #20192]
2024-01-18YJIT: Stop incrementing chain_depth on defer_compilation (#9597)Takashi Kokubun
2024-01-17YJIT: Support empty splat and some block_arg calls to ivar getters (#9567)Alan Wu
These seem odd at first glance, but they're used with `...` calls with `Module#delegate` from Active Support. These account for ~3% of fallback reasons in the `lobsters` benchmark.
2024-01-17YJIT: specialized codegen for integer right shift (#9564)Maxime Chevalier-Boisvert
* 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>