summaryrefslogtreecommitdiff
path: root/mjit.h
Commit message (Collapse)AuthorAgeFilesLines
* MJIT: Cancel all on disastrous situations (#7019)Takashi Kokubun2022-12-241-0/+14
| | | | | | | | | | I noticed this while running test_yjit with --mjit-call-threshold=1, which redefines `Integer#<`. When Ruby is monkey-patched, MJIT itself could be broken. Similarly, Ruby scripts could break MJIT in many different ways. I prepared the same set of hooks as YJIT so that we could possibly override it and disable it on those moments. Every constant under RubyVM::MJIT is private and thus it's an unsupported behavior though.
* MJIT: Give a more appropriate name to the initial stateTakashi Kokubun2022-12-081-2/+2
|
* MJIT: Drop an obsoleted explanation [ci skip]Takashi Kokubun2022-12-081-1/+1
| | | | There's no MJIT worker thread anymore
* Use a ruby-lang alias [ci skip]Takashi Kokubun2022-12-081-0/+1
|
* MJIT: Refactor mjit_waitTakashi Kokubun2022-12-061-1/+0
|
* MJIT: Remove obsoleted MJIT countersTakashi Kokubun2022-12-061-1/+0
|
* MJIT: Refactor the jit_func enum for MJITTakashi Kokubun2022-12-061-6/+6
| | | | | | All values should have a MJIT_ prefix. We could address the warning for the end mark if we just define the macro for the check next to the enum. It even simplifies some code for checking the enum.
* Rename --mjit-min-calls to --mjit-call-threshold (#6731)Takashi Kokubun2022-11-141-1/+1
| | | for consistency with YJIT
* s/mjit_func_t/jit_func_t/Takashi Kokubun2022-11-131-1/+1
|
* Make mjit_cont sharable with YJIT (#6556)Takashi Kokubun2022-10-171-4/+0
| | | | | | | * Make mjit_cont sharable with YJIT * Update dependencies * Update YJIT binding
* Allow hooking a different method after --mjit=pauseTakashi Kokubun2022-09-061-1/+3
| | | | | The interface is similar to RubyVM::ISeq.translate; it's used if defined. Same as --mjit=pause, this is an undocumented feature for MJIT experiments.
* Add an option to lazily boot MJIT for experimentsTakashi Kokubun2022-09-061-1/+3
| | | | | | You may use `RUBYOPT=--mjit=pause irb` to play with RubyVM::MJIT::C, control the boot timing of MJIT, or customize the implementation while paused. It's an undocumented feature for such experiments.
* Do not fork the process on --mjit-waitTakashi Kokubun2022-09-061-1/+1
| | | | | fork is for parallel compilation, but --mjit-wait cancels it. It's more useful to not fork it for binding.irb, debugging, etc.
* Prefer stdbool for MJIT optionsTakashi Kokubun2022-09-031-5/+5
| | | | same motivation as d6f21b308bcff03e82f8b3dbf11a852ce111b3b3
* Rename mjit_exec to jit_exec (#6262)Takashi Kokubun2022-08-191-1/+1
| | | | | | | * Rename mjit_exec to jit_exec * Rename mjit_exec_slowpath to mjit_check_iseq * Remove mjit_exec references from comments
* yjit.h is not necessary for all sources using mjit.hNobuyoshi Nakada2022-08-171-1/+0
|
* Move `mjit_exec` to vm.cNobuyoshi Nakada2022-08-171-95/+0
|
* Remove MJIT worker thread (#6006)Takashi Kokubun2022-06-151-4/+1
| | | [Misc #18830]
* Add ISEQ_BODY macroPeter Zhu2022-03-241-1/+1
| | | | | | Use ISEQ_BODY macro to get the rb_iseq_constant_body of the ISeq. Using this macro will make it easier for us to change the allocation strategy of rb_iseq_constant_body when using Variable Width Allocation.
* Cleanup diff against upstream. Add commentsAlan Wu2021-10-201-0/+1
| | | | | I did a `git diff --stat` against upstream and looked at all the files that are outside of YJIT to come up with these minor changes.
* Tweak mjit_exec() to remove YJIT symbol exportsAlan Wu2021-10-201-7/+14
| | | | | | | | We were exporting a couple of symbols in yjit.h because they could be used by code generated by MJIT. We don't want MJIT calling into YJIT code anyways so let's stop exporting them to libruby.so. Also adjust indentation and comments in mjit_exec().
* Always use `ret` to return to the interpreterAaron Patterson2021-10-201-3/+15
| | | | | | | | | | | | | | | | | | | | | 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.
* Fix GCC warningsAlan Wu2021-10-201-4/+2
| | | | Mostly unused and uninitialized warnings here and there
* Yet Another Ruby JIT!Jose Narvaez2021-10-201-4/+5
| | | | Renaming uJIT to YJIT. AKA s/ujit/yjit/g.
* Thread EC through jit state. Add codegen status enum.Maxime Chevalier-Boisvert2021-10-201-1/+1
|
* Implement --ujit-call-thresholdMaxime Chevalier-Boisvert2021-10-201-1/+1
|
* Refactor uJIT code into more files for readabilityMaxime Chevalier-Boisvert2021-10-201-1/+1
|
* Move MicroJIT compilation threshold into MicroJIT's headerAlan Wu2021-10-201-2/+1
|
* Fix MicroJIT logic in MJIT execAlan Wu2021-10-201-8/+12
|
* Never compile with MicroJIT when MJIT is enabledAlan Wu2021-10-201-1/+1
| | | | There is a crash in there that we don't want to worry about for now.
* Don't call MicroJIT from MJIT outputAlan Wu2021-10-201-0/+2
|
* MicroJIT: compile after ten callsAlan Wu2021-10-201-1/+7
|
* Print JIT cancel when all JIT-ed code is cancelledTakashi Kokubun2021-08-121-0/+2
|
* Avoid enqueueing the same ISeq twiceTakashi Kokubun2021-06-101-1/+1
| | | | | | | | | | by a race condition by multiple Ractors. Atmically incrementing body->total_calls may have its own cost, so for now we intentionally leave the unreliable total_calls. So we allow an ISeq to be never pushed when you use multiple Ractors. However, if you enqueue a single ccan node twice, get_from_list loops infinitely. Thus this patch takes care of such a situation.
* Drop JIT_ISEQ_SIZE_THRESHOLDTakashi Kokubun2021-05-311-4/+0
| | | | | | | | | Compiling everything seems to contributed to improving the final performance in general. MJIT's compilation is slow anyway, especially when you need to wait for JIT compaction. This might make sense for short-time benchmarks like Optcarrot with default parameters, but it didn't give benefits in my local environment.
* enable constant cache on ractorsKoichi Sasada2021-01-051-4/+0
| | | | | | | | | | | | | | | | constant cache `IC` is accessed by non-atomic manner and there are thread-safety issues, so Ruby 3.0 disables to use const cache on non-main ractors. This patch enables it by introducing `imemo_constcache` and allocates it by every re-fill of const cache like `imemo_callcache`. [Bug #17510] Now `IC` only has one entry `IC::entry` and it points to `iseq_inline_constant_cache_entry`, managed by T_IMEMO object. `IC` is atomic data structure so `rb_mjit_before_vm_ic_update()` and `rb_mjit_after_vm_ic_update()` is not needed.
* Skip mjit_wait if iseq is not a targetTakashi Kokubun2021-01-041-10/+1
|
* Stop managing valid class serialsTakashi Kokubun2020-12-291-4/+0
| | | | `mjit_valid_class_serial_p` has no longer been used since b9007b6c548.
* MJIT is enabled whenever an MJIT header is usedTakashi Kokubun2020-12-211-1/+5
| | | | | | | | | | | | | | | ``` $ benchmark-driver -v --rbenv 'before --jit;after --jit' --repeat-count=4 --alternate --output=all benchmark.yml before --jit: ruby 3.0.0dev (2020-12-22T05:16:39Z master 692af8e8f8) +JIT [x86_64-linux] after --jit: ruby 3.0.0dev (2020-12-22T06:05:59Z master d2ca23fdbc) +JIT [x86_64-linux] last_commit=MJIT is enabled whenever an MJIT header is used Calculating ------------------------------------- before --jit after --jit Optcarrot 180 frames 86.61115328062763 91.49245232931852 fps 90.18653732453176 92.31139517827663 91.29817884736318 93.84437713805814 92.76118222412521 93.91929147901106 ```
* Mark active_unitsTakashi Kokubun2020-12-201-0/+2
| | | | | | | | | | | | | | | | | | to avoid SEGV on mjit_recompile and compact_all_jit_code. For some reason, ISeqs on stack are sometimes GC-ed (why?) and therefore it may run mjit_recompile on a GC-ed ISeq, which I expected d07183ec85d to fix but apparently it may refer to random things if already GC-ed. Marking active_units would workaround the situation. http://ci.rvm.jp/results/trunk-mjit-wait@phosphorus-docker/3292740 Also, while compact_all_jit_code was executed, we saw some SEGVs where CCs seemed to be already GC-ed, meaning their owner ISeq was not marked properly. Even if units are still in active_units, it's not guaranteed that their ISeqs are in use. So in this case we need to mark active_units for a legitimate reason. http://ci.rvm.jp/results/trunk-mjit-wait@phosphorus-docker/3293277 http://ci.rvm.jp/results/trunk-mjit-wait@phosphorus-docker/3293090
* Stop marking unit_queueTakashi Kokubun2020-12-201-2/+0
| | | | | | | | | | The original motivation of this marking was https://github.com/k0kubun/yarv-mjit/issues/20. As wanabe said, there are multiple options to mitigate the issue, and Eric Wong introduced another fix at 143776f6fe by checking unit->iseq inside the lock. Therefore this particular condition has been covered in two ways, and the script given by wanabe no longer crashes without mjit_mark().
* Inline getconstant on JIT (#3906)Takashi Kokubun2020-12-161-0/+7
| | | | | * Inline getconstant on JIT * Support USE_MJIT=0
* ruby/internal/config.h needs to be included firstTakashi Kokubun2020-11-221-1/+1
| | | | to define USE_MJIT.
* Make --disable-jit-support compileTakashi Kokubun2020-11-221-1/+1
| | | | | | vm_core.h needs to be included to know rb_execution_context_t, etc. I also added a trivial refactoring in mjit.c and missing dependency for process.c.
* Combine mjit.h and internal/mjit.hTakashi Kokubun2020-11-221-12/+24
| | | | It's very hard to remember which mjit.h has what.
* Do not JIT inline builtin methodsTakashi Kokubun2020-06-241-0/+1
| | | | | It's probably not worth it because there's nothing we can optimize in such builtin methods. It's worth JIT only when inlined.
* Carve out mjit_exec_slowpathTakashi Kokubun2020-05-271-31/+41
| | | | and mark it as COLDFUN on JIT, assuming enqueue usually happens on VM.
* Eliminate a call instruction on JIT cancel pathTakashi Kokubun2020-05-261-1/+4
| | | | | | | by calling combined functions specialized for each cancel type. I'm hoping to improve locality of hot code, but this patch's impact should be insignificant.
* sed -i 's|ruby/impl|ruby/internal|'卜部昌平2020-05-111-1/+1
| | | | To fix build failures.
* sed -i s|ruby/3|ruby/impl|g卜部昌平2020-05-111-1/+1
| | | | This shall fix compile errors.