aboutsummaryrefslogtreecommitdiffstats
path: root/yjit
Commit message (Collapse)AuthorAgeFilesLines
* YJIT: Add RubyVM::YJIT.code_gc (#6644)Takashi Kokubun2022-10-313-8/+32
| | | | | * YJIT: Add RubyVM::YJIT.code_gc * Rename compiled_page_count to live_page_count
* YJIT: reduce default `--yjit-exec-mem-size` to 128MiB instead of 256 (#6649)Maxime Chevalier-Boisvert2022-10-311-1/+1
| | | Reduce default --yjit-exec-mem-size to 128MiB instead of 256
* YJIT: Use guard_known_class() for opt_aref on Arrays (#6643)Alan Wu2022-10-271-21/+13
| | | | | This code used to roll its own heap object check before we made a better version in guard_known_class(). The improved version uses one fewer comparison, so let's use that.
* YJIT: Support nil and blockparamproxy as blockarg in send (#6492)Matthew Draper2022-10-264-44/+167
| | | | | Co-authored-by: John Hawthorn <john@hawthorn.email> Co-authored-by: John Hawthorn <john@hawthorn.email>
* YJIT: Invalidate i-cache for the other cb on next_page (#6631)Takashi Kokubun2022-10-261-1/+18
| | | | | | | * YJIT: Invalidate i-cache for the other cb on next_page * YJIT: Invalidate only what's written by jmp_ptr * YJIT: Move the code to the arm64 backend
* YJIT: GC and recompile all code pages (#6406)Takashi Kokubun2022-10-258-23/+311
| | | | | when it fails to allocate a new page. Co-authored-by: Alan Wu <alansi.xingwu@shopify.com>
* Rename `iv_count` on shapes to `next_iv_index`Jemma Issroff2022-10-211-1/+1
| | | | | | `iv_count` is a misleading name because when IVs are unset, the new shape doesn't decrement this value. `next_iv_count` is an accurate, and more descriptive name.
* YJIT: Fix page rounding for icache bustingAlan Wu2022-10-211-5/+7
| | | | | | | | | | | | | | Previously, we found the current page by rounding the current pointer to the closest smaller page size. This is incorrect because pages are relative to the start of the address we reserve. For example, if the starting address is 12KiB modulo the 16KiB page size, once we have more than 4KiB of code, calculating with the address would incorrectly give us page 1 when we're actually still on page 0. Previously, I can reproduce crashes with: make btest RUN_OPTS=--yjit-code-page-size=32 on ARM64 macOS, where system page sizes are 16KiB.
* YJIT: Read rb_num_t as usize earlyAlan Wu2022-10-211-25/+22
| | | | | | | | | This patch makes sure that we're not accidentally reading rb_num_t instruction arguments as VALUE and accidentally baking them into code and marking them. Some of these are simply moving the cast earlier, but some of these avoid potential problems for flag and ID arguments. Follow-up for 39f7eddec4c55711d56f05b085992a83bf23159e.
* YJIT: Fix gen_expandarray treating argument as VALUEAlan Wu2022-10-201-11/+12
| | | | | | | | | | | | | | | | | | | The expandarray instruction interpreters its arguments as rb_num_t. YJIT was treating the num argument as a VALUE previously and when it has a certain bit pattern, it can look like a GC pointer. The argument is not a pointer, so YJIT crashed when trying to mark those pointers. This bug existed previously, but our test suite didn't expose it until f55212bce939f736559709a8cd16c409772389c8. TestArgf#test_to_io has a line like: a1, a2, a3, a4, a5, a6, a7, a8 = array Which maps to an expandarray with an argument of 8. Qnil happened to be defined as 8, which masked the issue. Fix it by not using the argument as a VALUE.
* YJIT: remove some stale comments [ci skip]Alan Wu2022-10-201-8/+0
|
* YJIT: incorporate ruby_special_constsNobuyoshi Nakada2022-10-204-21/+28
|
* Move "special consts" so `Qundef` and `Qnil` differ just 1 bitNobuyoshi Nakada2022-10-202-4/+3
|
* YJIT: Respect writable_addrs on --yjit-dump-iseq-disasm as well (#6596)Takashi Kokubun2022-10-192-10/+13
| | | | | YJIT: Respect writable_addrs on --yjit-dump-iseq-disasm as well
* YJIT: Skip dumping code for the other cb on --yjit-dump-disasm (#6592)Takashi Kokubun2022-10-193-14/+17
| | | | | YJIT: Skip dumping code for the other cb on --yjit-dump-disasm
* YJIT: fix a #[warn(unused_parens)]Alan Wu2022-10-191-1/+1
|
* YJIT: fold the "asm_comments" feature into "disasm" (#6591)Alan Wu2022-10-196-11/+10
| | | | | Previously, enabling only "disasm" didn't actually build. Since these two features are closely related and we don't really use one without the other, let's simplify and merge the two features together.
* Fixes remaining issues and turns back on dead code and unused (#6584)Jimmy Miller2022-10-182-5/+2
|
* Code clean around unused code for some architectures or features (#6581)Jimmy Miller2022-10-185-10/+16
|
* Allow passing a Rust closure to rb_iseq_callback (#6575)Takashi Kokubun2022-10-183-6/+16
|
* YJIT: Allow --yjit-dump-disasm to dump into a file (#6552)Takashi Kokubun2022-10-174-29/+40
| | | | | | | * YJIT: Allow --yjit-dump-disasm to dump into a file * YJIT: Move IO implementation to disasm.rs * YJIT: More consistent naming
* YJIT: Interleave inline and outlined code blocks (#6460)Takashi Kokubun2022-10-179-161/+378
| | | | Co-authored-by: Alan Wu <alansi.xingwu@shopify.com> Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>
* Make mjit_cont sharable with YJIT (#6556)Takashi Kokubun2022-10-171-2/+2
| | | | | | | * Make mjit_cont sharable with YJIT * Update dependencies * Update YJIT binding
* YJIT: call free_block to cleanup block when out of memoryAlan Wu2022-10-172-5/+4
| | | | | | | The commented out instance of free_block() is left over from the port. The addition in gen_single_block() was a place we missed. The new block is allocated in the same function and could have invariants associated with it even though there is no space to hold all the code.
* YJIT doesn't need rb_obj_ensure_iv_index_mappingAaron Patterson2022-10-142-4/+0
| | | | We should make this function static and remove it from YJIT bindings.
* YJIT: Avoid creating payloads for non-JITed ISEQs (#6549)Takashi Kokubun2022-10-144-28/+51
| | | | | * YJIT: Count freed ISEQs * YJIT: Avoid creating payloads for non-JITed ISEQs
* More clippy fixes (#6547)Jimmy Miller2022-10-144-52/+78
|
* fixes more clippy warnings (#6543)Jimmy Miller2022-10-139-87/+52
| | | | | * fixes more clippy warnings * Fix x86 c_callable to have doc_strings
* Make op_ext an optional for code clarity (#6542)Jimmy Miller2022-10-131-42/+50
|
* YJIT: No need to fill to get UDF on ARM64Alan Wu2022-10-131-4/+11
| | | | | On ARM64, all zeros is already undefined, so we don't need to do extra work to fill new memory with undefined instructions.
* Implement optimize send in yjit (#6488)Jimmy Miller2022-10-116-17/+238
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Implement optimize send in yjit This successfully makes all our benchmarks exit way less for optimize send reasons. It makes some benchmarks faster, but not by as much as I'd like. I think this implementation works, but there are definitely more optimial arrangements. For example, what if we compiled send to a jump table? That seems like perhaps the most optimal we could do, but not obvious (to me) how to implement give our current setup. Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> * Attempt at fixing the issues raised by @XrXr * fix allowlist * returns 0 instead of nil when not found * remove comment about encoding exception * Fix up c changes * Update assert Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> * get rid of unneeded code and fix the flags * Apply suggestions from code review Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> * rename and fix typo Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
* Make inline cache reads / writes atomic with object shapesJemma Issroff2022-10-112-5/+4
| | | | | | | | | | | | | | Prior to this commit, we were reading and writing ivar index and shape ID in inline caches in two separate instructions when getting and setting ivars. This meant there was a race condition with ractors and these caches where one ractor could change a value in the cache while another was still reading from it. This commit instead reads and writes shape ID and ivar index to inline caches atomically so there is no longer a race condition. Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org> Co-Authored-By: John Hawthorn <john@hawthorn.email>
* Revert "Revert "This commit implements the Object Shapes technique in CRuby.""Jemma Issroff2022-10-115-87/+106
| | | | This reverts commit 9a6803c90b817f70389cae10d60b50ad752da48f.
* YJIT: add an assert for branch_stub_hit() (#6505)Alan Wu2022-10-061-1/+4
| | | | | We set the PC in branch_stub_hit(), which only makes sense if we're running with the intended iseq for the stub. We ran into an issue caught by this while tweaking code layout.
* YJIT: fix ARM64 bitmask encoding for 32 bit registers (#6503)Alan Wu2022-10-064-22/+148
| | | | | | | | | | | | | | For logical instructions such as AND, there is a constraint that the N part of the bitmask immediate must be 0. We weren't respecting this condition previously and were silently emitting undefined instructions. Check for this condition in the assembler and tweak the backend to correctly detect whether a number could be encoded as an immediate in a 32 bit logical instruction. Due to the nature of the immediate encoding, the same numeric value encodes differently depending on the size of the register the instruction works on. We currently don't have cases where we use 32 bit immediates but we ran into this encoding issue during development.
* YJIT: add support for calling bmethods (#6489)Alan Wu2022-10-044-21/+324
| | | | | | | | | | | | | | | | | | | | | | | | * YJIT: fix a parameter name * YJIT: add support for calling bmethods This commit adds support for the VM_METHOD_TYPE_BMETHOD method type in YJIT. You can get these type of methods from facilities like Kernel#define_singleton_method and Module#define_method. Even though the body of these methods are blocks, the parameter setup for them is exactly the same as VM_METHOD_TYPE_ISEQ, so we can reuse the same logic in gen_send_iseq(). You can see this from how vm_call_bmethod() eventually calls setup_parameters_complex() with arg_setup_method. Bmethods do need their frame environment to be setup differently. We handle this by allowing callers of gen_send_iseq() to control the iseq, the frame flag, and the prev_ep. The `prev_ep` goes into the same location as the block handler would go into in an iseq method frame. Co-authored-by: John Hawthorn <john@hawthorn.email> Co-authored-by: John Hawthorn <john@hawthorn.email>
* Split cmp operations that aren't 32/64 bit for arm (#6484)Jimmy Miller2022-10-032-0/+24
|
* Fix YJIT args for rb_vm_set_ivar_idxJohn Hawthorn2022-09-301-1/+1
| | | | | This was broken accidentally with the revert of shapes (it conflicted with some unrelated cleanup).
* Fix YJIT build after shapes-revertJohn Hawthorn2022-09-301-1/+1
| | | | | An variable had been renamed in between the merge and revert, so the build was broken. This restores it.
* Revert "This commit implements the Object Shapes technique in CRuby."Aaron Patterson2022-09-305-106/+87
| | | | This reverts commit 68bc9e2e97d12f80df0d113e284864e225f771c2.
* A bunch of clippy auto fixes for yjit (#6476)Jimmy Miller2022-09-3016-52/+53
|
* This commit implements the Object Shapes technique in CRuby.Jemma Issroff2022-09-285-88/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Object Shapes is used for accessing instance variables and representing the "frozenness" of objects. Object instances have a "shape" and the shape represents some attributes of the object (currently which instance variables are set and the "frozenness"). Shapes form a tree data structure, and when a new instance variable is set on an object, that object "transitions" to a new shape in the shape tree. Each shape has an ID that is used for caching. The shape structure is independent of class, so objects of different types can have the same shape. For example: ```ruby class Foo def initialize # Starts with shape id 0 @a = 1 # transitions to shape id 1 @b = 1 # transitions to shape id 2 end end class Bar def initialize # Starts with shape id 0 @a = 1 # transitions to shape id 1 @b = 1 # transitions to shape id 2 end end foo = Foo.new # `foo` has shape id 2 bar = Bar.new # `bar` has shape id 2 ``` Both `foo` and `bar` instances have the same shape because they both set instance variables of the same name in the same order. This technique can help to improve inline cache hits as well as generate more efficient machine code in JIT compilers. This commit also adds some methods for debugging shapes on objects. See `RubyVM::Shape` for more details. For more context on Object Shapes, see [Feature: #18776] Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org> Co-Authored-By: Eileen M. Uchitelle <eileencodes@gmail.com> Co-Authored-By: John Hawthorn <john@hawthorn.email>
* YJIT: add assertion wrt label names (#6459)Maxime Chevalier-Boisvert2022-09-271-0/+2
| | | Add assertion wrt label names
* Change IncrCounter lowering on AArch64 (#6455)Kevin Newton2022-09-275-11/+181
| | | | | | | | | | | * Change IncrCounter lowering on AArch64 Previously we were using LDADDAL which is not available on Graviton 1 chips. Instead, we're going to use an exclusive load/store group through the LDAXR/STLXR instructions. * Update yjit/src/backend/arm64/mod.rs Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
* Revert this until we can figure out WB issues or remove shapes from GCAaron Patterson2022-09-265-109/+88
| | | | | | | | | | Revert "* expand tabs. [ci skip]" This reverts commit 830b5b5c351c5c6efa5ad461ae4ec5085e5f0275. Revert "This commit implements the Object Shapes technique in CRuby." This reverts commit 9ddfd2ca004d1952be79cf1b84c52c79a55978f4.
* This commit implements the Object Shapes technique in CRuby.Jemma Issroff2022-09-265-88/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Object Shapes is used for accessing instance variables and representing the "frozenness" of objects. Object instances have a "shape" and the shape represents some attributes of the object (currently which instance variables are set and the "frozenness"). Shapes form a tree data structure, and when a new instance variable is set on an object, that object "transitions" to a new shape in the shape tree. Each shape has an ID that is used for caching. The shape structure is independent of class, so objects of different types can have the same shape. For example: ```ruby class Foo def initialize # Starts with shape id 0 @a = 1 # transitions to shape id 1 @b = 1 # transitions to shape id 2 end end class Bar def initialize # Starts with shape id 0 @a = 1 # transitions to shape id 1 @b = 1 # transitions to shape id 2 end end foo = Foo.new # `foo` has shape id 2 bar = Bar.new # `bar` has shape id 2 ``` Both `foo` and `bar` instances have the same shape because they both set instance variables of the same name in the same order. This technique can help to improve inline cache hits as well as generate more efficient machine code in JIT compilers. This commit also adds some methods for debugging shapes on objects. See `RubyVM::Shape` for more details. For more context on Object Shapes, see [Feature: #18776] Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org> Co-Authored-By: Eileen M. Uchitelle <eileencodes@gmail.com> Co-Authored-By: John Hawthorn <john@hawthorn.email>
* YJIT: Support Rust 1.58.1 for --yjit-stats on Arm (#6410)Takashi Kokubun2022-09-231-13/+1
| | | | | | | | | | | | | | | | | | | | | | | * YJIT: Test Rust 1.58.1 as well on Cirrus * YJIT: Avoid using a Rust 1.60.0 feature * YJIT: Use autoconf to detect support * YJIT: We actually need to run it for checking it properly * YJIT: Try cfg!(target_feature = "lse") * Revert "YJIT: Try cfg!(target_feature = "lse")" This reverts commit 4e2a9ca9a9c83052c23b5e205c91bdf79e88342e. * YJIT: Add --features stats only when it works * Update configure.ac Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
* YJIT: add chain guards in `guard_two_fixnums` (#6422)Maxime Chevalier-Boisvert2022-09-221-13/+37
| | | | | * Add chain guards in guard_two_fixnums, opt_eq with symbols * Remove symbol comparison in gen_equality_specialized
* YJIT: Refactor into gen_push_frame (#6412)John Hawthorn2022-09-221-102/+161
| | | | | This refactors the "push frame" operation common to both gen_send_iseq and gen_send_cfunc into its own method. This allows that logic to live in one place.
* Guard `--yjit-stats` behind `#[cfg(feature = "stats")]` (#6409)Maxime Chevalier-Boisvert2022-09-201-0/+3
| | | | | | | | | | | | | * Guard --yjit-stats behind #[cfg(feature = "stats")] * Only ask for --yjit-stats with dev builds on cirrus CI * Revert "Only ask for --yjit-stats with dev builds on cirrus CI" This reverts commit cfb5ddfa4b9394ca240447eee02637788435b02a. * Make it so the --yjit-stats option works for non-release builds * Revert accidental changes