なかだです。

retryするときに同じ場所でEXEC_TAG()を繰り返すのを、減らしてみま
した。


Index: eval.c =================================================================== RCS file: /cvs/ruby/src/ruby/eval.c,v retrieving revision 1.515 diff -u -2 -p -r1.515 eval.c --- eval.c 14 Aug 2003 17:19:23 -0000 1.515 +++ eval.c 21 Aug 2003 06:48:42 -0000 @@ -2711,5 +2711,4 @@ rb_eval(self, n) case NODE_FOR: { - iter_retry: PUSH_TAG(PROT_FUNC); PUSH_BLOCK(node->nd_var, node->nd_body); @@ -2717,4 +2716,5 @@ rb_eval(self, n) state = EXEC_TAG(); if (state == 0) { + iter_retry: PUSH_ITER(ITER_PRE); if (nd_type(node) == NODE_ITER) { @@ -2734,8 +2734,14 @@ rb_eval(self, n) POP_ITER(); } - else if (_block.tag->dst == state) { - state &= TAG_MASK; - if (state == TAG_RETURN || state == TAG_BREAK) { - result = prot_tag->retval; + else { + if (_block.tag->dst == state) { + state &= TAG_MASK; + if (state == TAG_RETURN || state == TAG_BREAK) { + result = prot_tag->retval; + } + } + if (state == TAG_RETRY) { + state = 0; + goto iter_retry; } } @@ -2746,7 +2752,4 @@ rb_eval(self, n) break; - case TAG_RETRY: - goto iter_retry; - case TAG_BREAK: break; @@ -2808,7 +2811,7 @@ rb_eval(self, n) case NODE_RESCUE: - retry_entry: { volatile VALUE e_info = ruby_errinfo; + volatile int retrying = 0; PUSH_TAG(PROT_NONE); @@ -2816,6 +2819,14 @@ rb_eval(self, n) result = rb_eval(self, node->nd_head); } - POP_TAG(); - if (state == TAG_RAISE) { + else if (retrying) { + if (state != TAG_RAISE) { + ruby_errinfo = e_info; + if (state == TAG_RETRY) { + retrying = state = 0; + result = rb_eval(self, node->nd_head); + } + } + } + else if (state == TAG_RAISE) { NODE * volatile resq = node->nd_resq; @@ -2824,17 +2835,6 @@ rb_eval(self, n) if (handle_rescue(self, resq)) { state = 0; - PUSH_TAG(PROT_NONE); - if ((state = EXEC_TAG()) == 0) { - result = rb_eval(self, resq->nd_body); - } - POP_TAG(); - if (state == TAG_RETRY) { - state = 0; - ruby_errinfo = Qnil; - goto retry_entry; - } - if (state != TAG_RAISE) { - ruby_errinfo = e_info; - } + retrying = 1; + result = rb_eval(self, resq->nd_body); break; } @@ -2842,10 +2842,10 @@ rb_eval(self, n) } } - else if (node->nd_else) { /* else clause given */ - if (!state) { /* no exception raised */ - result = rb_eval(self, node->nd_else); - } - } + POP_TAG(); if (state) JUMP_TAG(state); + /* no exception raised */ + if (node->nd_else) { /* else clause given */ + result = rb_eval(self, node->nd_else); + } } break; @@ -4416,5 +4416,4 @@ rb_iterate(it_proc, data1, bl_proc, data VALUE self = ruby_top_self; - iter_retry: PUSH_ITER(ITER_PRE); PUSH_BLOCK(0, node); @@ -4423,10 +4422,17 @@ rb_iterate(it_proc, data1, bl_proc, data state = EXEC_TAG(); if (state == 0) { + iter_retry: retval = (*it_proc)(data1); } - if (ruby_block->tag->dst == state) { - state &= TAG_MASK; - if (state == TAG_RETURN || state == TAG_BREAK) { - retval = prot_tag->retval; + else { + if (ruby_block->tag->dst == state) { + state &= TAG_MASK; + if (state == TAG_RETURN || state == TAG_BREAK) { + retval = prot_tag->retval; + } + } + if (state == TAG_RETRY) { + state = 0; + goto iter_retry; } } @@ -4439,7 +4445,4 @@ rb_iterate(it_proc, data1, bl_proc, data break; - case TAG_RETRY: - goto iter_retry; - case TAG_BREAK: break; @@ -7026,5 +7029,4 @@ proc_invoke(proc, args, self, klass) ruby_block = &_block; - again: PUSH_ITER(ITER_CUR); ruby_frame->iter = ITER_CUR; @@ -7233,5 +7235,4 @@ block_pass(self, node) orphan = block_orphan(data); - retry: /* PUSH BLOCK from data */ old_block = ruby_block; @@ -7245,4 +7246,5 @@ block_pass(self, node) state = EXEC_TAG(); if (state == 0) { + retry: proc_set_safe_level(proc); if (safe > ruby_safe_level) @@ -7250,6 +7252,4 @@ block_pass(self, node) result = rb_eval(self, node->nd_iter); } - POP_TAG(); - POP_ITER(); if (_block.tag->dst == state) { if (orphan) { @@ -7271,4 +7271,10 @@ block_pass(self, node) } } + if (state == TAG_RETRY) { + state = 0; + goto retry; + } + POP_TAG(); + POP_ITER(); ruby_block = old_block; ruby_safe_level = safe; @@ -7280,6 +7286,4 @@ block_pass(self, node) result = prot_tag->retval; break; - case TAG_RETRY: - goto retry; case TAG_RETURN: if (orphan) {
-- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦