From 4c8e1dd556cd10109c071101bde11576b4fd4904 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Fri, 3 Apr 2015 17:15:00 -0400 Subject: [PATCH] Cleaned up stack scan logic --- source/runtime/gc.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) 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) { -- 2.55.0