ruby-changes:47042
From: ko1 <ko1@a...>
Date: Fri, 23 Jun 2017 17:24:59 +0900 (JST)
Subject: [ruby-changes:47042] ko1:r59157 (trunk): rb_catch_protect() accepts enum ruby_tag_type *.
ko1 2017-06-23 17:24:54 +0900 (Fri, 23 Jun 2017) New Revision: 59157 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59157 Log: rb_catch_protect() accepts enum ruby_tag_type *. Modified files: trunk/internal.h trunk/thread.c trunk/vm_core.h trunk/vm_eval.c Index: thread.c =================================================================== --- thread.c (revision 59156) +++ thread.c (revision 59157) @@ -4689,22 +4689,22 @@ exec_recursive(VALUE (*func) (VALUE, VAL https://github.com/ruby/ruby/blob/trunk/thread.c#L4689 return (*func)(obj, arg, TRUE); } else { + enum ruby_tag_type state; + p.func = func; if (outermost) { - int state; recursive_push(p.list, ID2SYM(recursive_key), 0); recursive_push(p.list, p.objid, p.pairid); result = rb_catch_protect(p.list, exec_recursive_i, (VALUE)&p, &state); if (!recursive_pop(p.list, p.objid, p.pairid)) goto invalid; if (!recursive_pop(p.list, ID2SYM(recursive_key), 0)) goto invalid; - if (state) JUMP_TAG(state); + if (state != TAG_NONE) JUMP_TAG(state); if (result == p.list) { result = (*func)(obj, arg, TRUE); } } else { - enum ruby_tag_type state; volatile VALUE ret = Qundef; recursive_push(p.list, p.objid, p.pairid); PUSH_TAG(); @@ -4718,7 +4718,7 @@ exec_recursive(VALUE (*func) (VALUE, VAL https://github.com/ruby/ruby/blob/trunk/thread.c#L4718 "for %+"PRIsVALUE" in %+"PRIsVALUE, sym, rb_thread_current()); } - if (state) JUMP_TAG(state); + if (state != TAG_NONE) JUMP_TAG(state); result = ret; } } Index: internal.h =================================================================== --- internal.h (revision 59156) +++ internal.h (revision 59157) @@ -1740,7 +1740,6 @@ typedef void rb_check_funcall_hook(int, https://github.com/ruby/ruby/blob/trunk/internal.h#L1740 VALUE rb_check_funcall_with_hook(VALUE recv, ID mid, int argc, const VALUE *argv, rb_check_funcall_hook *hook, VALUE arg); VALUE rb_check_funcall_default(VALUE, ID, int, const VALUE *, VALUE); -VALUE rb_catch_protect(VALUE t, rb_block_call_func *func, VALUE data, int *stateptr); VALUE rb_yield_1(VALUE val); VALUE rb_yield_force_blockarg(VALUE values); Index: vm_core.h =================================================================== --- vm_core.h (revision 59156) +++ vm_core.h (revision 59157) @@ -1537,6 +1537,8 @@ const rb_callable_method_entry_t *rb_vm_ https://github.com/ruby/ruby/blob/trunk/vm_core.h#L1537 #define CHECK_VM_STACK_OVERFLOW(cfp, margin) \ WHEN_VM_STACK_OVERFLOWED(cfp, (cfp)->sp, margin) vm_stackoverflow() +VALUE rb_catch_protect(VALUE t, rb_block_call_func *func, VALUE data, enum ruby_tag_type *stateptr); + /* for thread */ #if RUBY_VM_THREAD_MODEL == 2 Index: vm_eval.c =================================================================== --- vm_eval.c (revision 59156) +++ vm_eval.c (revision 59157) @@ -1958,28 +1958,9 @@ rb_catch(const char *tag, VALUE (*func)( https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1958 return rb_catch_obj(vtag, func, data); } -static VALUE vm_catch_protect(VALUE, rb_block_call_func *, VALUE, int *, rb_thread_t *volatile); - -VALUE -rb_catch_obj(VALUE t, VALUE (*func)(), VALUE data) -{ - int state; - rb_thread_t *th = GET_THREAD(); - VALUE val = vm_catch_protect(t, (rb_block_call_func *)func, data, &state, th); - if (state) - TH_JUMP_TAG(th, state); - return val; -} - -VALUE -rb_catch_protect(VALUE t, rb_block_call_func *func, VALUE data, int *stateptr) -{ - return vm_catch_protect(t, func, data, stateptr, GET_THREAD()); -} - static VALUE vm_catch_protect(VALUE tag, rb_block_call_func *func, VALUE data, - int *stateptr, rb_thread_t *volatile th) + enum ruby_tag_type *stateptr, rb_thread_t *volatile th) { enum ruby_tag_type state; VALUE val = Qnil; /* OK */ @@ -2006,6 +1987,22 @@ vm_catch_protect(VALUE tag, rb_block_cal https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1987 return val; } +VALUE +rb_catch_protect(VALUE t, rb_block_call_func *func, VALUE data, enum ruby_tag_type *stateptr) +{ + return vm_catch_protect(t, func, data, stateptr, GET_THREAD()); +} + +VALUE +rb_catch_obj(VALUE t, VALUE (*func)(), VALUE data) +{ + enum ruby_tag_type state; + rb_thread_t *th = GET_THREAD(); + VALUE val = vm_catch_protect(t, (rb_block_call_func *)func, data, &state, th); + if (state) TH_JUMP_TAG(th, state); + return val; +} + static void local_var_list_init(struct local_var_list *vars) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/