aboutsummaryrefslogtreecommitdiffstats
path: root/yjit/src
Commit message (Collapse)AuthorAgeFilesLines
* Refactor rb_shape_transition_shape_capa outJean Boussier2023-11-082-35/+22
| | | | | | | | | | | | | | | | Right now the `rb_shape_get_next` shape caller need to first check if there is capacity left, and if not call `rb_shape_transition_shape_capa` before it can call `rb_shape_get_next`. And on each of these it needs to checks if we got a TOO_COMPLEX back. All this logic is duplicated in the interpreter, YJIT and RJIT. Instead we can have `rb_shape_get_next` do the capacity transition when needed. The caller can compare the old and new shapes capacity to know if resizing is needed. It also can check for TOO_COMPLEX only once.
* YJIT: Fix assert in OOM scenarioAlan Wu2023-11-071-1/+1
| | | | | | | | | | | We still need to do `jit.record_boundary_patch_point = false` when gen_outlined_exit() returns `None` and we return with `?`. Previously, we tripped the assert at codegen.rs:1042. Found with `--yjit-exec-mem-size=3` on the lobsters benchmark. Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com> Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>
* YJIT: Use u32 for CodePtr to save 4 bytes eachAlan Wu2023-11-0714-161/+175
| | | | | | | | | | | | | | | | We've long had a size restriction on the code memory region such that a u32 could refer to everything. This commit capitalizes on this restriction by shrinking the size of `CodePtr` to be 4 bytes from 8. To derive a full raw pointer from a `CodePtr`, one needs a base pointer. Both `CodeBlock` and `VirtualMemory` can be used for this purpose. The base pointer is readily available everywhere, except for in the case of the `jit_return` "branch". Generalize lea_label() to lea_jump_target() in the IR to delay deriving the `jit_return` address until `compile()`, when the base pointer is available. On railsbench, this yields roughly a 1% reduction to `yjit_alloc_size` (58,397,765 to 57,742,248).
* YJIT: Inline basic Ruby methods (#8855)Takashi Kokubun2023-11-073-4/+59
| | | | | | | * YJIT: Inline basic Ruby methods * YJIT: Fix "InsnOut operand made it past register allocation" checktype should not generate a useless instruction.
* YJIT: handle out of shape situation in gen_setinstancevariable (#8857)Jean byroot Boussier2023-11-071-1/+5
| | | | | | If the VM ran out of shape, `rb_shape_transition_shape_capa` might return `OBJ_TOO_COMPLEX_SHAPE`. Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
* YJIT: implement two-step call threshold (#8839)Maxime Chevalier-Boisvert2023-11-032-3/+20
| | | | | | | | | | | | | | | | | | | * YJIT: implement two-step call threshold Automatically switch call threshold to a larger value for larger, production-sized apps, while still allowing smaller apps and command-line programs to start with a lower threshold. * Update yjit/src/options.rs Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> * Make the new variables constants * Check that a custom call threshold was not specified --------- Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
* YJIT: Delete some dead code and enable lintsAlan Wu2023-11-032-21/+6
|
* YJIT: Always define method codegen table at boot (#8807)Takashi Kokubun2023-11-022-99/+89
|
* updating bindgenAaron Patterson2023-10-241-0/+11
|
* YJIT: Skip printing stats at exit if --yjit-disable (#8727)Takashi Kokubun2023-10-201-1/+1
|
* YJIT: remove unused `--yjit-greedy-versioning` command-line option (#8713)Maxime Chevalier-Boisvert2023-10-192-15/+1
|
* YJIT: Return Option from asm.compile() for has_dropped_bytes()Alan Wu2023-10-197-176/+175
| | | | | | | | | So that we get a reminder to check CodeBlock::has_dropped_bytes(). Internally, asm.compile() already checks it, and this patch just propagates it out to the caller with a `#[must_use]`. Code GC logic moved out one level in entry_stub_hit(), so the body can freely use `?`
* YJIT: Add RubyVM::YJIT.enable (#8705)Takashi Kokubun2023-10-192-41/+47
|
* YJIT: Enable the dead_code lint and delete some dead codeAlan Wu2023-10-192-82/+6
|
* YJIT: Add a live ISeq counter Alan Wu2023-10-181-0/+6
| | | | | | | 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>
* Revert "shape.h: Make attr_index_t uint8_t"Katherine Oelsner2023-10-182-5/+5
| | | | This reverts commit e3afc212ec059525fe4e5387b2a3be920ffe0f0e.
* YJIT: Add --yjit-perf (#8697)Takashi Kokubun2023-10-187-8/+105
| | | Co-authored-by: Alan Wu <alansi.xingwu@shopify.com>
* YJIT: Fix clippy::redundant_localsAlan Wu2023-10-171-3/+1
| | | | | | > note: `#[deny(clippy::redundant_locals)]` on by default On Rust 1.73.0.
* YJIT: Remove call to compile() on empty AssemblerAlan Wu2023-10-171-4/+1
|
* YJIT: Add a few missing counters for send fallback (#8681)Takashi Kokubun2023-10-172-3/+6
|
* YJIT: Lookup IDs on boot instead of binding to themAlan Wu2023-10-175-219/+56
| | | | | | | | | | Previously, the version-controlled `cruby_bindings.inc.rs` file contained the build-time artifact `id.h`, which nobu mentioned hinders the goal of having fewer magic numbers in the repository. Lookup the IDs YJIT needs on boot. It costs cycles, but it's fine since YJIT only uses a handful of IDs at the moment. No perceptible degradation to boot time found in my testing.
* YJIT: Count cold_iseq_entry by default (#8654)Takashi Kokubun2023-10-141-5/+0
|
* YJIT: Fallback opt_getconstant_path for const_missing (#8623)Takashi Kokubun2023-10-132-9/+22
| | | | | | | * YJIT: Fallback opt_getconstant_path for const_missing * Fix a comment [ci skip] * Remove a wrapper function
* YJIT: Fix argument clobbering in some block_arg+rest_param calls (#8647)Alan Wu2023-10-132-42/+60
| | | | | | | | | | | | Previously, for block argument callsites with some specific argument count and callee local variable count combinations, YJIT ended up writing over arguments that are supposed to be collected into a rest parameter array unmodified. Detect when clobbering would happen and avoid it. Also, place the block handler after the stack overflow check, since it writes to new stack space. Reported-by: Takashi Kokubun <takashikkbn@gmail.com>
* YJIT: port call threshold logic from Rust to C for performance (#8628)Maxime Chevalier-Boisvert2023-10-124-67/+29
| | | | | | | | | | | | | | | | | * 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>
* shape.h: Make attr_index_t uint8_tJean Boussier2023-10-112-5/+5
| | | | | | | | | | Given `SHAPE_MAX_NUM_IVS 80`, we transition to TOO_COMPLEX way before we could overflow a 8bit counter. This reduce the size of `rb_shape_t` from 32B to 24B. If we decide to raise `SHAPE_MAX_NUM_IVS` we can always increase that type again.
* YJIT: Allow --yjit-trace-exits on release builds (#8619)Takashi Kokubun2023-10-101-21/+0
|
* Refactor rb_shape_transition_shape_capa to not accept capacityJean Boussier2023-10-102-7/+3
| | | | | This way the groth factor is encapsulated, which allows rb_shape_transition_shape_capa to be smarter about ideal sizes.
* YJIT: shink local types from 8 to 4 bytes (#8597)Maxime Chevalier-Boisvert2023-10-051-24/+79
| | | | | | | * Shink local types from 8 to 4 bytes, context from 21 to 17 bytes Use repr(packed) * Add comment about Type being limited to 4 bits
* YJIT: Run bindgenAlan Wu2023-10-051-1/+0
|
* YJIT: Remove duplicate cfp->iseq accessorAlan Wu2023-10-051-1/+1
|
* YJIT: Avoid writing return value to memory in `leave`Alan Wu2023-10-053-41/+111
| | | | | | | | | | | | | | | | | | | Previously, at the end of `leave` we did `*caller_cfp->sp = return_value`, like the interpreter. With future changes that leaves the SP field uninitialized for C frames, this will become problematic. For cases like returning from `rb_funcall()`, the return value was written above the stack and never read anyway (callers use the copy in the return register). Leave the return value in a register at the end of `leave` and have the code at `cfp->jit_return` decide what to do with it. This avoids the unnecessary memory write mentioned above. For JIT-to-JIT returns, it goes through `asm.stack_push()` and benefits from register allocation for stack temporaries. Mostly flat on benchmarks, with maybe some marginal speed improvements. Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
* YJIT: Add a comment for YJIT_OPTIONS [ci skip]Takashi Kokubun2023-10-041-0/+1
|
* Use a better variable name for wTakashi Kokubun2023-10-041-4/+5
|
* Make the function names consistentTakashi Kokubun2023-10-041-1/+1
|
* YJIT: Move help descriptions to options.rsTakashi Kokubun2023-10-041-1/+27
|
* YJIT: Call mprotect after entry stub failure (#8582)Takashi Kokubun2023-10-031-18/+16
| | | Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
* YJIT: add heuristic to avoid compiling cold ISEQs (#8522)Maxime Chevalier-Boisvert2023-10-034-3/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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: Stop spilling temps on jit_prepare_routine_call (#8581)Takashi Kokubun2023-10-031-34/+49
| | | YJIT: Remove spill_temps from jit_prepare_routine_call
* YJIT: Chain-guard opt_mult overflow (#8554)Takashi Kokubun2023-09-295-11/+29
| | | | | * YJIT: Chain-guard opt_mult overflow * YJIT: Support regenerating Jo after Mul
* YJIT: Use registers for passing C method arguments (#8538)Takashi Kokubun2023-09-291-19/+23
|
* YJIT: Remove obsoleted jit_rb_int_mul (#8539)Takashi Kokubun2023-09-291-29/+0
|
* YJIT: Avoid creating a vector in get_temp_regs() (#8446)Takashi Kokubun2023-09-156-21/+23
| | | | | | | | | | | | * YJIT: Avoid creating a vector in get_temp_regs() Co-authored-by: Alan Wu <alansi.xingwu@shopify.com> * Remove unused import --------- Co-authored-by: Alan Wu <alansi.xingwu@shopify.com> Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
* YJIT: Fix object movement bug in iseq guard for invokeblockAlan Wu2023-09-151-1/+1
| | | | | | | Since the compile-time iseq used in the guard was not marked and updated during compaction, a runtime value reusing the address could falsely pass the guard. Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
* YJIT: Fix and enable the unused_imports warningAlan Wu2023-09-151-4/+2
|
* YJIT: Skip Insn::Comment and format! if disasm is disabled (#8441)Takashi Kokubun2023-09-144-144/+151
| | | | | | | | | | | | | * YJIT: Skip Insn::Comment and format! if disasm is disabled Co-authored-by: Alan Wu <alansi.xingwu@shopify.com> * YJIT: Get rid of asm.comment --------- Co-authored-by: Alan Wu <alansi.xingwu@shopify.com>
* YJIT: Remove UTF-8 BOM [ci skip]Alan Wu2023-09-141-1/+1
| | | | | /yjit/src/backend/x86_64/mod.rs Is also UTF-8 and it doesn't have the marker. The standard recommends against it, so remove it.
* YJIT: Plug native stack overflowAlan Wu2023-09-143-3/+15
| | | | | | | Previously, TestStack#test_machine_stack_size failed pretty consistently on ARM64 macOS, with Rust code and part of the interpreter used for per-instruction fallback (rb_vm_invokeblock() and friends) touching the stack guard page and crashing with SEGV. I've also seen the same test fail on x64 Linux, though with a different symptom.
* YJIT: Initialize Vec with capacity for iterators (#8439)Takashi Kokubun2023-09-141-1/+1
|
* YJIT: Initialize Assembler vectors with capacity (#8437)Takashi Kokubun2023-09-141-2/+5
|