ruby-changes:38701
From: ko1 <ko1@a...>
Date: Fri, 5 Jun 2015 20:42:54 +0900 (JST)
Subject: [ruby-changes:38701] ko1:r50782 (trunk): * internal.h: move definition of rb_cref_t to method.h.
ko1 2015-06-05 20:42:34 +0900 (Fri, 05 Jun 2015) New Revision: 50782 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50782 Log: * internal.h: move definition of rb_cref_t to method.h. * eval_intern.h: move definition of rb_scope_visibility_t to method.h. * method.h: change rb_cref_t::scope_visi from VALUE to rb_scope_visibility_t. [Bug #11219] * vm.c (vm_cref_new): accept rb_method_visibility_t directly. * vm_insnhelper.c (rb_vm_rewrite_cref): don't use 0, but METHOD_VISI_UNDEF. * vm_method.c (rb_scope_visibility_set): don't need to use cast. * vm_method.c (rb_scope_module_func_set): ditto. Modified files: trunk/ChangeLog trunk/eval_intern.h trunk/internal.h trunk/method.h trunk/vm.c trunk/vm_insnhelper.c trunk/vm_method.c Index: eval_intern.h =================================================================== --- eval_intern.h (revision 50781) +++ eval_intern.h (revision 50782) @@ -228,22 +228,17 @@ CREF_NEXT_SET(rb_cref_t *cref, const rb_ https://github.com/ruby/ruby/blob/trunk/eval_intern.h#L228 RB_OBJ_WRITE(cref, &cref->next, next_cref); } -typedef struct rb_scope_visi_struct { - rb_method_visibility_t method_visi : 3; - unsigned int module_func : 1; -} rb_scope_visibility_t; - static inline const rb_scope_visibility_t * CREF_SCOPE_VISI(const rb_cref_t *cref) { - return (const rb_scope_visibility_t *)&cref->scope_visi; + return &cref->scope_visi; } static inline void -CREF_SCOPE_VISI_COPY(const rb_cref_t *dst_cref, rb_cref_t *src_cref) +CREF_SCOPE_VISI_COPY(rb_cref_t *dst_cref, const rb_cref_t *src_cref) { - rb_scope_visibility_t *src = (rb_scope_visibility_t *)&src_cref->scope_visi; - rb_scope_visibility_t *dst = (rb_scope_visibility_t *)&dst_cref->scope_visi; + const rb_scope_visibility_t *src = &src_cref->scope_visi; + rb_scope_visibility_t *dst = &dst_cref->scope_visi; dst->method_visi = src->method_visi; dst->module_func = src->module_func; Index: method.h =================================================================== --- method.h (revision 50781) +++ method.h (revision 50782) @@ -21,6 +21,28 @@ https://github.com/ruby/ruby/blob/trunk/method.h#L21 # endif #endif +/* cref */ + +typedef enum { + METHOD_VISI_UNDEF = 0x00, + METHOD_VISI_PUBLIC = 0x01, + METHOD_VISI_PRIVATE = 0x02, + METHOD_VISI_PROTECTED = 0x03 +} rb_method_visibility_t; + +typedef struct rb_scope_visi_struct { + rb_method_visibility_t method_visi : 3; + unsigned int module_func : 1; +} rb_scope_visibility_t; + +typedef struct rb_cref_struct { + VALUE flags; + const VALUE refinements; + const VALUE klass; + struct rb_cref_struct * const next; + rb_scope_visibility_t scope_visi; +} rb_cref_t; + /* method data type */ typedef struct rb_method_entry_struct { @@ -32,13 +54,6 @@ typedef struct rb_method_entry_struct { https://github.com/ruby/ruby/blob/trunk/method.h#L54 } rb_method_entry_t; typedef enum { - METHOD_VISI_UNDEF = 0x00, - METHOD_VISI_PUBLIC = 0x01, - METHOD_VISI_PRIVATE = 0x02, - METHOD_VISI_PROTECTED = 0x03 -} rb_method_visibility_t; - -typedef enum { VM_METHOD_TYPE_ISEQ, VM_METHOD_TYPE_CFUNC, VM_METHOD_TYPE_ATTRSET, Index: ChangeLog =================================================================== --- ChangeLog (revision 50781) +++ ChangeLog (revision 50782) @@ -1,3 +1,23 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Jun 5 20:37:10 2015 Koichi Sasada <ko1@a...> + + * internal.h: move definition of rb_cref_t to method.h. + + * eval_intern.h: move definition of rb_scope_visibility_t + to method.h. + + * method.h: change rb_cref_t::scope_visi from VALUE to + rb_scope_visibility_t. + [Bug #11219] + + * vm.c (vm_cref_new): accept rb_method_visibility_t directly. + + * vm_insnhelper.c (rb_vm_rewrite_cref): don't use 0, + but METHOD_VISI_UNDEF. + + * vm_method.c (rb_scope_visibility_set): don't need to use cast. + + * vm_method.c (rb_scope_module_func_set): ditto. + Fri Jun 5 17:27:30 2015 Eric Wong <e@8...> * ext/socket/ancdata.c (bsock_sendmsg_internal): avoid msg_control Index: vm_method.c =================================================================== --- vm_method.c (revision 50781) +++ vm_method.c (revision 50782) @@ -959,7 +959,7 @@ rb_scope_module_func_check(void) https://github.com/ruby/ruby/blob/trunk/vm_method.c#L959 void rb_scope_visibility_set(rb_method_visibility_t visi) { - rb_scope_visibility_t *scope_visi = (rb_scope_visibility_t *)&rb_vm_cref()->scope_visi; + rb_scope_visibility_t *scope_visi = &rb_vm_cref()->scope_visi; scope_visi->method_visi = visi; scope_visi->module_func = FALSE; } @@ -967,7 +967,7 @@ rb_scope_visibility_set(rb_method_visibi https://github.com/ruby/ruby/blob/trunk/vm_method.c#L967 static void rb_scope_module_func_set(void) { - rb_scope_visibility_t *scope_visi = (rb_scope_visibility_t *)&rb_vm_cref()->scope_visi; + rb_scope_visibility_t *scope_visi = &rb_vm_cref()->scope_visi; scope_visi->method_visi = METHOD_VISI_PRIVATE; scope_visi->module_func = TRUE; } Index: internal.h =================================================================== --- internal.h (revision 50781) +++ internal.h (revision 50782) @@ -545,15 +545,7 @@ imemo_type(VALUE imemo) https://github.com/ruby/ruby/blob/trunk/internal.h#L545 return (RBASIC(imemo)->flags >> FL_USHIFT) & imemo_mask; } -/* CREF */ - -typedef struct rb_cref_struct { - VALUE flags; - const VALUE refinements; - const VALUE klass; - VALUE scope_visi; - struct rb_cref_struct * const next; -} rb_cref_t; +/* CREF in method.h */ /* SVAR */ Index: vm.c =================================================================== --- vm.c (revision 50781) +++ vm.c (revision 50782) @@ -80,10 +80,16 @@ rb_vm_control_frame_block_ptr(const rb_c https://github.com/ruby/ruby/blob/trunk/vm.c#L80 } static rb_cref_t * -vm_cref_new(VALUE klass, long visi, const rb_cref_t *prev_cref) +vm_cref_new(VALUE klass, rb_method_visibility_t visi, const rb_cref_t *prev_cref) { - rb_cref_t *cref = (rb_cref_t *)rb_imemo_new(imemo_cref, klass, visi, (VALUE)prev_cref, Qnil); - return cref; + union { + rb_scope_visibility_t visi; + VALUE value; + } scope_visi; + scope_visi.visi.method_visi = visi; + scope_visi.visi.module_func = 0; + + return (rb_cref_t *)rb_imemo_new(imemo_cref, klass, (VALUE)prev_cref, scope_visi.value, Qnil); } static rb_cref_t * Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 50781) +++ vm_insnhelper.c (revision 50782) @@ -471,13 +471,13 @@ rb_vm_rewrite_cref(rb_cref_t *cref, VALU https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L471 while (cref) { if (CREF_CLASS(cref) == old_klass) { - new_cref = vm_cref_new(new_klass, 0, NULL); + new_cref = vm_cref_new(new_klass, METHOD_VISI_UNDEF, NULL); COPY_CREF_OMOD(new_cref, cref); CREF_NEXT_SET(new_cref, CREF_NEXT(cref)); *new_cref_ptr = new_cref; return; } - new_cref = vm_cref_new(CREF_CLASS(cref), 0, NULL); + new_cref = vm_cref_new(CREF_CLASS(cref), METHOD_VISI_UNDEF, NULL); COPY_CREF_OMOD(new_cref, cref); cref = CREF_NEXT(cref); *new_cref_ptr = new_cref; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/