summaryrefslogtreecommitdiff
path: root/yjit_codegen.c
AgeCommit message (Collapse)Author
2021-10-20Add rb_darray_clear() for Kevin. Fix some warnings.Maxime Chevalier-Boisvert
2021-10-20Add fixes for feedbackAaron Patterson
2021-10-20Use C_ARG_REGS earlierJohn Hawthorn
2021-10-20String and fixnum equalityJohn Hawthorn
2021-10-20Use method dispatch for opt_eqJohn Hawthorn
2021-10-20Add jit_rb_obj_equalJohn Hawthorn
2021-10-20Exit when the object is frozenAaron Patterson
Exit when the object is frozen, also add tests
2021-10-20Add a write barrier to ivar setAaron Patterson
We need to fire the write barrier during ivar set. This function extracts the write barrier function then calls it. Co-Authored-By: John Hawthorn <john@hawthorn.email>
2021-10-20Implement setivar method callseileencodes
2021-10-20Allow calling variadic cfuncs with many argsJohn Hawthorn
We have a check to ensure we don't have to push args on the stack to call a cfunc with many args. However we never need to use the stack for variadic cfuncs, so we shouldn't care about the number of arguments.
2021-10-20Add codegen for rb_true and rb_falseJohn Hawthorn
These are used by .nil? and therefore opt_nil_p
2021-10-20Allow special case of expandarray with nilJohn Hawthorn
2021-10-20Shave a few instructions off of leaveAlan Wu
The code path for leave that returns to the interpreter (gen_leave() -> yjit_gen_leave_exit()) used to have the logic: ``` cfp->sp++; cfp->sp[-1] = return_val; cfp->sp--; return return_val; ``` The SP changes it made was unnecessary and this change removes it. After this change, `leave` doesn't adjust the `cfp->sp` of the caller and only writes `cfp->sp[0]`. To accomodate this in the JIT-to-JIT return case, return stubs have an `sp_offset` of 1. The change removes sp adjustment from the JIT-to-JIT return case, too, making it more efficient. Also, since the C method case of `send` has an `sp_offset` of 1 after the call, this change enables block version sharing.
2021-10-20Use reg1 in GEN_COUNTER_INC to avoid clobbering RAXAlan Wu
2021-10-20Implement newrangeJohn Hawthorn
2021-10-20Implement invokesuper using cfp->ep[ME] checkJohn Hawthorn
This fixes and re-enables invokesuper, replacing the existing guards with a guard on the method entry for the EP.
2021-10-20Use jit_prepare_routine_callJohn Hawthorn
2021-10-20Implement gen_putstringJohn Hawthorn
2021-10-20typo, rename, commentAlan Wu
2021-10-20Avoid immediate side exits in checktypeJohn Hawthorn
Previously checktype only supported heap objects, however it's not uncommon to receive an immediate, for example when string interpolating a Symbol or Integer.
2021-10-20filter out internal events. add comments. reorderAlan Wu
2021-10-20Lock, don't loock.Alan Wu
2021-10-20TracePoint supportAlan Wu
This change fixes some cases where YJIT fails to fire tracing events. Most of the situations YJIT did not handle correctly involves enabling tracing while running inside generated code. A new operation to invalidate all generated code is added, which uses patching to make generated code exit at the next VM instruction boundary. A new routine called `jit_prepare_routine_call()` is introduced to facilitate this and should be used when generating code that could allocate, or could otherwise use `RB_VM_LOCK_ENTER()`. The `c_return` event is fired in the middle of an instruction as opposed to at an instruction boundary, so it requires special handling. C method call return points are patched to go to a fucntion which does everything the interpreter does, including firing the `c_return` event. The generated code for C method calls normally does not fire the event. Invalided code should not change after patching so the exits are not clobbered. A new variable is introduced to track the region of code that should not change.
2021-10-20Redo the ivtable lookp once the ivar is setMaxime Chevalier-Boisvert
2021-10-20Make sure that there is always an index table entry for getivarsMaxime Chevalier-Boisvert
2021-10-20Allow to compile with --yjit-stats support but not the full RUBY_DEBUGJean Boussier
RUBY_DEBUG have a very significant performance overhead. Enough that YJIT with RUBY_DEBUG is noticeably slower than the interpreter without RUBY_DEBUG. This makes it hard to collect yjit-stats in production environments. By allowing to collect JIT statistics without the RUBy_DEBUG overhead, I hope to make such use cases smoother.
2021-10-20Add toregexp to yjiteileencodes
The FIXME is there so we remember to investigate why insns clears the temporary array. Is this necessary? If it's not we can remove it from both. Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2021-10-20Use cmov to handle Qundef case in getivar instead of side-exitMaxime Chevalier-Boisvert
2021-10-20Add ASM commentMaxime Chevalier-Boisvert
2021-10-20Implement putspecialobjectJohn Hawthorn
2021-10-20Add opt_regexpmatch2John Hawthorn
2021-10-20Assign directly to C_ARG_REGS now when possibleJohn Hawthorn
2021-10-20Use callee-saved regs for REG_SP, REG_EP, REG_CFPJohn Hawthorn
2021-10-20Move yjit_type_of_value into yjit_core.cJohn Hawthorn
2021-10-20Implement verify_ctx for debuggingJohn Hawthorn
2021-10-20More detection of immediate constantsJohn Hawthorn
2021-10-20Implement tostring instruction for yjiteileencodes
Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2021-10-20Introduce ctx_{get,set}_opnd_mappingJohn Hawthorn
2021-10-20Rename to ctx_upgrade_opnd_typeJohn Hawthorn
2021-10-20Return if fixnums impossibleJohn Hawthorn
2021-10-20Save PC and SP before accessing globalsAlan Wu
These instructions are marked as not leaf in insns.def, which indicate that they could raise exceptions and/or call Ruby methods.
2021-10-20Add setglobal to yjiteileencodes
Adds yjit support for setting global variables. Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org> Co-authored-by: John Hawthorn <john@hawthorn.email>
2021-10-20Add getglobal to yjiteileencodes
Adds getglobal to yjit and a test for it. Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2021-10-20Change register definitions to match the entry point calling conventionAaron Patterson
The JIT entry point passes the CFP as RSI and the EC as RDI. Lets match that so we don't have to shuffle registers around.
2021-10-20Add a guard that we start executing on the first PCAaron Patterson
Methods with optional parameters don't always start executing at the first PC, but we compile all methods assuming that they do. This commit adds a guard to ensure that we're actually starting at the first PC for methods with optional params
2021-10-20fix alignmentAaron Patterson
2021-10-20Always use `ret` to return to the interpreterAaron Patterson
Always using `ret` to return to the interpreter means that we never have to check the VM_FRAME_FLAG_FINISH flag. In the case that we return `Qundef`, the interpreter will execute the cfp. We can take advantage of this by setting the PC to the instruction we can't handle, and let the interpreter pick up the ball from there. If we return a value other than Qundef, the interpreter will take that value as the "return value" from the JIT and push that to the SP of the caller The leave instruction puts the return value on the top of the calling frame's stack. YJIT does the same thing for leave instructions. However, when we're returning back to the interpreter, the leave instruction _should not_ put the return value on the top of the stack, but put it in RAX and use RET. This commit pops the last value from the stack pointer and puts it in RAX so that the interpreter is happy with SP.
2021-10-20Ensure we guard the value before we returnKevin Newton
Otherwise you can end up not implicitly calling `to_ary`, which if it has side-effects will result in different behavior.
2021-10-20Code review for expandarray and testsKevin Newton
2021-10-20Convert jumps to cmovKevin Newton