ruby-changes:38021
From: nobu <ko1@a...>
Date: Sat, 28 Mar 2015 08:51:39 +0900 (JST)
Subject: [ruby-changes:38021] nobu:r50102 (trunk): vm_eval.c: simplify rb_iterate
nobu 2015-03-28 08:51:18 +0900 (Sat, 28 Mar 2015) New Revision: 50102 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50102 Log: vm_eval.c: simplify rb_iterate * internal.h (IFUNC_NEW): add argument for ID. * vm_eval.c (rb_iterate): create ifunnc only when it is used. Modified files: trunk/compile.c trunk/internal.h trunk/vm_eval.c Index: compile.c =================================================================== --- compile.c (revision 50101) +++ compile.c (revision 50102) @@ -5397,7 +5397,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L5397 */ int is_index = iseq->is_size++; VALUE once_iseq = NEW_CHILD_ISEQVAL( - (NODE *)IFUNC_NEW(build_postexe_iseq, node->nd_body), + (NODE *)IFUNC_NEW(build_postexe_iseq, node->nd_body, 0), make_name_for_block(iseq), ISEQ_TYPE_BLOCK, line); ADD_INSN2(ret, line, once, once_iseq, INT2FIX(is_index)); @@ -6315,7 +6315,7 @@ method_for_self(VALUE name, VALUE arg, r https://github.com/ruby/ruby/blob/trunk/compile.c#L6315 acc.arg = arg; acc.func = func; acc.line = caller_location(&path, &absolute_path); - return rb_iseq_new_with_opt((NODE *)IFUNC_NEW(build, (VALUE)&acc), + return rb_iseq_new_with_opt((NODE *)IFUNC_NEW(build, (VALUE)&acc, 0), rb_sym2str(name), path, absolute_path, INT2FIX(acc.line), 0, ISEQ_TYPE_METHOD, 0); } Index: vm_eval.c =================================================================== --- vm_eval.c (revision 50101) +++ vm_eval.c (revision 50102) @@ -1105,12 +1105,11 @@ rb_iterate(VALUE (* it_proc) (VALUE), VA https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1105 { int state; volatile VALUE retval = Qnil; - struct vm_ifunc *ifunc = IFUNC_NEW(bl_proc, data2); + struct vm_ifunc *ifunc = bl_proc ? + IFUNC_NEW(bl_proc, data2, rb_frame_this_func()) : 0; rb_thread_t *th = GET_THREAD(); rb_control_frame_t *volatile cfp = th->cfp; - ifunc->id = rb_frame_this_func(); - TH_PUSH_TAG(th); state = TH_EXEC_TAG(); if (state == 0) { @@ -1144,8 +1143,8 @@ rb_iterate(VALUE (* it_proc) (VALUE), VA https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1143 rb_vm_rewind_cfp(th, cfp); } - else{ - /* SDR(); printf("%p, %p\n", cdfp, escape_dfp); */ + else if (0) { + SDR(); fprintf(stderr, "%p, %p\n", cfp, escape_cfp); } } else if (state == TAG_RETRY) { @@ -1163,10 +1162,7 @@ rb_iterate(VALUE (* it_proc) (VALUE), VA https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1162 } TH_POP_TAG(); - switch (state) { - case 0: - break; - default: + if (state) { TH_JUMP_TAG(th, state); } return retval; Index: internal.h =================================================================== --- internal.h (revision 50101) +++ internal.h (revision 50102) @@ -585,7 +585,7 @@ struct vm_ifunc { https://github.com/ruby/ruby/blob/trunk/internal.h#L585 ID id; }; -#define IFUNC_NEW(a, b) ((struct vm_ifunc *)rb_imemo_new(imemo_ifunc, (VALUE)(a), (VALUE)(b), 0, 0)) +#define IFUNC_NEW(a, b, c) ((struct vm_ifunc *)rb_imemo_new(imemo_ifunc, (VALUE)(a), (VALUE)(b), (VALUE)(c), 0)) /* MEMO */ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/