[ruby-cvs:73103] ko1:r66003 (trunk): Support targetting TracePoint [Feature #15289]

ko1 at ruby-lang.org ko1 at ruby-lang.org
Tue Nov 27 03:16:40 JST 2018


ko1	2018-11-27 03:16:39 +0900 (Tue, 27 Nov 2018)

  New Revision: 66003

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

  Log:
    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.

  Modified files:
    trunk/cont.c
    trunk/gc.c
    trunk/iseq.c
    trunk/iseq.h
    trunk/method.h
    trunk/mjit_worker.c
    trunk/prelude.rb
    trunk/proc.c
    trunk/test/ruby/test_settracefunc.rb
    trunk/thread.c
    trunk/tool/ruby_vm/views/_mjit_compile_insn.erb
    trunk/tool/ruby_vm/views/_mjit_compile_send.erb
    trunk/vm.c
    trunk/vm_core.h
    trunk/vm_insnhelper.c
    trunk/vm_method.c
    trunk/vm_trace.c


More information about the ruby-cvs mailing list