aboutsummaryrefslogtreecommitdiffstats
path: root/vm_trace.c
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2021-08-23 15:22:14 -0700
committerJeremy Evans <code@jeremyevans.net>2021-08-29 07:23:39 -0700
commit2d98593bf54a37397c6e4886ccc7e3654c2eaf85 (patch)
tree33d08b3e99dcd4b00ee76f0a286bdbacbabcc85f /vm_trace.c
parent5f7c2291d6b3ba890d62c7e3a686202dffb14759 (diff)
downloadruby-2d98593bf54a37397c6e4886ccc7e3654c2eaf85.tar.gz
Support tracing of attr_reader and attr_writer
In vm_call_method_each_type, check for c_call and c_return events before dispatching to vm_call_ivar and vm_call_attrset. With this approach, the call cache will still dispatch directly to those functions, so this change will only decrease performance for the first (uncached) call, and even then, the performance decrease is very minimal. This approach requires that we clear the call caches when tracing is enabled or disabled. The approach currently switches all vm_call_ivar and vm_call_attrset call caches to vm_call_general any time tracing is enabled or disabled. So it could theoretically result in a slowdown for code that constantly enables or disables tracing. This approach does not handle targeted tracepoints, but from my testing, c_call and c_return events are not supported for targeted tracepoints, so that shouldn't matter. This includes a benchmark showing the performance decrease is minimal if detectable at all. Fixes [Bug #16383] Fixes [Bug #10470] Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
Diffstat (limited to 'vm_trace.c')
-rw-r--r--vm_trace.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/vm_trace.c b/vm_trace.c
index ed218b8120..cec5e42e31 100644
--- a/vm_trace.c
+++ b/vm_trace.c
@@ -74,6 +74,8 @@ rb_hook_list_free(rb_hook_list_t *hooks)
/* ruby_vm_event_flags management */
+void rb_clear_attr_ccs(void);
+
static void
update_global_event_hook(rb_event_flag_t vm_events)
{
@@ -91,6 +93,9 @@ update_global_event_hook(rb_event_flag_t vm_events)
/* write all ISeqs if and only if new events are added */
rb_iseq_trace_set_all(new_iseq_events | enabled_iseq_events);
}
+ else {
+ rb_clear_attr_ccs();
+ }
ruby_vm_event_flags = vm_events;
ruby_vm_event_enabled_global_flags |= vm_events;