[前][次][番号順一覧][スレッド一覧]

ruby-changes:38711

From: ko1 <ko1@a...>
Date: Sat, 6 Jun 2015 19:20:06 +0900 (JST)
Subject: [ruby-changes:38711] ko1:r50792 (trunk): * method.h: back to share rb_method_definition_t by

ko1	2015-06-06 19:19:48 +0900 (Sat, 06 Jun 2015)

  New Revision: 50792

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50792

  Log:
    * method.h: back to share rb_method_definition_t by
      rb_method_entry_t.
      r50728 changed sharing `def's to isolating `def's
      on alias and so on. However, this change conflicts
      future improvement plan. So I change back to sharing approach.
    * method.h: move rb_method_definition_t::flags to
      rb_method_entry_t::attr::flags.
      rb_method_entry_t::attr is union with VALUE because this field
      should have same size of VALUE. rb_method_entry_t is T_IMEMO).
      And also add the following access macros to it's fileds.
      * METHOD_ENTRY_VISI(me)
      * METHOD_ENTRY_BASIC(me)
      * METHOD_ENTRY_SAFE(me)
    * vm_method.c (rb_method_definition_addref): added instead of
      rb_method_definition_clone().
      Do not create new definition, but increment alias_count.
    * class.c (clone_method): catch up this fix.
    * class.c (method_entry_i): ditto.
    * proc.c (mnew_internal): ditto.
    * proc.c (mnew_missing): ditto.
    * vm_eval.c: ditto.
    * vm_insnhelper.c: ditto.
    * vm_method.c: ditto.

  Modified files:
    trunk/ChangeLog
    trunk/class.c
    trunk/method.h
    trunk/proc.c
    trunk/vm_eval.c
    trunk/vm_insnhelper.c
    trunk/vm_method.c
Index: method.h
===================================================================
--- method.h	(revision 50791)
+++ method.h	(revision 50792)
@@ -47,12 +47,25 @@ typedef struct rb_cref_struct { https://github.com/ruby/ruby/blob/trunk/method.h#L47
 
 typedef struct rb_method_entry_struct {
     VALUE flags;
-    VALUE reserved;
+
+    union {
+	struct {
+	    rb_method_visibility_t visi: 3;
+	    unsigned int safe: 3;
+	    unsigned int basic: 1;
+	} flags;
+	VALUE v; /* it should be VALUE size */
+    } attr;
+
     struct rb_method_definition_struct * const def;
     ID called_id;
     const VALUE klass;    /* should be marked */
 } rb_method_entry_t;
 
+#define METHOD_ENTRY_VISI(me)  (me)->attr.flags.visi
+#define METHOD_ENTRY_BASIC(me) (me)->attr.flags.basic
+#define METHOD_ENTRY_SAFE(me)  (me)->attr.flags.safe
+
 typedef enum {
     VM_METHOD_TYPE_ISEQ,
     VM_METHOD_TYPE_CFUNC,
@@ -97,12 +110,8 @@ typedef struct rb_method_refined_struct https://github.com/ruby/ruby/blob/trunk/method.h#L110
 } rb_method_refined_t;
 
 typedef struct rb_method_definition_struct {
-    struct {
-	rb_method_visibility_t visi: 3;
-	unsigned int safe: 3;
-	unsigned int basic: 1;
-    } flags;
     rb_method_type_t type; /* method type */
+    int alias_count;
 
     union {
 	rb_method_iseq_t iseq;
@@ -120,7 +129,6 @@ typedef struct rb_method_definition_stru https://github.com/ruby/ruby/blob/trunk/method.h#L129
 	} optimize_type;
     } body;
 
-    int *alias_count_ptr;
     ID original_id;
 } rb_method_definition_t;
 
@@ -157,7 +165,7 @@ VALUE rb_obj_method_location(VALUE obj, https://github.com/ruby/ruby/blob/trunk/method.h#L165
 void rb_free_method_entry(const rb_method_entry_t *me);
 void rb_sweep_method_entry(void *vm);
 
-rb_method_entry_t *rb_method_entry_create(ID called_id, VALUE klass, rb_method_definition_t *def);
+rb_method_entry_t *rb_method_entry_create(ID called_id, VALUE klass, rb_method_visibility_t visi, rb_method_definition_t *def);
 rb_method_entry_t *rb_method_entry_clone(const rb_method_entry_t *me);
 void rb_method_entry_copy(rb_method_entry_t *dst, const rb_method_entry_t *src);
 
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 50791)
+++ ChangeLog	(revision 50792)
@@ -1,3 +1,43 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Jun  6 18:23:41 2015  Koichi Sasada  <ko1@a...>
+
+	* method.h: back to share rb_method_definition_t by
+	  rb_method_entry_t.
+
+	  r50728 changed sharing `def's to isolating `def's
+	  on alias and so on. However, this change conflicts
+	  future improvement plan. So I change back to sharing approach.
+
+	* method.h: move rb_method_definition_t::flags to
+	  rb_method_entry_t::attr::flags.
+
+	  rb_method_entry_t::attr is union with VALUE because this field
+	  should have same size of VALUE. rb_method_entry_t is T_IMEMO).
+
+	  And also add the following access macros to it's fileds.
+
+	  * METHOD_ENTRY_VISI(me)
+	  * METHOD_ENTRY_BASIC(me)
+	  * METHOD_ENTRY_SAFE(me)
+
+	* vm_method.c (rb_method_definition_addref): added instead of
+	  rb_method_definition_clone().
+
+	  Do not create new definition, but increment alias_count.
+
+	* class.c (clone_method): catch up this fix.
+
+	* class.c (method_entry_i): ditto.
+
+	* proc.c (mnew_internal): ditto.
+
+	* proc.c (mnew_missing): ditto.
+
+	* vm_eval.c: ditto.
+
+	* vm_insnhelper.c: ditto.
+
+	* vm_method.c: ditto.
+
 Sat Jun  6 15:59:38 2015  Koichi Sasada  <ko1@a...>
 
 	* class.c: ins_methods_push() needs rb_method_visibility_t type on
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 50791)
+++ vm_eval.c	(revision 50792)
@@ -387,7 +387,7 @@ check_funcall_respond_to(rb_thread_t *th https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L387
     VALUE defined_class;
     const rb_method_entry_t *me = rb_method_entry(klass, idRespond_to, &defined_class);
 
-    if (me && !me->def->flags.basic) {
+    if (me && !METHOD_ENTRY_BASIC(me)) {
 	const rb_block_t *passed_block = th->passed_block;
 	VALUE args[2], result;
 	int arity = rb_method_entry_arity(me);
@@ -570,7 +570,7 @@ rb_method_call_status(rb_thread_t *th, c https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L570
     }
     klass = me->klass;
     oid = me->def->original_id;
-    visi = me->def->flags.visi;
+    visi = METHOD_ENTRY_VISI(me);
 
     if (oid != idMethodMissing) {
 	/* receiver specified form for private method */
@@ -592,7 +592,7 @@ rb_method_call_status(rb_thread_t *th, c https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L592
 		}
 	    }
 
-	    if (me->def->flags.safe > th->safe_level) {
+	    if (METHOD_ENTRY_SAFE(me) > th->safe_level) {
 		rb_raise(rb_eSecurityError, "calling insecure method: %"PRIsVALUE, rb_id2str(me->called_id));
 	    }
 	}
Index: proc.c
===================================================================
--- proc.c	(revision 50791)
+++ proc.c	(revision 50792)
@@ -1161,11 +1161,11 @@ mnew_missing(VALUE rclass, VALUE klass, https://github.com/ruby/ruby/blob/trunk/proc.c#L1161
     data->id = rid;
 
     def = ZALLOC(rb_method_definition_t);
-    def->flags.visi = METHOD_VISI_UNDEF;
     def->type = VM_METHOD_TYPE_MISSING;
     def->original_id = id;
 
-    me = rb_method_entry_create(id, klass, def);
+    me = rb_method_entry_create(id, klass, METHOD_VISI_UNDEF, def);
+
     RB_OBJ_WRITE(method, &data->me, me);
 
     OBJ_INFECT(method, klass);
@@ -1181,7 +1181,6 @@ mnew_internal(const rb_method_entry_t *m https://github.com/ruby/ruby/blob/trunk/proc.c#L1181
     VALUE rclass = klass;
     VALUE method;
     ID rid = id;
-    rb_method_definition_t *def = 0;
     rb_method_visibility_t visi = METHOD_VISI_UNDEF;
 
   again:
@@ -1192,17 +1191,16 @@ mnew_internal(const rb_method_entry_t *m https://github.com/ruby/ruby/blob/trunk/proc.c#L1191
 	if (!error) return Qnil;
 	rb_print_undef(klass, id, 0);
     }
-    def = me->def;
     if (visi == METHOD_VISI_UNDEF) {
-	visi = def->flags.visi;
+	visi = METHOD_ENTRY_VISI(me);
 	if (scope && (visi != METHOD_VISI_PUBLIC)) {
 	    if (!error) return Qnil;
 	    rb_print_inaccessible(klass, id, visi);
 	}
     }
-    if (def->type == VM_METHOD_TYPE_ZSUPER) {
+    if (me->def->type == VM_METHOD_TYPE_ZSUPER) {
 	klass = RCLASS_SUPER(defined_class);
-	id = def->original_id;
+	id = me->def->original_id;
 	me = rb_method_entry_without_refinements(klass, id, &defined_class);
 	goto again;
     }
Index: vm_method.c
===================================================================
--- vm_method.c	(revision 50791)
+++ vm_method.c	(revision 50792)
@@ -134,23 +134,17 @@ static void https://github.com/ruby/ruby/blob/trunk/vm_method.c#L134
 rb_method_definition_release(rb_method_definition_t *def)
 {
     if (def != NULL) {
-	if (def->alias_count_ptr == NULL) {
-	    if (METHOD_DEBUG) fprintf(stderr, " %p-%s:NULL\n", def, rb_id2name(def->original_id));
+	const int count = def->alias_count;
+	if (METHOD_DEBUG) assert(count >= 0);
+
+	if (count == 0) {
+	    if (METHOD_DEBUG) fprintf(stderr, "-%p-%s:%d\n", def, rb_id2name(def->original_id), count);
+	    xfree(def);
 	}
 	else {
-	    int *iptr = def->alias_count_ptr;
-
-	    if (*iptr == 0) {
-		if (METHOD_DEBUG) fprintf(stderr, "-%p-%s:%d\n", def, rb_id2name(def->original_id), *iptr);
-		xfree(iptr);
-	    }
-	    else {
-		if (METHOD_DEBUG) fprintf(stderr, "-%p-%s:%d->%d\n", def, rb_id2name(def->original_id), *iptr, *iptr-1);
-		*iptr -= 1;
-	    }
+	    if (METHOD_DEBUG) fprintf(stderr, "-%p-%s:%d->%d\n", def, rb_id2name(def->original_id), count, count-1);
+	    def->alias_count--;
 	}
-
-	xfree(def);
     }
 }
 
@@ -293,13 +287,9 @@ rb_method_definition_set(rb_method_defin https://github.com/ruby/ruby/blob/trunk/vm_method.c#L287
 }
 
 static rb_method_definition_t *
-rb_method_definition_create(rb_method_visibility_t visi, rb_method_type_t type, ID mid, void *opts)
+rb_method_definition_create(rb_method_type_t type, ID mid, void *opts)
 {
     rb_method_definition_t *def = ZALLOC(rb_method_definition_t);
-    /* def->alias_count_ptr = NULL; already cleared */
-    def->flags.visi = visi;
-    def->flags.basic = ruby_running ? FALSE : TRUE;
-    def->flags.safe = rb_safe_level();
     def->type = type;
     def->original_id = mid;
     if (opts != NULL) rb_method_definition_set(def, opts);
@@ -334,47 +324,40 @@ rb_method_definition_reset(const rb_meth https://github.com/ruby/ruby/blob/trunk/vm_method.c#L324
 }
 
 static rb_method_definition_t *
-rb_method_definition_clone(rb_method_definition_t *src_def)
+rb_method_definition_addref(rb_method_definition_t *def)
 {
-    int *iptr = src_def->alias_count_ptr;
-    rb_method_definition_t *def = rb_method_definition_create(src_def->flags.visi, src_def->type, src_def->original_id, NULL);
-
-    def->flags.basic = src_def->flags.basic;
-    def->flags.safe = src_def->flags.safe;
-    memcpy(&def->body, &src_def->body, sizeof(def->body));
-    def->alias_count_ptr = src_def->alias_count_ptr;
-
-    if (!src_def->alias_count_ptr) {
-	iptr = def->alias_count_ptr = src_def->alias_count_ptr = ALLOC(int);
-	*iptr = 0;
-    }
-    *iptr += 1;
-
-    if (METHOD_DEBUG) fprintf(stderr, "+%p-%s:%d\n", src_def, rb_id2name(src_def->original_id), *iptr);
-
+    def->alias_count++;
+    if (METHOD_DEBUG) fprintf(stderr, "+%p-%s:%d\n", def, rb_id2name(def->original_id), def->alias_count);
     return def;
 }
 
 rb_method_entry_t *
-rb_method_entry_create(ID called_id, VALUE klass, rb_method_definition_t *def)
+rb_method_entry_create(ID called_id, VALUE klass, rb_method_visibility_t visi, rb_method_definition_t *def)
 {
     rb_method_entry_t *me = (rb_method_entry_t *)rb_imemo_new(imemo_ment, (VALUE)NULL, (VALUE)called_id, (VALUE)klass, 0);
+    METHOD_ENTRY_VISI(me) = visi;
+    METHOD_ENTRY_BASIC(me) = ruby_running ? FALSE : TRUE;
+    METHOD_ENTRY_SAFE(me) = rb_safe_level();
     rb_method_definition_reset(me, def);
+
     assert(def != NULL);
+
     return me;
 }
 
 rb_method_entry_t *
 rb_method_entry_clone(const rb_method_entry_t *src_me)
 {
-    rb_method_entry_t *me = rb_method_entry_create(src_me->called_id, src_me->klass, rb_method_definition_clone(src_me->def));
+    rb_method_entry_t *me = rb_method_entry_create(src_me->called_id, src_me->klass,
+						   METHOD_ENTRY_VISI(src_me),
+						   rb_method_definition_addref(src_me->def));
     return me;
 }
 
 void
 rb_method_entry_copy(rb_method_entry_t *dst, const rb_method_entry_t *src)
 {
-    rb_method_definition_reset(dst, rb_method_definition_clone(src->def));
+    rb_method_definition_reset(dst, rb_method_definition_addref(src->def));
     dst->called_id = src->called_id;
     RB_OBJ_WRITE((VALUE)dst, &dst->klass, src->klass);
 }
@@ -388,8 +371,9 @@ make_method_entry_refined(rb_method_entr https://github.com/ruby/ruby/blob/trunk/vm_method.c#L371
 
     rb_vm_check_redefinition_opt_method(me, me->klass);
 
-    new_def = rb_method_definition_create(METHOD_VISI_PUBLIC, VM_METHOD_TYPE_REFINED, me->called_id, rb_method_entry_clone(me));
+    new_def = rb_method_definition_create(VM_METHOD_TYPE_REFINED, me->called_id, rb_method_entry_clone(me));
     rb_method_definition_reset(me, new_def);
+    METHOD_ENTRY_VISI(me) = METHOD_VISI_PUBLIC;
 }
 
 void
@@ -470,7 +454,7 @@ rb_method_entry_make(VALUE klass, ID mid https://github.com/ruby/ruby/blob/trunk/vm_method.c#L454
 
 	if (RTEST(ruby_verbose) &&
 	    type != VM_METHOD_TYPE_UNDEF &&
-	    (old_def->alias_count_ptr == NULL || *old_def->alias_count_ptr == 0) &&
+	    (old_def->alias_count == 0) &&
 	    old_def->type != VM_METHOD_TYPE_UNDEF &&
 	    old_def->type != VM_METHOD_TYPE_ZSUPER &&
 	    old_def->type != VM_METHOD_TYPE_ALIAS) {
@@ -496,9 +480,7 @@ rb_method_entry_make(VALUE klass, ID mid https://github.com/ruby/ruby/blob/trunk/vm_method.c#L480
 	}
     }
 
-    me = rb_method_entry_create(mid, defined_class, def);
-    def->flags.visi = visi;
-    def->flags.safe = rb_safe_level(); /* TODO: maybe we need to remove it. */
+    me = rb_method_entry_create(mid, defined_class, visi, def);
 
     rb_clear_method_cache_by_class(klass);
 
@@ -545,7 +527,7 @@ method_added(VALUE klass, ID mid) https://github.com/ruby/ruby/blob/trunk/vm_method.c#L527
 rb_method_entry_t *
 rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *opts, rb_method_visibility_t visi)
 {
-    rb_method_definition_t *def = rb_method_definition_create(visi, type, mid, opts);
+    rb_method_definition_t *def = rb_method_definition_create(type, mid, opts);
     rb_method_entry_t *me = rb_method_entry_make(klass, mid, type, def, visi, klass);
 
     if (me->def->type == VM_METHOD_TYPE_REFINED && me->def->body.refined.orig_me) { /* TODO: really needed? */
@@ -577,9 +559,9 @@ static rb_method_entry_t * https://github.com/ruby/ruby/blob/trunk/vm_method.c#L559
 method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *me,
 		 rb_method_visibility_t visi, VALUE defined_class)
 {
-    rb_method_definition_t *def = rb_method_definition_clone(me->def);
+    rb_method_definition_t *def = rb_method_definition_addref(me->def);
     rb_method_entry_t *newme = rb_method_entry_make(klass, mid, me->def->type, def, visi, defined_class);
-    def->flags.safe = me->def->flags.safe;
+    METHOD_ENTRY_SAFE(newme) = METHOD_ENTRY_SAFE(me);
     method_added(klass, mid);
     return newme;
 }
@@ -891,14 +873,14 @@ rb_export_method(VALUE klass, ID name, r https://github.com/ruby/ruby/blob/trunk/vm_method.c#L873
 	rb_print_undef(klass, name, 0);
     }
 
-    if (me->def->flags.visi != visi) {
+    if (METHOD_ENTRY_VISI(me) != visi) {
 	rb_vm_check_redefinition_opt_method(me, klass);
 
 	if (klass == defined_class || RCLASS_ORIGIN(klass) == defined_class) {
-	    me->def->flags.visi = visi;
+	    METHOD_ENTRY_VISI(me) = visi;
 
 	    if (me->def->type == VM_METHOD_TYPE_REFINED && me->def->body.refined.orig_me) {
-		me->def->body.refined.orig_me->def->flags.visi = visi;
+		METHOD_ENTRY_VISI((rb_method_entry_t *)me->def->body.refined.orig_me) = visi;
 	    }
 	    rb_clear_method_cache_by_class(klass);
 	}
@@ -917,15 +899,13 @@ rb_method_boundp(VALUE klass, ID id, int https://github.com/ruby/ruby/blob/trunk/vm_method.c#L899
     const rb_method_entry_t *me = rb_method_entry_without_refinements(klass, id, 0);
 
     if (me != 0) {
-	rb_method_definition_t *def = me->def;
-
 	if ((ex & ~BOUND_RESPONDS) &&
-	    ((def->flags.visi == METHOD_VISI_PRIVATE) ||
-	     ((ex & BOUND_RESPONDS) && (def->flags.visi == METHOD_VISI_PROTECTED)))) {
+	    ((METHOD_ENTRY_VISI(me) == METHOD_VISI_PRIVATE) ||
+	     ((ex & BOUND_RESPONDS) && (METHOD_ENTRY_VISI(me) == METHOD_VISI_PROTECTED)))) {
 	    return 0;
 	}
 
-	if (def->type == VM_METHOD_TYPE_NOTIMPLEMENTED) {
+	if (me->def->type == VM_METHOD_TYPE_NOTIMPLEMENTED) {
 	    if (ex & BOUND_RESPONDS) return 2;
 	    return 0;
 	}
@@ -1157,7 +1137,7 @@ check_definition(VALUE mod, VALUE mid, r https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1137
     if (!id) return Qfalse;
     me = rb_method_entry_without_refinements(mod, id, 0);
     if (me) {
-	if (me->def->flags.visi == visi) return Qtrue;
+	if (METHOD_ENTRY_VISI(me) == visi) return Qtrue;
     }
     return Qfalse;
 }
@@ -1401,11 +1381,11 @@ rb_alias(VALUE klass, ID alias_name, ID https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1381
     if (orig_me->def->type == VM_METHOD_TYPE_ZSUPER) {
 	klass = RCLASS_SUPER(klass);
 	original_name = orig_me->def->original_id;
-	visi = orig_me->def->flags.visi;
+	visi = METHOD_ENTRY_VISI(orig_me);
 	goto again;
     }
 
-    if (visi == METHOD_VISI_UNDEF) visi = orig_me->def->flags.visi;
+    if (visi == METHOD_VISI_UNDEF) visi = METHOD_ENTRY_VISI(orig_me);
 
     if (defined_class != target_klass) { /* inter class/module alias */
 	VALUE real_owner;
@@ -1423,7 +1403,7 @@ rb_alias(VALUE klass, ID alias_name, ID https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1403
 	RB_OBJ_WRITE(alias_me, &alias_me->klass, defined_class);
 	alias_me->def->original_id = orig_me->called_id;
 	*(ID *)&alias_me->def->body.alias.original_me->called_id = alias_name;
-	alias_me->def->flags.safe = orig_me->def->flags.safe;
+	METHOD_ENTRY_SAFE(alias_me) = METHOD_ENTRY_SAFE(orig_me);
     }
     else {
 	method_entry_set(target_klass, alias_name, orig_me, visi, defined_class);
@@ -1723,7 +1703,7 @@ int https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1703
 rb_method_basic_definition_p(VALUE klass, ID id)
 {
     const rb_method_entry_t *me = rb_method_entry(klass, id, 0);
-    return (me && me->def->flags.basic) ? TRUE : FALSE;
+    return (me && METHOD_ENTRY_BASIC(me)) ? TRUE : FALSE;
 }
 
 static inline int
Index: class.c
===================================================================
--- class.c	(revision 50791)
+++ class.c	(revision 50792)
@@ -248,11 +248,11 @@ clone_method(VALUE old_klass, VALUE new_ https://github.com/ruby/ruby/blob/trunk/class.c#L248
 	rb_cref_t *new_cref;
 	newiseqval = rb_iseq_clone(me->def->body.iseq.iseqptr->self, new_klass);
 	rb_vm_rewrite_cref(me->def->body.iseq.cref, old_klass, new_klass, &new_cref);
-	rb_add_method_iseq(new_klass, mid, newiseqval, new_cref, me->def->flags.visi);
+	rb_add_method_iseq(new_klass, mid, newiseqval, new_cref, METHOD_ENTRY_VISI(me));
 	RB_GC_GUARD(newiseqval);
     }
     else {
-	rb_method_entry_set(new_klass, mid, me, me->def->flags.visi);
+	rb_method_entry_set(new_klass, mid, me, METHOD_ENTRY_VISI(me));
     }
 }
 
@@ -1129,7 +1129,7 @@ method_entry_i(st_data_t key, st_data_t https://github.com/ruby/ruby/blob/trunk/class.c#L1129
 	    type = METHOD_VISI_UNDEF; /* none */
 	}
 	else {
-	    type = me->def->flags.visi;
+	    type = METHOD_ENTRY_VISI(me);
 	}
 	st_add_direct(arg->list, key, (st_data_t)type);
     }
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 50791)
+++ vm_insnhelper.c	(revision 50792)
@@ -1315,7 +1315,7 @@ vm_callee_setup_arg(rb_thread_t *th, rb_ https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1315
 
 	CI_SET_FASTPATH(ci,
 			(UNLIKELY(ci->flag & VM_CALL_TAILCALL) ? vm_call_iseq_setup_tailcall : vm_call_iseq_setup_normal),
-			(!IS_ARGS_SPLAT(ci) && !IS_ARGS_KEYWORD(ci) && !(ci->me->def->flags.visi == METHOD_VISI_PROTECTED)));
+			(!IS_ARGS_SPLAT(ci) && !IS_ARGS_KEYWORD(ci) && !(METHOD_ENTRY_VISI(ci->me) == METHOD_VISI_PROTECTED)));
     }
     else {
 	ci->aux.opt_pc = setup_parameters_complex(th, iseq, ci, argv, arg_setup_method);
@@ -1908,7 +1908,7 @@ vm_call_method(rb_thread_t *th, rb_contr https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1908
 
   start_method_dispatch:
     if (ci->me != 0) {
-	if (LIKELY(ci->me->def->flags.visi == METHOD_VISI_PUBLIC && ci->me->def->flags.safe == 0)) {
+	if (LIKELY(METHOD_ENTRY_VISI(ci->me) == METHOD_VISI_PUBLIC && METHOD_ENTRY_SAFE(ci->me) == 0)) {
 	    VALUE klass;
 
 	  normal_method_dispatch:
@@ -2036,7 +2036,7 @@ vm_call_method(rb_thread_t *th, rb_contr https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2036
 	}
 	else {
 	    int safe;
-	    if (!(ci->flag & VM_CALL_FCALL) && (ci->me->def->flags.visi == METHOD_VISI_PRIVATE)) {
+	    if (!(ci->flag & VM_CALL_FCALL) && (METHOD_ENTRY_VISI(ci->me) == METHOD_VISI_PRIVATE)) {
 		enum method_missing_reason stat = MISSING_PRIVATE;
 		bp();
 		if (ci->flag & VM_CALL_VCALL) stat |= MISSING_VCALL;
@@ -2045,7 +2045,7 @@ vm_call_method(rb_thread_t *th, rb_contr https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2045
 		CI_SET_FASTPATH(ci, vm_call_method_missing, 1);
 		return vm_call_method_missing(th, cfp, ci);
 	    }
-	    else if (!(ci->flag & VM_CALL_OPT_SEND) && (ci->me->def->flags.visi == METHOD_VISI_PROTECTED)) {
+	    else if (!(ci->flag & VM_CALL_OPT_SEND) && (METHOD_ENTRY_VISI(ci->me) == METHOD_VISI_PROTECTED)) {
 		enable_fastpath = 0;
 		if (!rb_obj_is_kind_of(cfp->self, ci->defined_class)) {
 		    ci->aux.method_missing_reason = MISSING_PROTECTED;
@@ -2055,7 +2055,7 @@ vm_call_method(rb_thread_t *th, rb_contr https://github.com/ruby/rub (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]