ruby-changes:40054
From: nobu <ko1@a...>
Date: Fri, 16 Oct 2015 00:55:01 +0900 (JST)
Subject: [ruby-changes:40054] nobu:r52135 (trunk): proc.c: refine ifunc checks
nobu 2015-10-16 00:54:48 +0900 (Fri, 16 Oct 2015) New Revision: 52135 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52135 Log: proc.c: refine ifunc checks * proc.c (IS_METHOD_PROC_IFUNC): separate from IS_METHOD_PROC_ISEQ for vm_ifunc. * proc.c (rb_proc_get_iseq): use RUBY_VM_IFUNC_P to see if iseq is an ifunc. * proc.c (rb_proc_get_iseq, proc_binding): reduce redundant checsk by IS_METHOD_PROC_IFUNC. Modified files: trunk/proc.c Index: proc.c =================================================================== --- proc.c (revision 52134) +++ proc.c (revision 52135) @@ -40,7 +40,10 @@ static int method_min_max_arity(VALUE, i https://github.com/ruby/ruby/blob/trunk/proc.c#L40 /* Proc */ -#define IS_METHOD_PROC_ISEQ(iseq) (RUBY_VM_IFUNC_P(iseq) && ((struct vm_ifunc *)(iseq))->func == bmcall) +#define IS_METHOD_PROC_IFUNC(ifunc) ((ifunc)->func == bmcall) +#define IS_METHOD_PROC_ISEQ(iseq) \ + (RUBY_VM_IFUNC_P(iseq) && \ + IS_METHOD_PROC_IFUNC((struct vm_ifunc *)(iseq))) static void proc_mark(void *ptr) @@ -952,10 +955,10 @@ rb_proc_get_iseq(VALUE self, int *is_pro https://github.com/ruby/ruby/blob/trunk/proc.c#L955 GetProcPtr(self, proc); iseq = proc->block.iseq; if (is_proc) *is_proc = !proc->is_lambda; - if (!RUBY_VM_NORMAL_ISEQ_P(iseq)) { + if (RUBY_VM_IFUNC_P(iseq)) { const struct vm_ifunc *ifunc = (struct vm_ifunc *)iseq; iseq = 0; - if (IS_METHOD_PROC_ISEQ(ifunc)) { + if (IS_METHOD_PROC_IFUNC(ifunc)) { /* method(:foo).to_proc */ iseq = rb_method_iseq((VALUE)ifunc->data); if (is_proc) *is_proc = 0; @@ -2607,8 +2610,9 @@ proc_binding(VALUE self) https://github.com/ruby/ruby/blob/trunk/proc.c#L2610 envval = rb_vm_proc_envval(proc); iseq = proc->block.iseq; if (RUBY_VM_IFUNC_P(iseq)) { - if (IS_METHOD_PROC_ISEQ(iseq)) { - VALUE method = (VALUE)((struct vm_ifunc *)iseq)->data; + struct vm_ifunc *ifunc = (struct vm_ifunc *)iseq; + if (IS_METHOD_PROC_IFUNC(ifunc)) { + VALUE method = (VALUE)ifunc->data; envval = env_clone(envval, method_receiver(method), method_cref(method)); } else { @@ -2620,9 +2624,10 @@ proc_binding(VALUE self) https://github.com/ruby/ruby/blob/trunk/proc.c#L2624 GetBindingPtr(bindval, bind); bind->env = envval; - if (!RUBY_VM_NORMAL_ISEQ_P(iseq)) { - if (IS_METHOD_PROC_ISEQ(iseq)) { - VALUE method = (VALUE)((struct vm_ifunc *)iseq)->data; + if (RUBY_VM_IFUNC_P(iseq)) { + struct vm_ifunc *ifunc = (struct vm_ifunc *)iseq; + if (IS_METHOD_PROC_IFUNC(ifunc)) { + VALUE method = (VALUE)ifunc->data; iseq = rb_method_iseq(method); } else { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/