Граф коммитов

331 Коммитов

Автор SHA1 Сообщение Дата
Takashi Kokubun e7166c9bb7
Allow passing a Rust closure to rb_iseq_callback (#6575) 2022-10-18 09:07:11 -07:00
Takashi Kokubun e7c71c6c92
Make mjit_cont sharable with YJIT (#6556)
* Make mjit_cont sharable with YJIT

* Update dependencies

* Update YJIT binding
2022-10-17 09:27:59 -07:00
Samuel Williams 22af2e9084 Rework vm_core to use `int first_lineno` struct member. 2022-09-26 00:41:16 +13:00
Takashi Kokubun cac0dcfbff
Fix typo
I meant the other one. Otherwise this option doesn't make sense.
2022-09-07 14:26:58 +09:00
Takashi Kokubun 496bdf01e2
Adjust pch_status for --mjit=pause
to let mjit_add_iseq_to_process work
2022-09-06 22:14:01 -07:00
Takashi Kokubun f0661bf3a0
Skip early mjit_add_iseq_to_process on --mjit=pause 2022-09-06 18:40:23 -07:00
Takashi Kokubun f24c65ea7e
Skip calling check_unit_queue with mjit_opts.custom
fixing the behavior of b726c06e7e
2022-09-06 18:25:46 -07:00
Takashi Kokubun b726c06e7e
Allow hooking a different method after --mjit=pause
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.
2022-09-06 15:52:02 +09:00
Takashi Kokubun 341b40bd0c
Cache RubyVM::MJIT constants
for performance
2022-09-06 15:50:14 +09:00
Takashi Kokubun 5b3bd91fcb
Add an option to lazily boot MJIT for experiments
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.
2022-09-06 15:45:10 +09:00
Takashi Kokubun f6925fab85
Do not fork the process on --mjit-wait
fork is for parallel compilation, but --mjit-wait cancels it.
It's more useful to not fork it for binding.irb, debugging, etc.
2022-09-06 15:42:02 +09:00
Takashi Kokubun 63ed61e322
Deal with MJIT_FORCE_ENABLE miniruby
http://ci.rvm.jp/results/trunk-mjit@phosphorus-docker/4225469
2022-09-05 08:39:37 -07:00
Takashi Kokubun 3767c6a90d
Ruby MJIT (#6028) 2022-09-04 21:53:46 -07:00
Takashi Kokubun f6d569b7c0
Call appropriate hooks on MJIT's fork
This takes care of signal_self_pipe and other things.
2022-09-04 18:22:25 -07:00
Takashi Kokubun cfa40e225a
Prefer stdbool for MJIT options
same motivation as d6f21b308b
2022-09-03 20:01:51 -07:00
Nobuyoshi Nakada f6d4d73abd
Use `rb_fork` to suppress deprecated-declarations warnings 2022-08-21 14:04:52 +09:00
Takashi Kokubun ddf96b7693
Drop mswin support of MJIT (#6265)
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]
2022-08-20 18:35:36 -07:00
Takashi Kokubun dc8d70e461
Execute MJIT in a forked Ruby process (#6264)
[Misc #18968]
2022-08-20 16:33:03 -07:00
Yuta Saito 00f411c58a Add `-bundle_loader` to mjit compilation args on macOS 2022-08-04 16:29:22 +09:00
Nobuyoshi Nakada f42230ff22
Adjust styles [ci skip] 2022-07-27 18:42:27 +09:00
Takashi Kokubun 6c2cad835a MJIT: Share rb_mjit_unit through mjit_unit.h
mjit_compile.c should be able to access this more easily.
2022-07-14 22:54:20 -07:00
Takashi Kokubun 439d31bc77
MJIT: Merge mjit_worker.c back to mjit.c (#6138)
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.
2022-07-14 20:34:46 -07:00
Takashi Kokubun cbcc92f788
MJIT: s/assert/VM_ASSERT/
include/ruby/assert.h sets NDEBUG by default.
As MJIT CI uses -DVM_CHECK_MODE, using only VM_ASSERT might be more
helpful.
2022-07-11 23:49:13 -07:00
Takashi Kokubun 8ef312fc5b
MJIT: Consider compaction on CC failure 2022-06-16 00:47:16 -07:00
Takashi Kokubun b5079794fd
MJIT: Handle compaction units on stop_worker 2022-06-15 22:09:38 -07:00
Takashi Kokubun 66f0ce34f1
MJIT: Get rid of obsoleted compiling_iseqs 2022-06-15 21:58:00 -07:00
Takashi Kokubun 1ffc6c43f6
MJIT: Deal with mjit_free_iseq on mjit_notify_waitpid 2022-06-15 21:32:30 -07:00
Takashi Kokubun 332985c178
MJIT: Fix test_jit_failure for mswin 2022-06-15 17:18:19 -07:00
Takashi Kokubun 15a6dd56e0
MJIT: Handle C compiler failures 2022-06-15 16:50:47 -07:00
Takashi Kokubun 5310147bb8
MJIT: Handle JIT failure properly 2022-06-15 15:57:30 -07:00
Takashi Kokubun a327ce8b07
Remove unused rb_thread_create_mjit_thread
follow up https://github.com/ruby/ruby/pull/6006
2022-06-15 10:57:38 -07:00
Takashi Kokubun 23459e4dbb
Move RubyVM::MJIT to builtin Ruby
just less C code to maintain
2022-06-15 10:52:37 -07:00
Takashi Kokubun 1162523bae
Remove MJIT worker thread (#6006)
[Misc #18830]
2022-06-15 09:40:54 -07:00
Takashi Kokubun f8502a2699
Drop MinGW support of MJIT (#6012)
[Feature #18824]
2022-06-13 09:28:28 -07:00
Nobuyoshi Nakada 42a0bed351
Prefix ccan headers (#4568)
* 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>
2022-03-30 20:36:31 +13:00
Peter Zhu 5f10bd634f Add ISEQ_BODY macro
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.
2022-03-24 10:03:51 -04:00
Nobuyoshi Nakada c1bcfeec38
Transfer the responsibility for MJIT options to mjit.c 2022-01-15 18:57:33 +09:00
Takashi Kokubun ee362302c0
Revert "Pause an MJIT worker when JIT is cancelled"
This reverts commit b64f81c817.

It seems to cause a problem in --jit / --jit-wait CIs. Reverting for now.
2021-08-13 09:13:09 -07:00
Takashi Kokubun 365da4c6ac
Don't run mjit_cancel_all when MJIT is disabled 2021-08-12 23:19:59 -07:00
Takashi Kokubun b64f81c817
Pause an MJIT worker when JIT is cancelled 2021-08-12 23:15:34 -07:00
Takashi Kokubun b3f8c491ef
Print JIT cancel when all JIT-ed code is cancelled 2021-08-12 23:11:38 -07:00
Takashi Kokubun 474f79958b
Cast jit_func for Windows
https://ci.appveyor.com/project/ruby/ruby/builds/39542385/job/8b7aq951f9t01x4x
2021-06-10 00:40:59 -07:00
Takashi Kokubun c5e8a49bde
Avoid enqueueing the same ISeq twice
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.
2021-06-10 00:32:24 -07:00
Takashi Kokubun 7e14762159
Do not doubly hold an MJIT lock
This is a follow-up of 86c262541a.
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.
2021-06-02 23:59:33 -07:00
Takashi Kokubun 86c262541a
Fix a race condition around mjit_recompile
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.
2021-06-02 22:11:37 -07:00
Takashi Kokubun 028f1887c2
Change the default --jit-max-cache to 10000
This is useful for large applications like Rails.
https://k0kubun.medium.com/ruby-3-jit-can-make-rails-faster-756310f235a
2021-05-31 22:01:04 -07:00
Takashi Kokubun 07c05b6fe9
Drop JIT_ISEQ_SIZE_THRESHOLD
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.
2021-05-31 21:12:48 -07:00
Takashi Kokubun 1aac0e8819
Mark inlined ISeqs during MJIT compilation (#4539)
[Bug #17584]
2021-05-30 21:42:02 -07:00
Koichi Sasada e7fc353f04 enable constant cache on ractors
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.
2021-01-05 02:27:58 +09:00
Takashi Kokubun 095972e799
Skip mjit_wait if iseq is not a target 2021-01-04 00:24:02 -08:00