summaryrefslogtreecommitdiff
path: root/yjit
Commit message (Collapse)AuthorAgeFilesLines
...
* YJIT: Test more kw and rest cases and change exit nameJimmy Miller2023-03-302-2/+2
|
* YJIT: Generate side exits as late as possible (#7612)Takashi Kokubun2023-03-302-238/+215
| | | | | | | * YJIT: Generate side exits late as possible * YJIT: s/for_stack_size/with_stack_size/ * YJIT: s/get_counter/exit_counter/
* YJIT: Leave cfp->pc uninitialized for VM_FRAME_MAGIC_CFUNCAlan Wu2023-03-291-1/+5
| | | | | | | | | C function frames don't need to use the VM-specific pc field to run properly. When pushing a control frame from output code, save one instruction by leaving the field uninitialized. Fix-up rb_vm_svar_lep(), which is used while setting local variables via Regexp#=~. Use cfp->iseq as a secondary signal so it can stop assuming that all CFUNC frames always have zero pc's.
* YJIT: code_gc(): Assert self is inline to avoid other_cb()Alan Wu2023-03-291-3/+6
| | | | | | | The derived `&mut` from `other_cb()` overlapped with the parameter `ocb`. Use `cfg!()` instead of `#[cfg...]` to avoid unused warnings.
* YJIT: Take VM lock in RubyVM::YJIT.code_gcAlan Wu2023-03-291-3/+6
| | | | Code GC needs synchronization.
* YJIT: Fix overlapping &mut in Assembler::code_gc()Alan Wu2023-03-293-14/+11
| | | | | | | | | Making overlapping `&mut`s triggers Undefined Bahavior. This function previously had them through `cb` and `ocb` aliasing with `self` or live references in the caller. To fix the overlap, take `ocb` as a parameter and don't use `get_inline_cb()` in the body of the function.
* YJIT: Rest and keyword (non-supplying) (#7608)Jimmy Miller2023-03-292-89/+89
| | | | | | | | | * YJIT: Rest and keyword (non-supplying) * Update yjit/src/codegen.rs --------- Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
* YJIT: Add `--yjit-pause` and `RubyVM::YJIT.resume` (#7609)Maxime Chevalier-Boisvert2023-03-282-0/+28
| | | | | | | | | | | | | | | | | | | * YJIT: Add --yjit-pause and RubyVM::YJIT.resume This allows booting YJIT in a suspended state. We chose to add a new command line option as opposed to simply allowing YJIT.resume to work without any command line option because it allows for combining with YJIT tuning command line options. It also simpifies implementation. Paired with Kokubun and Maxime. * Update yjit.rb Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com> --------- Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
* YJIT: Stop using the starting_context pattern (#7610)Takashi Kokubun2023-03-281-72/+64
|
* YJIT: Rest and block_arg support (#7584)Jimmy Miller2023-03-242-9/+3
|
* YJIT: Constify EC to avoid an `as` pointer cast (#7591)Alan Wu2023-03-242-2/+2
|
* YJIT: Save PC on rb_str_concat (#7586)Takashi Kokubun2023-03-231-2/+4
| | | | | [Bug #19483] Co-authored-by: Alan Wu <alansi.xingwu@shopify.com>
* YJIT: Use starting context for status === CantCompile (#7583)Jimmy Miller2023-03-231-3/+8
|
* Use shape information in YJIT's definedivar implementation (#7579)Ole Friis Østergaard2023-03-231-19/+66
| | | | | * Use shape information in YJIT's definedivar implementation * Handle complex shape for definedivar
* `vm_call_single_noarg_inline_builtin`Koichi Sasada2023-03-231-0/+1
| | | | | | | | If the iseq only contains `opt_invokebuiltin_delegate_leave` insn and the builtin-function (bf) is inline-able, the caller doesn't need to build a method frame. `vm_call_single_noarg_inline_builtin` is fast path for such cases.
* YJIT: Fix large ISeq rejection (#7576)Alan Wu2023-03-212-3/+17
| | | | | | | | | | | | We crashed in some edge cases due to the recent change to not compile encoded iseqs that are larger than `u16::MAX`. - Match the C signature of rb_yjit_constant_ic_update() and clamp down to `IseqIdx` size - Return failure instead of panicking with `unwrap()` in codegen when the iseq is too large Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> Co-authored-by: Noah Gibbs <noah.gibbs@shopify.com>
* YJIT: Fix incorrect exit in splat (#7575)Jimmy Miller2023-03-211-1/+1
| | | | | | | So by itself, this shouldn't have been a correctness issue, but we also pop the stack for block_args. Doing stack manipulation like that and then side-exiting causes issues. So, while this fixes the immediate failure, we have a bigger issue with block_args popping and then exiting that we need to deal with.
* Revert "YJIT: Rest and block_arg support (#7557)"Peter Zhu2023-03-212-3/+9
| | | | | | | | | | | | | | | | | | | | | | | This reverts commit 5d0a1ffafa61da04dbda38a5cb5565bcb8032a78. This commit is causing sequel in yjit-bench to raise with this stack trace: ``` sequel-5.64.0/lib/sequel/dataset/sql.rb:266:in `literal': wrong argument type Array (expected Proc) (TypeError) from sequel-5.64.0/lib/sequel/database/misc.rb:269:in `literal' from sequel-5.64.0/lib/sequel/adapters/shared/sqlite.rb:314:in `column_definition_default_sql' from sequel-5.64.0/lib/sequel/database/schema_methods.rb:564:in `block in column_definition_sql' from sequel-5.64.0/lib/sequel/database/schema_methods.rb:564:in `each' from sequel-5.64.0/lib/sequel/database/schema_methods.rb:564:in `column_definition_sql' from sequel-5.64.0/lib/sequel/database/schema_methods.rb:634:in `block in column_list_sql' from sequel-5.64.0/lib/sequel/database/schema_methods.rb:634:in `map' from sequel-5.64.0/lib/sequel/database/schema_methods.rb:634:in `column_list_sql' from sequel-5.64.0/lib/sequel/database/schema_methods.rb:753:in `create_table_sql' from sequel-5.64.0/lib/sequel/adapters/shared/sqlite.rb:348:in `create_table_sql' from sequel-5.64.0/lib/sequel/database/schema_methods.rb:702:in `create_table_from_generator' from sequel-5.64.0/lib/sequel/database/schema_methods.rb:203:in `create_table' from benchmarks/sequel/benchmark.rb:19:in `<main>' ```
* YJIT: Make dev_nodebug closer to dev (#7570)Takashi Kokubun2023-03-201-3/+4
|
* YJIT: tag output type as UnknownHeap in `toregexp` (#7562)Maxime Chevalier-Boisvert2023-03-201-1/+1
|
* YJIT: Simplify using the BITS associated constantAlan Wu2023-03-171-8/+8
| | | | All the integer types have it.
* YJIT: make type info more specific in gen_fixnum_cmp and gen_opt_mod (#7555)Maxime Chevalier-Boisvert2023-03-171-3/+3
|
* YJIT: Delete --yjit-global-constant-state (#7559)Alan Wu2023-03-172-35/+5
| | | | | It was useful for evaluating 6068da8937d7e4358943f95e7450dae7179a7763 but I think we should remove it now to make the logic around invalidation more straight forward.
* YJIT: Add and use Branch::assert_layout()Alan Wu2023-03-171-0/+14
| | | | | | This assert would've caught a bug I wrote while developing ruby/ruby#7443 so I figured it would be good to commit it as it could be helpful in the future.
* YJIT: Rest and block_arg support (#7557)Jimmy Miller2023-03-172-9/+3
| | | | | | | | | * YJIT: Rest and block_arg support * Update bootstraptest/test_yjit.rb --------- Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
* YJIT: Support entry for multiple PCs per ISEQ (GH-7535)Takashi Kokubun2023-03-176-32/+262
|
* YJIT: Use raw pointers and shared references over `Rc<RefCell<_>>`Alan Wu2023-03-175-637/+965
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `Rc` and `RefCell` both incur runtime space costs. In addition, `RefCell` has given us some headaches with the non obvious borrow panics it likes to throw out. The latest one started with 7fd53eeb46db261bbc20025cdab70096245a5cbe and is yet to be resolved. Since we already rely on the GC to properly reclaim memory for `Block` and `Branch`, we might as well stop paying the overhead of `Rc` and `RefCell`. The `RefCell` panics go away with this change, too. On 25 iterations of `railsbench` with a stats build I got `yjit_alloc_size: 8,386,129 => 7,348,637`, with the new memory size 87.6% of the status quo. This makes the metadata and machine code size roughly line up one-to-one. The general idea here is to use `&` shared references with [interior mutability][1] with `Cell`, which doesn't take any extra space. The `noalias` requirement that `&mut` imposes is way too hard to meet and verify. Imagine replacing places where we would've gotten `BorrowError` from `RefCell` with Rust/LLVM miscompiling us due to aliasing violations. With shared references, we don't have to think about subtle cases like the GC _sometimes_ calling the mark callback while codegen has an aliasing reference in a stack frame below. We mostly only need to worry about liveness, with which the GC already helps. There is now a clean split between blocks and branches that are not yet fully constructed and ones that are "in-service", so to speak. Working with `PendingBranch` and `JITState` don't really involve `unsafe` stuff. This change allows `Branch` and `Block` to not have as many optional fields as many of them are only optional during compilation. Fields that change post-compilation are wrapped in `Cell` to facilitate mutation through shared references. I do some `unsafe` dances here. I've included just a couple tests to run with Miri (`cargo +nightly miri test miri`). We can add more Miri tests if desired. [1]: https://doc.rust-lang.org/std/cell/struct.UnsafeCell.html
* YJIT: Remove exit for rest and send combo (#7546)Jimmy Miller2023-03-161-5/+0
|
* YJIT: add stats to keep track of when branch direction is known (#7544)Maxime Chevalier-Boisvert2023-03-162-0/+12
| | | This measures the impact of changes made by @jhawthorn last year.
* YJIT: Eliminate unnecessary mov for trampolines (#7537)Takashi Kokubun2023-03-151-1/+4
|
* YJIT: Use assert_disasm! in an A64 test to avoid unused warningAlan Wu2023-03-151-0/+6
| | | I kept getting unused warnings for this macro on A64 macOS.
* YJIT: use u16 for insn_idx instead of u32 (#7534)Maxime Chevalier-Boisvert2023-03-155-35/+37
|
* YJIT: Assert that we have the VM lock while markingAlan Wu2023-03-153-6/+21
| | | | | Somewhat important because having the lock is a key part of the soundness reasoning for the `unsafe` usage here.
* Make EC required on JIT state (#7520)Aaron Patterson2023-03-151-14/+17
| | | | | | | | | | | | * Make EC required on JIT state Lets make EC required on the JITState object so we don't need to `unwrap` it. * Minor nitpicks --------- Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
* YJIT: Introduce no_gc attribute (#7511)Takashi Kokubun2023-03-143-15/+19
|
* YJIT: Implement throw instruction (#7491)Takashi Kokubun2023-03-141-0/+35
| | | | | | | * Break up jit_exec from vm_sendish * YJIT: Implement throw instruction * YJIT: Explain what rb_vm_throw does [ci skip]
* YJIT: Allow testing assembler with disasm (#7470)Takashi Kokubun2023-03-142-2/+86
| | | | | | | | | | | * YJIT: Allow testing assembler with disasm * YJIT: Drop new dependencies * YJIT: Avoid address manipulation * YJIT: Introduce assert_disasm! macro * YJIT: Update the comment about assert_disasm
* YJIT: Merge add/sub/and/or/xor and mov on x86_64 (#7492)Takashi Kokubun2023-03-131-23/+90
|
* YJIT: Handle rest+splat where non-splat < required (#7499)Jimmy Miller2023-03-133-23/+59
|
* YJIT: Bump SEND_MAX_DEPTH to 20 (#7469)Takashi Kokubun2023-03-102-3/+5
| | | | | * YJIT: Bump SEND_MAX_DEPTH to 20 * Fix a test failure
* YJIT: upgrade type in `guard_object_is_string` (#7489)Maxime Chevalier-Boisvert2023-03-092-35/+49
| | | | | | | | | * 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()
* YJIT: Merge x86_merge into x86_split (#7487)Takashi Kokubun2023-03-091-31/+12
|
* Another fix for 262254dc7dTakashi Kokubun2023-03-091-1/+1
| | | | Koichi might want to adjust his editor configuration.
* Revert an unneeded diff in 262254dc7dTakashi Kokubun2023-03-091-3/+3
|
* rename `defined_ivar` to `definedivar`Koichi Sasada2023-03-102-9/+9
| | | | because non-opt instructions should contain `_` char.
* YJIT: Optimize `cmp REG, 0` into `test REG, REG` (#7471)Takashi Kokubun2023-03-091-2/+31
|
* Add defined_ivar as YJIT instruction as wellOle Friis Østergaard2023-03-083-159/+201
| | | | | | | | | | This works much like the existing `defined` implementation, but calls out to rb_ivar_defined instead of the more general rb_vm_defined. Other difference to the existing `defined` implementation is that this new instruction has to take the same operands as the CRuby `defined_ivar` instruction.
* Remove MJIT's builtin function compilerTakashi Kokubun2023-03-071-8/+0
|
* YJIT: Add comments to peek and x86_mergeTakashi Kokubun2023-03-072-0/+4
|
* YJIT: Merge lea and mov on x86_64 when possibleTakashi Kokubun2023-03-072-3/+55
|