]> granicus.if.org Git - gc/commitdiff
Do not push frame pointer on Darwin/arm and Darwin/arm64
authorJonathan Chambers <joncham@gmail.com>
Fri, 2 Feb 2018 17:29:20 +0000 (20:29 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Fri, 2 Feb 2018 17:29:20 +0000 (20:29 +0300)
(part of commit 9379c66 from Unity-Technologies/bdwgc)

Issue #173 (bdwgc).

* darwin_stop_world.c [!DARWIN_DONT_PARSE_STACK && ARM32]
(GC_stack_range_for): Pass r[7] (instead of sp register) to
GC_FindTopOfStack().
* darwin_stop_world.c [ARM32] (GC_stack_range_for): Do not push r[7]
register (as it holds frame pointer on iOS); add comment.
* darwin_stop_world.c [!DARWIN_DONT_PARSE_STACK && AARCH64]
(GC_stack_range_for): Pass fp (instead of sp) register to
GC_FindTopOfStack().
* darwin_stop_world.c [AARCH64] (GC_stack_range_for): Do not push fp
register.

darwin_stop_world.c

index 062eb213e8b927e623a7bd93651f5e99f6211970..1eab1f1c6a67d141aedd002365aabffeb0a182b6 100644 (file)
@@ -282,13 +282,15 @@ STATIC ptr_t GC_stack_range_for(ptr_t *phi, thread_act_t thread, GC_thread p,
 #   elif defined(ARM32)
       lo = (void *)state.THREAD_FLD(sp);
 #     ifndef DARWIN_DONT_PARSE_STACK
-        *phi = GC_FindTopOfStack(state.THREAD_FLD(sp));
+        *phi = GC_FindTopOfStack(state.THREAD_FLD(r[7])); /* fp */
 #     endif
       {
         int j;
-        for (j = 0; j <= 12; j++) {
+        for (j = 0; j < 7; j++)
+          GC_push_one(state.THREAD_FLD(r[j]));
+        j++; /* "r7" is skipped (iOS uses it as a frame pointer) */
+        for (; j <= 12; j++)
           GC_push_one(state.THREAD_FLD(r[j]));
-        }
       }
       /* "pc" and "sp" are skipped */
       GC_push_one(state.THREAD_FLD(lr));
@@ -297,7 +299,7 @@ STATIC ptr_t GC_stack_range_for(ptr_t *phi, thread_act_t thread, GC_thread p,
 #   elif defined(AARCH64)
       lo = (void *)state.THREAD_FLD(sp);
 #     ifndef DARWIN_DONT_PARSE_STACK
-        *phi = GC_FindTopOfStack(state.THREAD_FLD(sp));
+        *phi = GC_FindTopOfStack(state.THREAD_FLD(fp));
 #     endif
       {
         int j;
@@ -305,14 +307,13 @@ STATIC ptr_t GC_stack_range_for(ptr_t *phi, thread_act_t thread, GC_thread p,
           GC_push_one(state.THREAD_FLD(x[j]));
         }
       }
-      /* "cpsr", "pc" and "sp" are skipped */
-      GC_push_one(state.THREAD_FLD(fp));
+      /* "cpsr", "fp", "pc" and "sp" are skipped */
       GC_push_one(state.THREAD_FLD(lr));
 
 #   elif defined(CPPCHECK)
       lo = NULL;
 #   else
-#     error FIXME for non-x86 || ppc || arm architectures
+#     error FIXME for non-arm/ppc/x86 architectures
 #   endif
   } /* thread != my_thread */