Created
December 1, 2012 02:10
-
-
Save wanabe/4180183 to your computer and use it in GitHub Desktop.
patch for r38021 of ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/method.h b/method.h | |
| index 57a409f..2996775 100644 | |
| --- a/method.h | |
| +++ b/method.h | |
| @@ -22,7 +22,8 @@ typedef enum { | |
| NOEX_MODFUNC = 0x12, | |
| NOEX_SUPER = 0x20, | |
| NOEX_VCALL = 0x40, | |
| - NOEX_RESPONDS = 0x80 | |
| + NOEX_RESPONDS = 0x80, | |
| + NOEX_TEMPORARY = 0x100 | |
| } rb_method_flag_t; | |
| #define NOEX_SAFE(n) ((int)((n) >> 8) & 0x0F) | |
| diff --git a/vm_eval.c b/vm_eval.c | |
| index 5959e93..b30b388 100644 | |
| --- a/vm_eval.c | |
| +++ b/vm_eval.c | |
| @@ -183,10 +183,10 @@ vm_call0_body(rb_thread_t* th, rb_call_info_t *ci, const VALUE *argv) | |
| { | |
| if (ci->me->def->type == VM_METHOD_TYPE_REFINED && | |
| ci->me->def->body.orig_def) { | |
| - rb_method_entry_t orig_me; | |
| - orig_me = *ci->me; | |
| - orig_me.def = ci->me->def->body.orig_def; | |
| - ci->me = &orig_me; | |
| + rb_method_entry_t *orig_me = ALLOC(rb_method_entry_t); | |
| + *orig_me = *ci->me; | |
| + orig_me->def = ci->me->def->body.orig_def; | |
| + ci->me = orig_me; | |
| goto again; | |
| } | |
| diff --git a/vm_insnhelper.c b/vm_insnhelper.c | |
| index d242097..8c66115 100644 | |
| --- a/vm_insnhelper.c | |
| +++ b/vm_insnhelper.c | |
| @@ -92,6 +92,9 @@ vm_push_frame(rb_thread_t *th, | |
| static inline void | |
| vm_pop_frame(rb_thread_t *th) | |
| { | |
| + if (th->cfp->me && th->cfp->me->flag & NOEX_TEMPORARY) { | |
| + xfree(th->cfp->me); | |
| + } | |
| th->cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp); | |
| if (VMDEBUG == 2) { | |
| @@ -1826,7 +1829,7 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci) | |
| NODE *cref = rb_vm_get_cref(cfp->iseq, cfp->ep); | |
| VALUE refinements = cref ? cref->nd_refinements : Qnil; | |
| VALUE refinement, defined_class; | |
| - rb_method_entry_t orig_me, *me; | |
| + rb_method_entry_t *orig_me, *me; | |
| ci_temp = *ci; | |
| ci = &ci_temp; | |
| @@ -1851,9 +1854,11 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci) | |
| no_refinement_dispatch: | |
| if (ci->me->def->body.orig_def) { | |
| - orig_me = *ci->me; | |
| - orig_me.def = ci->me->def->body.orig_def; | |
| - ci->me = &orig_me; | |
| + orig_me = ALLOC(rb_method_entry_t); | |
| + *orig_me = *ci->me; | |
| + orig_me->flag |= NOEX_TEMPORARY; | |
| + orig_me->def = ci->me->def->body.orig_def; | |
| + ci->me = orig_me; | |
| goto normal_method_dispatch; | |
| } | |
| else { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment