(a cherry-pick of commit
95f5767 from Unity-Technologies/bdwgc)
Issue #173 (bdwgc).
Avoid clearing large sections of the stack. It was clearing
up to 16k which may not be available in cases of small stacks or stack
overflow situations (for some targets).
* misc.c [ALWAYS_SMALL_CLEAR_STACK] (GC_clear_stack): Do only BZERO for
dummy where dummy is a local array of length SMALL_CLEAR_SIZE.
# define SMALL_CLEAR_SIZE 256 /* Clear this much every time. */
#endif
-#if defined(STACK_NOT_SCANNED)
+#if defined(ALWAYS_SMALL_CLEAR_STACK) || defined(STACK_NOT_SCANNED)
GC_API void * GC_CALL GC_clear_stack(void *arg)
{
+# ifndef STACK_NOT_SCANNED
+ word volatile dummy[SMALL_CLEAR_SIZE];
+ BZERO((/* no volatile */ void *)dummy, sizeof(dummy));
+# endif
return arg;
}
#else
return arg;
}
-#endif /* !STACK_NOT_SCANNED */
+#endif /* !ALWAYS_SMALL_CLEAR_STACK && !STACK_NOT_SCANNED */
/* Return a pointer to the base address of p, given a pointer to a */
/* an address within an object. Return 0 o.w. */