summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-30 02:11:59 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-30 02:11:59 +0000
commit9e449748744cbb28ede16ecb3064e3fcb0899022 (patch)
tree9d61dc0828e816c66f91aebdf2b2ee7a4e8411f2 /vm_insnhelper.c
parent696ebcd8cafece7c0ed6407af9679699a16a5c5a (diff)
* revert r37993 to avoid SEGV in tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c94
1 files changed, 3 insertions, 91 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index d242097771..c40f66bbe9 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1694,47 +1694,6 @@ vm_call_method_missing(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_inf
return vm_call_method(th, reg_cfp, &ci_entry);
}
-static VALUE
-copy_refinement_iclass(VALUE iclass, VALUE superclass)
-{
- VALUE result, c;
-
- Check_Type(iclass, T_ICLASS);
- c = result = rb_include_class_new(RBASIC(iclass)->klass, superclass);
- RCLASS_REFINED_CLASS(c) = RCLASS_REFINED_CLASS(iclass);
- iclass = RCLASS_SUPER(iclass);
- while (iclass && BUILTIN_TYPE(iclass) == T_ICLASS) {
- c = RCLASS_SUPER(c) = rb_include_class_new(RBASIC(iclass)->klass,
- RCLASS_SUPER(c));
- RCLASS_REFINED_CLASS(c) = RCLASS_REFINED_CLASS(iclass);
- iclass = RCLASS_SUPER(iclass);
- }
- return result;
-}
-
-static VALUE
-find_refinement(VALUE refinements, VALUE klass)
-{
- VALUE refinement;
-
- if (NIL_P(refinements)) {
- return Qnil;
- }
- refinement = rb_hash_lookup(refinements, klass);
- if (NIL_P(refinement) &&
- BUILTIN_TYPE(klass) == T_ICLASS) {
- refinement = rb_hash_lookup(refinements,
- RBASIC(klass)->klass);
- if (!NIL_P(refinement)) {
- refinement = copy_refinement_iclass(refinement, klass);
- }
- }
- return refinement;
-}
-
-static int rb_method_definition_eq(const rb_method_definition_t *d1, const rb_method_definition_t *d2);
-static VALUE vm_call_super_method(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_info_t *ci);
-
static inline VALUE
vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci)
{
@@ -1776,10 +1735,7 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci)
return vm_call_bmethod(th, cfp, ci);
}
case VM_METHOD_TYPE_ZSUPER:{
- VALUE klass;
-
- zsuper_method_dispatch:
- klass = RCLASS_SUPER(ci->me->klass);
+ VALUE klass = RCLASS_SUPER(ci->me->klass);
ci_temp = *ci;
ci = &ci_temp;
@@ -1822,44 +1778,6 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci)
break;
case VM_METHOD_TYPE_UNDEF:
break;
- case VM_METHOD_TYPE_REFINED:{
- NODE *cref = rb_vm_get_cref(cfp->iseq, cfp->ep);
- VALUE refinements = cref ? cref->nd_refinements : Qnil;
- VALUE refinement, defined_class;
- rb_method_entry_t orig_me, *me;
- ci_temp = *ci;
- ci = &ci_temp;
-
- refinement = find_refinement(refinements,
- ci->defined_class);
- if (NIL_P(refinement)) {
- goto no_refinement_dispatch;
- }
- me = rb_method_entry(refinement, ci->mid, &defined_class);
- if (me) {
- if (ci->call == vm_call_super_method &&
- cfp->me &&
- rb_method_definition_eq(me->def, cfp->me->def)) {
- goto no_refinement_dispatch;
- }
- ci->me = me;
- ci->defined_class = defined_class;
- if (me->def->type != VM_METHOD_TYPE_REFINED) {
- goto normal_method_dispatch;
- }
- }
-
- no_refinement_dispatch:
- if (ci->me->def->body.orig_def) {
- orig_me = *ci->me;
- orig_me.def = ci->me->def->body.orig_def;
- ci->me = &orig_me;
- goto normal_method_dispatch;
- }
- else {
- goto zsuper_method_dispatch;
- }
- }
}
rb_bug("vm_call_method: unsupported method type (%d)", ci->me->def->type);
}
@@ -1923,12 +1841,6 @@ vm_call_general(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_info_t *ci
return vm_call_method(th, reg_cfp, ci);
}
-static VALUE
-vm_call_super_method(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_info_t *ci)
-{
- return vm_call_method(th, reg_cfp, ci);
-}
-
/* super */
static inline VALUE
@@ -2017,7 +1929,7 @@ vm_search_super_method(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_inf
/* TODO: use inline cache */
ci->me = rb_method_entry(ci->klass, ci->mid, &ci->defined_class);
- ci->call = vm_call_super_method;
+ ci->call = vm_call_general;
while (iseq && !iseq->klass) {
iseq = iseq->parent_iseq;
@@ -2025,7 +1937,7 @@ vm_search_super_method(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_inf
if (ci->me && ci->me->def->type == VM_METHOD_TYPE_ISEQ && ci->me->def->body.iseq == iseq) {
ci->klass = RCLASS_SUPER(ci->defined_class);
- ci->me = rb_method_entry(ci->klass, ci->mid, &ci->defined_class);
+ ci->me = rb_method_entry_get_with_refinements(Qnil, ci->klass, ci->mid, &ci->defined_class);
}
}