public unsafe static void Test1(int n) { Console.WriteLine("Enter Test1"); LargeStruct s = new LargeStruct(); s.i1 = 7; s.i2 = 9; BigArgSpace(s); // Localloc some space; this moves the outgoing argument space. if (n < 1) { n = 1; } int *a = stackalloc int[n * 4096]; a[0] = 7; int i; for (i = 1; i < 5; ++i) { a[i] = i + a[i - 1]; } // Now call a function that touches the potentially un-probed // outgoing argument space. SmallArgSpace(1, 2, 3, 4, 5, 6, 7, 8, 9, a[4]); iret = 100; }
public static void BigArgSpace(LargeStruct s) { long result = s.i1 + s.i2; Console.Write("BigArgSpace: "); Console.WriteLine(result); }
public static void Test1() { Console.WriteLine("Enter Test1"); LargeStruct s = new LargeStruct(); s.i2 = 5; TestWrite(1, 2, 3, 4, s); // 4 int reg args, then struct stack arg }
public static void EatStackThenTest1(int level = 0) { LargeStruct s = new LargeStruct(); s.i2 = level; Escape(ref s); if (level < 10) { EatStackThenTest1(level + 1); } else { Test1(); } }
public static void Escape(ref LargeStruct s) { }
public static void TestWrite(int i1, int i2, int i3, int i4, LargeStruct s) { Console.Write("Enter TestWrite: "); Console.WriteLine(i1 + i2 + i3 + i4 + s.i2); iret = 100; }