ruby-changes:13806
From: nobu <ko1@a...>
Date: Sun, 1 Nov 2009 08:23:43 +0900 (JST)
Subject: [ruby-changes:13806] Ruby:r25604 (trunk): * gc.c (GET_STACK_BOUNDS): refactored common code. based on a
nobu 2009-11-01 08:17:52 +0900 (Sun, 01 Nov 2009) New Revision: 25604 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25604 Log: * gc.c (GET_STACK_BOUNDS): refactored common code. based on a patch from Suraj N. Kurapati <sunaku AT gmail.com> in [ruby-core:26443]. Modified files: trunk/ChangeLog trunk/gc.c Index: ChangeLog =================================================================== --- ChangeLog (revision 25603) +++ ChangeLog (revision 25604) @@ -1,3 +1,9 @@ +Sun Nov 1 08:17:48 2009 Nobuyoshi Nakada <nobu@r...> + + * gc.c (GET_STACK_BOUNDS): refactored common code. based on a + patch from Suraj N. Kurapati <sunaku AT gmail.com> in + [ruby-core:26443]. + Sat Oct 31 23:44:35 2009 Yukihiro Matsumoto <matz@r...> * enum.c (enum_count): remove optimization using #size. Index: gc.c =================================================================== --- gc.c (revision 25603) +++ gc.c (revision 25604) @@ -2089,6 +2089,16 @@ void rb_vm_mark(void *ptr); +#if STACK_GROW_DIRECTION < 0 +#define GET_STACK_BOUNDS(start, end, appendix) (start = STACK_END, end = STACK_START) +#elif STACK_GROW_DIRECTION > 0 +#define GET_STACK_BOUNDS(start, end, appendix) (start = STACK_START, end = STACK_END+appendix) +#else +#define GET_STACK_BOUNDS(stack_start, stack_end, appendix) \ + ((STACK_END < STACK_START) ? \ + (start = STACK_END, end = STACK_START) : (start = STACK_START, end = STACK_END+appendix)) +#endif + static void mark_current_machine_context(rb_objspace_t *objspace, rb_thread_t *th) { @@ -2100,22 +2110,7 @@ rb_setjmp(save_regs_gc_mark); SET_STACK_END; -#if STACK_GROW_DIRECTION < 0 - stack_start = th->machine_stack_end; - stack_end = th->machine_stack_start; -#elif STACK_GROW_DIRECTION > 0 - stack_start = th->machine_stack_start; - stack_end = th->machine_stack_end + 1; -#else - if (th->machine_stack_end < th->machine_stack_start) { - stack_start = th->machine_stack_end; - stack_end = th->machine_stack_start; - } - else { - stack_start = th->machine_stack_start; - stack_end = th->machine_stack_end + 1; - } -#endif + GET_STACK_BOUNDS(stack_start, stack_end, 1); mark_locations_array(objspace, (VALUE*)save_regs_gc_mark, @@ -2220,18 +2215,10 @@ rb_gc_mark_machine_stack(rb_thread_t *th) { rb_objspace_t *objspace = &rb_objspace; -#if STACK_GROW_DIRECTION < 0 - rb_gc_mark_locations(th->machine_stack_end, th->machine_stack_start); -#elif STACK_GROW_DIRECTION > 0 - rb_gc_mark_locations(th->machine_stack_start, th->machine_stack_end); -#else - if (th->machine_stack_start < th->machine_stack_end) { - rb_gc_mark_locations(th->machine_stack_start, th->machine_stack_end); - } - else { - rb_gc_mark_locations(th->machine_stack_end, th->machine_stack_start); - } -#endif + VALUE *stack_start, *stack_end; + + GET_STACK_BOUNDS(stack_start, stack_end, 0); + rb_gc_mark_locations(stack_start, stack_end); #ifdef __ia64 rb_gc_mark_locations(th->machine_register_stack_start, th->machine_register_stack_end); #endif -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/