ruby-changes:12371
From: yugui <ko1@a...>
Date: Mon, 13 Jul 2009 15:10:43 +0900 (JST)
Subject: [ruby-changes:12371] Ruby:r24068 (ruby_1_9_1): merges r23959 from trunk into ruby_1_9_1.
yugui 2009-07-13 15:10:26 +0900 (Mon, 13 Jul 2009) New Revision: 24068 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=24068 Log: merges r23959 from trunk into ruby_1_9_1. -- * thread.c (rb_threadptr_exec_event_hooks): new function to execute event hooks, with preserving errinfo. [ruby-core:24118] Modified files: branches/ruby_1_9_1/ChangeLog branches/ruby_1_9_1/test/ruby/test_settracefunc.rb branches/ruby_1_9_1/thread.c branches/ruby_1_9_1/version.h branches/ruby_1_9_1/vm_core.h Index: ruby_1_9_1/ChangeLog =================================================================== --- ruby_1_9_1/ChangeLog (revision 24067) +++ ruby_1_9_1/ChangeLog (revision 24068) @@ -1,3 +1,8 @@ +Sun Jul 5 14:04:36 2009 Nobuyoshi Nakada <nobu@r...> + + * thread.c (rb_threadptr_exec_event_hooks): new function to + execute event hooks, with preserving errinfo. [ruby-core:24118] + Sun Jul 5 08:08:25 2009 Nobuyoshi Nakada <nobu@r...> * vm_insnhelper.c (vm_yield_setup_block_args): restores the firs Index: ruby_1_9_1/vm_core.h =================================================================== --- ruby_1_9_1/vm_core.h (revision 24067) +++ ruby_1_9_1/vm_core.h (revision 24068) @@ -631,30 +631,14 @@ RUBY_VM_CHECK_INTS_TH(GET_THREAD()) /* tracer */ -static inline void -exec_event_hooks(rb_event_hook_t *hook, rb_event_flag_t flag, VALUE self, ID id, VALUE klass) -{ - if (self == rb_mRubyVMFrozenCore) return; - while (hook) { - if (flag & hook->flag) { - (*hook->func)(flag, hook->data, self, id, klass); - } - hook = hook->next; - } -} +void +rb_threadptr_exec_event_hooks(rb_thread_t *th, rb_event_flag_t flag, VALUE self, ID id, VALUE klass); #define EXEC_EVENT_HOOK(th, flag, self, id, klass) do { \ rb_event_flag_t wait_event__ = th->event_flags; \ if (UNLIKELY(wait_event__)) { \ if (wait_event__ & (flag | RUBY_EVENT_VM)) { \ - VALUE self__ = (self), klass__ = (klass); \ - ID id__ = (id); \ - if (wait_event__ & flag) { \ - exec_event_hooks(th->event_hooks, flag, self__, id__, klass__); \ - } \ - if (wait_event__ & RUBY_EVENT_VM) { \ - exec_event_hooks(th->vm->event_hooks, flag, self__, id__, klass__); \ - } \ + rb_threadptr_exec_event_hooks(th, flag, self, id, klass); \ } \ } \ } while (0) Index: ruby_1_9_1/thread.c =================================================================== --- ruby_1_9_1/thread.c (revision 24067) +++ ruby_1_9_1/thread.c (revision 24068) @@ -3484,7 +3484,33 @@ st_foreach(GET_VM()->living_threads, set_threads_event_flags_i, (st_data_t) flag); } +static inline void +exec_event_hooks(const rb_event_hook_t *hook, rb_event_flag_t flag, VALUE self, ID id, VALUE klass) +{ + for (; hook; hook = hook->next) { + if (flag & hook->flag) { + (*hook->func)(flag, hook->data, self, id, klass); + } + } +} + void +rb_threadptr_exec_event_hooks(rb_thread_t *th, rb_event_flag_t flag, VALUE self, ID id, VALUE klass) +{ + const VALUE errinfo = th->errinfo; + const rb_event_flag_t wait_event = th->event_flags; + + if (self == rb_mRubyVMFrozenCore) return; + if (wait_event & flag) { + exec_event_hooks(th->event_hooks, flag, self, id, klass); + } + if (wait_event & RUBY_EVENT_VM) { + exec_event_hooks(th->vm->event_hooks, flag, self, id, klass); + } + th->errinfo = errinfo; +} + +void rb_add_event_hook(rb_event_hook_func_t func, rb_event_flag_t events, VALUE data) { rb_event_hook_t *hook = alloc_event_hook(func, events, data); Index: ruby_1_9_1/version.h =================================================================== --- ruby_1_9_1/version.h (revision 24067) +++ ruby_1_9_1/version.h (revision 24068) @@ -1,6 +1,6 @@ #define RUBY_VERSION "1.9.1" #define RUBY_RELEASE_DATE "2009-07-12" -#define RUBY_PATCHLEVEL 218 +#define RUBY_PATCHLEVEL 219 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 Index: ruby_1_9_1/test/ruby/test_settracefunc.rb =================================================================== --- ruby_1_9_1/test/ruby/test_settracefunc.rb (revision 24067) +++ ruby_1_9_1/test/ruby/test_settracefunc.rb (revision 24068) @@ -181,4 +181,9 @@ def test_invalid_proc assert_raise(TypeError) { set_trace_func(1) } end + + def test_raise_in_trace + set_trace_func proc {raise rescue nil} + assert_equal(42, (raise rescue 42), '[ruby-core:24118]') + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/