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

ruby-changes:44519

From: ktsj <ko1@a...>
Date: Sat, 5 Nov 2016 22:15:31 +0900 (JST)
Subject: [ruby-changes:44519] ktsj:r56592 (trunk): * eval.c, method.h, proc.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c:

ktsj	2016-11-05 22:15:26 +0900 (Sat, 05 Nov 2016)

  New Revision: 56592

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

  Log:
    * eval.c, method.h, proc.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c:
      TracePoint#method_id should return method_id, not callee_id.
      [ruby-core:77241] [Feature #12747]
    
    * test/ruby/test_settracefunc.rb: change accordingly.

  Modified files:
    trunk/ChangeLog
    trunk/eval.c
    trunk/method.h
    trunk/proc.c
    trunk/test/ruby/test_settracefunc.rb
    trunk/vm.c
    trunk/vm_eval.c
    trunk/vm_insnhelper.c
    trunk/vm_method.c
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 56591)
+++ vm_insnhelper.c	(revision 56592)
@@ -1738,8 +1738,8 @@ vm_call_cfunc_with_frame(rb_thread_t *th https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1738
     VALUE block_handler = calling->block_handler;
     int argc = calling->argc;
 
-    RUBY_DTRACE_CMETHOD_ENTRY_HOOK(th, me->owner, me->called_id);
-    EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, recv, me->called_id, me->owner, Qundef);
+    RUBY_DTRACE_CMETHOD_ENTRY_HOOK(th, me->owner, me->def->original_id);
+    EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, recv, me->def->original_id, me->owner, Qundef);
 
     vm_push_frame(th, NULL, VM_FRAME_MAGIC_CFUNC | VM_FRAME_FLAG_CFRAME | VM_ENV_FLAG_LOCAL, recv,
 		  block_handler, (VALUE)me,
@@ -1757,8 +1757,8 @@ vm_call_cfunc_with_frame(rb_thread_t *th https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1757
 
     rb_vm_pop_frame(th);
 
-    EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, recv, me->called_id, me->owner, val);
-    RUBY_DTRACE_CMETHOD_RETURN_HOOK(th, me->owner, me->called_id);
+    EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, recv, me->def->original_id, me->owner, val);
+    RUBY_DTRACE_CMETHOD_RETURN_HOOK(th, me->owner, me->def->original_id);
 
     return val;
 }
@@ -2087,7 +2087,7 @@ aliased_callable_method_entry(const rb_c https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2087
     if (orig_me->defined_class == 0) {
 	VALUE defined_class = find_defined_class_by_owner(me->defined_class, orig_me->owner);
 	VM_ASSERT(RB_TYPE_P(orig_me->owner, T_MODULE));
-	cme = rb_method_entry_complement_defined_class(orig_me, defined_class);
+	cme = rb_method_entry_complement_defined_class(orig_me, me->called_id, defined_class);
 
 	if (me->def->alias_count + me->def->complemented_count == 0) {
 	    RB_OBJ_WRITE(me, &me->def->body.alias.original_me, cme);
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 56591)
+++ ChangeLog	(revision 56592)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Nov  5 22:09:48 2016  Kazuki Tsujimoto  <kazuki@c...>
+
+	* eval.c, method.h, proc.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c:
+	  TracePoint#method_id should return method_id, not callee_id.
+	  [ruby-core:77241] [Feature #12747]
+
+	* test/ruby/test_settracefunc.rb: change accordingly.
+
 Sat Nov  5 18:49:37 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* numeric.c (flo_round, int_round): support round-to-nearest-even
Index: vm_method.c
===================================================================
--- vm_method.c	(revision 56591)
+++ vm_method.c	(revision 56592)
@@ -408,9 +408,9 @@ rb_method_entry_clone(const rb_method_en https://github.com/ruby/ruby/blob/trunk/vm_method.c#L408
 }
 
 const rb_callable_method_entry_t *
-rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, VALUE defined_class)
+rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, ID called_id, VALUE defined_class)
 {
-    rb_method_entry_t *me = rb_method_entry_alloc(src_me->called_id, src_me->owner, defined_class,
+    rb_method_entry_t *me = rb_method_entry_alloc(called_id, src_me->owner, defined_class,
 						  method_definition_addref_complement(src_me->def));
     METHOD_ENTRY_FLAGS_COPY(me, src_me);
     METHOD_ENTRY_COMPLEMENTED_SET(me);
@@ -816,7 +816,7 @@ prepare_callable_method_entry(VALUE defi https://github.com/ruby/ruby/blob/trunk/vm_method.c#L816
 	    VM_ASSERT(callable_method_entry_p(cme));
 	}
 	else {
-	    cme = rb_method_entry_complement_defined_class(me, defined_class);
+	    cme = rb_method_entry_complement_defined_class(me, me->called_id, defined_class);
 	    rb_id_table_insert(mtbl, id, (VALUE)cme);
 	    VM_ASSERT(callable_method_entry_p(cme));
 	}
@@ -949,7 +949,7 @@ rb_resolve_refined_method_callable(VALUE https://github.com/ruby/ruby/blob/trunk/vm_method.c#L949
     const rb_method_entry_t *resolved_me = resolve_refined_method(refinements, (const rb_method_entry_t *)me, &defined_class);
 
     if (resolved_me && resolved_me->defined_class == 0) {
-	return rb_method_entry_complement_defined_class(resolved_me, defined_class);
+	return rb_method_entry_complement_defined_class(resolved_me, me->called_id, defined_class);
     }
     else {
 	return (const rb_callable_method_entry_t *)resolved_me;
Index: method.h
===================================================================
--- method.h	(revision 56591)
+++ method.h	(revision 56592)
@@ -205,7 +205,7 @@ void rb_free_method_entry(const rb_metho https://github.com/ruby/ruby/blob/trunk/method.h#L205
 void rb_sweep_method_entry(void *vm);
 
 const rb_method_entry_t *rb_method_entry_clone(const rb_method_entry_t *me);
-const rb_callable_method_entry_t *rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, VALUE defined_class);
+const rb_callable_method_entry_t *rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, ID called_id, VALUE defined_class);
 void rb_method_entry_copy(rb_method_entry_t *dst, const rb_method_entry_t *src);
 
 void rb_scope_visibility_set(rb_method_visibility_t);
Index: vm.c
===================================================================
--- vm.c	(revision 56591)
+++ vm.c	(revision 56592)
@@ -522,8 +522,8 @@ rb_vm_pop_cfunc_frame(void) https://github.com/ruby/ruby/blob/trunk/vm.c#L522
     rb_control_frame_t *cfp = th->cfp;
     const rb_callable_method_entry_t *me = rb_vm_frame_method_entry(cfp);
 
-    EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, cfp->self, me->called_id, me->owner, Qnil);
-    RUBY_DTRACE_CMETHOD_RETURN_HOOK(th, me->owner, me->called_id);
+    EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, cfp->self, me->def->original_id, me->owner, Qnil);
+    RUBY_DTRACE_CMETHOD_RETURN_HOOK(th, me->owner, me->def->original_id);
     vm_pop_frame(th, cfp, cfp->ep);
 }
 
@@ -983,11 +983,11 @@ invoke_bmethod(rb_thread_t *th, const rb https://github.com/ruby/ruby/blob/trunk/vm.c#L983
 		  th->cfp->sp + arg_size, iseq->body->local_table_size - arg_size,
 		  iseq->body->stack_max);
 
-    RUBY_DTRACE_METHOD_ENTRY_HOOK(th, me->owner, me->called_id);
-    EXEC_EVENT_HOOK(th, RUBY_EVENT_CALL, self, me->called_id, me->owner, Qnil);
+    RUBY_DTRACE_METHOD_ENTRY_HOOK(th, me->owner, me->def->original_id);
+    EXEC_EVENT_HOOK(th, RUBY_EVENT_CALL, self, me->def->original_id, me->owner, Qnil);
     ret = vm_exec(th);
-    EXEC_EVENT_HOOK(th, RUBY_EVENT_RETURN, self, me->called_id, me->owner, ret);
-    RUBY_DTRACE_METHOD_RETURN_HOOK(th, me->owner, me->called_id);
+    EXEC_EVENT_HOOK(th, RUBY_EVENT_RETURN, self, me->def->original_id, me->owner, ret);
+    RUBY_DTRACE_METHOD_RETURN_HOOK(th, me->owner, me->def->original_id);
     return ret;
 }
 
@@ -1602,7 +1602,7 @@ hook_before_rewind(rb_thread_t *th, rb_c https://github.com/ruby/ruby/blob/trunk/vm.c#L1602
 	    if (!will_finish_vm_exec) {
 		/* kick RUBY_EVENT_RETURN at invoke_block_from_c() for bmethod */
 		EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_RETURN, th->cfp->self,
-					      rb_vm_frame_method_entry(th->cfp)->called_id,
+					      rb_vm_frame_method_entry(th->cfp)->def->original_id,
 					      rb_vm_frame_method_entry(th->cfp)->owner, Qnil);
 	    }
 	}
@@ -1734,11 +1734,11 @@ vm_exec(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/vm.c#L1734
 	while (th->cfp->pc == 0 || th->cfp->iseq == 0) {
 	    if (UNLIKELY(VM_FRAME_TYPE(th->cfp) == VM_FRAME_MAGIC_CFUNC)) {
 		EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, th->cfp->self,
-				rb_vm_frame_method_entry(th->cfp)->called_id,
+				rb_vm_frame_method_entry(th->cfp)->def->original_id,
 				rb_vm_frame_method_entry(th->cfp)->owner, Qnil);
 		RUBY_DTRACE_CMETHOD_RETURN_HOOK(th,
 					       rb_vm_frame_method_entry(th->cfp)->owner,
-					       rb_vm_frame_method_entry(th->cfp)->called_id);
+					       rb_vm_frame_method_entry(th->cfp)->def->original_id);
 	    }
 	    rb_vm_pop_frame(th);
 	}
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 56591)
+++ vm_eval.c	(revision 56592)
@@ -117,7 +117,7 @@ vm_call0_cfunc_with_frame(rb_thread_t* t https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L117
     VALUE block_handler = calling->block_handler;
 
     RUBY_DTRACE_CMETHOD_ENTRY_HOOK(th, me->owner, mid);
-    EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, recv, mid, me->owner, Qnil);
+    EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, recv, me->def->original_id, me->owner, Qnil);
     {
 	rb_control_frame_t *reg_cfp = th->cfp;
 
@@ -136,7 +136,7 @@ vm_call0_cfunc_with_frame(rb_thread_t* t https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L136
 	VM_PROFILE_UP(C2C_POPF);
 	rb_vm_pop_frame(th);
     }
-    EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, recv, mid, me->owner, val);
+    EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, recv, me->def->original_id, me->owner, val);
     RUBY_DTRACE_CMETHOD_RETURN_HOOK(th, me->owner, mid);
 
     return val;
Index: test/ruby/test_settracefunc.rb
===================================================================
--- test/ruby/test_settracefunc.rb	(revision 56591)
+++ test/ruby/test_settracefunc.rb	(revision 56592)
@@ -1153,8 +1153,8 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L1153
     }
     assert_equal([
       [:call, :size],
-      [:c_call, :original_size],
-      [:c_return, :original_size],
+      [:c_call, :size],
+      [:c_return, :size],
       [:return, :size]
     ], events, "should use alias method name for tracing c methods")
   end
@@ -1287,7 +1287,7 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L1287
       }.enable{
         p 1
       }
-    }, %w[:p :inspect 1], [], '[Bug #9940]')
+    }, %w[:p :to_s 1], [], '[Bug #9940]')
   end
 
   def method_prefix event
Index: proc.c
===================================================================
--- proc.c	(revision 56591)
+++ proc.c	(revision 56592)
@@ -2224,7 +2224,7 @@ umethod_bind(VALUE method, VALUE recv) https://github.com/ruby/ruby/blob/trunk/proc.c#L2224
 	else {
 	    klass = rb_include_class_new(methclass, klass);
 	}
-	RB_OBJ_WRITE(method, &bound->me, rb_method_entry_complement_defined_class(bound->me, klass));
+	RB_OBJ_WRITE(method, &bound->me, rb_method_entry_complement_defined_class(bound->me, bound->me->called_id, klass));
     }
 
     return method;
Index: eval.c
===================================================================
--- eval.c	(revision 56591)
+++ eval.c	(revision 56592)
@@ -749,7 +749,7 @@ rb_raise_jump(VALUE mesg, VALUE cause) https://github.com/ruby/ruby/blob/trunk/eval.c#L749
     ID mid = me->called_id;
 
     rb_vm_pop_frame(th);
-    EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, self, mid, klass, Qnil);
+    EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, self, me->def->original_id, klass, Qnil);
 
     setup_exception(th, TAG_RAISE, mesg, cause);
 

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

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