]> git.mdlowis.com Git - archive/atc.git/commitdiff
Cleaned up stack scan logic
authorMichael D. Lowis <mike@mdlowis.com>
Fri, 3 Apr 2015 21:15:00 +0000 (17:15 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Fri, 3 Apr 2015 21:15:00 +0000 (17:15 -0400)
source/runtime/gc.c

index 07b3bff8fe35aeb4f32826e1b607373218a25eea..2ecf2de73598b9c2e591a0eb80a0c86eee277fd4 100644 (file)
@@ -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) {