[ruby-cvs:72722] ko1:r65622 (trunk): separate Thread type (func or proc) explicitly.

ko1 at ruby-lang.org ko1 at ruby-lang.org
Thu Nov 8 14:01:24 JST 2018


ko1	2018-11-08 14:01:23 +0900 (Thu, 08 Nov 2018)

  New Revision: 65622

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

  Log:
    separate Thread type (func or proc) explicitly.
    
    * vm_core.h (rb_thread_struct): introduce new fields `invoke_type`
      and `invoke_arg`.
      There are two types threads: invoking proc (normal Ruby thread
      created by `Thread.new do ... end`) and invoking func, created
      by C-API. `invoke_type` shows the types.
    
    * thread.c (thread_do_start): copy `invoke_arg.proc.args` contents
      from Array to ALLOCA stack memory if args length is enough small (<8).
      We don't need to keep Array and don't need to cancel using transient heap.
    
    * vm.c (thread_mark): For func invoking threads, they can pass (void *)
      parameter (rb_thread_t::invoke_arg::func::arg). However, a rubyspec test
      (thread_spec.c) passes an Array object and it expect to mark it.
      Clealy it is out of scope (misuse of `rb_thread_create` C-API). However,
      I'm not sure someone else has such kind of misunderstanding.
      So now we mark conservatively this (void *) arg with rb_gc_mark_maybe.
    
      This misuse is found by this error log.
      http://ci.rvm.jp/results/trunk-theap-asserts@silicon-docker/1448164

  Modified files:
    trunk/thread.c
    trunk/thread_pthread.c
    trunk/vm.c
    trunk/vm_core.h


More information about the ruby-cvs mailing list