summaryrefslogtreecommitdiff
path: root/mjit.c
Commit message (Collapse)AuthorAgeFilesLines
* Use `rb_fork` to suppress deprecated-declarations warningsNobuyoshi Nakada2022-08-211-2/+3
|
* Drop mswin support of MJIT (#6265)Takashi Kokubun2022-08-201-326/+8
| | | | | | | The current MJIT relies on SIGCHLD and fork(2) to be performant, and it's something mswin can't offer. You could run Linux MJIT on WSL instead. [Misc #18968]
* Execute MJIT in a forked Ruby process (#6264)Takashi Kokubun2022-08-201-23/+62
| | | [Misc #18968]
* Add `-bundle_loader` to mjit compilation args on macOSYuta Saito2022-08-041-2/+10
|
* Adjust styles [ci skip]Nobuyoshi Nakada2022-07-271-1/+2
|
* MJIT: Share rb_mjit_unit through mjit_unit.hTakashi Kokubun2022-07-141-30/+1
| | | | mjit_compile.c should be able to access this more easily.
* MJIT: Merge mjit_worker.c back to mjit.c (#6138)Takashi Kokubun2022-07-141-5/+1264
| | | | | Since #6006, we no longer avoid executing GC on mjit_worker.c and thus there's no need to carefully change how we write code whether you're in mjit.c or mjit_worker.c anymore.
* MJIT: s/assert/VM_ASSERT/Takashi Kokubun2022-07-111-2/+2
| | | | | | include/ruby/assert.h sets NDEBUG by default. As MJIT CI uses -DVM_CHECK_MODE, using only VM_ASSERT might be more helpful.
* MJIT: Consider compaction on CC failureTakashi Kokubun2022-06-161-1/+3
|
* MJIT: Handle compaction units on stop_workerTakashi Kokubun2022-06-151-6/+13
|
* MJIT: Get rid of obsoleted compiling_iseqsTakashi Kokubun2022-06-151-33/+3
|
* MJIT: Deal with mjit_free_iseq on mjit_notify_waitpidTakashi Kokubun2022-06-151-7/+9
|
* MJIT: Fix test_jit_failure for mswinTakashi Kokubun2022-06-151-1/+1
|
* MJIT: Handle C compiler failuresTakashi Kokubun2022-06-151-4/+5
|
* MJIT: Handle JIT failure properlyTakashi Kokubun2022-06-151-1/+9
|
* Remove unused rb_thread_create_mjit_threadTakashi Kokubun2022-06-151-2/+0
| | | | follow up https://github.com/ruby/ruby/pull/6006
* Move RubyVM::MJIT to builtin RubyTakashi Kokubun2022-06-151-3/+7
| | | | just less C code to maintain
* Remove MJIT worker thread (#6006)Takashi Kokubun2022-06-151-132/+184
| | | [Misc #18830]
* Drop MinGW support of MJIT (#6012)Takashi Kokubun2022-06-131-18/+0
| | | [Feature #18824]
* Prefix ccan headers (#4568)Nobuyoshi Nakada2022-03-301-7/+7
| | | | | | | | | | | | | * Prefixed ccan headers * Remove unprefixed names in ccan/build_assert * Remove unprefixed names in ccan/check_type * Remove unprefixed names in ccan/container_of * Remove unprefixed names in ccan/list Co-authored-by: Samuel Williams <samuel.williams@oriontransfer.co.nz>
* Add ISEQ_BODY macroPeter Zhu2022-03-241-31/+31
| | | | | | 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.
* Transfer the responsibility for MJIT options to mjit.cNobuyoshi Nakada2022-01-151-0/+58
|
* Revert "Pause an MJIT worker when JIT is cancelled"Takashi Kokubun2021-08-131-3/+0
| | | | | | This reverts commit b64f81c81729bbc248d19af01cafde88eb60fdc7. It seems to cause a problem in --jit / --jit-wait CIs. Reverting for now.
* Don't run mjit_cancel_all when MJIT is disabledTakashi Kokubun2021-08-121-0/+3
|
* Pause an MJIT worker when JIT is cancelledTakashi Kokubun2021-08-121-0/+3
|
* Print JIT cancel when all JIT-ed code is cancelledTakashi Kokubun2021-08-121-1/+11
|
* Cast jit_func for WindowsTakashi Kokubun2021-06-101-1/+1
| | | | https://ci.appveyor.com/project/ruby/ruby/builds/39542385/job/8b7aq951f9t01x4x
* Avoid enqueueing the same ISeq twiceTakashi Kokubun2021-06-101-10/+20
| | | | | | | | | | 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.
* Do not doubly hold an MJIT lockTakashi Kokubun2021-06-021-9/+14
| | | | | | | | | This is a follow-up of 86c262541ad07528842d76dab4b9b34bd888d5f4. CRITICAL_SECTION_START/FINISH are not needed when it's called from an MJIT worker. Also, ZALLOC needs to be calloc because ZALLOC may trigger GC, which an MJIT worker must not do.
* Fix a race condition around mjit_recompileTakashi Kokubun2021-06-021-8/+13
| | | | | | | | | This fixes SEGVs like https://github.com/ruby/ruby/runs/2715166621?check_suite_focus=true. When mjit_recompile is called when mjit_compile is compiling the exact same iseq (and after it called mjit_capture_cc_entries), iseq->body->jit_unit is re-created and its cc_entries becomes NULL. Then, when it tries to lookup cc_entries through iseq->body->jit_unit, it fails.
* Change the default --jit-max-cache to 10000Takashi Kokubun2021-05-311-1/+1
| | | | | This is useful for large applications like Rails. https://k0kubun.medium.com/ruby-3-jit-can-make-rails-faster-756310f235a
* Drop JIT_ISEQ_SIZE_THRESHOLDTakashi Kokubun2021-05-311-2/+1
| | | | | | | | | 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.
* Mark inlined ISeqs during MJIT compilation (#4539)Takashi Kokubun2021-05-301-5/+13
| | | [Bug #17584]
* enable constant cache on ractorsKoichi Sasada2021-01-051-18/+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-0/+14
|
* Avoid hanging on --jit-wait after MJIT.pauseTakashi Kokubun2021-01-031-0/+3
| | | | When a worker is stopped, nobody will JIT a method for you.
* Stop managing valid class serialsTakashi Kokubun2020-12-291-48/+1
| | | | `mjit_valid_class_serial_p` has no longer been used since b9007b6c548.
* Mark an ISeq being JIT-edTakashi Kokubun2020-12-201-2/+10
| | | | | This is to avoid SEGV on a CC reference in a normal compilation https://github.com/ruby/ruby/runs/1586578023
* Mark active_unitsTakashi Kokubun2020-12-201-4/+37
| | | | | | | | | | | | | | | | | | 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-27/+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().
* Do not access jit_unit if NULLTakashi Kokubun2020-12-161-1/+4
|
* Inline getconstant on JIT (#3906)Takashi Kokubun2020-12-161-0/+26
| | | | | * Inline getconstant on JIT * Support USE_MJIT=0
* Lazily move units from active_units to stale_unitsTakashi Kokubun2020-12-161-3/+4
| | | | | | to avoid SEGV like http://ci.rvm.jp/results/trunk-mjit@phosphorus-docker/3289588 by a race condition between mjit_recompile and compation around active_units
* Assert unit->iseq null out happens under the JIT/GC guardTakashi Kokubun2020-12-031-0/+2
|
* Throttle unload_unitsTakashi Kokubun2020-11-271-1/+1
| | | | | | | | | | Because d80226e7bd often reduces the number of unloaded units, it increases the number of unload_units calls, which are heavy. To mitigate that, this throttles unload_units per `max_cache_size / 10`. Also hoping to fix https://ci.appveyor.com/project/ruby/ruby/builds/36552382/job/kjmjgw9cjyf2ksd7
* Run unload_units in the JIT worker threadTakashi Kokubun2020-11-271-101/+1
| | | | | | | | to avoid "Too many JIT code, but skipped unloading units for JIT compaction". Now we can forget the `in_compact` locking. Moving some functions from mjit.c to mjit_worker.c because mjit_worker.c should have functions executed in the JIT worker.
* Handle calloc failureTakashi Kokubun2020-11-241-0/+2
| | | | for cfd8c7e6ca9f923cee3a062b548d0824fc67e9a5.
* Prefer calloc/free over ZALLOC/xfreeTakashi Kokubun2020-11-231-2/+5
| | | | | To avoid SEGV like http://ci.rvm.jp/logfiles/brlog.trunk-mjit.20201124-061530
* ruby/internal/config.h needs to be included firstTakashi Kokubun2020-11-221-1/+2
| | | | to define USE_MJIT.
* Make --disable-jit-support compileTakashi Kokubun2020-11-221-2/+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.