From: Tanner Gooding Date: Sat, 30 Jun 2018 19:10:40 +0000 (-0700) Subject: Updating the Avx.Extract/Insert methods to throw PNSE when IsSupported is false X-Git-Tag: accepted/tizen/unified/20190422.045933~1773 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=50b2ac829a6d16cca84858ddae25de71b8d04708;p=platform%2Fupstream%2Fcoreclr.git Updating the Avx.Extract/Insert methods to throw PNSE when IsSupported is false a --- diff --git a/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Avx.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Avx.cs index 63e0e29..2115e96 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Avx.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Avx.cs @@ -241,6 +241,10 @@ namespace System.Runtime.Intrinsics.X86 /// public static byte Extract(Vector256 value, byte index) { + if (!IsSupported) + { + throw new PlatformNotSupportedException(); + } return Unsafe.Add(ref Unsafe.As, byte>(ref value), index & 0x1F); } @@ -251,6 +255,10 @@ namespace System.Runtime.Intrinsics.X86 /// public static ushort Extract(Vector256 value, byte index) { + if (!IsSupported) + { + throw new PlatformNotSupportedException(); + } return Unsafe.Add(ref Unsafe.As, ushort>(ref value), index & 0xF); } @@ -260,6 +268,10 @@ namespace System.Runtime.Intrinsics.X86 /// public static int Extract(Vector256 value, byte index) { + if (!IsSupported) + { + throw new PlatformNotSupportedException(); + } return Unsafe.Add(ref Unsafe.As, int>(ref value), index & 0x7); } @@ -269,6 +281,10 @@ namespace System.Runtime.Intrinsics.X86 /// public static uint Extract(Vector256 value, byte index) { + if (!IsSupported) + { + throw new PlatformNotSupportedException(); + } return Unsafe.Add(ref Unsafe.As, uint>(ref value), index & 0x7); } @@ -278,7 +294,7 @@ namespace System.Runtime.Intrinsics.X86 /// public static long Extract(Vector256 value, byte index) { - if (IntPtr.Size != 8) + if (!IsSupported || (IntPtr.Size != 8)) { throw new PlatformNotSupportedException(); } @@ -291,7 +307,7 @@ namespace System.Runtime.Intrinsics.X86 /// public static ulong Extract(Vector256 value, byte index) { - if (IntPtr.Size != 8) + if (!IsSupported || (IntPtr.Size != 8)) { throw new PlatformNotSupportedException(); } @@ -523,6 +539,11 @@ namespace System.Runtime.Intrinsics.X86 /// public static Vector256 Insert(Vector256 value, long data, byte index) { + if (IntPtr.Size != 8) + { + throw new PlatformNotSupportedException(); + } + unsafe { index &= 0x3; @@ -539,6 +560,11 @@ namespace System.Runtime.Intrinsics.X86 /// public static Vector256 Insert(Vector256 value, ulong data, byte index) { + if (IntPtr.Size != 8) + { + throw new PlatformNotSupportedException(); + } + unsafe { index &= 0x3;