ruby-changes:37855
From: ko1 <ko1@a...>
Date: Wed, 11 Mar 2015 21:49:47 +0900 (JST)
Subject: [ruby-changes:37855] ko1:r49936 (trunk): * vm_insnhelper.h: use T_IMEMO to create THROW_DATA.
ko1 2015-03-11 21:49:27 +0900 (Wed, 11 Mar 2015) New Revision: 49936 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49936 Log: * vm_insnhelper.h: use T_IMEMO to create THROW_DATA. Add THROW_DATA_NEW(). * internal.h: move defnition of `struct THROW_DATA' from vm_insnhelper.h to internal.h. Rename `THROW_DATA' to `vm_throw_data'. * eval_intern.h (THROW_DATA_P): move to internal.h. THROW_DATA is no longer T_NODE, so check T_IMEMO. * gc.c (gc_mark_children): mark THROW_DATA. * vm.c: catch up these changes. * vm_eval.c: ditto. * vm_insnhelper.c: ditto. Modified files: trunk/ChangeLog trunk/eval_intern.h trunk/gc.c trunk/internal.h trunk/vm.c trunk/vm_eval.c trunk/vm_insnhelper.c trunk/vm_insnhelper.h Index: eval_intern.h =================================================================== --- eval_intern.h (revision 49935) +++ eval_intern.h (revision 49936) @@ -199,8 +199,6 @@ enum ruby_tag_type { https://github.com/ruby/ruby/blob/trunk/eval_intern.h#L199 #define TAG_FATAL RUBY_TAG_FATAL #define TAG_MASK RUBY_TAG_MASK -#define THROW_DATA_P(err) RB_TYPE_P((err), T_NODE) - #define SCOPE_TEST(f) (CREF_VISI(rb_vm_cref()) & (f)) #define SCOPE_CHECK(f) (CREF_VISI(rb_vm_cref()) == (f)) #define SCOPE_SET(f) (CREF_VISI_SET(rb_vm_cref(), (f))) Index: ChangeLog =================================================================== --- ChangeLog (revision 49935) +++ ChangeLog (revision 49936) @@ -1,3 +1,25 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Mar 11 21:45:36 2015 Koichi Sasada <ko1@a...> + + * vm_insnhelper.h: use T_IMEMO to create THROW_DATA. + + Add THROW_DATA_NEW(). + + * internal.h: move defnition of `struct THROW_DATA' + from vm_insnhelper.h to internal.h. + + Rename `THROW_DATA' to `vm_throw_data'. + + * eval_intern.h (THROW_DATA_P): move to internal.h. + THROW_DATA is no longer T_NODE, so check T_IMEMO. + + * gc.c (gc_mark_children): mark THROW_DATA. + + * vm.c: catch up these changes. + + * vm_eval.c: ditto. + + * vm_insnhelper.c: ditto. + Wed Mar 11 21:21:56 2015 Koichi Sasada <ko1@a...> * vm_insnhelper.c: use T_IMEMO to create SVAR. Index: vm_eval.c =================================================================== --- vm_eval.c (revision 49935) +++ vm_eval.c (revision 49936) @@ -1132,7 +1132,7 @@ rb_iterate(VALUE (* it_proc) (VALUE), VA https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1132 retval = (*it_proc) (data1); } else { - const struct THROW_DATA *err = (struct THROW_DATA *)th->errinfo; + const struct vm_throw_data *err = (struct vm_throw_data *)th->errinfo; if (state == TAG_BREAK) { const rb_control_frame_t *escape_cfp = THROW_DATA_CATCH_FRAME(err); @@ -1881,7 +1881,7 @@ rb_throw_obj(VALUE tag, VALUE value) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1881 rb_exc_raise(rb_class_new_instance(numberof(desc), desc, rb_eUncaughtThrow)); } - th->errinfo = (VALUE)NEW_THROW_DATA(tag, NULL, TAG_THROW); + th->errinfo = (VALUE)THROW_DATA_NEW(tag, NULL, TAG_THROW); JUMP_TAG(TAG_THROW); } @@ -1996,7 +1996,7 @@ rb_catch_protect(VALUE t, rb_block_call_ https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1996 /* call with argc=1, argv = [tag], block = Qnil to insure compatibility */ val = (*func)(tag, data, 1, (const VALUE *)&tag, Qnil); } - else if (state == TAG_THROW && THROW_DATA_VAL((struct THROW_DATA *)th->errinfo) == tag) { + else if (state == TAG_THROW && THROW_DATA_VAL((struct vm_throw_data *)th->errinfo) == tag) { rb_vm_rewind_cfp(th, saved_cfp); val = th->tag->retval; th->errinfo = Qnil; Index: gc.c =================================================================== --- gc.c (revision 49935) +++ gc.c (revision 49936) @@ -383,6 +383,7 @@ typedef struct RVALUE { https://github.com/ruby/ruby/blob/trunk/gc.c#L383 union { rb_cref_t cref; struct vm_svar svar; + struct vm_throw_data throw_data; } imemo; struct { struct RBasic basic; @@ -4163,6 +4164,9 @@ gc_mark_children(rb_objspace_t *objspace https://github.com/ruby/ruby/blob/trunk/gc.c#L4164 gc_mark(objspace, RANY(obj)->as.imemo.svar.backref); gc_mark(objspace, RANY(obj)->as.imemo.svar.others); return; + case imemo_throw_data: + gc_mark(objspace, RANY(obj)->as.imemo.throw_data.throw_obj); + return; default: rb_bug("T_IMEMO: unreachable"); } Index: internal.h =================================================================== --- internal.h (revision 49935) +++ internal.h (revision 49936) @@ -533,6 +533,7 @@ enum imemo_type { https://github.com/ruby/ruby/blob/trunk/internal.h#L533 imemo_none, imemo_cref, imemo_svar, + imemo_throw_data, imemo_mask = 0x07 }; @@ -645,6 +646,18 @@ struct vm_svar { https://github.com/ruby/ruby/blob/trunk/internal.h#L646 const VALUE others; }; +/* THROW_DATA */ + +struct vm_throw_data { + VALUE flags; + VALUE reserved; + const VALUE throw_obj; + const struct rb_control_frame_struct *catch_frame; + VALUE throw_state; +}; + +#define THROW_DATA_P(err) RB_TYPE_P((err), T_IMEMO) + /* MEMO */ struct MEMO { Index: vm.c =================================================================== --- vm.c (revision 49935) +++ vm.c (revision 49936) @@ -1176,7 +1176,7 @@ vm_iter_break(rb_thread_t *th, VALUE val https://github.com/ruby/ruby/blob/trunk/vm.c#L1176 rb_control_frame_t *target_cfp = rb_vm_search_cf_from_ep(th, cfp, ep); th->state = TAG_BREAK; - th->errinfo = (VALUE)NEW_THROW_DATA(val, target_cfp, TAG_BREAK); + th->errinfo = (VALUE)THROW_DATA_NEW(val, target_cfp, TAG_BREAK); TH_JUMP_TAG(th, TAG_BREAK); } @@ -1421,7 +1421,7 @@ vm_exec(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/vm.c#L1421 int state; VALUE result; VALUE initial = 0; - struct THROW_DATA *err; + struct vm_throw_data *err; TH_PUSH_TAG(th); _tag.retval = Qnil; @@ -1429,7 +1429,7 @@ vm_exec(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/vm.c#L1429 vm_loop_start: result = vm_exec_core(th, initial); if ((state = th->state) != 0) { - err = (struct THROW_DATA *)result; + err = (struct vm_throw_data *)result; th->state = 0; goto exception_handler; } @@ -1444,7 +1444,7 @@ vm_exec(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/vm.c#L1444 VALUE type; const rb_control_frame_t *escape_cfp; - err = (struct THROW_DATA *)th->errinfo; + err = (struct vm_throw_data *)th->errinfo; exception_handler: cont_pc = cont_sp = catch_iseqval = 0; Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 49935) +++ vm_insnhelper.c (revision 49936) @@ -642,7 +642,7 @@ vm_throw_continue(rb_thread_t *th, VALUE https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L642 th->state = TAG_THROW; } else if (THROW_DATA_P(err)) { - th->state = THROW_DATA_STATE((struct THROW_DATA *)err); + th->state = THROW_DATA_STATE((struct vm_throw_data *)err); } else { th->state = TAG_RAISE; @@ -781,7 +781,7 @@ vm_throw_start(rb_thread_t * const th, r https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L781 } th->state = state; - return (VALUE)NEW_THROW_DATA(throwobj, escape_cfp, state); + return (VALUE)THROW_DATA_NEW(throwobj, escape_cfp, state); } static VALUE Index: vm_insnhelper.h =================================================================== --- vm_insnhelper.h (revision 49935) +++ vm_insnhelper.h (revision 49936) @@ -229,46 +229,38 @@ enum vm_regan_acttype { https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.h#L229 static VALUE make_no_method_exception(VALUE exc, const char *format, VALUE obj, int argc, const VALUE *argv); -struct THROW_DATA { - VALUE flags; - VALUE reserved; - VALUE throw_obj; - const rb_control_frame_t *catch_frame; - VALUE throw_state; -}; - -static inline struct THROW_DATA * -NEW_THROW_DATA(VALUE val, rb_control_frame_t *cf, VALUE st) +static inline struct vm_throw_data * +THROW_DATA_NEW(VALUE val, rb_control_frame_t *cf, VALUE st) { - return (struct THROW_DATA *)rb_node_newnode(NODE_LIT, val, (VALUE)cf, st); + return (struct vm_throw_data *)rb_imemo_new(imemo_throw_data, val, (VALUE)cf, st, 0); } static inline void -THROW_DATA_CATCH_FRAME_SET(struct THROW_DATA *obj, const rb_control_frame_t *cfp) +THROW_DATA_CATCH_FRAME_SET(struct vm_throw_data *obj, const rb_control_frame_t *cfp) { obj->catch_frame = cfp; } static inline void -THROW_DATA_STATE_SET(struct THROW_DATA *obj, int st) +THROW_DATA_STATE_SET(struct vm_throw_data *obj, int st) { obj->throw_state = (VALUE)st; } static inline VALUE -THROW_DATA_VAL(const struct THROW_DATA *obj) +THROW_DATA_VAL(const struct vm_throw_data *obj) { return obj->throw_obj; } static inline const rb_control_frame_t * -THROW_DATA_CATCH_FRAME(const struct THROW_DATA *obj) +THROW_DATA_CATCH_FRAME(const struct vm_throw_data *obj) { return obj->catch_frame; } static int -THROW_DATA_STATE(const struct THROW_DATA *obj) +THROW_DATA_STATE(const struct vm_throw_data *obj) { return (int)obj->throw_state; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/