[前][次][番号順一覧][スレッド一覧]

ruby-changes:48581

From: ko1 <ko1@a...>
Date: Tue, 7 Nov 2017 17:19:30 +0900 (JST)
Subject: [ruby-changes:48581] ko1:r60696 (trunk): th->ec: dtrace

ko1	2017-11-07 17:19:25 +0900 (Tue, 07 Nov 2017)

  New Revision: 60696

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60696

  Log:
    th->ec: dtrace
    
    * vm.c (ruby_th_dtrace_setup): rename to rb_dtrace_setup()
      and accept `ec`.

  Modified files:
    trunk/insns.def
    trunk/probes_helper.h
    trunk/vm.c
    trunk/vm_eval.c
    trunk/vm_insnhelper.c
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 60695)
+++ vm_insnhelper.c	(revision 60696)
@@ -1910,7 +1910,7 @@ vm_call_cfunc_with_frame(rb_execution_co https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1910
     VALUE block_handler = calling->block_handler;
     int argc = calling->argc;
 
-    RUBY_DTRACE_CMETHOD_ENTRY_HOOK(rb_ec_thread_ptr(ec), me->owner, me->def->original_id);
+    RUBY_DTRACE_CMETHOD_ENTRY_HOOK(ec, me->owner, me->def->original_id);
     EXEC_EVENT_HOOK(ec, RUBY_EVENT_C_CALL, recv, me->def->original_id, ci->mid, me->owner, Qundef);
 
     vm_push_frame(ec, NULL, VM_FRAME_MAGIC_CFUNC | VM_FRAME_FLAG_CFRAME | VM_ENV_FLAG_LOCAL, recv,
@@ -1928,7 +1928,7 @@ vm_call_cfunc_with_frame(rb_execution_co https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1928
     rb_vm_pop_frame(ec);
 
     EXEC_EVENT_HOOK(ec, RUBY_EVENT_C_RETURN, recv, me->def->original_id, ci->mid, me->owner, val);
-    RUBY_DTRACE_CMETHOD_RETURN_HOOK(rb_ec_thread_ptr(ec), me->owner, me->def->original_id);
+    RUBY_DTRACE_CMETHOD_RETURN_HOOK(ec, me->owner, me->def->original_id);
 
     return val;
 }
@@ -3018,7 +3018,7 @@ vm_check_keyword(lindex_t bits, lindex_t https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L3018
 }
 
 static void
-vm_dtrace(rb_event_flag_t flag, rb_thread_t *th)
+vm_dtrace(rb_event_flag_t flag, rb_execution_context_t *ec)
 {
     if (RUBY_DTRACE_METHOD_ENTRY_ENABLED() ||
 	RUBY_DTRACE_METHOD_RETURN_ENABLED() ||
@@ -3027,16 +3027,16 @@ vm_dtrace(rb_event_flag_t flag, rb_threa https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L3027
 
 	switch (flag) {
 	  case RUBY_EVENT_CALL:
-	    RUBY_DTRACE_METHOD_ENTRY_HOOK(th, 0, 0);
+	    RUBY_DTRACE_METHOD_ENTRY_HOOK(ec, 0, 0);
 	    return;
 	  case RUBY_EVENT_C_CALL:
-	    RUBY_DTRACE_CMETHOD_ENTRY_HOOK(th, 0, 0);
+	    RUBY_DTRACE_CMETHOD_ENTRY_HOOK(ec, 0, 0);
 	    return;
 	  case RUBY_EVENT_RETURN:
-	    RUBY_DTRACE_METHOD_RETURN_HOOK(th, 0, 0);
+	    RUBY_DTRACE_METHOD_RETURN_HOOK(ec, 0, 0);
 	    return;
 	  case RUBY_EVENT_C_RETURN:
-	    RUBY_DTRACE_CMETHOD_RETURN_HOOK(th, 0, 0);
+	    RUBY_DTRACE_CMETHOD_RETURN_HOOK(ec, 0, 0);
 	    return;
 	}
     }
Index: insns.def
===================================================================
--- insns.def	(revision 60695)
+++ insns.def	(revision 60696)
@@ -789,7 +789,7 @@ trace https://github.com/ruby/ruby/blob/trunk/insns.def#L789
 {
     rb_event_flag_t flag = (rb_event_flag_t)nf;
 
-    vm_dtrace(flag, rb_ec_thread_ptr(ec));
+    vm_dtrace(flag, ec);
     EXEC_EVENT_HOOK(ec, flag, GET_SELF(), 0, 0, 0 /* id and klass are resolved at callee */,
 		    (flag & (RUBY_EVENT_RETURN | RUBY_EVENT_B_RETURN)) ? TOPN(0) : Qundef);
 }
@@ -807,7 +807,7 @@ trace2 https://github.com/ruby/ruby/blob/trunk/insns.def#L807
 {
     rb_event_flag_t flag = (rb_event_flag_t)nf;
 
-    vm_dtrace(flag, rb_ec_thread_ptr(ec));
+    vm_dtrace(flag, ec);
     EXEC_EVENT_HOOK(ec, flag, GET_SELF(), 0, 0, 0 /* id and klass are resolved at callee */, data);
 }
 
Index: vm.c
===================================================================
--- vm.c	(revision 60695)
+++ vm.c	(revision 60696)
@@ -335,13 +335,13 @@ rb_vm_inc_const_missing_count(void) https://github.com/ruby/ruby/blob/trunk/vm.c#L335
 VALUE rb_class_path_no_cache(VALUE _klass);
 
 int
-ruby_th_dtrace_setup(rb_thread_t *th, VALUE klass, ID id,
-		     struct ruby_dtrace_method_hook_args *args)
+rb_dtrace_setup(rb_execution_context_t *ec, VALUE klass, ID id,
+		struct ruby_dtrace_method_hook_args *args)
 {
     enum ruby_value_type type;
     if (!klass) {
-	if (!th) th = GET_THREAD();
-	if (!rb_ec_frame_method_id_and_class(th->ec, &id, 0, &klass) || !klass)
+	if (!ec) ec = GET_EC();
+	if (!rb_ec_frame_method_id_and_class(ec, &id, 0, &klass) || !klass)
 	    return FALSE;
     }
     if (RB_TYPE_P(klass, T_ICLASS)) {
@@ -537,7 +537,7 @@ rb_vm_pop_cfunc_frame(void) https://github.com/ruby/ruby/blob/trunk/vm.c#L537
     const rb_callable_method_entry_t *me = rb_vm_frame_method_entry(cfp);
 
     EXEC_EVENT_HOOK(ec, RUBY_EVENT_C_RETURN, cfp->self, me->def->original_id, me->called_id, me->owner, Qnil);
-    RUBY_DTRACE_CMETHOD_RETURN_HOOK(rb_ec_thread_ptr(ec), me->owner, me->def->original_id);
+    RUBY_DTRACE_CMETHOD_RETURN_HOOK(ec, me->owner, me->def->original_id);
     vm_pop_frame(ec, cfp, cfp->ep);
 }
 
@@ -999,12 +999,12 @@ invoke_bmethod(rb_execution_context_t *e https://github.com/ruby/ruby/blob/trunk/vm.c#L999
 		  iseq->body->local_table_size - arg_size,
 		  iseq->body->stack_max);
 
-    RUBY_DTRACE_METHOD_ENTRY_HOOK(rb_ec_thread_ptr(ec), me->owner, me->def->original_id);
+    RUBY_DTRACE_METHOD_ENTRY_HOOK(ec, me->owner, me->def->original_id);
     EXEC_EVENT_HOOK(ec, RUBY_EVENT_CALL, self, me->def->original_id, me->called_id, me->owner, Qnil);
     VM_ENV_FLAGS_SET(ec->cfp->ep, VM_FRAME_FLAG_FINISH);
     ret = vm_exec(ec);
     EXEC_EVENT_HOOK(ec, RUBY_EVENT_RETURN, self, me->def->original_id, me->called_id, me->owner, ret);
-    RUBY_DTRACE_METHOD_RETURN_HOOK(rb_ec_thread_ptr(ec), me->owner, me->def->original_id);
+    RUBY_DTRACE_METHOD_RETURN_HOOK(ec, me->owner, me->def->original_id);
     return ret;
 }
 
@@ -1672,7 +1672,7 @@ hook_before_rewind(rb_execution_context_ https://github.com/ruby/ruby/blob/trunk/vm.c#L1672
     }
     switch (VM_FRAME_TYPE(ec->cfp)) {
       case VM_FRAME_MAGIC_METHOD:
-	RUBY_DTRACE_METHOD_RETURN_HOOK(rb_ec_thread_ptr(ec), 0, 0);
+	RUBY_DTRACE_METHOD_RETURN_HOOK(ec, 0, 0);
 	EXEC_EVENT_HOOK_AND_POP_FRAME(ec, RUBY_EVENT_RETURN, ec->cfp->self, 0, 0, 0, frame_return_value(err));
 	THROW_DATA_CONSUMED_SET(err);
 	break;
@@ -1825,7 +1825,7 @@ vm_exec(rb_execution_context_t *ec) https://github.com/ruby/ruby/blob/trunk/vm.c#L1825
 				rb_vm_frame_method_entry(ec->cfp)->def->original_id,
 				rb_vm_frame_method_entry(ec->cfp)->called_id,
 				rb_vm_frame_method_entry(ec->cfp)->owner, Qnil);
-		RUBY_DTRACE_CMETHOD_RETURN_HOOK(rb_ec_thread_ptr(ec),
+		RUBY_DTRACE_CMETHOD_RETURN_HOOK(ec,
 						rb_vm_frame_method_entry(ec->cfp)->owner,
 						rb_vm_frame_method_entry(ec->cfp)->def->original_id);
 	    }
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 60695)
+++ vm_eval.c	(revision 60696)
@@ -70,7 +70,7 @@ vm_call0_cfunc_with_frame(rb_execution_c https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L70
     ID mid = ci->mid;
     VALUE block_handler = calling->block_handler;
 
-    RUBY_DTRACE_CMETHOD_ENTRY_HOOK(rb_ec_thread_ptr(ec), me->owner, me->def->original_id);
+    RUBY_DTRACE_CMETHOD_ENTRY_HOOK(ec, me->owner, me->def->original_id);
     EXEC_EVENT_HOOK(ec, RUBY_EVENT_C_CALL, recv, me->def->original_id, mid, me->owner, Qnil);
     {
 	rb_control_frame_t *reg_cfp = ec->cfp;
@@ -89,7 +89,7 @@ vm_call0_cfunc_with_frame(rb_execution_c https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L89
 	rb_vm_pop_frame(ec);
     }
     EXEC_EVENT_HOOK(ec, RUBY_EVENT_C_RETURN, recv, me->def->original_id, mid, me->owner, val);
-    RUBY_DTRACE_CMETHOD_RETURN_HOOK(rb_ec_thread_ptr(ec), me->owner, me->def->original_id);
+    RUBY_DTRACE_CMETHOD_RETURN_HOOK(ec, me->owner, me->def->original_id);
 
     return val;
 }
Index: probes_helper.h
===================================================================
--- probes_helper.h	(revision 60695)
+++ probes_helper.h	(revision 60696)
@@ -13,13 +13,13 @@ struct ruby_dtrace_method_hook_args { https://github.com/ruby/ruby/blob/trunk/probes_helper.h#L13
     volatile VALUE name;
 };
 
-NOINLINE(int ruby_th_dtrace_setup(rb_thread_t *, VALUE, ID, struct ruby_dtrace_method_hook_args *));
+NOINLINE(int rb_dtrace_setup(rb_execution_context_t *, VALUE, ID, struct ruby_dtrace_method_hook_args *));
 
-#define RUBY_DTRACE_METHOD_HOOK(name, th, klazz, id) \
+#define RUBY_DTRACE_METHOD_HOOK(name, ec, klazz, id) \
 do { \
     if (UNLIKELY(RUBY_DTRACE_##name##_ENABLED())) { \
 	struct ruby_dtrace_method_hook_args args; \
-	if (ruby_th_dtrace_setup(th, klazz, id, &args)) { \
+	if (rb_dtrace_setup(ec, klazz, id, &args)) { \
 	    RUBY_DTRACE_##name(args.classname, \
 			       args.methodname, \
 			       args.filename, \
@@ -28,16 +28,16 @@ do { \ https://github.com/ruby/ruby/blob/trunk/probes_helper.h#L28
     } \
 } while (0)
 
-#define RUBY_DTRACE_METHOD_ENTRY_HOOK(th, klass, id) \
-    RUBY_DTRACE_METHOD_HOOK(METHOD_ENTRY, th, klass, id)
+#define RUBY_DTRACE_METHOD_ENTRY_HOOK(ec, klass, id) \
+    RUBY_DTRACE_METHOD_HOOK(METHOD_ENTRY, ec, klass, id)
 
-#define RUBY_DTRACE_METHOD_RETURN_HOOK(th, klass, id) \
-    RUBY_DTRACE_METHOD_HOOK(METHOD_RETURN, th, klass, id)
+#define RUBY_DTRACE_METHOD_RETURN_HOOK(ec, klass, id) \
+    RUBY_DTRACE_METHOD_HOOK(METHOD_RETURN, ec, klass, id)
 
-#define RUBY_DTRACE_CMETHOD_ENTRY_HOOK(th, klass, id) \
-    RUBY_DTRACE_METHOD_HOOK(CMETHOD_ENTRY, th, klass, id)
+#define RUBY_DTRACE_CMETHOD_ENTRY_HOOK(ec, klass, id) \
+    RUBY_DTRACE_METHOD_HOOK(CMETHOD_ENTRY, ec, klass, id)
 
-#define RUBY_DTRACE_CMETHOD_RETURN_HOOK(th, klass, id) \
-    RUBY_DTRACE_METHOD_HOOK(CMETHOD_RETURN, th, klass, id)
+#define RUBY_DTRACE_CMETHOD_RETURN_HOOK(ec, klass, id) \
+    RUBY_DTRACE_METHOD_HOOK(CMETHOD_RETURN, ec, klass, id)
 
 #endif /* RUBY_PROBES_HELPER_H */

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]