summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-31 23:17:52 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-31 23:17:52 +0000
commit0243c024f8c3e0d229f160ad6fa0db96a70cb8ab (patch)
tree5f6a39eb92c039cf01bf606c99be19a0f3f9a430 /gc.c
parentc0a0aa0c47f2cd5c97a35effb8b073eeb84b7d2d (diff)
* gc.c (GET_STACK_BOUNDS): refactored common code. based on a
patch from Suraj N. Kurapati <sunaku AT gmail.com> in [ruby-core:26443]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c43
1 files changed, 15 insertions, 28 deletions
diff --git a/gc.c b/gc.c
index 2568d42b14..737b124b1b 100644
--- a/gc.c
+++ b/gc.c
@@ -2089,6 +2089,16 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
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 @@ mark_current_machine_context(rb_objspace_t *objspace, rb_thread_t *th)
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 @@ void
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