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

192 Коммитов

Автор SHA1 Сообщение Дата
Koichi Sasada e2a45cb984 use builtin for TracePoint.
Define TracePoint in trace_point.rb and use __builtin_ syntax.
2019-11-08 09:09:29 +09:00
Nobuyoshi Nakada 0c2d81dada
Renamed ruby_finalize_{0,1}
And pass rb_execution_context_t as an argument.
2019-08-13 09:47:08 +09:00
Koichi Sasada df317151a5 should not free local hook_list here.
exec_hooks_postcheck() clean executed hook_list if it is needed.
list_exec is freed if there are no events and this list is local
event (connected to specific iseq). However, iseq keeps to point
this local hook_list, freed list. To prevent this situation,
do not free hook_list here even if it has no events.

This issue is reported by @joker1007.
https://twitter.com/joker1007/status/1153649170797830144
2019-07-24 05:39:09 +09:00
Nobuyoshi Nakada 1ca03dc4f7
Suppress warnings by gcc 9.1 2019-06-08 19:46:32 +09:00
kazu ede77e64a7 Fix typos
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67349 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-27 23:56:14 +00:00
nobu 139634a16f vm_trace.c: [DOC] remove the trick [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67314 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-20 04:24:42 +00:00
hsbt b55586902d Improve TracePoint docs.
* Mention new :script_compiled event;
  * Deduplicate __enable/enable methods;
  * Document target: and target_line: arguments.

  [Bug #15484][ruby-core:90801]

  Co-authored-by: zverok <zverok.offline@gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-20 02:08:34 +00:00
nobu 3c8ff424c6 vm_trace.c: trick rdoc for TracePoint#enable
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-01 05:20:07 +00:00
ko1 94f4a0e91e `TracePoint#enable(target_thraed:)` [Feature #15473]
* vm_trace.c (tracepoint_enable_m): `TracePoint#enable` supports
  `target_thread:` keyword to filter a target thread.
  [Feature #15473]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-29 16:44:09 +00:00
ko1 7510eef748 remove `compiled_` prefix. [Feature #15287]
* vm_trace.c: remove `compiled_` prefix from the following methods:
  * `compiled_eval_script`
  * `compiled_instruction_sequence`
  [Feature #15287]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-12 15:45:06 +00:00
svn a352ee8961 * expand tabs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-06 13:42:35 +00:00
ko1 5ac990e83e `script_compiled` TracePoint event [Feature #15287]
* vm_trace.c: add `script_compiled` event. This event invoked
  after script compiling and before evaluating compiled script.
  Also the following methods are added:

  `TracePoint#compiled_instruction_sequence` method to get compiled
  `RubyVM::InstructionSequence` instance.

  `TracePoint#compiled_eval_script` method to get compiled script (String)
  by *eval methods (return nil if compiling by file).

* vm_trace.c (tracepoint_attr_raised_exception):


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-06 13:42:32 +00:00
normal eb38fb670b vm_trace.c: workqueue as thread-safe version of postponed_job
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
2018-11-30 03:56:29 +00:00
ko1 72e60a0437 `TracePoint#enable(target_line:)` is supported. [Feature #15289]
* vm_trace.c: `TracePoint#enable(target_line:)` is supported.
  This option enables a hook only at specified target_line.
  target_line should be combination with target and :line event.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-26 20:16:14 +00:00
svn 61c8247d55 * expand tabs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-26 18:16:54 +00:00
ko1 96990203b7 Support targetting TracePoint [Feature #15289]
* 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
2018-11-26 18:16:39 +00:00
k0kubun 67485fee42 vm_trace.c: MJIT-limited thread-safety for postponed_job
[Bug #15316]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-26 15:47:20 +00:00
normal 644f2013d6 vm_trace.c (rb_postponed_job_flush): use rb_atomic_t for mask
ec->interrupt_mask will remain rb_atomic_t and is 32-bit on some
64-bit systems while "unsigned long" is 64-bits.  So avoid
mismatching lengths and stick to rb_atomic_t.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-18 04:34:52 +00:00
ko1 8634e62a62 initialize VM postponed_job first. [Bug #15288]
* inits.c: call `Init_vm_postponed_job` first because
  postponed_job is used by transient heap.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-08 05:35:46 +00:00
svn 57e906a778 * expand tabs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65317 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-23 03:47:48 +00:00
normal b67d76b3a6 Revert "vm_trace: implement postponed_jobs as st_table"
This reverts commit 5a1dfb04bc (r63451)

And mark the functions as async-signal-safe while we're at it to
prevent future developers from making the same mistake as I did :x

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65316 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-23 03:47:45 +00:00
ko1 b710785f1a add disabling MJIT features option.
* 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
2018-10-20 06:53:00 +00:00
k0kubun e1be448840 mjit.c: disable calling JIT-ed code
when TracePoint is enabled. We're cancelling JIT-ed code execution AFTER
each instruction, but there is no guard before the first insn of method.

To prevent spoiling performance, I don't want to modify the JIT-ed code
to fix this. So this commit replaces `mjit_enabled` check with `mjit_call_p`
check.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-23 14:11:19 +00:00
mame cd0fec3728 Add TracePoint#parameters
It can be used to get the parameters' information of method and block.
There was no way to get block parameters.
It was possible but ineffective to get method parameters via Method
object: `tp.defined_class.method(tp.method_id).parameters`
TracePoint#parameters allows us to get the information easily.
[Feature #14694]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63562 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-03 05:10:41 +00:00
normal 5a1dfb04bc vm_trace: implement postponed_jobs as st_table
st_table allows the use of st_shift to act as an order-preserving
queue while allowing fast lookups to prevent duplicate jobs.

In typical Ruby apps, this table will only have one entry
for gc_finalize_deferred_register.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-17 04:20:33 +00:00
normal b86daec202 vm_trace: remove rb_postponed_job_t->flags
This field has been taking up space for 5 years and never used.
Save 8kb of memory on x86-64 for now.  If we ever care about
this flag, we'll simply re-add it.

* vm_trace.c (rb_postponed_job_struct): remove flags
  (postponed_job_register): comment out flags assignment
  [ruby-core:87052] [Misc #14764]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-17 03:48:32 +00:00
normal 61d4df8920 vm_trace.c: spelling fix: PJRR_SUCESS => PJRR_SUCCESS
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63449 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-17 03:48:27 +00:00
k0kubun ed935aa5be mjit_compile.c: merge initial JIT compiler
which has been developed by Takashi Kokubun <takashikkbn@gmail> as
YARV-MJIT. Many of its bugs are fixed by wanabe <s.wanabe@gmail.com>.

This JIT compiler is designed to be a safe migration path to introduce
JIT compiler to MRI. So this commit does not include any bytecode
changes or dynamic instruction modifications, which are done in original
MJIT.

This commit even strips off some aggressive optimizations from
YARV-MJIT, and thus it's slower than YARV-MJIT too. But it's still
fairly faster than Ruby 2.5 in some benchmarks (attached below).

Note that this JIT compiler passes `make test`, `make test-all`, `make
test-spec` without JIT, and even with JIT. Not only it's perfectly safe
with JIT disabled because it does not replace VM instructions unlike
MJIT, but also with JIT enabled it stably runs Ruby applications
including Rails applications.

I'm expecting this version as just "initial" JIT compiler. I have many
optimization ideas which are skipped for initial merging, and you may
easily replace this JIT compiler with a faster one by just replacing
mjit_compile.c. `mjit_compile` interface is designed for the purpose.

common.mk: update dependencies for mjit_compile.c.

internal.h: declare `rb_vm_insn_addr2insn` for MJIT.

vm.c: exclude some definitions if `-DMJIT_HEADER` is provided to
compiler. This avoids to include some functions which take a long time
to compile, e.g. vm_exec_core. Some of the purpose is achieved in
transform_mjit_header.rb (see `IGNORED_FUNCTIONS`) but others are
manually resolved for now. Load mjit_helper.h for MJIT header.
mjit_helper.h: New. This is a file used only by JIT-ed code. I'll
refactor `mjit_call_cfunc` later.
vm_eval.c: add some #ifdef switches to skip compiling some functions
like Init_vm_eval.

win32/mkexports.rb: export thread/ec functions, which are used by MJIT.

include/ruby/defines.h: add MJIT_FUNC_EXPORTED macro alis to clarify
that a function is exported only for MJIT.

array.c: export a function used by MJIT.
bignum.c: ditto.
class.c: ditto.
compile.c: ditto.
error.c: ditto.
gc.c: ditto.
hash.c: ditto.
iseq.c: ditto.
numeric.c: ditto.
object.c: ditto.
proc.c: ditto.
re.c: ditto.
st.c: ditto.
string.c: ditto.
thread.c: ditto.
variable.c: ditto.
vm_backtrace.c: ditto.
vm_insnhelper.c: ditto.
vm_method.c: ditto.

I would like to improve maintainability of function exports, but I
believe this way is acceptable as initial merging if we clarify the
new exports are for MJIT (so that we can use them as TODO list to fix)
and add unit tests to detect unresolved symbols.
I'll add unit tests of JIT compilations in succeeding commits.

Author: Takashi Kokubun <takashikkbn@gmail.com>
Contributor: wanabe <s.wanabe@gmail.com>

Part of [Feature #14235]

---

* Known issues
  * Code generated by gcc is faster than clang. The benchmark may be worse
    in macOS. Following benchmark result is provided by gcc w/ Linux.
  * Performance is decreased when Google Chrome is running
  * JIT can work on MinGW, but it doesn't improve performance at least
    in short running benchmark.
  * Currently it doesn't perform well with Rails. We'll try to fix this
    before release.

---

* Benchmark reslts

Benchmarked with:
Intel 4.0GHz i7-4790K with 16GB memory under x86-64 Ubuntu 8 Cores

- 2.0.0-p0: Ruby 2.0.0-p0
- r62186: Ruby trunk (early 2.6.0), before MJIT changes
- JIT off: On this commit, but without `--jit` option
- JIT on: On this commit, and with `--jit` option

** Optcarrot fps

Benchmark: https://github.com/mame/optcarrot

|         |2.0.0-p0 |r62186   |JIT off  |JIT on   |
|:--------|:--------|:--------|:--------|:--------|
|fps      |37.32    |51.46    |51.31    |58.88    |
|vs 2.0.0 |1.00x    |1.38x    |1.37x    |1.58x    |

** MJIT benchmarks

Benchmark: https://github.com/benchmark-driver/mjit-benchmarks
(Original: https://github.com/vnmakarov/ruby/tree/rtl_mjit_branch/MJIT-benchmarks)

|           |2.0.0-p0 |r62186   |JIT off  |JIT on   |
|:----------|:--------|:--------|:--------|:--------|
|aread      |1.00     |1.09     |1.07     |2.19     |
|aref       |1.00     |1.13     |1.11     |2.22     |
|aset       |1.00     |1.50     |1.45     |2.64     |
|awrite     |1.00     |1.17     |1.13     |2.20     |
|call       |1.00     |1.29     |1.26     |2.02     |
|const2     |1.00     |1.10     |1.10     |2.19     |
|const      |1.00     |1.11     |1.10     |2.19     |
|fannk      |1.00     |1.04     |1.02     |1.00     |
|fib        |1.00     |1.32     |1.31     |1.84     |
|ivread     |1.00     |1.13     |1.12     |2.43     |
|ivwrite    |1.00     |1.23     |1.21     |2.40     |
|mandelbrot |1.00     |1.13     |1.16     |1.28     |
|meteor     |1.00     |2.97     |2.92     |3.17     |
|nbody      |1.00     |1.17     |1.15     |1.49     |
|nest-ntimes|1.00     |1.22     |1.20     |1.39     |
|nest-while |1.00     |1.10     |1.10     |1.37     |
|norm       |1.00     |1.18     |1.16     |1.24     |
|nsvb       |1.00     |1.16     |1.16     |1.17     |
|red-black  |1.00     |1.02     |0.99     |1.12     |
|sieve      |1.00     |1.30     |1.28     |1.62     |
|trees      |1.00     |1.14     |1.13     |1.19     |
|while      |1.00     |1.12     |1.11     |2.41     |

** Discourse's script/bench.rb

Benchmark: https://github.com/discourse/discourse/blob/v1.8.7/script/bench.rb

NOTE: Rails performance was somehow a little degraded with JIT for now.
We should fix this.
(At least I know opt_aref is performing badly in JIT and I have an idea
 to fix it. Please wait for the fix.)

*** JIT off
Your Results: (note for timings- percentile is first, duration is second in millisecs)

categories_admin:
  50: 17
  75: 18
  90: 22
  99: 29
home_admin:
  50: 21
  75: 21
  90: 27
  99: 40
topic_admin:
  50: 17
  75: 18
  90: 22
  99: 32
categories:
  50: 35
  75: 41
  90: 43
  99: 77
home:
  50: 39
  75: 46
  90: 49
  99: 95
topic:
  50: 46
  75: 52
  90: 56
  99: 101

*** JIT on
Your Results: (note for timings- percentile is first, duration is second in millisecs)

categories_admin:
  50: 19
  75: 21
  90: 25
  99: 33
home_admin:
  50: 24
  75: 26
  90: 30
  99: 35
topic_admin:
  50: 19
  75: 20
  90: 25
  99: 30
categories:
  50: 40
  75: 44
  90: 48
  99: 76
home:
  50: 42
  75: 48
  90: 51
  99: 89
topic:
  50: 49
  75: 55
  90: 58
  99: 99

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-04 11:22:28 +00:00
kazu f1b7bf1047 Fix wrong function names in rb_bug messages [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-31 00:19:33 +00:00
ko1 975e3a19a7 do not disable `trace_` prefix insns.
* vm.c: introduce `ruby_vm_event_enabled_flags` which represents which
  event flags are enabled before.

* vm_trace.c: do not turn off `trace_` prefix instructions because turn on
  overhead is a matter if a program repeats turn on and turn off frequently.

* iseq.c (finish_iseq_build): respect `ruby_vm_event_enabled_flags`.

* vm_insnhelper.c (vm_trace): check `ruby_vm_event_flags` and disable
  lazy trace-off technique (do not disable traces).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61122 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-11 19:17:25 +00:00
mame 9be95d2a71 Remove RUBY_EVENT_SPECIFIED_LINE
Follow up of r61044

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61048 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-06 07:19:16 +00:00
ko1 ec1d41ba0e fix last commit
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61045 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-06 06:54:40 +00:00
ko1 104ca9f4df remove unsupported RUBY_EVENT_SPECIFIED_LINE.
* vm_trace.c (get_event_id): remove experimental in past, and not supported
  now feature.

* vm_trace.c (tracepoint_inspect): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-06 06:53:15 +00:00
ko1 0e34638f79 remove `PUSH_TAG`/`EXEC_AG`/`POP_TAG`/`JUMO_TAG`.
* eval_intern.h: remove non-`EC_` prefix *_TAG() macros.
  Use `EC_` prefix macros explicitly.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-06 03:16:08 +00:00
nobu 98ab1510c4 vm_trace.c: suppress -Wclobbered warning
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-01 12:00:10 +00:00
nobu f5c5a1979a vm_trace.c: remove duplicate flag
* vm_trace.c (rb_suppress_tracing): remove duplicate flag
  `tracing`, which equals to `ec->trace_arg != NULL`.  and that
  `ec->trace_arg` points `dummy_trace_arg` means it was NULL at
  the beginning.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-01 12:00:09 +00:00
ko1 26451ab3ba introduce `trace_events' info for iseq.
* vm_core.h (rb_iseq_t::aux): add `trace_events` which represents
  which events are enabled on this iseq. With this information,
  we can skip useless trace-on changes for ISeqs.

* vm_trace.c (RUBY_EVENTS_TRACE_BY_ISEQ): moved to iseq.h and rename it
  with ISEQ_TRACE_EVENTS.

* iseq.h: introduce ISEQ_USE_COMPILE_DATA iseq (imemo) flag to represent
  COMPILE_DATA is available. In other words, iseq->aux.trace_events is not
  available when this flag is set.
  * ISEQ_COMPILE_DATA() is changed from a macro.
  * ISEQ_COMPILE_DATA_ALLOC() is added.
  * ISEQ_COMPILE_DATA_CLEAR() is added.

* iseq.c: use them.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-18 09:39:41 +00:00
ko1 8a664f0c96 don't use `goto`.
* vm_trace.c (rb_exec_event_hooks): we don't need to use goto statement.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-17 07:47:03 +00:00
svn 1fcdec57da * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-17 06:24:56 +00:00
ko1 1a96057626 remove `trace_` prefix insns lazily.
* vm_trace.c (update_global_event_hook): set only when tracing is added.
  If tracing was off (event flags are decreased), then ignore them.
  Next `trace_` prefix instruction will trace off itself (lazy tracing off).

* vm_insnhelper.c (vm_trace): trace-off for when trace is not needed.

* iseq.c (rb_iseq_trace_set): fix trace-off process (it was never off tracing).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-17 06:24:55 +00:00
ko1 23e452b17b cleanup hook cleanup code.
* vm_trace.c: before this patch, deleted hooks are remvoed at
  *the beggining* of hooks (exec_hooks_precheck).
  This patch cleanup deleted hooks at
  (1) just after hook is deleted (TracePoint#disable and so on)
  (2) just after executing hooks (exec_hooks_postcheck)
  Most of time (1) is enough, but if some threads running hooks,
  we need to wait cleaning up deleted hooks until threads finish
  running the hooks. This is why (2) is introduced (and this is
  why current impl cleanup deleted hooks at the beggining of hooks).

* test/lib/tracepointchecker.rb: check also the number of delete
  waiting hooks.

* cont.c (cont_restore_thread): fix VM->trace_running count.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16 02:47:58 +00:00
ko1 a3071ea4e3 remove rb_thread_t::event_hooks.
* vm_core.h (rb_thread_t): remove rb_thread_t::event_hooks.

* vm_trace.c: all hooks are connected to vm->event_hooks and
  add rb_event_hook_t::filter::th to filter invoke thread.
  It will simplify invoking hooks code.

* thread.c (thread_start_func_2): clear thread specific trace_func.

* test/ruby/test_settracefunc.rb: add a test for Thread#add_trace_func.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-15 13:21:24 +00:00
ko1 19ae98d5ce rewrite only if changed.
* vm_trace.c (update_global_event_hook): rewrite ISeqs only when
  effective events are changed.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-14 13:25:11 +00:00
ko1 665ba24b44 remove `trace` instruction. [Feature #14104]
* tool/instruction.rb: create `trace_` prefix instructions.

* compile.c (ADD_TRACE): do not add `trace` instructions but add
  TRACE link elements. TRACE elements will be unified with a next
  instruction as instruction information.

* vm_trace.c (update_global_event_hook): modify all ISeqs when
  hooks are enabled.

* iseq.c (rb_iseq_trace_set): added to toggle `trace_` instructions.

* vm_insnhelper.c (vm_trace): added.
  This function is a body of `trace_` prefix instructions.

* vm_insnhelper.h (JUMP): save PC to a control frame.

* insns.def (trace): removed.

* vm_exec.h (INSN_ENTRY_SIG): add debug output (disabled).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-14 12:58:36 +00:00
marcandre a5abde57b8 TracePoint.new: raise ArgumentError when no block given [#14074]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-09 22:04:47 +00:00
a_matsuda d3b63f9597 Fix typo in doc [ci skip]
`enable` and `disable` are instance methods.

Patch by: yuuji.yaginuma <yuuji.yaginuma@gmail.com>

https://github.com/ruby/ruby/pull/1744
[Fix GH-1744]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-08 16:43:23 +00:00
ko1 7285177c97 * vm_trace.c (rb_exec_event_hooks): accepts pop_p.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-07 05:54:34 +00:00
ko1 ee189904f0 rename to rb_ec_set_raised().
* thread.c (rb_threadptr_set_raised): rename to rb_ec_set_raised
  and accepts `ec`


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-07 05:12:39 +00:00
ko1 001eb22c75 remove `rb_postponed_job_t::th`.
* vm_trace.c (rb_postponed_job_t): remove `th` field because it is not used.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60678 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-07 04:53:11 +00:00
ko1 f3482ddabf rename because it doesn't receive `th`.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-07 04:04:18 +00:00