summaryrefslogtreecommitdiff
path: root/vm_method.c
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-18 02:32:17 (GMT)
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-18 02:32:17 (GMT)
commitf211abcb9c8c82c2e70d3d20ad40883ce446d0ac (patch)
tree8b8c74b52b12fccec0eeef41c05e71cf24b5c7b0 /vm_method.c
parent68bac3cca4d8975d9f8ac2e4772471a30c604b12 (diff)
* vm_method.c (rb_method_entry_make, check_override_opt_method):
should check whether a newly created method override a optimize method in case the method is defined in a prepended module of a built-in class. [ruby-core:72226] [Bug #11836] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_method.c')
-rw-r--r--vm_method.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/vm_method.c b/vm_method.c
index eff6b94..24f37dc 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -25,6 +25,7 @@
#define GLOBAL_METHOD_CACHE(c,m) (rb_bug("global method cache disabled improperly"), NULL)
#endif
+static int vm_redefinition_check_flag(VALUE klass);
static void rb_vm_check_redefinition_opt_method(const rb_method_entry_t *me, VALUE klass);
#define object_id idObject_id
@@ -468,6 +469,22 @@ rb_add_refined_method_entry(VALUE refined_class, ID mid)
}
}
+static void
+check_override_opt_method(VALUE klass, VALUE arg)
+{
+ ID mid = (ID)arg;
+ const rb_method_entry_t *me, *newme;
+
+ if (vm_redefinition_check_flag(klass)) {
+ me = lookup_method_table(RCLASS_ORIGIN(klass), mid);
+ if (me) {
+ newme = rb_method_entry(klass, mid);
+ if (newme != me) rb_vm_check_redefinition_opt_method(me, me->owner);
+ }
+ }
+ rb_class_foreach_subclass(klass, check_override_opt_method, (VALUE)mid);
+}
+
/*
* klass->method_table[mid] = method_entry(defined_class, visi, def)
*
@@ -579,6 +596,11 @@ rb_method_entry_make(VALUE klass, ID mid, VALUE defined_class, rb_method_visibil
VM_ASSERT(me->def != NULL);
+ /* check optimized method override by a prepended module */
+ if (RB_TYPE_P(klass, T_MODULE)) {
+ check_override_opt_method(klass, (VALUE)mid);
+ }
+
return me;
}