unsafe static int TestMethodInlining(VT *pVT) { int v1, v2, v3; pVT->Get(out v1, out v2, out v3); return(Do(v1, v2)); }
unsafe static int TestByPtr(VT *pVT) { int v1, v2, v3; v1 = pVT->F1; v2 = pVT->F2; v3 = pVT->F3; return(Do(v1, v2)); }
private static unsafe bool CheckDoubleAlignment1(VT *p) { Console.WriteLine("Address {0}", (IntPtr)p); if ((int)(long)p % sizeof(double) != 0) { Console.WriteLine("not double aligned"); return(false); } else { return(true); } }
unsafe static int TestByPtr(VT *pVT) { int v1, v2, v3, v4, v5, v6, v7, v8; v1 = pVT->F1; v2 = pVT->F2; v3 = pVT->F3; v4 = pVT->F4; v5 = pVT->F5; v6 = pVT->F6; v7 = pVT->F7; v8 = pVT->F8; return(Do(v1)); }
unsafe static int Main(string[] args) { byte *pDataBytes = stackalloc byte[VT.Size]; VT * pVT = (VT *)pDataBytes; pVT->F1 = 1; pVT->F2 = 2; pVT->F3 = 3; pVT->F4 = 4; pVT->F5 = 5; pVT->F6 = 6; pVT->F7 = 7; pVT->F8 = 8; int result = TestByPtr(pVT); return(result + 99); }
unsafe static int Main(string[] args) { byte *pDataBytes = stackalloc byte[VT.Size]; VT * pVT = (VT *)pDataBytes; pVT->F1 = 44; pVT->F2 = 56; pVT->F3 = 3; int result = -200; result += TestMethodInlining(pVT); result += TestByRef(ref *pVT); result += TestByPtr(pVT); return(result); }
private static unsafe bool CheckDoubleAlignment1(VT *p) { Console.WriteLine("Address {0}", (IntPtr)p); if (OperatingSystem.IsWindows() || (RuntimeInformation.ProcessArchitecture != Architecture.X86)) { if ((int)(long)p % sizeof(double) != 0) { Console.WriteLine("not double aligned"); return(false); } else { return(true); } } else { // Current JIT implementation doesn't use double alignment stack optimization for Linux/x86 return(true); } }