Граф коммитов

469 Коммитов

Автор SHA1 Сообщение Дата
tarui d64a73e1dd revert r38141 for stack problem
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-02 08:56:27 +00:00
tarui 1e88b393e0 * thread.c (RB_GC_SAVE_MACHINE_CONTEXT, rb_gc_save_machine_context):
Don't set machine_regs and machine_stack_end with a different scope.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-02 08:45:14 +00:00
ko1 e742a446c8 * thread.c (Thread.async_interrupt_timing): fix RDoc.
:never is not used any more.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30 18:47:00 +00:00
kosaki a113ab64b2 * thread.c (rb_threadptr_interrupt_mask, async_interrupt_timing_func):
merge into them into rb_thread_s_async_interrupt_timing.
* thread.c (rb_thread_s_async_interrupt_timing): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30 17:39:59 +00:00
kosaki 279cd29b1b * thread.c (rb_threadptr_interrupt_mask): add argument check.
* thread.c (async_interrupt_timing_arg_check_i): helper function
  for the above.
* test/ruby/test_thread.rb (test_async_interrupt_timing_invalid_argument):
  test for the above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30 17:39:48 +00:00
kosaki 15b25acd25 * vm_core.h (rb_vm_struct): add thread_destruct_lock field.
* thread.c (Init_Thread): ditto.
* thread.c (rb_vm_gvl_destroy): ditto.

* thread.c (thread_start_func_2): make sure vm->running_thread
  don't point to dead thread.
* thread.c (timer_thread_function): close a race against thead
  destruction. [Bug #4911][ruby-dev:43859]

* vm_core.h (rb_thread_set_current): reset running time of
  current thread instead of previous thread. We no longer
  assume previous running thread still live.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30 13:52:34 +00:00
kosaki 2e72d1c323 revert r35486 (add rb_thread_t#yeiling field). because it doesn't help
to close a race.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30 13:52:24 +00:00
ko1 bb4410a289 * thread.c: TracePoint#self returns invoking/exitting thread object
at thread_begin/end event.
* test/ruby/test_settracefunc.rb: fix test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30 11:50:26 +00:00
ko1 719e0cd530 * thread.c: rename Thread.control_interrupt
to Thread.async_interrupt_timing.
  The option name `:never' is also changed to  `:defer'.
  [ruby-core:50375] [ruby-trunk - Feature #6762]
* thread.c: remove Thread.check_interrupt.
  This method is difficult to understand by name.
* thraed.c: add Thread.async_interrupted?.
  This method check any defered async interrupts.
* test/ruby/test_thread.rb: change tests for above.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30 09:28:35 +00:00
ko1 c86379402c * thread.c (rb_thread_interrupted): avoid warning of
implicit conversion.
* thread.c (rb_threadptr_execute_interrupts): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 22:44:51 +00:00
ko1 4db8340398 [EXPERIMENTAL: NEED DISCUSS]
* vm_trace.c: add events
* :thread_begin - hook at thread beggining.
* :thead_end - hook at thread ending.
* :b_call - hook at block enter.
* :b_return - hook at block leave.
  This change slow down block invocation.
  Please try and give us feedback until 2.0 code freeze.
* include/ruby/ruby.h: ditto.
* compile.c (rb_iseq_compile_node): ditto.
* insns.def: ditto.
* thread.c: ditto.
* vm.c: ditto.
* include/ruby/debug.h: add a comment.
* test/ruby/test_settracefunc.rb: add a tests.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 22:28:16 +00:00
kosaki c058d821f8 Revert r37956: thread.c (thread_start_func_2): small cleanups.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 02:50:11 +00:00
kosaki 989c529c89 * thread.c (thread_start_func_2): remove unused code. When
th->safe_level == 4, th->errinfo never be thrown. So, to
  create new exception makes no sense.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 02:09:36 +00:00
naruse d1dfebc05a Revert r37953: thread.c (thread_start_func_2): remove unused code. security
This sticks at bootstraptest/test_fork.rb:24 on FreeBSD and darwin.
http://fb.rubyci.org/~chkbuild/ruby-trunk/log/20121128T230302Z.log.html.gz
http://a.mrkn.jp/~mrkn/chkbuild/sl/ruby-trunk-m64-gcc42-o0/log/20121128T235908Z.log.html.gz

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37960 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 01:11:47 +00:00
naruse e2779a53ef * thread.c (do_select): suppress warning (uninitialized value warning)
with UNINITIALIZED_VAR().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 00:52:51 +00:00
kosaki b76b6b5c98 * thread.c (thread_start_func_2): small cleanups.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37956 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 21:55:26 +00:00
kosaki 5e606aee2f * thread.c (thread_start_func_2): remove unused code.
this function never be used for main thread.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 21:55:14 +00:00
kosaki fdda95ed8c * thread.c (thread_start_func_2): remove unused code.
errinfo = th->errinfo; and errinfo = rb_errinfo(); are
  the same.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37954 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 21:55:03 +00:00
kosaki 1d207fcff0 * thread.c (thread_start_func_2): remove unused code. security
level is checked before rb_eSecurityError raises.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 21:54:52 +00:00
ko1 09f9aa4385 * thread.c (rb_mutex_sleep): fix to allow spurious wakeup.
* NEWS: write about spurious wakeup.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 14:40:00 +00:00
ko1 9d0de48e66 * include/ruby/thread.h (rb_thread_call_without_gvl2): change
meaning of function.
  This function is called with same parameters of
  `rb_thread_call_without_gvl()'.
  However, if interrupts are detected, when return immediately.
* thread.c: implement `rb_thread_call_without_gvl2()'.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 13:01:25 +00:00
tarui f5dc27aa77 * thread.c (thread_join_sleep): check spurious wakeup by itself for
corresponding status change in trap context.
	* vm_core.h (struct rb_thread_struct): add rb_thread_list_t and use as join_list for
	reentry by trap context.
	* thread.c (thread_start_func_2): ditto.
	* thread.c (remove_from_join_list): ditto.
	* thread.c (rb_thread_atfork): ditto.
	* thread.c (thread_join): ditto. & remove trap handler check.
	* thread.c (sleep_forever): add argument : spurious_check.
	* thread.c (sleep_timeval): ditto.
	* thread.c (rb_thread_sleep_forever): set spurious_check.
	* thread.c (rb_thread_sleep_deadly): ditto.
	* thread.c (sleep_for_polling): ditto.
	* thread.c (rb_thread_wait_for): ditto.
	* thread.c (sleep_wait_for_interrupt): bypass spurious_check.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 12:34:15 +00:00
kosaki 9cbf473287 * vm_core.h (enum rb_thread_status): remove THREAD_TO_KILL
* vm_core.h (struct rb_thread_struct): add to_kill field
* thread.c (terminate_i): convert THREAD_TO_KILL to to_kill.
* thread.c (rb_threadptr_to_kill): ditto.
* thread.c (rb_thread_kill): ditto.
* thread.c (rb_thread_wakeup_alive): ditto.
* thread.c (thread_list_i): ditto.
* thread.c (static const char): ditto.
* thread.c (thread_status_name): ditto.
* thread.c (rb_thread_status): ditto.
* thread.c (rb_thread_inspect): ditto.
* vm_backtrace.c (thread_backtrace_to_ary): ditto.

* thread.c (rb_threadptr_execute_interrupts): fix thread status
  overwritten issue. [Bug #7450] [ruby-core:50249]

* test/ruby/test_thread.rb (test_hread_status_raise_after_kill):
  test for the above.
* test/ruby/test_thread.rb (test_thread_status_in_trap): test for
  thread status in trap.
* test/ruby/test_thread.rb (test_status_and_stop_p): remove
  Thread.control_interrupt unsafe test. Thread#kill no longer
  changes thread status. Instead of, Thread#kill receiver changes
  their own status when receiving kill signal.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37931 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 08:31:03 +00:00
kosaki b8a1e36201 * thread.c (struct rb_mutex_struct): add allow_trap field.
* internal.h (rb_mutex_allow_trap): added.
* thread.c (rb_mutex_lock, rb_mutex_unlock): check mutex->allow_trap.
* thread.c (mutex_sleep): remove trap check because it uses
  rb_mutex_lock and rb_mutex_unlock internally.
* thread.c (rb_mutex_allow_trap): new helper function for the above.

* io.c (io_binwrite): mark fptr->write_lock as writable in trap.

* test/ruby/test_signal.rb (test_trap_puts): test for the above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 08:30:51 +00:00
kosaki 835d24f637 * thread.c (rb_mutex_lock): moved trap context check from
rb_mutex_trylock because try_lock have no change to make
  a deadlock.
* thread.c (rb_mutex_trylock): ditto.
* NEWS: news for the above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 05:40:54 +00:00
kosaki 8111b32d68 * thread.c (thread_s_new): uses main_thread->status instead of
th->inhibit_thread_creation for preventing thread creation.
* vm_core.h (rb_vm_struct): remove inhibit_thread_creation field.
* thread.c (rb_thread_terminate_all): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 04:43:15 +00:00
kosaki 694c77633c * thread.c (thread_join): A trap handler check was moved from
thread_join_m because Thread#value should be raised an exception
  too.
* thread.c (thread_join_m): remove trap handler check.
* test/ruby/test_thread.rb (test_thread_join_in_trap): add test
  for thread#value.
* NEWS: documentation fix for the above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37918 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 04:09:38 +00:00
ko1 c72f0daa87 * thread.c (rb_thread_terminate_all): retry broadcast only when
an exception is raised.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-27 03:18:29 +00:00
ko1 2f9ee7af47 * thread.c (rb_thread_terminate_all): broadcast terminate event
not only an interrupt exception but any exceptions.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-27 03:04:36 +00:00
kosaki 863e087326 * thread.c (rb_thread_terminate_all): suppress a warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-27 02:00:29 +00:00
kosaki b1a18cf49b * thread.c (thread_join): raises ThreadError if target therad
is a main thread.
* test/ruby/test_thread.rb (test_thread_join_main_thread):
  test for the above.
* NEWS: news for the above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-27 02:00:19 +00:00
kosaki 8079f8a6f2 * thread.c (thread_join): raises ThreadError if target thread
is a current thread.
* test/ruby/test_thread.rb (test_thread_join_current):
  test for the above.
* NEWS: news for the above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-27 02:00:09 +00:00
kosaki a916278900 * thread.c (rb_thread_terminate_all): broadcast eTerminateSignal
again when Ctrl-C was pressed. [Feature #1952] [ruby-dev:39107]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26 23:08:36 +00:00
kosaki 253938067a * thread.c (rb_thread_terminate_all): add RUBY_VM_CHECK_INTS_BLOCKING().
Otherwise the loop in this function behave as busy loop because
  native_sleep() return immediately when RUBY_VM_INTERRUPTED() is true.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26 22:49:36 +00:00
kosaki 5b238e8dc7 * thread.c (rb_mutex_trylock, rb_mutex_unlock, mutex_sleep):
raises ThreadError if called from trap handler as Thread#join.
* NEWS: news fot the above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26 15:17:01 +00:00
kosaki 39d38ff82f * thread.c (rb_thread_terminate_all): use native_sleep() instead
of rb_thread_schedule(). Otherwise, it consume 100% cpu meaninglessly.
  [Bug #5368] [ruby-dev:44546]
* thread.c (thread_start_func_2): last sub-thread wakes up main thread.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26 13:47:23 +00:00
kosaki 66e2e6ee69 * vm_core.h (RUBY_VM_SET_TIMER_INTERRUPT, RUBY_VM_SET_INTERRUPT)
(RUBY_VM_SET_FINALIZER_INTERRUPT, RUBY_VM_SET_TRAP_INTERRUPT)
(RUBY_VM_INTERRUPTED): use enum symbol instead of immediate value.
* thread.c (thread_join_m, rb_threadptr_execute_interrupts): ditto.
* signal.c (signal_exec): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37864 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26 12:17:10 +00:00
kosaki 58543f00b6 * thread.c (thread_join_m): use th->interrupt_mask instead of
th->in_trap.

* vm_core.h (struct rb_thread_struct): remove in_trap member.
* signal.c (signal_exec): ditto.
* thread.c (thread_create_core): ditto.
* thread.c (Init_Thread): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26 11:45:39 +00:00
kosaki 6190bb4d8a * ruby_atomic.h (ATOMIC_CAS): new macro for compare-and-exchange.
* vm_core.h (struct rb_thread_struct): add interrupt_mask member.
* thread.c (thread_create_core, Init_Thread): initialize
  th->thread_mask.

* vm_core.h (RUBY_VM_INTERRUPTED_ANY): new macro for avoiding
  bare th->interrupt_flag.
* vm_core.h (RUBY_VM_INTERRUPTED, RUBY_VM_INTERRUPTED): check
  th->interrupt_mask.
* thread.c (set_unblock_function, rb_thread_schedule): replace
  th->interrupt_flag with RUBY_VM_INTERRUPTED_ANY()

* signal.c (signal_exec): set up thread->interrupt_mask for
  preventing recursive trap handler.
* vm_core.h (RUBY_VM_CHECK_INTS, RUBY_VM_CHECK_INTS_BLOCKING): ditto.

* thread.c (rb_threadptr_execute_interrupts):
  don't process interrupt if it is masked.
  [Bug #6009] [ruby-core:42524]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26 10:57:39 +00:00
kosaki 7087153156 split trap interrupt and async interrupt
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37855 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26 09:22:01 +00:00
kosaki f150ed1532 * vm_core.h (rb_thread_struct): added 'in_trap' member for marking
running trap handler.
* signal.c (signal_exec): turn on in_trap when running trap.
* thread.c (Init_Thread, thread_create_core): initialize in_trap
  when creating new threads.
* thread.c (thread_join_m): raise ThreadError when running trap
  handler.Bug [#6416][ruby-core:44956]
* test/ruby/test_thread.rb (test_thread_join_in_trap): new test
  for the above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26 08:05:49 +00:00
kosaki 82b33551a4 * thread.c (thread_create_core): don't use th->thread_id before
initialized.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-24 02:00:10 +00:00
ko1 553931962a * vm_trace.c: add two methods:
(1) TracePoint#return_value which returns return
  value on the :return and :c_return event.
  (2) TracePoint#raised_exception which returns raised exception
  value on the :raise event.
  Eeach methods raise RuntimeError if it is called at unsupported
  event.
  Please review and give us feedback until next preview
  release (Dec/2012) of Ruby 2.0.0.
* insns.def, vm.c, vm_eval.c, vm_insnhelper.c, eval.c, thread.c:
  ditto.
* vm_trace.c, vm_core.h: move definition of rb_trace_arg_t from
  vm_trace.c to vm_core.h.
  Caller fills rb_trace_arg_t and pass the pointer of this variable.
* test/ruby/test_settracefunc.rb: fix tests to test this change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-20 09:48:24 +00:00
kosaki b74e1b21db revert r37730
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37740 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-20 01:21:19 +00:00
kosaki 57ee812851 * thread.c (rb_thread_s_check_interrupt): removed redundant
GET_THREAD().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-19 11:15:07 +00:00
kosaki 4b25e0ceca * thread.c (rb_threadptr_async_errinfo_active_p): added a small
comment.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-19 11:13:40 +00:00
kosaki 212150c2e1 * thread.c, vm_core.h: big rename th to cur_th when works only
th is current thread.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37730 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-19 11:10:24 +00:00
kosaki 0a2da327f4 * thread.c (rb_thread_blocking_region_end): replaced GET_THREAD()
with ruby_thread_from_native(). We don't have GVL here.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37729 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-19 11:07:53 +00:00
kosaki 7643e4604b * thread.c (rb_threadptr_execute_interrupts) removed.
* thread.c (rb_threadptr_execute_interrupts_common) renamed to
  rb_threadptr_execute_interrupts. I.e. unified
  rb_threadptr_execute_interrupts and rb_threadptr_execute_interrupts_common.
* thread.c (rb_thread_schedule, rb_thread_execute_interrupts) s/_common//.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-19 11:04:39 +00:00
kosaki 6c56dae4b2 * prelude.rb: Moved Mutex#synchronize to
* thread.c (rb_mutex_synchronize_m): here. [Bug #4266]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-19 10:22:53 +00:00