From 260d02d91d769f4ef3075e9248e1aae73e22a22b Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 3 Aug 2012 16:56:08 +0000 Subject: [PATCH] vm_insnhelper.c: no recv * vm_insnhelper.c (vm_search_normal_superclass): no longer needs receiver, klass is always unique in the ancestors now. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ insns.def | 4 ++-- vm_eval.c | 2 +- vm_insnhelper.c | 29 ++++++----------------------- 4 files changed, 14 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index e7e0627d37..7c565f105e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Aug 4 01:56:06 2012 Nobuyoshi Nakada + + * vm_insnhelper.c (vm_search_normal_superclass): no longer needs + receiver, klass is always unique in the ancestors now. + Sat Aug 4 01:27:40 2012 Shugo Maeda * insns.def (invokesuper): reverted r36612 so that super in an diff --git a/insns.def b/insns.def index 24e358d16f..fd102a63f5 100644 --- a/insns.def +++ b/insns.def @@ -828,7 +828,7 @@ defined case DEFINED_ZSUPER:{ const rb_method_entry_t *me = GET_CFP()->me; if (me) { - VALUE klass = vm_search_normal_superclass(me->klass, GET_SELF()); + VALUE klass = vm_search_normal_superclass(me->klass); ID id = me->def ? me->def->original_id : me->called_id; if (rb_method_boundp(klass, id, 0)) { expr_type = "super"; @@ -1039,7 +1039,7 @@ invokesuper flag = VM_CALL_SUPER_BIT | VM_CALL_FCALL_BIT; recv = GET_SELF(); - vm_search_superclass(GET_CFP(), GET_ISEQ(), recv, TOPN(num), &id, &klass); + vm_search_superclass(GET_CFP(), GET_ISEQ(), TOPN(num), &id, &klass); ip = GET_ISEQ(); while (ip && !ip->klass) { diff --git a/vm_eval.c b/vm_eval.c index a4f7843d0b..05d5d883b9 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -164,7 +164,7 @@ vm_call_super(rb_thread_t *th, int argc, const VALUE *argv) klass = RCLASS_SUPER(cfp->klass); if (klass == 0) { - klass = vm_search_normal_superclass(cfp->me->klass, recv); + klass = vm_search_normal_superclass(cfp->me->klass); } id = cfp->me->def->original_id; } diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 21bd4a5e06..7ea579a7bf 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -1461,32 +1461,15 @@ vm_method_search(VALUE id, VALUE klass, IC ic, VALUE *defined_class_ptr) } static inline VALUE -vm_search_normal_superclass(VALUE klass, VALUE recv) +vm_search_normal_superclass(VALUE klass) { - if (BUILTIN_TYPE(klass) == T_CLASS || BUILTIN_TYPE(klass) == T_ICLASS) { - klass = RCLASS_ORIGIN(klass); - return RCLASS_SUPER(klass); - } - else if (BUILTIN_TYPE(klass) == T_MODULE) { - VALUE k = CLASS_OF(recv); - while (k) { - if (BUILTIN_TYPE(k) == T_ICLASS && RBASIC(k)->klass == klass) { - return RCLASS_SUPER(k); - } - k = RCLASS_SUPER(k); - } - return rb_cObject; - } - else { - rb_bug("vm_search_normal_superclass: should not be reach here"); - } - - UNREACHABLE; + klass = RCLASS_ORIGIN(klass); + return RCLASS_SUPER(klass); } static void vm_search_superclass(rb_control_frame_t *reg_cfp, rb_iseq_t *iseq, - VALUE recv, VALUE sigval, + VALUE sigval, ID *idp, VALUE *klassp) { ID id; @@ -1532,10 +1515,10 @@ vm_search_superclass(rb_control_frame_t *reg_cfp, rb_iseq_t *iseq, } id = lcfp->me->def->original_id; - klass = vm_search_normal_superclass(lcfp->klass, recv); + klass = vm_search_normal_superclass(lcfp->klass); } else { - klass = vm_search_normal_superclass(reg_cfp->klass, recv); + klass = vm_search_normal_superclass(reg_cfp->klass); } *idp = id;