This reverts commit bb1a1aeab0.
We hit something on ci.rvm.jp, reverting until investigation is done.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
and functions to clarify the intention and make sure it's not used in a
surprising way (like using 2, 3, ... other than 0, 1 even while it seems
to be a boolean).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* configure.ac: disable using __builtin_setjmp to avoid errors when execution
globally jumps out of JITted code. Specify -std=gnu99 to JIT compilation
to avoid errors regarding the "restrict" keyword in the precompiled header.
Specify -shared in addition to -Wl,-G when building shared libraries
to make mjit_build_dir.so expose the MJIT_BUILD_DIR symbol. Use LDR_PRELOAD
to load mjit_build_dir.so.
* mjit_worker.c: do not specify -nodefaultlibs or -nostdlibs because on AIX
JITted code internally refers to the memcpy function.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
in a new variable cc_common_args.
`cflags=-save-temps=obj` makes MJIT fail like:
https://rubyci.org/logs/www.rubyist.net/~akr/chkbuild/debian/ruby-trunk/log/20181203T095000Z.log.html.gz
This rubyci specifies -save-temps=obj in CFLAGS to use update-deps, and
the flag is harmful when we want to use -pipe flag.
mjit_worker.c: prefer cc_common_args over CC_COMMON_ARGS
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66164 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
because we mostly use cc_path now and the comment is obsolete (CC_PATH
is now absolute path and the TODO is already resolved).
mjit.c: use CC_COMMON_ARGS[0] directly
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
postponed_job is safe to use in signal handlers, but is not
thread-safe for MJIT. Implement a workqueue for MJIT
thread-safety.
[Bug #15316]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66100 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-local variable to global variable.
Consider this case:
1. MJIT worker: dequeue ISeq (stop_worker_p was still FALSE)
2. Ruby thread: call Kernel#exec, which calls mjit_finish(FALSE),
sets `stop_worker_p = TRUE`, and fires RUBY_VM_CHECK_INTS() once
3. MJIT worker: register copy job, but found stop_worker_p is TRUE.
set `worker_stopped = TRUE` and the thread stops.
4. Function-local job variable expires by the thread stop (this is eliminated by this commit)
5. Ruby thread: find `worker_stopped` becamse TRUE, start Kernel#exec.
Kernel#exec fails but exception is rescued.
6. Ruby thread: call RUBY_VM_CHECK_INTS. copy job is dispatched but job variable
is already expired.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_trace.c (rb_tracepoint_enable_for_target): support targetting
TracePoint. [Feature #15289]
Tragetting TracePoint is only enabled on specified method, proc
and so on, example: `tp.enable(target: code)`.
`code` should be consisted of InstructionSeuqnece (iseq)
(RubyVM::InstructionSeuqnece.of(code) should not return nil)
If code is a tree of iseq, TracePoint is enabled on all of
iseqs in a tree.
Enabled tragetting TracePoints can not enabled again with
and without target.
* vm_core.h (rb_iseq_t): introduce `rb_iseq_t::local_hooks`
to store local hooks.
`rb_iseq_t::aux::trace_events` is renamed to
`global_trace_events` to contrast with `local_hooks`.
* vm_core.h (rb_hook_list_t): add `rb_hook_list_t::running`
to represent how many Threads/Fibers are used this list.
If this field is 0, nobody using this hooks and we can
delete it.
This is why we can remove code from cont.c.
* vm_core.h (rb_vm_t): because of above change, we can eliminate
`rb_vm_t::trace_running` field.
Also renamed from `rb_vm_t::event_hooks` to `global_hooks`.
* vm_core.h, vm.c (ruby_vm_event_enabled_global_flags): renamed
from `ruby_vm_event_enabled_flags.
* vm_core.h, vm.c (ruby_vm_event_local_num): added to count
enabled targetting TracePoints.
* vm_core.h, vm_trace.c (rb_exec_event_hooks): accepts
hook list.
* vm_core.h (rb_vm_global_hooks): added for convinience.
* method.h (rb_method_bmethod_t): added to maintain Proc
and `rb_hook_list_t` for bmethod (defined by define_method).
* prelude.rb (TracePoint#enable): extracet a keyword parameter
(because it is easy than writing in C).
It calls `TracePoint#__enable` internal method written in C.
* vm_insnhelper.c (vm_trace): check also iseq->local_hooks.
* vm.c (invoke_bmethod): check def->body.bmethod.hooks.
* vm.c (hook_before_rewind): check iseq->local_hooks
and def->body.bmethod.hooks before rewind by exception.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
by launching MJIT worker thread in child Ruby process.
See the comment before `mjit_child_after_fork` for details.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
r65577 seems to have made MJIT_CC (MJIT_CC_COMMONA) become an absolute
path. So start_process doesn't need to find that from PATH by dln_find_exe_r.
This commit is motivated by the msys2 AppVeyor CI failure:
https://ci.appveyor.com/project/ruby/ruby/builds/20084104/job/1pg15os4dtttyl0q
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65599 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
I'm planning to use _one later, but it may be doubly registered by
switching `stop_worker_p` now and so we should not use _one for now.
Otherwise stale job may reject new job registration and
copy_cache_from_main_thread may wait forever.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65571 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-available region. reducing risk of SEGV in mjit_copy_job_handler() like
http://ci.rvm.jp/results/trunk-mjit@silicon-docker/1446117
I'm not sure which exact part is causing "[BUG] Segmentation fault at 0x0000000000000008"
on `(mjit_copy_job_handler+0x12) [0x564a6c4ce632] /home/ko1/ruby/src/trunk-mjit/mjit.c:26`...
mjit.c: ditto
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
When we return there, `unit` is already freed.
This is detected by coverity scan.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
In https://bugs.ruby-lang.org/issues/14867#note-98, it's considered
useless at once. So I emphasized the necessity of it in the comment.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
rb_mjit_unit can either exist in unit_queue or active_units, but
not both. This will make state transitions for event-based MJIT
process management easier.
v2: recheck unit->iseq after GC wakeup
The iseq may be GC-ed while we were waiting for it since we
delete the unit from unit_queue during get_from_list
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65475 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
https://bugs.ruby-lang.org/issues/14867#note-112
I wanna touch similar places. To avoid our conflict, let me merge Eric's patch earlier.
Let's watch trunk-mjit / trunk-mjit-wait CIs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
rb_mjit_unit can either exist in unit_queue or active_units, but
not both. This will make state transitions for event-based MJIT
process management easier.
[ruby-core:89654]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c, internal.h: support theap for small Hash.
Introduce RHASH_ARRAY (li_table) besides st_table and small Hash
(<=8 entries) are managed by an array data structure.
This array data can be managed by theap.
If st_table is needed, then converting array data to st_table data.
For st_table using code, we prepare "stlike" APIs which accepts hash value
and are very similar to st_ APIs.
This work is based on the GSoC achievement
by tacinight <tacingiht@gmail.com> and refined by ko1.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
when main thread is waiting for MJIT worker forever without executing
RUBY_VM_CHECK_INTS due to --jit-wait.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Given that `copy_cache_from_main_thread()` breaks the loop when `stop_worker_p`
is TRUE, memory of `job` allocated by `alloca` may be invalid if `stop_worker_p`
is already TRUE.
mjit_worker.c: explain why `copy_cache_from_main_thread()` should not
stop checking `stop_worker_p`.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
of copy job. When job is being stopped but job is actually finished,
returning FALSE could be a little confusing from the function name.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65301 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
by stop_worker(). Previously copy_cache_from_main_thread() might loop forever
even with stop_worker() is being called from ruby_cleanup().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
on VM_CHECK_INTS. Letting MJIT worker directly see inline cache which
may be being updated could result in inconsistent IC index and serial.
mjit_worker.c: request the copy job after dequeue, and receive the
result synchronously.
tool/ruby_vm/views/_mjit_compile_ivar.erb: use the copied IC
mjit_compile.c: change the interface to pass is_entries
mjit.h: ditto
=== Optcarrot Benchmark ===
Thankfully this didn't have major performance regression.
$ benchmark-driver benchmark.yml --rbenv 'before::before --disable-gems --jit;after::after --disable-gems --jit' -v --repeat-count 24
before: ruby 2.6.0dev (2018-10-21 trunk 65263) +JIT [x86_64-linux]
after: ruby 2.6.0dev (2018-10-21 trunk 65263) +JIT [x86_64-linux]
last_commit=mjit.c: copy inline cache values to MJIT worker
Calculating -------------------------------------
before after
Optcarrot Lan_Master.nes 85.421 85.454 fps
Comparison:
Optcarrot Lan_Master.nes
after: 85.5 fps
before: 85.4 fps - 1.00x slower
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
remove_from_list() frees node, but after that node->next could be used
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65231 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* configure.ac: introduce new configure option `--enable-mjit` and
`--disable-mjit`. Default is "enable".
`--disable-mjit` disables all of MJIT features so that `ruby --jit`
can't enable MJIT.
This option affect a macro `USE_MJIT`.
This change remove `--enable/disable-install-mjit-header` option.
* Makefile.in: introduce the `ENABLE_MJIT` variable.
* common.mk: use `ENABLE_MJIT` option.
* internal.h: respect `USE_MJIT`. Same as other *.c, *.h.
* test/ruby/test_jit.rb: check `ENABLE_MJIT` key of rbconfg.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Prior to this commit, max_cache_size + 1 methods could be active.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65174 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Prior to this commit, some of parent process's output was unintentionally
suppressed. We couldn't suppress only child process's output with spawnvp.
Instead of that, this commit uses CreateProcess directly to redirect stdout
and stderr only for child process.
As it's dealing with HANDLE returned from CreateProcess, now waitpid macro
needs to CloseHandle it.
win32/win32.c: Introduce rb_w32_start_process which is designed for MJIT
worker. Other similar functions can't be used since they are using ALLOCV
that may trigger GC, which should be avoided on MJIT worker.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
in the MJIT-header-specific path, not default path like vc140.pdb.
mjit_worker.c: specify the MJIT-header-specific pdb path.
tool/rbinstall.rb: install MJIT header pdb as well.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
because somehow AppVeyor fails to remove so file by Permission Deined.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
prior to this commit, .obj file is generated on current directory and nobody deletes that.
This changes it to make sure it's generated to temporary directory and removes that.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
I gave up to introduce the optimization that skips pc motion by checking
C code's line number. The same code can often be shared by multiple
program counters and it's so hard to achieve the optimization in MJIT's
architecture.
Reverting to improve performance by removing -g1 and to remove so file
when it becomes not necessary.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
is configured now, to force -Wl,--compress-debug-sections=no
for MJIT only when the option is used in MJIT_DLDFLAGS.
This needs to be done in configure.ac to resolve build failure like
https://travis-ci.org/ruby/ruby/builds/415120662.
Makefile.in: define it in mjit_config.h
mjit_worker.c: replace hard-coded flag to MJIT_DLDFLAGS_NOCOMPRESS
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64325 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
on ELF.
I need symbol name and line number to lazily create program counter for
optimization on ELF binary.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
on addr2line.c, if --jit-save-temps is specified.
I'm going to use the line number to lazily create program counter to
improve the performance degraded in r64283.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
on MJIT worker. That may trigger GC. And handled strdup failure instead.
mjit_compile.c: update comment about GC
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64301 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
so that related things are placed closely.
Sorry for mixing them in previous commits...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64291 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
instead of linking functions with mjit_worker.o.
In the r64285's structure, we needed to publish some variables with
mjit_ prefix. But ideally those variables should be completely private
in mjit.o (or old mjit_worker.o), and it was hard.
So I chose an approach similar to vm*.c for mjit.c and mjit_worker.c.
I believe mjit_compile.c is still nice to be separated.
After this commit, I'll remove the mjit_ prefix again...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64289 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
from mjit.c because it's executed only on MJIT worker thread.
Instead of that, `valid_class_serials` is shared with mjit_ prefix.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64288 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
which was just forgotten.
mjit.c: ditto
mjit_internal.h: moved some macros only used by mjit_worker.c to it.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64287 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
The motivation of this change is to make sure rb_funcall or GC-related
functions are not called on worker-related code. Currently such
functions are used in some places and I believe it's partly because it's
hard to identify which part is called on MJIT worker thread.
Now, mjit.c is safe to use them but we know we need to safely deal with
mjit_compile.c, mjit_worker.c and mjit_internal.h.
mjit_compile.c: update the comment about it
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e