summaryrefslogtreecommitdiff
path: root/yjit/src/core.rs
AgeCommit message (Collapse)Author
2023-03-15YJIT: use u16 for insn_idx instead of u32 (#7534)Maxime Chevalier-Boisvert
Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2023-03-15YJIT: Assert that we have the VM lock while markingAlan Wu
Somewhat important because having the lock is a key part of the soundness reasoning for the `unsafe` usage here. Notes: Merged: https://github.com/ruby/ruby/pull/7530
2023-03-10YJIT: Bump SEND_MAX_DEPTH to 20 (#7469)Takashi Kokubun
* YJIT: Bump SEND_MAX_DEPTH to 20 * Fix a test failure Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2023-03-09YJIT: upgrade type in `guard_object_is_string` (#7489)Maxime Chevalier-Boisvert
* YJIT: upgrade type in guard_object_is_string Also make logic more in line with other guard_xxx methods * Update yjit/src/core.rs * Revert changes to Type::upgrade() Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2023-03-02YJIT: shrink stack_size/sp_offet to u8/i8 (#7426)Maxime Chevalier-Boisvert
Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2023-03-02YJIT: Delete stale `frozen_bytes` related code (#7423)Alan Wu
The code and comments in there have been disabled by comments for a long time. The issues that the counter used to solve are now solved more comprehensively by "runningness" [tracking][1] introduced by Code GC and [delayed deallocation][2]. Having a single counter doesn't fit our current model where code pages that could be touched or not are interleaved, anyway. Just delete the code. [1]: e7c71c6c9271b0c29f210769159090e17128e740 [2]: a0b0365e905e1ac51998ace7e6fc723406a2f157 Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2023-03-01YJIT: Use a boxed slice for outgoing branches and cme dependencies (#7409)Takashi Kokubun
YJIT: Use a boxed slice for outgoing branches and cme dependencies Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2023-02-28YJIT: Compress BranchGenFn and BranchShape (#7401)Takashi Kokubun
* YJIT: Compress BranchGenFn and BranchShape * YJIT: Derive Debug for Branch * YJIT: Capitalize BranchGenFn names Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> Co-authored-by: Alan Wu <alansi.xingwu@shopify.com> Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2023-02-28YJIT: Use a boxed slice for gc_obj_offsets (#7397)Takashi Kokubun
* YJIT: Use a boxed slice for gc_obj_offsets * YJIT: Stop using Option * YJIT: s/add_counter/incr_counter_by/ Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2023-02-28YJIT: add defer_empty_count statMaxime Chevalier-Boisvert
Count how often we defer from a block that is empty Notes: Merged: https://github.com/ruby/ruby/pull/7396
2023-02-24YJIT: Use enum for expressing type diff (#7370)Takashi Kokubun
Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2023-02-24YJIT: Compress TempMapping (#7368)Takashi Kokubun
Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2023-02-23YJIT: Trivial fixes in codegen.rsTakashi Kokubun
2023-02-22YJIT: Introduce Opnd::Stack (#7352)Takashi Kokubun
Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2023-02-21YJIT: Fix clippy issues and remove unused params (#7348)Jimmy Miller
* YJIT: Fix clippy issues and remove unused params * Remove an unnecessary whitespace --------- Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com> Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2023-02-17YJIT: Consolidate jit methods in JITState impl (#7336)Jimmy Miller
These jit_* methods don't jit code, but instead check things on the JITState. We had other methods that did the same thing that were just added on the impl JITState. For consistency I added these methods there. Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2023-02-16YJIT: Show Context stats on exit (#7327)Takashi Kokubun
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2023-02-06YJIT: Support arg0 splat on invokeblock (#7234)Takashi Kokubun
Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2023-02-03YJIT: Make Block::start_addr non-optionalAlan Wu
We set the block address as soon as we make the block, so there is no point in making it `Option<CodePtr>`. No memory saving, unfortunately, as `mem::size_of::<Block>() = 176` before and after this change. Still a simplification for the logic, though. Notes: Merged: https://github.com/ruby/ruby/pull/7243
2023-02-02Fix typos in YJIT [ci skip]Alan Wu
2023-01-31YJIT: Fix BorrowMutError on BOP invalidation (#7212)Takashi Kokubun
Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2023-01-30YJIT: Fix BorrowMutError on GC.compact (#7176)Takashi Kokubun
YJIT: Fix BorrowMutError Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2023-01-30YJIT: Skip defer_compilation for fixnums if possible (#7168)Takashi Kokubun
* YJIT: Skip defer_compilation for fixnums if possible * YJIT: It should be Some(false) * YJIT: Define two_fixnums_on_stack on Context Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2023-01-20YJIT: Avoid BorrowError on GC.compact (#7164)Takashi Kokubun
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2023-01-19YJIT: Remove duplicated information in BranchTarget (#7151)Takashi Kokubun
Note: On the new code of yjit/src/core.rs:2178, we no longer leave the state `.block=None` but `.address=Some...`, which might be important. We assume it's actually not needed and take a risk here to minimize heap allocations, but in case it turns out to be necessary, we could signal/resurrect that state by introducing a new BranchTarget (or BranchShape) variant dedicated to it. Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2023-01-12Enable `clippy` checks for yjit in CI (#7093)Ian Ker-Seymer
* Add job to check clippy lints in CI * Address all remaining clippy lints * Check lints on arm64 as well * Apply latest clippy lints * Do not exit 0 on clippy warnings Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2023-01-11YJIT: Add a few asm comments (#7105)Takashi Kokubun
* YJIT: Add a few asm comments * YJIT: Clarify exiting insns * YJIT: Fix cargo test Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2023-01-10Differentiate T_ARRAY and array subclasses (#7091)Aaron Patterson
* Differentiate T_ARRAY and array subclasses This commit teaches the YJIT context the difference between Arrays (objects with type T_ARRAY and class rb_cArray) vs Array subclasses (objects with type T_ARRAY but _not_ class rb_cArray). It uses this information to reduce the number of guards emitted when using `jit_guard_known_klass` with rb_cArray, notably opt_aref * Update yjit/src/core.rs Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com> Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2023-01-09YJIT: Remove old comments for regenerated branches (#7083)Takashi Kokubun
Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2023-01-06YJIT: Make iseq_get_location consistent with iseq.c (#7074)Takashi Kokubun
* YJIT: Make iseq_get_location consistent with iseq.c * YJIT: Call it "YJIT entry point" Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com> Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com> Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2022-12-15YJIT: Fix code GC freeing stubs with a trampoline (#6937)Alan Wu
Stubs we generate for invalidation don't necessarily co-locate with the code that jump to the stub. Since we rely on co-location to keep stubs alive as they are in the outlined code block, it used to be possible for code GC inside branch_stub_hit() to free the stub that's its direct caller, leading us to return to freed code after. Stubs used to look like: ``` mov arg0, branch_ptr mov arg1, target_idx mov arg2, ec call branch_stub_hit jmp return_reg ``` Since the call and the jump after the call is the same for all stubs, we can extract them and use a static trampoline for them. That makes branch_stub_hit() always return to static code. Stubs now look like: ``` mov arg0, branch_ptr mov arg1, target_idx jmp trampoline ``` Where the trampoline is: ``` mov arg2, ec call branch_stub_hit jmp return_reg ``` Code GC can now free stubs without problems since we'll always return to the trampoline, which we generate once on boot and lives forever. This might save a small bit of memory due to factoring out the static part of stubs, but it's probably minor. [Bug #19234] Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com> Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2022-12-08YJIT: Drop Copy trait from Context (#6889)Takashi Kokubun
Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2022-11-30YJIT: add new counters for deferred compilation and queued blocks (#6837)Maxime Chevalier-Boisvert
Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2022-11-30YJIT: Deallocate `struct Block` to plug memory leaksAlan Wu
Previously we essentially never freed block even after invalidation. Their reference count never reached zero for a couple of reasons: 1. `Branch::block` formed a cycle with the block holding the branch 2. Strong count on a branch that has ever contained a stub never reached 0 because we increment the `.clone()` call for `BranchRef::into_raw()` didn't have a matching decrement. It's not safe to immediately deallocate blocks during invalidation since `branch_stub_hit()` can end up running with a branch pointer from an invalidated branch. To plug the leaks, we wait until code GC or global invalidation and deallocate the blocks for iseqs that are definitely not running. Notes: Merged: https://github.com/ruby/ruby/pull/6833
2022-11-24YJIT: rename `InsnOpnd` => `YARVOpnd` (#6801)Maxime Chevalier-Boisvert
Rename InsnOpnd => YARVOpnd Make it more clear this refers to YARV insn/vm operands rather than backend IR, x86 or ARM insn operands. Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2022-11-23YJIT: Use a Box for branch targets to save memoryAlan Wu
We frequently make branches that only have one target but we used to always allocate space for two branch targets. This patch moves all the information a branch target has into a struct and refer to them using Option<Box<BranchTarget>>, this way when the second branch target is not present it only takes 8 bytes. Retained heap size on railsbench went from 16.17 MiB to 14.57 MiB, a ratio of about 1.1. Notes: Merged: https://github.com/ruby/ruby/pull/6799
2022-11-22YJIT: Skip padding jumps to side exits on Arm (#6790)Takashi Kokubun
YJIT: Skip padding jumps to side exits Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> Co-authored-by: Alan Wu <alansi.xingwu@shopify.com> Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> Co-authored-by: Alan Wu <alansi.xingwu@shopify.com> Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2022-11-18YJIT: Improve the failure message on enlarging a branch (#6769)Takashi Kokubun
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2022-11-16YJIT: Shrink version lists after mutation (#6749)Takashi Kokubun
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2022-11-16YJIT: Pack BlockId and CodePtr (#6748)Takashi Kokubun
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2022-11-16YJIT: Add compiled_branch_count stats (#6746)Takashi Kokubun
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2022-11-16YJIT: Stop wrapping CmePtr with CmeDependency (#6747)Takashi Kokubun
* YJIT: Stop wrapping CmePtr with CmeDependency * YJIT: Fix an outdated comment [ci skip] Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2022-11-16YJIT: Shrink the vectors of Block after mutation (#6739)Takashi Kokubun
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2022-11-15YJIT: Invalidate redefined methods only through cme (#6734)Takashi Kokubun
Co-authored-by: Alan Wu <alansi.xingwu@shopify.com> Co-authored-by: Alan Wu <alansi.xingwu@shopify.com> Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2022-11-13YJIT: Remove unused src_ctx from Block (#6714)Takashi Kokubun
Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2022-11-08YJIT: Reset dropped_bytes when patching codeAlan Wu
We switch to a new page when we detect dropped_bytes flipping from false to true. Previously, when we patch code for invalidation during code gc, we start with the flag being set to true, so we failed to apply patches that straddle pages. We would write out jumps half way and then stop, which left the code corrupted. Reset the flag before patching so we patch across pages properly. Notes: Merged: https://github.com/ruby/ruby/pull/6686
2022-11-03YJIT: Fix a wrong type reference (#6661)Takashi Kokubun
* YJIT: Fix a wrong type reference * YJIT: Just remove CapturedSelfOpnd for now Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2022-11-02YJIT: Support invokeblock (#6640)Takashi Kokubun
* YJIT: Support invokeblock * Update yjit/src/backend/arm64/mod.rs * Update yjit/src/codegen.rs Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com> Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2022-11-02YJIT: Avoid accumulating freed pages in the payload (#6657)Takashi Kokubun
Co-Authored-By: Alan Wu <alansi.xingwu@shopify.com> Co-Authored-By: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> Co-authored-by: Alan Wu <alansi.xingwu@shopify.com> Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2022-11-01YJIT: Add an assert to help with Context changesAlan Wu
While experimenting I found that it's easy to change Context and forget to also change the copying operation in limit_block_versions(). Add an assert to make sure we substitute a compatible generic context when limiting the number of versions. Notes: Merged: https://github.com/ruby/ruby/pull/6656