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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-03-27 23:51:18 +00:00
Родитель 55152ae26d
Коммит 1c59cc2cce
3 изменённых файлов: 8 добавлений и 12 удалений

Просмотреть файл

@ -5397,7 +5397,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
*/
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, rb_insn_func_t func,
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);
}

Просмотреть файл

@ -585,7 +585,7 @@ struct vm_ifunc {
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 */

Просмотреть файл

@ -1105,12 +1105,11 @@ rb_iterate(VALUE (* it_proc) (VALUE), VALUE data1,
{
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), VALUE data1,
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), VALUE data1,
}
TH_POP_TAG();
switch (state) {
case 0:
break;
default:
if (state) {
TH_JUMP_TAG(th, state);
}
return retval;