summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-27 23:51:18 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-27 23:51:18 +0000
commit1c59cc2ccecb81512a2789ece0691ada6172beed (patch)
tree34d5340b92abc68b0d7dc53af50f947b030ef61d
parent55152ae26d200be3bd59170e9750949058fa82a2 (diff)
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
-rw-r--r--compile.c4
-rw-r--r--internal.h2
-rw-r--r--vm_eval.c14
3 files changed, 8 insertions, 12 deletions
diff --git a/compile.c b/compile.c
index 13015dfbf8..39d10f88cc 100644
--- a/compile.c
+++ b/compile.c
@@ -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);
}
diff --git a/internal.h b/internal.h
index 76435c16b0..e29fcb2e08 100644
--- a/internal.h
+++ b/internal.h
@@ -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 */
diff --git a/vm_eval.c b/vm_eval.c
index 9dbb05b9ed..2dbe610888 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -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;