summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-11 19:17:25 (GMT)
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-11 19:17:25 (GMT)
commit975e3a19a7ef725f6358d74f5bf7fd20d4403587 (patch)
tree22303ef0f4a2fc40fec963f9ffe68f244211fd15 /vm_insnhelper.c
parent9e9498c227085d8b999799843aa2d388b19653a6 (diff)
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
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c102
1 files changed, 57 insertions, 45 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 9a2f3cb..40175ad 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -3727,56 +3727,68 @@ NOINLINE(static void vm_trace(rb_execution_context_t *ec, rb_control_frame_t *re
static void
vm_trace(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, const VALUE *pc)
{
- const rb_iseq_t *iseq = reg_cfp->iseq;
- size_t pos = pc - iseq->body->iseq_encoded;
rb_event_flag_t vm_event_flags = ruby_vm_event_flags;
- rb_event_flag_t events = rb_iseq_event_flags(iseq, pos);
- rb_event_flag_t event;
- if ((events & vm_event_flags) == 0) {
- /* disable trace */
- rb_iseq_trace_set(iseq, vm_event_flags & ISEQ_TRACE_EVENTS);
+ if (vm_event_flags == 0) {
return;
}
+ else {
+ const rb_iseq_t *iseq = reg_cfp->iseq;
+ size_t pos = pc - iseq->body->iseq_encoded;
+ rb_event_flag_t events = rb_iseq_event_flags(iseq, pos);
+ rb_event_flag_t event;
- if (ec->trace_arg != NULL) return;
+ if ((events & vm_event_flags) == 0) {
+#if 0
+ /* disable trace */
+ rb_iseq_trace_set(iseq, vm_event_flags & ISEQ_TRACE_EVENTS);
+#else
+ /* do not disable trace because of performance problem
+ * (re-enable overhead)
+ */
+#endif
+ return;
+ }
- if (0) {
- fprintf(stderr, "vm_trace>>%4d (%4x) - %s:%d %s\n",
- (int)pos,
- (int)events,
- RSTRING_PTR(rb_iseq_path(iseq)),
- (int)rb_iseq_line_no(iseq, pos),
- RSTRING_PTR(rb_iseq_label(iseq)));
- }
-
- VM_ASSERT(reg_cfp->pc == pc);
- VM_ASSERT(events != 0);
- VM_ASSERT(vm_event_flags & events);
-
- /* increment PC because source line is calculated with PC-1 */
- if (event = (events & (RUBY_EVENT_CLASS | RUBY_EVENT_CALL | RUBY_EVENT_B_CALL))) {
- VM_ASSERT(event == RUBY_EVENT_CLASS ||
- event == RUBY_EVENT_CALL ||
- event == RUBY_EVENT_B_CALL);
- reg_cfp->pc++;
- vm_dtrace(event, ec);
- EXEC_EVENT_HOOK(ec, event, GET_SELF(), 0, 0, 0, Qundef);
- reg_cfp->pc--;
- }
- if (events & RUBY_EVENT_LINE) {
- reg_cfp->pc++;
- vm_dtrace(RUBY_EVENT_LINE, ec);
- EXEC_EVENT_HOOK(ec, RUBY_EVENT_LINE, GET_SELF(), 0, 0, 0, Qundef);
- reg_cfp->pc--;
- }
- if (event = (events & (RUBY_EVENT_END | RUBY_EVENT_RETURN | RUBY_EVENT_B_RETURN))) {
- VM_ASSERT(event == RUBY_EVENT_END ||
- event == RUBY_EVENT_RETURN ||
- event == RUBY_EVENT_B_RETURN);
- reg_cfp->pc++;
- vm_dtrace(RUBY_EVENT_LINE, ec);
- EXEC_EVENT_HOOK(ec, event, GET_SELF(), 0, 0, 0, TOPN(0));
- reg_cfp->pc--;
+ if (ec->trace_arg != NULL) return;
+
+ if (0) {
+ fprintf(stderr, "vm_trace>>%4d (%4x) - %s:%d %s\n",
+ (int)pos,
+ (int)events,
+ RSTRING_PTR(rb_iseq_path(iseq)),
+ (int)rb_iseq_line_no(iseq, pos),
+ RSTRING_PTR(rb_iseq_label(iseq)));
+ }
+
+ VM_ASSERT(reg_cfp->pc == pc);
+ VM_ASSERT(events != 0);
+ VM_ASSERT(vm_event_flags & events);
+
+ /* increment PC because source line is calculated with PC-1 */
+ if (event = (events & (RUBY_EVENT_CLASS | RUBY_EVENT_CALL | RUBY_EVENT_B_CALL))) {
+ VM_ASSERT(event == RUBY_EVENT_CLASS ||
+ event == RUBY_EVENT_CALL ||
+ event == RUBY_EVENT_B_CALL);
+ reg_cfp->pc++;
+ vm_dtrace(event, ec);
+ EXEC_EVENT_HOOK(ec, event, GET_SELF(), 0, 0, 0, Qundef);
+ reg_cfp->pc--;
+ }
+ if (events & RUBY_EVENT_LINE) {
+ reg_cfp->pc++;
+ vm_dtrace(RUBY_EVENT_LINE, ec);
+ EXEC_EVENT_HOOK(ec, RUBY_EVENT_LINE, GET_SELF(), 0, 0, 0, Qundef);
+ reg_cfp->pc--;
+ }
+ if (event = (events & (RUBY_EVENT_END | RUBY_EVENT_RETURN | RUBY_EVENT_B_RETURN))) {
+ VM_ASSERT(event == RUBY_EVENT_END ||
+ event == RUBY_EVENT_RETURN ||
+ event == RUBY_EVENT_B_RETURN);
+ reg_cfp->pc++;
+ vm_dtrace(RUBY_EVENT_LINE, ec);
+ EXEC_EVENT_HOOK(ec, event, GET_SELF(), 0, 0, 0, TOPN(0));
+ reg_cfp->pc--;
+ }
}
}