From: Michael D. Lowis Date: Fri, 3 Apr 2015 21:15:00 +0000 (-0400) Subject: Cleaned up stack scan logic X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=4c8e1dd556cd10109c071101bde11576b4fd4904;p=archive%2Fatc.git Cleaned up stack scan logic --- diff --git a/source/runtime/gc.c b/source/runtime/gc.c index 07b3bff..2ecf2de 100644 --- a/source/runtime/gc.c +++ b/source/runtime/gc.c @@ -70,14 +70,11 @@ static void gc_scan_stack(void) { /* Setup pointers to the stack top and bottom */ uintptr_t* stack_bot = Stack_Bottom; uintptr_t* stack_top = (uintptr_t*)&stack_top; - /* Make sure we swap them in the event the stack grows downward */ - if (stack_bot > stack_top) { - uintptr_t* temp = stack_top; - stack_top = stack_bot; - stack_bot = temp; - } /* Scan the stack and mark any live objects */ - gc_scan_region(stack_bot, stack_top); + if (stack_bot <= stack_top) + gc_scan_region(stack_bot, stack_top); + else + gc_scan_region(stack_top, stack_bot); } static void gc_scan_roots(void) {