[MethodImpl(MethodImplOptions.NoInlining)] // Only called once per thread, no point in inlining. private static unsafe byte *GetSufficientStackLimit() { IntPtr lower, upper; RuntimeImports.RhGetCurrentThreadStackBounds(out lower, out upper); // Compute the limit used by EnsureSufficientExecutionStack and cache it on the thread. This minimum // stack size should be sufficient to allow a typical non-recursive call chain to execute, including // potential exception handling and garbage collection. #if BIT64 const int MinExecutionStackSize = 128 * 1024; #else const int MinExecutionStackSize = 64 * 1024; #endif byte *limit = (((byte *)upper - (byte *)lower > MinExecutionStackSize)) ? ((byte *)lower + MinExecutionStackSize) : ((byte *)upper); return(t_sufficientStackLimit = limit); }