summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitattributes6
-rw-r--r--CMakeLists.txt52
-rw-r--r--Documentation/botr/clr-abi.md4
-rw-r--r--Documentation/building/cross-building.md18
-rw-r--r--Documentation/building/windows-instructions.md3
-rw-r--r--Documentation/project-docs/linux-performance-tracing.md22
-rwxr-xr-xbuild-test.sh4
-rw-r--r--build.cmd18
-rw-r--r--buildpipeline/DotNet-CoreClr-Trusted-Windows-x86.json14
-rw-r--r--buildpipeline/DotNet-CoreClr-Trusted-Windows.json11
-rw-r--r--buildpipeline/DotNet-Trusted-Publish.json56
-rw-r--r--clrfeatures.cmake7
-rwxr-xr-xcross/armel/tizen-fetch.sh10
-rw-r--r--cross/armel/tizen/tizen-dotnet.ks11
-rw-r--r--dir.props12
-rwxr-xr-xnetci.groovy552
-rw-r--r--perf.groovy90
-rw-r--r--src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.Linux.Microsoft.NETCore.Runtime.CoreCLR.props1
-rw-r--r--src/ToolBox/SOS/NETCore/SymbolReader.cs2
-rw-r--r--src/ToolBox/SOS/Strike/disasm.cpp8
-rw-r--r--src/ToolBox/SOS/Strike/strike.cpp41
-rw-r--r--src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h12
-rw-r--r--src/ToolBox/superpmi/superpmi-shared/lwmlist.h1
-rw-r--r--src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp21
-rw-r--r--src/ToolBox/superpmi/superpmi-shared/methodcontext.h8
-rw-r--r--src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp10
-rw-r--r--src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp8
-rw-r--r--src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp7
-rw-r--r--src/ToolBox/superpmi/superpmi/commandline.cpp112
-rw-r--r--src/ToolBox/superpmi/superpmi/commandline.h6
-rw-r--r--src/ToolBox/superpmi/superpmi/icorjitinfo.cpp9
-rw-r--r--src/ToolBox/superpmi/superpmi/jithost.cpp39
-rw-r--r--src/ToolBox/superpmi/superpmi/jitinstance.cpp14
-rw-r--r--src/ToolBox/superpmi/superpmi/jitinstance.h5
-rw-r--r--src/ToolBox/superpmi/superpmi/parallelsuperpmi.cpp47
-rw-r--r--src/ToolBox/superpmi/superpmi/superpmi.cpp6
-rw-r--r--src/classlibnative/float/floatdouble.cpp37
-rw-r--r--src/classlibnative/float/floatsingle.cpp37
-rw-r--r--src/classlibnative/inc/floatdouble.h4
-rw-r--r--src/classlibnative/inc/floatsingle.h4
-rw-r--r--src/debug/daccess/daccess.cpp29
-rw-r--r--src/debug/shared/arm/primitives.cpp9
-rw-r--r--src/debug/shared/i386/primitives.cpp2
-rw-r--r--src/dlls/mscoree/mscorwks_unixexports.src1
-rw-r--r--src/gc/env/gcenv.object.h2
-rw-r--r--src/gc/gc.cpp60
-rw-r--r--src/inc/clrconfigvalues.h9
-rw-r--r--src/inc/corinfo.h16
-rw-r--r--src/inc/jithelpers.h7
-rw-r--r--src/inc/xclrdata.idl14
-rw-r--r--src/jit/ICorJitInfo_API_names.h1
-rw-r--r--src/jit/ICorJitInfo_API_wrapper.hpp10
-rw-r--r--src/jit/codegenarm.cpp14
-rw-r--r--src/jit/codegenarm64.cpp357
-rw-r--r--src/jit/codegenarmarch.cpp338
-rw-r--r--src/jit/codegenlinear.cpp3
-rw-r--r--src/jit/codegenlinear.h3
-rw-r--r--src/jit/codegenxarch.cpp18
-rw-r--r--src/jit/compiler.h49
-rw-r--r--src/jit/earlyprop.cpp32
-rw-r--r--src/jit/emit.cpp12
-rw-r--r--src/jit/emit.h9
-rw-r--r--src/jit/emitarm64.cpp131
-rw-r--r--src/jit/emitarm64.h15
-rw-r--r--src/jit/emitxarch.cpp44
-rw-r--r--src/jit/emitxarch.h10
-rw-r--r--src/jit/flowgraph.cpp114
-rw-r--r--src/jit/gentree.cpp169
-rw-r--r--src/jit/gentree.h24
-rw-r--r--src/jit/gtlist.h37
-rw-r--r--src/jit/gtstructs.h2
-rw-r--r--src/jit/importer.cpp389
-rw-r--r--src/jit/instr.cpp26
-rw-r--r--src/jit/lclvars.cpp80
-rw-r--r--src/jit/lir.cpp149
-rw-r--r--src/jit/liveness.cpp3
-rw-r--r--src/jit/lower.cpp124
-rw-r--r--src/jit/lowerarmarch.cpp108
-rw-r--r--src/jit/lowerxarch.cpp67
-rw-r--r--src/jit/lsra.cpp125
-rw-r--r--src/jit/lsra.h4
-rw-r--r--src/jit/lsraarm.cpp63
-rw-r--r--src/jit/lsraarm64.cpp17
-rw-r--r--src/jit/lsraarmarch.cpp14
-rw-r--r--src/jit/lsraxarch.cpp31
-rw-r--r--src/jit/morph.cpp24
-rw-r--r--src/jit/namedintrinsiclist.h7
-rw-r--r--src/jit/rationalize.cpp4
-rw-r--r--src/jit/register_arg_convention.h9
-rw-r--r--src/jit/simd.cpp3
-rw-r--r--src/jit/simdcodegenxarch.cpp4
-rw-r--r--src/jit/target.h9
-rw-r--r--src/jit/utils.cpp28
-rw-r--r--src/jit/valuenum.cpp12
-rw-r--r--src/mscorlib/System.Private.CoreLib.csproj29
-rw-r--r--src/mscorlib/shared/System.Private.CoreLib.Shared.projitems7
-rw-r--r--src/mscorlib/shared/System/Boolean.cs1
-rw-r--r--src/mscorlib/shared/System/Buffers/MemoryHandle.cs12
-rw-r--r--src/mscorlib/shared/System/Buffers/OwnedMemory.cs4
-rw-r--r--src/mscorlib/shared/System/Byte.cs4
-rw-r--r--src/mscorlib/shared/System/Char.cs25
-rw-r--r--src/mscorlib/shared/System/Collections/Generic/ICollection.cs1
-rw-r--r--src/mscorlib/shared/System/Collections/Generic/ICollectionDebugView.cs34
-rw-r--r--src/mscorlib/shared/System/Collections/Generic/IDictionary.cs1
-rw-r--r--src/mscorlib/shared/System/Collections/Generic/IDictionaryDebugView.cs80
-rw-r--r--src/mscorlib/shared/System/Collections/Generic/IEnumerable.cs1
-rw-r--r--src/mscorlib/shared/System/Collections/Generic/IList.cs1
-rw-r--r--src/mscorlib/shared/System/Collections/Generic/IReadOnlyCollection.cs1
-rw-r--r--src/mscorlib/shared/System/Collections/Generic/IReadOnlyDictionary.cs1
-rw-r--r--src/mscorlib/shared/System/Collections/Generic/IReadOnlyList.cs1
-rw-r--r--src/mscorlib/shared/System/Collections/Generic/List.cs (renamed from src/mscorlib/src/System/Collections/Generic/List.cs)188
-rw-r--r--src/mscorlib/shared/System/Collections/ICollection.cs1
-rw-r--r--src/mscorlib/shared/System/Collections/IDictionary.cs1
-rw-r--r--src/mscorlib/shared/System/Collections/IEnumerable.cs2
-rw-r--r--src/mscorlib/shared/System/Collections/IList.cs1
-rw-r--r--src/mscorlib/shared/System/Collections/ListDictionaryInternal.cs8
-rw-r--r--src/mscorlib/shared/System/Collections/ObjectModel/Collection.cs2
-rw-r--r--src/mscorlib/shared/System/Collections/ObjectModel/ReadOnlyCollection.cs2
-rw-r--r--src/mscorlib/shared/System/Convert.cs158
-rw-r--r--src/mscorlib/shared/System/CurrentSystemTimeZone.cs1
-rw-r--r--src/mscorlib/shared/System/DateTime.cs49
-rw-r--r--src/mscorlib/shared/System/Diagnostics/Tracing/ActivityTracker.cs7
-rw-r--r--src/mscorlib/shared/System/Diagnostics/Tracing/EventDescriptor.cs6
-rw-r--r--src/mscorlib/shared/System/Diagnostics/Tracing/EventProvider.cs7
-rw-r--r--src/mscorlib/shared/System/Diagnostics/Tracing/EventSource.cs17
-rw-r--r--src/mscorlib/shared/System/Diagnostics/Tracing/StubEnvironment.cs23
-rw-r--r--src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/EventPayload.cs6
-rw-r--r--src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/EventSourceActivity.cs7
-rw-r--r--src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/PropertyValue.cs6
-rw-r--r--src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/SimpleTypeInfos.cs6
-rw-r--r--src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventSource.cs5
-rw-r--r--src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventTypes.cs11
-rw-r--r--src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/TraceLoggingTypeInfo.cs8
-rw-r--r--src/mscorlib/shared/System/Double.cs13
-rw-r--r--src/mscorlib/shared/System/Globalization/Calendar.cs5
-rw-r--r--src/mscorlib/shared/System/Globalization/CalendarData.Unix.cs1
-rw-r--r--src/mscorlib/shared/System/Globalization/ChineseLunisolarCalendar.cs3
-rw-r--r--src/mscorlib/shared/System/Globalization/CultureData.Unix.cs1
-rw-r--r--src/mscorlib/shared/System/Globalization/DateTimeFormat.cs5
-rw-r--r--src/mscorlib/shared/System/Globalization/DateTimeFormatInfo.cs34
-rw-r--r--src/mscorlib/shared/System/Globalization/DateTimeFormatInfoScanner.cs1
-rw-r--r--src/mscorlib/shared/System/Globalization/DateTimeParse.cs8
-rw-r--r--src/mscorlib/shared/System/Globalization/EastAsianLunisolarCalendar.cs6
-rw-r--r--src/mscorlib/shared/System/Globalization/GregorianCalendar.cs7
-rw-r--r--src/mscorlib/shared/System/Globalization/GregorianCalendarHelper.cs7
-rw-r--r--src/mscorlib/shared/System/Globalization/HebrewCalendar.cs2
-rw-r--r--src/mscorlib/shared/System/Globalization/HijriCalendar.cs5
-rw-r--r--src/mscorlib/shared/System/Globalization/JapaneseCalendar.cs3
-rw-r--r--src/mscorlib/shared/System/Globalization/JapaneseLunisolarCalendar.cs2
-rw-r--r--src/mscorlib/shared/System/Globalization/JulianCalendar.cs3
-rw-r--r--src/mscorlib/shared/System/Globalization/KoreanCalendar.cs3
-rw-r--r--src/mscorlib/shared/System/Globalization/KoreanLunisolarCalendar.cs3
-rw-r--r--src/mscorlib/shared/System/Globalization/LocaleData.Unix.cs1
-rw-r--r--src/mscorlib/shared/System/Globalization/NumberFormatInfo.cs28
-rw-r--r--src/mscorlib/shared/System/Globalization/PersianCalendar.cs3
-rw-r--r--src/mscorlib/shared/System/Globalization/SortKey.cs2
-rw-r--r--src/mscorlib/shared/System/Globalization/StringInfo.cs5
-rw-r--r--src/mscorlib/shared/System/Globalization/TaiwanCalendar.cs3
-rw-r--r--src/mscorlib/shared/System/Globalization/TaiwanLunisolarCalendar.cs2
-rw-r--r--src/mscorlib/shared/System/Globalization/ThaiBuddhistCalendar.cs3
-rw-r--r--src/mscorlib/shared/System/Globalization/UmAlQuraCalendar.cs4
-rw-r--r--src/mscorlib/shared/System/Guid.cs254
-rw-r--r--src/mscorlib/shared/System/IFormattable.cs2
-rw-r--r--src/mscorlib/shared/System/IO/Error.cs2
-rw-r--r--src/mscorlib/shared/System/IO/FileStream.Unix.cs18
-rw-r--r--src/mscorlib/shared/System/IO/Path.cs9
-rw-r--r--src/mscorlib/shared/System/IO/PinnedBufferMemoryStream.cs1
-rw-r--r--src/mscorlib/shared/System/IO/UnmanagedMemoryStream.cs39
-rw-r--r--src/mscorlib/shared/System/IO/UnmanagedMemoryStreamWrapper.cs4
-rw-r--r--src/mscorlib/shared/System/Int16.cs7
-rw-r--r--src/mscorlib/shared/System/Int32.cs16
-rw-r--r--src/mscorlib/shared/System/Int64.cs5
-rw-r--r--src/mscorlib/shared/System/Lazy.cs6
-rw-r--r--src/mscorlib/shared/System/Math.cs (renamed from src/mscorlib/src/System/Math.cs)972
-rw-r--r--src/mscorlib/shared/System/MathF.cs (renamed from src/mscorlib/src/System/MathF.cs)175
-rw-r--r--src/mscorlib/shared/System/Memory.cs10
-rw-r--r--src/mscorlib/shared/System/MemoryDebugView.cs40
-rw-r--r--src/mscorlib/shared/System/ParseNumbers.cs674
-rw-r--r--src/mscorlib/shared/System/ReadOnlyMemory.cs8
-rw-r--r--src/mscorlib/shared/System/ReadOnlySpan.cs4
-rw-r--r--src/mscorlib/shared/System/Resources/RuntimeResourceSet.cs2
-rw-r--r--src/mscorlib/shared/System/Runtime/CompilerServices/ConfiguredValueTaskAwaitable.cs5
-rw-r--r--src/mscorlib/shared/System/Runtime/CompilerServices/ValueTaskAwaiter.cs3
-rw-r--r--src/mscorlib/shared/System/Runtime/Versioning/TargetFrameworkAttribute.cs2
-rw-r--r--src/mscorlib/shared/System/SByte.cs7
-rw-r--r--src/mscorlib/shared/System/Single.cs13
-rw-r--r--src/mscorlib/shared/System/Span.cs4
-rw-r--r--src/mscorlib/shared/System/StringComparer.cs11
-rw-r--r--src/mscorlib/shared/System/Text/ASCIIEncoding.cs14
-rw-r--r--src/mscorlib/shared/System/Text/Decoder.cs6
-rw-r--r--src/mscorlib/shared/System/Text/DecoderNLS.cs7
-rw-r--r--src/mscorlib/shared/System/Text/DecoderReplacementFallback.cs2
-rw-r--r--src/mscorlib/shared/System/Text/Encoder.cs6
-rw-r--r--src/mscorlib/shared/System/Text/EncoderBestFitFallback.cs2
-rw-r--r--src/mscorlib/shared/System/Text/EncoderExceptionFallback.cs3
-rw-r--r--src/mscorlib/shared/System/Text/EncoderNLS.cs7
-rw-r--r--src/mscorlib/shared/System/Text/EncoderReplacementFallback.cs3
-rw-r--r--src/mscorlib/shared/System/Text/Encoding.cs55
-rw-r--r--src/mscorlib/shared/System/Text/EncodingNLS.cs12
-rw-r--r--src/mscorlib/shared/System/Text/Latin1Encoding.cs3
-rw-r--r--src/mscorlib/shared/System/Text/StringBuilder.cs51
-rw-r--r--src/mscorlib/shared/System/Text/UTF32Encoding.cs15
-rw-r--r--src/mscorlib/shared/System/Text/UTF7Encoding.cs14
-rw-r--r--src/mscorlib/shared/System/Text/UTF8Encoding.cs14
-rw-r--r--src/mscorlib/shared/System/Text/UnicodeEncoding.cs14
-rw-r--r--src/mscorlib/shared/System/Threading/ExecutionContext.cs4
-rw-r--r--src/mscorlib/shared/System/TimeSpan.cs4
-rw-r--r--src/mscorlib/shared/System/UInt16.cs5
-rw-r--r--src/mscorlib/shared/System/UInt32.cs5
-rw-r--r--src/mscorlib/shared/System/UInt64.cs5
-rw-r--r--src/mscorlib/shared/System/ValueTuple.cs6
-rw-r--r--src/mscorlib/shared/System/Version.cs6
-rw-r--r--src/mscorlib/src/Internal/Padding.cs1
-rw-r--r--src/mscorlib/src/Internal/Runtime/Augments/RuntimeThread.cs5
-rw-r--r--src/mscorlib/src/Microsoft/Win32/OAVariantLib.cs4
-rw-r--r--src/mscorlib/src/Microsoft/Win32/RegistryKey.cs5
-rw-r--r--src/mscorlib/src/System/Activator.cs3
-rw-r--r--src/mscorlib/src/System/AppDomain.cs10
-rw-r--r--src/mscorlib/src/System/AppDomainSetup.cs2
-rw-r--r--src/mscorlib/src/System/ArgIterator.cs1
-rw-r--r--src/mscorlib/src/System/Array.cs145
-rw-r--r--src/mscorlib/src/System/ArraySegment.cs14
-rw-r--r--src/mscorlib/src/System/Attribute.cs39
-rw-r--r--src/mscorlib/src/System/BCLDebug.cs5
-rw-r--r--src/mscorlib/src/System/Buffer.cs1
-rw-r--r--src/mscorlib/src/System/Collections/Comparer.cs2
-rw-r--r--src/mscorlib/src/System/Collections/CompatibleComparer.cs2
-rw-r--r--src/mscorlib/src/System/Collections/Concurrent/ConcurrentDictionary.cs2
-rw-r--r--src/mscorlib/src/System/Collections/EmptyReadOnlyDictionaryInternal.cs5
-rw-r--r--src/mscorlib/src/System/Collections/Generic/ArraySortHelper.cs255
-rw-r--r--src/mscorlib/src/System/Collections/Generic/Comparer.cs3
-rw-r--r--src/mscorlib/src/System/Collections/Generic/ComparerHelpers.cs3
-rw-r--r--src/mscorlib/src/System/Collections/Generic/DebugView.cs124
-rw-r--r--src/mscorlib/src/System/Collections/Generic/Dictionary.cs9
-rw-r--r--src/mscorlib/src/System/Collections/Generic/EqualityComparer.cs35
-rw-r--r--src/mscorlib/src/System/Collections/Hashtable.cs35
-rw-r--r--src/mscorlib/src/System/Collections/ObjectModel/ReadOnlyDictionary.cs10
-rw-r--r--src/mscorlib/src/System/DateTime.CoreCLR.cs2
-rw-r--r--src/mscorlib/src/System/Decimal.cs13
-rw-r--r--src/mscorlib/src/System/Delegate.cs9
-rw-r--r--src/mscorlib/src/System/Diagnostics/Assert.cs1
-rw-r--r--src/mscorlib/src/System/Diagnostics/Contracts/Contracts.cs4
-rw-r--r--src/mscorlib/src/System/Diagnostics/Contracts/ContractsBCL.cs6
-rw-r--r--src/mscorlib/src/System/Diagnostics/DebuggerAttributes.cs5
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/XplatEventLogger.cs4
-rw-r--r--src/mscorlib/src/System/Diagnostics/LogSwitch.cs2
-rw-r--r--src/mscorlib/src/System/Diagnostics/Stackframe.cs3
-rw-r--r--src/mscorlib/src/System/Diagnostics/Stacktrace.cs7
-rw-r--r--src/mscorlib/src/System/Diagnostics/log.cs2
-rw-r--r--src/mscorlib/src/System/Empty.cs1
-rw-r--r--src/mscorlib/src/System/Enum.cs31
-rw-r--r--src/mscorlib/src/System/Environment.cs4
-rw-r--r--src/mscorlib/src/System/Exception.cs3
-rw-r--r--src/mscorlib/src/System/GC.cs45
-rw-r--r--src/mscorlib/src/System/Globalization/CalendarData.Windows.cs1
-rw-r--r--src/mscorlib/src/System/Globalization/CharUnicodeInfo.cs5
-rw-r--r--src/mscorlib/src/System/Globalization/CompareInfo.Invariant.cs2
-rw-r--r--src/mscorlib/src/System/Globalization/CompareInfo.Unix.cs2
-rw-r--r--src/mscorlib/src/System/Globalization/CompareInfo.Windows.cs2
-rw-r--r--src/mscorlib/src/System/Globalization/CompareInfo.cs25
-rw-r--r--src/mscorlib/src/System/Globalization/CultureInfo.cs27
-rw-r--r--src/mscorlib/src/System/Globalization/EncodingTable.Unix.cs2
-rw-r--r--src/mscorlib/src/System/Globalization/EncodingTable.cs2
-rw-r--r--src/mscorlib/src/System/Globalization/IdnMapping.cs9
-rw-r--r--src/mscorlib/src/System/Globalization/RegionInfo.cs2
-rw-r--r--src/mscorlib/src/System/Globalization/TextInfo.Unix.cs1
-rw-r--r--src/mscorlib/src/System/Globalization/TextInfo.cs3
-rw-r--r--src/mscorlib/src/System/Guid.CoreCLR.cs8
-rw-r--r--src/mscorlib/src/System/IO/BinaryReader.cs28
-rw-r--r--src/mscorlib/src/System/IO/Directory.cs23
-rw-r--r--src/mscorlib/src/System/IO/File.cs8
-rw-r--r--src/mscorlib/src/System/IO/FileSystemEnumerable.cs36
-rw-r--r--src/mscorlib/src/System/IO/MemoryStream.cs47
-rw-r--r--src/mscorlib/src/System/IO/Stream.cs164
-rw-r--r--src/mscorlib/src/System/IO/StreamReader.cs9
-rw-r--r--src/mscorlib/src/System/IO/TextReader.cs39
-rw-r--r--src/mscorlib/src/System/IO/UnmanagedMemoryAccessor.cs9
-rw-r--r--src/mscorlib/src/System/IO/__Error.cs2
-rw-r--r--src/mscorlib/src/System/IntPtr.cs6
-rw-r--r--src/mscorlib/src/System/Math.CoreCLR.cs85
-rw-r--r--src/mscorlib/src/System/MathF.CoreCLR.cs76
-rw-r--r--src/mscorlib/src/System/MissingMemberException.cs1
-rw-r--r--src/mscorlib/src/System/MulticastDelegate.cs3
-rw-r--r--src/mscorlib/src/System/Nullable.cs2
-rw-r--r--src/mscorlib/src/System/Number.cs1
-rw-r--r--src/mscorlib/src/System/Object.cs16
-rw-r--r--src/mscorlib/src/System/ParseNumbers.cs75
-rw-r--r--src/mscorlib/src/System/Reflection/Assembly.CoreCLR.cs16
-rw-r--r--src/mscorlib/src/System/Reflection/AssemblyName.cs3
-rw-r--r--src/mscorlib/src/System/Reflection/Associates.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/CustomAttribute.cs98
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs16
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderData.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ConstructorBuilder.cs2
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs2
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs12
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs7
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs4
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/EventBuilder.cs4
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs4
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/FlowControl.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs3
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs27
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/MethodBuilder.cs12
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs3
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs49
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ModuleBuilderData.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/OpCodeType.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/OpCodes.cs2
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/Opcode.cs5
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/OperandType.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ParameterBuilder.cs3
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs2
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs5
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/StackBehaviour.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/SymbolMethod.cs2
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/SymbolType.cs4
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs57
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs7
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs4
-rw-r--r--src/mscorlib/src/System/Reflection/ExceptionHandlingClause.cs2
-rw-r--r--src/mscorlib/src/System/Reflection/MdImport.cs4
-rw-r--r--src/mscorlib/src/System/Reflection/RtFieldInfo.cs3
-rw-r--r--src/mscorlib/src/System/Reflection/RuntimeAssembly.cs6
-rw-r--r--src/mscorlib/src/System/Reflection/RuntimeConstructorInfo.cs7
-rw-r--r--src/mscorlib/src/System/Reflection/RuntimeEventInfo.cs7
-rw-r--r--src/mscorlib/src/System/Reflection/RuntimeFieldInfo.cs3
-rw-r--r--src/mscorlib/src/System/Reflection/RuntimeMethodInfo.cs11
-rw-r--r--src/mscorlib/src/System/Reflection/RuntimeModule.cs4
-rw-r--r--src/mscorlib/src/System/Reflection/RuntimeParameterInfo.cs11
-rw-r--r--src/mscorlib/src/System/Reflection/RuntimePropertyInfo.cs13
-rw-r--r--src/mscorlib/src/System/ResId.cs97
-rw-r--r--src/mscorlib/src/System/Resources/FileBasedResourceGroveler.cs1
-rw-r--r--src/mscorlib/src/System/Resources/ManifestBasedResourceGroveler.cs11
-rw-r--r--src/mscorlib/src/System/Resources/ResourceManager.cs9
-rw-r--r--src/mscorlib/src/System/Resources/ResourceReader.cs37
-rw-r--r--src/mscorlib/src/System/Resources/ResourceSet.cs3
-rw-r--r--src/mscorlib/src/System/Resources/__FastResourceComparer.cs1
-rw-r--r--src/mscorlib/src/System/RtType.cs53
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs855
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/TaskAwaiter.cs108
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/TypeDependencyAttribute.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/YieldAwaitable.cs14
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/jithelpers.cs10
-rw-r--r--src/mscorlib/src/System/Runtime/GcSettings.cs3
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/Attributes.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/GcHandle.cs3
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/Marshal.cs30
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/SafeBuffer.cs5
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToCollectionAdapter.cs5
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToListAdapter.cs3
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIKeyValuePairImpl.cs8
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIPropertyValueImpl.cs65
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIReferenceImpl.cs13
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs15
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CustomPropertyImpl.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryToMapAdapter.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryValueCollection.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/EnumeratorToIteratorAdapter.cs3
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/EventRegistrationTokenTable.cs6
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IClosable.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ICustomProperty.cs7
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ICustomPropertyProvider.cs24
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IIterable.cs3
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IIterator.cs6
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IMap.cs11
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IMapViewToIReadOnlyDictionaryAdapter.cs5
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IPropertyValue.cs40
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IReadOnlyDictionaryToIMapViewAdapter.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IReadOnlyListToIVectorViewAdapter.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IVector.cs21
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IVectorViewToIReadOnlyListAdapter.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IteratorToEnumeratorAdapter.cs3
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToBindableVectorAdapter.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToBindableVectorViewAdapter.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToVectorAdapter.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ManagedActivationFactory.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapToCollectionAdapter.cs3
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapToDictionaryAdapter.cs9
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapViewToReadOnlyCollectionAdapter.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/PropertyValue.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorToCollectionAdapter.cs3
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorToListAdapter.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorViewToReadOnlyCollectionAdapter.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs36
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMetadata.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Aes.PlatformNotSupported.cs74
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Aes.cs26
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Avx.PlatformNotSupported.cs996
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Avx.cs440
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Avx2.PlatformNotSupported.cs1362
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Avx2.cs632
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Bmi1.PlatformNotSupported.cs80
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Bmi1.cs30
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Bmi2.PlatformNotSupported.cs54
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Bmi2.cs18
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Fma.PlatformNotSupported.cs119
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Fma.cs50
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Lzcnt.PlatformNotSupported.cs26
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Lzcnt.cs7
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Pclmulqdq.PlatformNotSupported.cs27
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Pclmulqdq.cs6
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Popcnt.PlatformNotSupported.cs26
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Popcnt.cs7
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse.PlatformNotSupported.cs218
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse.cs80
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse2.PlatformNotSupported.cs1057
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse2.cs492
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse3.PlatformNotSupported.cs78
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse3.cs38
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse41.PlatformNotSupported.cs408
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse41.cs240
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse42.PlatformNotSupported.cs233
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse42.cs76
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Ssse3.PlatformNotSupported.cs92
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/X86/Ssse3.cs34
-rw-r--r--src/mscorlib/src/System/Runtime/Loader/AssemblyLoadContext.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/MemoryFailPoint.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/FormatterConverter.cs18
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/SerializationInfo.cs8
-rw-r--r--src/mscorlib/src/System/RuntimeHandles.cs6
-rw-r--r--src/mscorlib/src/System/SharedStatics.cs1
-rw-r--r--src/mscorlib/src/System/String.Comparison.cs66
-rw-r--r--src/mscorlib/src/System/String.Manipulation.cs125
-rw-r--r--src/mscorlib/src/System/String.Searching.cs31
-rw-r--r--src/mscorlib/src/System/String.cs36
-rw-r--r--src/mscorlib/src/System/StubHelpers.cs3
-rw-r--r--src/mscorlib/src/System/Text/Normalization.Windows.cs1
-rw-r--r--src/mscorlib/src/System/Threading/EventWaitHandle.cs4
-rw-r--r--src/mscorlib/src/System/Threading/ManualResetEventSlim.cs3
-rw-r--r--src/mscorlib/src/System/Threading/Monitor.cs3
-rw-r--r--src/mscorlib/src/System/Threading/Mutex.cs3
-rw-r--r--src/mscorlib/src/System/Threading/Overlapped.cs3
-rw-r--r--src/mscorlib/src/System/Threading/Semaphore.cs1
-rw-r--r--src/mscorlib/src/System/Threading/SemaphoreSlim.cs3
-rw-r--r--src/mscorlib/src/System/Threading/SynchronizationContext.cs2
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/AsyncCausalityTracer.cs1
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/ConcurrentExclusiveSchedulerPair.cs24
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/FutureFactory.cs47
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/ProducerConsumerQueues.cs11
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/Task.cs123
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/TaskCompletionSource.cs1
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/TaskContinuation.cs23
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/TaskExceptionHolder.cs11
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/TaskFactory.cs50
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/TaskScheduler.cs3
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/TaskToApm.cs13
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/ThreadPoolTaskScheduler.cs1
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/future.cs1
-rw-r--r--src/mscorlib/src/System/Threading/Thread.cs12
-rw-r--r--src/mscorlib/src/System/Threading/ThreadLocal.cs1
-rw-r--r--src/mscorlib/src/System/Threading/ThreadPool.cs142
-rw-r--r--src/mscorlib/src/System/Threading/Timer.cs7
-rw-r--r--src/mscorlib/src/System/Threading/WaitHandle.cs7
-rw-r--r--src/mscorlib/src/System/ThrowHelper.cs5
-rw-r--r--src/mscorlib/src/System/TimeZoneInfo.AdjustmentRule.cs3
-rw-r--r--src/mscorlib/src/System/TimeZoneInfo.TransitionTime.cs5
-rw-r--r--src/mscorlib/src/System/TimeZoneInfo.Unix.cs3
-rw-r--r--src/mscorlib/src/System/TimeZoneInfo.cs11
-rw-r--r--src/mscorlib/src/System/Tuple.cs1
-rw-r--r--src/mscorlib/src/System/Type.CoreCLR.cs6
-rw-r--r--src/mscorlib/src/System/TypeLoadException.cs1
-rw-r--r--src/mscorlib/src/System/TypeNameParser.cs6
-rw-r--r--src/mscorlib/src/System/TypedReference.cs2
-rw-r--r--src/mscorlib/src/System/UIntPtr.cs4
-rw-r--r--src/mscorlib/src/System/Variant.cs1
-rw-r--r--src/mscorlib/src/System/WeakReference.cs3
-rw-r--r--src/mscorlib/src/System/WeakReferenceOfT.cs3
-rw-r--r--src/pal/inc/pal.h54
-rw-r--r--src/pal/prebuilt/idl/xclrdata_i.cpp3
-rw-r--r--src/pal/prebuilt/inc/xclrdata.h179
-rw-r--r--src/pal/src/file/file.cpp3
-rw-r--r--src/pal/src/include/pal/corunix.hpp3
-rw-r--r--src/pal/src/include/pal/synchobjects.hpp3
-rw-r--r--src/pal/src/init/pal.cpp8
-rw-r--r--src/pal/src/numa/numa.cpp112
-rw-r--r--src/pal/src/synchmgr/synchcontrollers.cpp152
-rw-r--r--src/pal/src/synchmgr/synchmanager.cpp2
-rw-r--r--src/pal/src/synchmgr/synchmanager.hpp7
-rw-r--r--src/pal/src/synchmgr/wait.cpp35
-rw-r--r--src/scripts/genEventPipe.py2
-rw-r--r--src/sign.builds2
-rw-r--r--src/vm/amd64/JitHelpers_InlineGetThread.asm1005
-rw-r--r--src/vm/amd64/JitHelpers_Slow.asm888
-rw-r--r--src/vm/amd64/asmconstants.h33
-rw-r--r--src/vm/amd64/cgencpu.h10
-rw-r--r--src/vm/class.cpp9
-rw-r--r--src/vm/compile.cpp1
-rw-r--r--src/vm/comsynchronizable.cpp14
-rw-r--r--src/vm/comutilnative.cpp645
-rw-r--r--src/vm/comutilnative.h36
-rw-r--r--src/vm/ecalllist.h16
-rw-r--r--src/vm/eventpipe.cpp15
-rw-r--r--src/vm/eventpipeconfiguration.cpp45
-rw-r--r--src/vm/eventpipeconfiguration.h6
-rw-r--r--src/vm/eventpipeprovider.cpp18
-rw-r--r--src/vm/eventpipeprovider.h2
-rw-r--r--src/vm/exceptionhandling.cpp2
-rw-r--r--src/vm/finalizerthread.cpp2
-rw-r--r--src/vm/gcenv.os.cpp4
-rw-r--r--src/vm/gdbjit.cpp265
-rw-r--r--src/vm/gdbjit.h10
-rw-r--r--src/vm/i386/asmconstants.h76
-rw-r--r--src/vm/i386/asmhelpers.S3
-rw-r--r--src/vm/i386/cgencpu.h18
-rw-r--r--src/vm/i386/cgenx86.cpp25
-rw-r--r--src/vm/i386/jithelp.asm1052
-rw-r--r--src/vm/jithelpers.cpp319
-rw-r--r--src/vm/jitinterface.cpp117
-rw-r--r--src/vm/jitinterface.h8
-rw-r--r--src/vm/jitinterfacegen.cpp42
-rw-r--r--src/vm/method.hpp3
-rw-r--r--src/vm/mscorlib.h11
-rw-r--r--src/vm/prestub.cpp6
-rw-r--r--src/vm/readytoruninfo.cpp12
-rw-r--r--src/vm/syncblk.cpp84
-rw-r--r--src/vm/syncblk.h10
-rw-r--r--src/vm/syncblk.inl227
-rw-r--r--src/vm/synch.cpp412
-rw-r--r--src/vm/synch.h93
-rw-r--r--src/vm/threads.cpp47
-rw-r--r--src/vm/threads.h137
-rw-r--r--src/vm/util.cpp15
-rw-r--r--src/vm/util.hpp5
-rw-r--r--src/vm/virtualcallstub.cpp8
-rw-r--r--src/vm/virtualcallstub.h7
-rw-r--r--src/vm/win32threadpool.cpp119
-rw-r--r--src/vm/win32threadpool.h244
-rw-r--r--src/zap/zapinfo.cpp6
-rw-r--r--src/zap/zapinfo.h4
-rw-r--r--tests/arm/Tests.lst182
-rw-r--r--tests/arm64/Tests.lst24
-rw-r--r--tests/build.proj6
-rw-r--r--tests/issues.targets18
-rw-r--r--tests/runtest.cmd4
-rw-r--r--tests/runtest.proj1
-rwxr-xr-xtests/scripts/arm32_ci_script.sh4
-rw-r--r--tests/scripts/arm64_post_build.py42
-rw-r--r--tests/src/Common/build_against_pkg_dependencies/build_against_pkg_dependencies.csproj2
-rw-r--r--tests/src/Common/external/external.depproj4
-rw-r--r--tests/src/Common/targeting_pack_ref/targeting_pack_ref.csproj2
-rw-r--r--tests/src/Common/test_dependencies/test_dependencies.csproj2
-rw-r--r--tests/src/Common/test_runtime/test_runtime.csproj2
-rw-r--r--tests/src/Interop/MarshalAPI/String/StringMarshalingTest.cs19
-rw-r--r--tests/src/JIT/CodeGenBringUpTests/StructReturn.cs420
-rw-r--r--tests/src/JIT/CodeGenBringUpTests/StructReturn.csproj30
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/README.TXT34
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/binarytrees/binarytrees-2.cs122
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/binarytrees/binarytrees-2.csproj (renamed from tests/src/JIT/Performance/CodeQuality/BenchmarksGame/binarytrees/binarytrees.csproj)4
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/binarytrees/binarytrees-5.cs147
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/binarytrees/binarytrees-5.csproj (renamed from tests/src/JIT/Performance/CodeQuality/BenchmarksGame/binarytrees/binarytrees3.csproj)4
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/binarytrees/binarytrees.csharp.cs154
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/binarytrees/binarytrees.csharp3.cs141
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fannkuch-redux/fannkuch-redux-2.cs (renamed from tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fannkuch-redux/fannkuch-redux.csharp.cs)74
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fannkuch-redux/fannkuch-redux-2.csproj (renamed from tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fasta/fasta.csproj)4
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fannkuch-redux/fannkuch-redux-5.cs158
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fannkuch-redux/fannkuch-redux-5.csproj (renamed from tests/src/JIT/Performance/CodeQuality/BenchmarksGame/nbody/nbody.csproj)6
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fasta/fasta-1.cs307
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fasta/fasta-1.csproj (renamed from tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fannkuch-redux/fannkuch-redux.csproj)4
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fasta/fasta-2.cs210
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fasta/fasta-2.csproj38
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fasta/fasta.csharp-2.cs222
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fastaredux/fastaredux.csharp.cs186
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/harness-helpers.cs102
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/k-nucleotide-1.cs230
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/k-nucleotide-1.csproj (renamed from tests/src/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/k-nucleotide.csproj)9
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/k-nucleotide-9.cs333
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/k-nucleotide-9.csproj49
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/k-nucleotide.cs311
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/mandelbrot/mandelbrot-2.cs138
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/mandelbrot/mandelbrot-2.csproj (renamed from tests/src/JIT/Performance/CodeQuality/BenchmarksGame/mandelbrot/mandelbrot.csproj)4
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/mandelbrot/mandelbrot-4.cs (renamed from tests/src/JIT/Performance/CodeQuality/BenchmarksGame/mandelbrot/mandelbrot.csharp.cs)117
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/mandelbrot/mandelbrot-4.csproj38
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/n-body/n-body-3.cs160
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/n-body/n-body-3.csproj (renamed from tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fastaredux/fastaredux.csproj)4
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/nbody/nbody.csharp-3.cs158
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/pidigits/pi-digits.cs116
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/pidigits/pidigits-3.cs160
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/pidigits/pidigits-3.csproj38
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/harness-helpers.cs94
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/regex-redux-1.cs131
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/regex-redux-1.csproj (renamed from tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regexdna/regexdna.csproj)5
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/regex-redux-5.cs123
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/regex-redux-5.csproj49
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/regexdna-input25.txt (renamed from tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regexdna/regexdna-input25.txt)0
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/regexdna-input25000.txt (renamed from tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regexdna/regexdna-input25000.txt)0
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regexdna/regexdna.csharp-6.cs229
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/revcomp/revcomp.csharp-1.cs249
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/harness-helpers.cs97
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/revcomp-input25.txt (renamed from tests/src/JIT/Performance/CodeQuality/BenchmarksGame/revcomp/revcomp-input25.txt)0
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/revcomp-input25000.txt (renamed from tests/src/JIT/Performance/CodeQuality/BenchmarksGame/revcomp/revcomp-input25000.txt)0
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/reverse-complement-1.cs180
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/reverse-complement-1.csproj (renamed from tests/src/JIT/Performance/CodeQuality/BenchmarksGame/revcomp/revcomp.csproj)5
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/reverse-complement-6.cs290
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/reverse-complement-6.csproj49
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm-1.cs115
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm-1.csproj38
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm-3.cs175
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm-3.csproj38
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm.cs128
-rw-r--r--tests/src/JIT/Performance/CodeQuality/Devirtualization/DefaultEqualityComparerPerf.cs207
-rw-r--r--tests/src/JIT/Performance/CodeQuality/Devirtualization/DefaultEqualityComparerPerf.csproj40
-rw-r--r--tests/src/JIT/Regression/JitBlue/DevDiv_491206/DevDiv_491206.il70
-rw-r--r--tests/src/JIT/Regression/JitBlue/DevDiv_491206/DevDiv_491206.ilproj (renamed from tests/src/JIT/Performance/CodeQuality/BenchmarksGame/pidigits/pi-digits.csproj)20
-rw-r--r--tests/src/JIT/Regression/JitBlue/DevDiv_495792/DevDiv_495792.il140
-rw-r--r--tests/src/JIT/Regression/JitBlue/DevDiv_495792/DevDiv_495792.ilproj (renamed from tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm.csproj)21
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_13057/GitHub_13057.cs80
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_13057/GitHub_13057.csproj38
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_13568/GitHub_13568.cs168
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_13568/GitHub_13568.csproj26
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_13910/GitHub_13910.cs120
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_13910/GitHub_13910.csproj45
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_14028/GitHub_14028.cs31
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_14028/GitHub_14028.csproj39
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_14116/GitHub_14116.il58
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_14116/GitHub_14116.ilproj24
-rw-r--r--tests/src/JIT/opt/FastTailCall/FastTailCallInlining.cs39
-rw-r--r--tests/src/JIT/opt/FastTailCall/FastTailCallInlining.csproj45
-rw-r--r--tests/src/baseservices/threading/commitstackonlyasneeded/StackCommitCommon.cs14
-rw-r--r--tests/src/dirs.proj1
-rw-r--r--tests/src/performance/performance.csproj3
-rw-r--r--tests/src/sizeondisk/sodbench/SoDBench.cs702
-rw-r--r--tests/src/sizeondisk/sodbench/SoDBench.csproj42
-rw-r--r--tests/src/tracing/common/common.csproj1
-rw-r--r--tests/src/tracing/eventsourcesmoke/eventsourcesmoke.csproj1
-rw-r--r--tests/x64_arm64_altjit.cmd6
-rw-r--r--tests/x86_arm_altjit.cmd6
629 files changed, 19963 insertions, 14324 deletions
diff --git a/.gitattributes b/.gitattributes
index 519ecbb037..27e6703185 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -69,8 +69,10 @@ src/pal/tests/palsuite/paltestlist_to_be_reviewed.txt text eol=lf
tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regexdna/regexdna-input25.txt text eol=lf
tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regexdna/regexdna-input25000.txt text eol=lf
-tests/src/JIT/Performance/CodeQuality/BenchmarksGame/revcomp/revcomp-input25.txt text eol=lf
-tests/src/JIT/Performance/CodeQuality/BenchmarksGame/revcomp/revcomp-input25000.txt text eol=lf
+tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/regexdna-input25.txt text eol=lf
+tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/regexdna-input25000.txt text eol=lf
+tests/src/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/revcomp-input25.txt text eol=lf
+tests/src/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/revcomp-input25000.txt text eol=lf
tests/src/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/knucleotide-input.txt text eol=lf
tests/src/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/knucleotide-input-big.txt text eol=lf
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9b24a77e90..be792744bf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -43,7 +43,7 @@ endif()
# Ensure other tools are present
if (WIN32)
if(CLR_CMAKE_HOST_ARCH STREQUAL arm)
-
+
# Confirm that Windows SDK is present
if(NOT DEFINED CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION OR CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION STREQUAL "" )
message(FATAL_ERROR "Windows SDK is required for the Arm32 build.")
@@ -57,9 +57,9 @@ if (WIN32)
else()
file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}\\bin\\HostX86\\arm\\armasm.exe" CMAKE_ASM_COMPILER)
endif()
-
+
set(CMAKE_ASM_MASM_COMPILER ${CMAKE_ASM_COMPILER})
- message("CMAKE_ASM_MASM_COMPILER explicitly set to: ${CMAKE_ASM_MASM_COMPILER}")
+ message("CMAKE_ASM_MASM_COMPILER explicitly set to: ${CMAKE_ASM_MASM_COMPILER}")
# Enable generic assembly compilation to avoid CMake generate VS proj files that explicitly
# use ml[64].exe as the assembler.
@@ -75,13 +75,13 @@ if (WIN32)
endif()
if (CLR_CMAKE_HOST_ARCH STREQUAL arm64)
- # CMAKE_CXX_COMPILER will default to the compiler installed with
- # Visual studio. Overwrite it to the compiler on the path.
- # TODO, remove when cmake generator supports Arm64 as a target.
- find_program(PATH_CXX_COMPILER cl)
- set(CMAKE_CXX_COMPILER ${PATH_CXX_COMPILER})
- message("Overwriting the CMAKE_CXX_COMPILER.")
- message(CMAKE_CXX_COMPILER found:${CMAKE_CXX_COMPILER})
+ # CMAKE_CXX_COMPILER will default to the compiler installed with
+ # Visual studio. Overwrite it to the compiler on the path.
+ # TODO, remove when cmake generator supports Arm64 as a target.
+ find_program(PATH_CXX_COMPILER cl)
+ set(CMAKE_CXX_COMPILER ${PATH_CXX_COMPILER})
+ message("Overwriting the CMAKE_CXX_COMPILER.")
+ message(CMAKE_CXX_COMPILER found:${CMAKE_CXX_COMPILER})
endif()
else (WIN32)
@@ -97,7 +97,7 @@ else (WIN32)
# but the generated executables won't work on a system where PAX is set
# to prevent applications to create executable memory mappings.
find_program(PAXCTL paxctl)
-
+
if (CMAKE_SYSTEM_NAME STREQUAL Darwin)
# Ensure that dsymutil and strip are present
@@ -155,7 +155,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL Linux)
endif()
else()
# CMAKE_SYSTEM_PROCESSOR returns the value of `uname -p` on target.
- # For the AMD/Intel 64bit architecure two different strings are common.
+ # For the AMD/Intel 64bit architecture two different strings are common.
# Linux and Darwin identify it as "x86_64" while FreeBSD and netbsd uses the
# "amd64" string. Accept either of the two here.
if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64)
@@ -330,13 +330,13 @@ if (WIN32)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /MANIFEST:NO") #Do not create Side-by-Side Assembly Manifest
if (CLR_CMAKE_PLATFORM_ARCH_ARM)
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,6.02") #windows subsystem - arm minimum is 6.02
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,6.02") #windows subsystem - arm minimum is 6.02
elseif(CLR_CMAKE_PLATFORM_ARCH_ARM64)
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,6.03") #windows subsystem - arm64 minimum is 6.03
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,6.03") #windows subsystem - arm64 minimum is 6.03
else ()
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,6.01") #windows subsystem
endif ()
-
+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LARGEADDRESSAWARE") # can handle addresses larger than 2 gigabytes
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NXCOMPAT") #Compatible with Data Execution Prevention
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DYNAMICBASE") #Use address space layout randomization
@@ -379,11 +379,11 @@ if (WIN32)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /machine:arm64")
endif(CLR_CMAKE_PLATFORM_ARCH_ARM64)
- # Force uCRT to be dynamically linked for Release build
- set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
- set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
- set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
- set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
+ # Force uCRT to be dynamically linked for Release build
+ set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
+ set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
+ set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
+ set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
elseif (CLR_CMAKE_PLATFORM_UNIX)
# Set the values to display when interactively configuring CMAKE_BUILD_TYPE
@@ -446,11 +446,11 @@ elseif (CLR_CMAKE_PLATFORM_UNIX)
endif(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL CHECKED)
endif(WIN32)
-if(CLR_CMAKE_PLATFORM_LINUX)
+if(CLR_CMAKE_PLATFORM_LINUX)
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Wa,--noexecstack")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--build-id=sha1")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--build-id=sha1")
-endif(CLR_CMAKE_PLATFORM_LINUX)
+endif(CLR_CMAKE_PLATFORM_LINUX)
#------------------------------------
# Definitions (for platform)
@@ -505,9 +505,9 @@ if (CLR_CMAKE_PLATFORM_UNIX)
message("Detected FreeBSD amd64")
endif(CLR_CMAKE_PLATFORM_FREEBSD)
- if(CLR_CMAKE_PLATFORM_NETBSD)
- message("Detected NetBSD amd64")
- endif(CLR_CMAKE_PLATFORM_NETBSD)
+ if(CLR_CMAKE_PLATFORM_NETBSD)
+ message("Detected NetBSD amd64")
+ endif(CLR_CMAKE_PLATFORM_NETBSD)
endif(CLR_CMAKE_PLATFORM_UNIX)
if (WIN32)
@@ -578,7 +578,7 @@ endif()
# Above projects do not build with these compile options
# All of the compiler options are specified in file compileoptions.cmake
-# Do not add any new options here. They shoul be added in compileoptions.cmake
+# Do not add any new options here. They should be added in compileoptions.cmake
if(WIN32)
add_compile_options(/FIWarningControl.h) # force include of WarningControl.h
add_compile_options(/Zl) # omit default library name in .OBJ
diff --git a/Documentation/botr/clr-abi.md b/Documentation/botr/clr-abi.md
index c0ec331911..cfa0130f62 100644
--- a/Documentation/botr/clr-abi.md
+++ b/Documentation/botr/clr-abi.md
@@ -75,7 +75,7 @@ NOTE: This optimization is now disabled for all platforms (`IsStructRequiringSta
## Hidden parameters
-*Stub dispatch* - when a virtual call uses a VSD stub, rather than back-patching the calling code (or disassembling it), the JIT must place the address of the stub used to load the call target, the "stub indirection cell", in (x86) `EAX` / (AMD64) `R11` / (ARM) `R4` / (ARM64) `R11`. In the JIT, this is `REG_VIRTUAL_STUB_PARAM`.
+*Stub dispatch* - when a virtual call uses a VSD stub, rather than back-patching the calling code (or disassembling it), the JIT must place the address of the stub used to load the call target, the "stub indirection cell", in (x86) `EAX` / (AMD64) `R11` / (AMD64 CoreRT ABI) `R10` / (ARM) `R4` / (ARM CoreRT ABI) `R12` / (ARM64) `R11`. In the JIT, this is encapsulated in the `VirtualStubParamInfo` class.
AMD64-only: Fast Pinvoke - The VM wants a conservative estimate of the size of the stack arguments placed in `R11`. (This is consumed by callout stubs used in SQL hosting).
@@ -119,7 +119,7 @@ For IL stubs only, the per-frame initialization includes setting `Thread->m_pFra
2. For JIT64/AMD64 only: Next for non-IL stubs, the InlinedCallFrame is 'pushed' by setting `Thread->m_pFrame` to point to the InlinedCallFrame (recall that the per-frame initialization already set `InlinedCallFrame->m_pNext` to point to the previous top). For IL stubs this step is accomplished in the per-frame initialization.
3. The Frame is made active by setting `InlinedCallFrame->m_pCallerReturnAddress`.
4. The code then toggles the GC mode by setting `Thread->m_fPreemptiveGCDisabled = 0`.
-5. Starting now, no GC pointers may be live in registers.
+5. Starting now, no GC pointers may be live in registers. RyuJit LSRA meets this requirement by adding special refPositon `RefTypeKillGCRefs` before unmanaged calls and special helpers.
6. Then comes the actual call/PInvoke.
7. The GC mode is set back by setting `Thread->m_fPreemptiveGCDisabled = 1`.
8. Then we check to see if `g_TrapReturningThreads` is set (non-zero). If it is, we call `CORINFO_HELP_STOP_FOR_GC`.
diff --git a/Documentation/building/cross-building.md b/Documentation/building/cross-building.md
index 30c7aca741..261b902b06 100644
--- a/Documentation/building/cross-building.md
+++ b/Documentation/building/cross-building.md
@@ -1,3 +1,21 @@
+Cross Compilation for ARM on Windows
+==================================
+
+Building ARM for Windows can be done using cross compilation.
+
+Requirements
+------------
+
+Install the ARM tools and Windows SDK, as described [here](https://github.com/dotnet/coreclr/blob/master/Documentation/building/windows-instructions.md).
+
+Cross compiling CoreCLR
+-----------------------
+
+Build using "-arm" as the architecture. For example:
+
+ C:\coreclr> build.cmd -arm -debug
+
+
Cross Compilation for ARM on Linux
==================================
diff --git a/Documentation/building/windows-instructions.md b/Documentation/building/windows-instructions.md
index a5ce25780c..6700aba970 100644
--- a/Documentation/building/windows-instructions.md
+++ b/Documentation/building/windows-instructions.md
@@ -45,7 +45,8 @@ For Visual Studio 2017:
* Visual Studio C++ core features
* Under "SDKs, libraries, and frameworks":
* Windows 10 SDK or Windows 8.1 SDK
-* To build for Arm32, Make sure that you have the Windows 10 SDK installed (or selected to be installed as part of VS installation). To explicitly install Windows SDK, download it from here: [Windows SDK for Windows 10](https://developer.microsoft.com/en-us/windows/downloads)
+* To build for Arm32, Make sure that you have the Windows 10 SDK installed (or selected to be installed as part of VS installation). To explicitly install Windows SDK, download it from here: [Windows SDK for Windows 10](https://developer.microsoft.com/en-us/windows/downloads).
+ * In addition, ensure you install the ARM tools. In the "Individual components" window, in the "Compilers, build tools, and runtimes" section, check the box for "Visual C++ compilers and libraries for ARM".
* **Important:** You must have the `msdia120.dll` COM Library registered in order to build the repository.
* This binary is registered by default when installing the "VC++ Tools" with Visual Studio 2015
* You can also manually register the binary by launching the "Developer Command Prompt for VS2017" with Administrative privileges and running `regsvr32.exe "%VSINSTALLDIR%\Common7\IDE\msdia120.dll"`
diff --git a/Documentation/project-docs/linux-performance-tracing.md b/Documentation/project-docs/linux-performance-tracing.md
index c9d66fa8dd..559c82f6ff 100644
--- a/Documentation/project-docs/linux-performance-tracing.md
+++ b/Documentation/project-docs/linux-performance-tracing.md
@@ -1,4 +1,4 @@
-Performance Tracing on Linux
+Performance Tracing on Linux
============================
When a performance problem is encountered on Linux, these instructions can be used to gather detailed information about what was happening on the machine at the time of the performance problem.
@@ -81,6 +81,26 @@ Follow these steps to prepare your machine to collect a performance trace.
The compressed trace file is now stored in the current working directory.
+# Resolving Framework Symbols #
+Framework symbols need to be manually generated at the time the trace is collected. They are different than app-level symbols because the framework is pre-compiled while apps are just-in-time-compiled.
+
+The easiest way to generate framework symbols is to have perfcollect do it for you automatically when the trace is collected. To do this, crossgen must be present on the collection machine and located next to libcoreclr.so. This can be done manually using the following steps:
+
+1. Download the CoreCLR nuget package. A simple way to do this is to create a self-contained version of your application using the dotnet CLI:
+ > ```bash
+ > dotnet publish --self-contained -r linux-x64
+ > ```
+
+ This will create a bin/*/netcoreapp2.0/Linux-x64/publish directory which contains all of the files required to run your app including the .NET runtime and framework. As a side-effect, the dotnet CLI downloads and extracts the CoreCLR nuget package. You should be able to find crossgen at:
+
+ > ```bash
+ > ~/packages/runtime.linux-x64.microsoft.netcore.app/2.0.0/tools/crossgen
+ > ```
+
+2. Copy crossgen next to libcoreclr.so. If you run your application out of the publish directory, you can copy it into the directory that you just created during step # 1. If you run your application using the dotnet CLI, then you likely need to copy it to /usr/share/dotnet/shared/Microsoft.NETCore.App/<Version> where <Version> is the version number of CoreCLR. This should match the version number in the path to crossgen from step # 1.
+
+Now, traces containing apps that were run on the updated runtime should contain framework-level symbols. To view the trace with framework-level symbols, you will need to use PerfView. Details on using PerfView to view a trace are available below in this document.
+
# Collecting in a Docker Container #
Perfcollect can be used to collect data for an application running inside a Docker container. The main thing to know is that collecting a trace requires elevated privileges because the [default seccomp profile](https://docs.docker.com/engine/security/seccomp/) blocks a required syscall - perf_events_open.
diff --git a/build-test.sh b/build-test.sh
index 0ebee805de..2b83380dcb 100755
--- a/build-test.sh
+++ b/build-test.sh
@@ -37,6 +37,10 @@ initTargetDistroRid()
export __DistroRid="osx-$__BuildArch"
fi
fi
+
+ if [ "$ID.$VERSION_ID" == "ubuntu.16.04" ]; then
+ export __DistroRid="ubuntu.14.04-$__BuildArch"
+ fi
}
isMSBuildOnNETCoreSupported()
diff --git a/build.cmd b/build.cmd
index c0c5cb7a43..b26743008e 100644
--- a/build.cmd
+++ b/build.cmd
@@ -273,9 +273,9 @@ if not exist "%__BinDir%" md "%__BinDir%"
if not exist "%__IntermediatesDir%" md "%__IntermediatesDir%"
if not exist "%__LogsDir%" md "%__LogsDir%"
-REM It is convinient to have your Nuget search path include the location where the build
-REM will plass packages. However nuget used during the build will fail if that directory
-REM does not exist. Avoid this in at least one case by agressively creating the directory.
+REM It is convenient to have your Nuget search path include the location where the build
+REM will place packages. However nuget used during the build will fail if that directory
+REM does not exist. Avoid this in at least one case by aggressively creating the directory.
if not exist "%__BinDir%\.nuget\pkg" md "%__BinDir%\.nuget\pkg"
echo %__MsgPrefix%Commencing CoreCLR Repo build
@@ -296,7 +296,7 @@ echo %__MsgPrefix%Using environment: "%__VSToolsRoot%\VsDevCmd.bat"
call "%__VSToolsRoot%\VsDevCmd.bat"
@if defined _echo @echo on
-@call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\build.proj -generateHeaderWindows -NativeVersionHeaderFile="%__RootBinDir%\obj\_version.h" %__RunArgs% %__UnprocessedBuildArgs%
+@call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\build.proj -generateHeaderWindows -NativeVersionHeaderFile="%__RootBinDir%\obj\_version.h" %__RunArgs% %__UnprocessedBuildArgs%
REM =========================================================================================
REM ===
@@ -342,7 +342,7 @@ if %__BuildNative% EQU 1 (
set nativePlatfromArgs=-platform=%__BuildArch%
if /i "%__BuildArch%" == "arm64" ( set nativePlatfromArgs=-useEnv )
- if /i "%__BuildArch%" == "arm64" (
+ if /i "%__BuildArch%" == "arm64" (
rem arm64 builds currently use private toolset which has not been released yet
REM TODO, remove once the toolset is open.
call :PrivateToolSet
@@ -354,7 +354,7 @@ if %__BuildNative% EQU 1 (
if /i "%__BuildArch%" == "x86" ( set __VCBuildArch=x86 )
if /i "%__BuildArch%" == "arm" (
set __VCBuildArch=x86_arm
-
+
REM Make CMake pick the highest installed version in the 10.0.* range
set ___SDKVersion="-DCMAKE_SYSTEM_VERSION=10.0"
)
@@ -474,7 +474,7 @@ if /i "%__DoCrossArchBuild%"=="1" (
echo !__BuildWrn!
echo !__BuildErr!
exit /b 1
- )
+ )
:SkipCrossCompBuild
REM } Scope environment changes end
@@ -632,7 +632,7 @@ if %__BuildTests% EQU 1 (
rem arm64 builds currently use private toolset which has not been released yet
REM TODO, remove once the toolset is open.
- if /i "%__BuildArch%" == "arm64" call :PrivateToolSet
+ if /i "%__BuildArch%" == "arm64" call :PrivateToolSet
set NEXTCMD=call %__ProjectDir%\build-test.cmd %__BuildArch% %__BuildType% %__UnprocessedBuildArgs%
echo %__MsgPrefix%!NEXTCMD!
@@ -642,7 +642,7 @@ if %__BuildTests% EQU 1 (
REM buildtest.cmd has already emitted an error message and mentioned the build log file to examine.
exit /b 1
)
-)
+)
REM =========================================================================================
REM ===
diff --git a/buildpipeline/DotNet-CoreClr-Trusted-Windows-x86.json b/buildpipeline/DotNet-CoreClr-Trusted-Windows-x86.json
index a4d6566a98..f941575fe1 100644
--- a/buildpipeline/DotNet-CoreClr-Trusted-Windows-x86.json
+++ b/buildpipeline/DotNet-CoreClr-Trusted-Windows-x86.json
@@ -6,13 +6,14 @@
"alwaysRun": false,
"displayName": "Install Signing Plugin",
"timeoutInMinutes": 0,
+ "condition": "ne(variables['PB_SignType'], 'oss')",
"task": {
"id": "30666190-6959-11e5-9f96-f56098202fef",
"versionSpec": "1.*",
"definitionType": "task"
},
"inputs": {
- "signType": "$(SignType)",
+ "signType": "real",
"zipSources": "false",
"version": "",
"feedSource": "https://devdiv.pkgs.visualstudio.com/DefaultCollection/_packaging/MicroBuildToolset/nuget/v3/index.json"
@@ -86,7 +87,7 @@
},
"inputs": {
"filename": "build.cmd",
- "arguments": "$(Architecture) $(PB_BuildType) skiptests skipbuildpackages $(PB_EnforcePGO) -OfficialBuildId=$(OfficialBuildId) -skiprestore -Priority=$(Priority)",
+ "arguments": "$(Architecture) $(PB_BuildType) skiptests skipbuildpackages $(PB_EnforcePGO) -OfficialBuildId=$(OfficialBuildId) -skiprestore -Priority=$(Priority) -- /p:SignType=$(PB_SignType)",
"workingFolder": "",
"failOnStandardError": "false"
}
@@ -106,7 +107,7 @@
"solution": "src\\sign.builds",
"platform": "",
"configuration": "",
- "msbuildArguments": "/p:SignType=$(SignType) /p:BuildType=$(PB_BuildType) /p:BuildArch=$(Architecture)",
+ "msbuildArguments": "/p:SignType=$(PB_SignType) /p:BuildType=$(PB_BuildType) /p:BuildArch=$(Architecture)",
"clean": "false",
"maximumCpuCount": "false",
"restoreNugetPackages": "false",
@@ -131,7 +132,7 @@
},
"inputs": {
"filename": "build-packages.cmd",
- "arguments": "-BuildArch=$(Architecture) -BuildType=$(PB_BuildType) -- /p:OfficialBuildId=$(OfficialBuildId)",
+ "arguments": "-BuildArch=$(Architecture) -BuildType=$(PB_BuildType) -- /p:SignType=$(PB_SignType) /p:OfficialBuildId=$(OfficialBuildId)",
"workingFolder": "",
"failOnStandardError": "false"
}
@@ -276,8 +277,9 @@
"Label": {
"value": "$(Build.BuildNumber)"
},
- "SignType": {
- "value": "test"
+ "PB_SignType": {
+ "value": "test",
+ "allowOverride": true
},
"TeamName": {
"value": "DotNetCore"
diff --git a/buildpipeline/DotNet-CoreClr-Trusted-Windows.json b/buildpipeline/DotNet-CoreClr-Trusted-Windows.json
index a97132b25e..6997893c17 100644
--- a/buildpipeline/DotNet-CoreClr-Trusted-Windows.json
+++ b/buildpipeline/DotNet-CoreClr-Trusted-Windows.json
@@ -6,13 +6,14 @@
"alwaysRun": false,
"displayName": "Install Signing Plugin",
"timeoutInMinutes": 0,
+ "condition": "ne(variables['PB_SignType'], 'oss')",
"task": {
"id": "30666190-6959-11e5-9f96-f56098202fef",
"versionSpec": "1.*",
"definitionType": "task"
},
"inputs": {
- "signType": "$(SignType)",
+ "signType": "real",
"zipSources": "false",
"version": "",
"feedSource": "https://devdiv.pkgs.visualstudio.com/DefaultCollection/_packaging/MicroBuildToolset/nuget/v3/index.json"
@@ -86,7 +87,7 @@
},
"inputs": {
"filename": "build.cmd",
- "arguments": "$(Architecture) $(PB_BuildType) skiptests skipbuildpackages $(PB_EnforcePGO) toolset_dir C:\\tools\\clr -OfficialBuildId=$(OfficialBuildId) -Priority=$(Priority) -skiprestore -disableoss -- /flp:\"v=diag\"",
+ "arguments": "$(Architecture) $(PB_BuildType) skiptests skipbuildpackages $(PB_EnforcePGO) toolset_dir C:\\tools\\clr -OfficialBuildId=$(OfficialBuildId) -Priority=$(Priority) -skiprestore -- /p:SignType=$(PB_SignType) /flp:\"v=diag\"",
"workingFolder": "",
"failOnStandardError": "false"
}
@@ -106,7 +107,7 @@
"solution": "src\\sign.builds",
"platform": "",
"configuration": "",
- "msbuildArguments": "/p:SignType=$(SignType) /p:BuildType=$(PB_BuildType) /p:BuildArch=$(Architecture)",
+ "msbuildArguments": "/p:SignType=$(PB_SignType) /p:BuildType=$(PB_BuildType) /p:BuildArch=$(Architecture)",
"clean": "false",
"maximumCpuCount": "false",
"restoreNugetPackages": "false",
@@ -131,7 +132,7 @@
},
"inputs": {
"filename": "build-packages.cmd",
- "arguments": "-BuildArch=$(Architecture) -BuildType=$(PB_BuildType) -- /p:OfficialBuildId=$(OfficialBuildId)",
+ "arguments": "-BuildArch=$(Architecture) -BuildType=$(PB_BuildType) -- /p:SignType=$(PB_SignType) /p:OfficialBuildId=$(OfficialBuildId)",
"workingFolder": "",
"failOnStandardError": "false"
}
@@ -278,7 +279,7 @@
"Label": {
"value": "$(Build.BuildNumber)"
},
- "SignType": {
+ "PB_SignType": {
"value": "test",
"allowOverride": true
},
diff --git a/buildpipeline/DotNet-Trusted-Publish.json b/buildpipeline/DotNet-Trusted-Publish.json
index a1f0e665c9..490ea2b936 100644
--- a/buildpipeline/DotNet-Trusted-Publish.json
+++ b/buildpipeline/DotNet-Trusted-Publish.json
@@ -25,6 +25,7 @@
"alwaysRun": false,
"displayName": "Install Signing Plugin",
"timeoutInMinutes": 0,
+ "condition": "and(succeeded(), ne(variables['PB_SignType'], 'oss'))",
"task": {
"id": "30666190-6959-11e5-9f96-f56098202fef",
"versionSpec": "1.*",
@@ -103,6 +104,7 @@
"alwaysRun": false,
"displayName": "Inject signed symbol catalogs",
"timeoutInMinutes": 0,
+ "condition": "and(succeeded(), ne(variables['PB_SignType'], 'oss'))",
"task": {
"id": "d9bafed4-0b18-4f58-968d-86655b4d2ce9",
"versionSpec": "1.*",
@@ -187,9 +189,9 @@
"inputs": {
"scriptType": "inlineScript",
"scriptName": "",
- "arguments": "-ApiKey $(MyGetApiKey) -ConfigurationGroup $(ConfigurationGroup) -PackagesGlob $(Pipeline.SourcesDirectory)\\packages\\AzureTransfer\\$(ConfigurationGroup)\\$(AzureContainerPackageGlob) -MyGetFeedUrl $(MyGetFeedUrl)",
+ "arguments": "-ApiKey $(MyGetApiKey) -ConfigurationGroup $(ConfigurationGroup) -PackagesGlob $(Pipeline.SourcesDirectory)\\packages\\AzureTransfer\\$(ConfigurationGroup)\\$(AzureContainerPackageGlob) -MyGetFeedUrl $(MyGetFeedUrl) -SignType $(PB_SignType)",
"workingFolder": "$(Pipeline.SourcesDirectory)",
- "inlineScript": "param($ApiKey, $ConfigurationGroup, $PackagesGlob, $MyGetFeedUrl)\n\nif ($ConfigurationGroup -ne \"Release\") { exit }\n\nmsbuild /t:NuGetPush /v:Normal `\n/p:NuGetExePath=$env:CustomNuGetPath `\n/p:NuGetApiKey=$ApiKey `\n/p:NuGetSource=$MyGetFeedUrl `\n/p:PackagesGlob=$PackagesGlob",
+ "inlineScript": "param($ApiKey, $ConfigurationGroup, $PackagesGlob, $MyGetFeedUrl, $SignType=\"unset\")\n\nif ($ConfigurationGroup.ToLower() -ne \"release\") { Write-host \"Chose not to publish\"; exit }\n\nmsbuild /t:NuGetPush /v:Normal `\n/p:NuGetExePath=$env:CustomNuGetPath `\n/p:NuGetApiKey=$ApiKey `\n/p:NuGetSource=$MyGetFeedUrl `\n/p:PackagesGlob=$PackagesGlob",
"failOnStandardError": "true"
}
},
@@ -207,49 +209,9 @@
"inputs": {
"scriptType": "inlineScript",
"scriptName": "",
- "arguments": "-ApiKey $(MyGetApiKey) -ConfigurationGroup $(ConfigurationGroup) -PackagesGlob $(Build.StagingDirectory)\\IndexedSymbolPackages\\*.nupkg -MyGetFeedUrl $(MyGetFeedUrl)",
+ "arguments": "-ApiKey $(MyGetApiKey) -ConfigurationGroup $(ConfigurationGroup) -PackagesGlob $(Build.StagingDirectory)\\IndexedSymbolPackages\\*.nupkg -MyGetFeedUrl $(MyGetFeedUrl) -SignType $(PB_SignType)",
"workingFolder": "$(Pipeline.SourcesDirectory)",
- "inlineScript": "param($ApiKey, $ConfigurationGroup, $PackagesGlob, $MyGetFeedUrl)\n\nif ($ConfigurationGroup -ne \"Release\") { exit }\nif ($env:SourceBranch.StartsWith(\"release/\")) { exit }\n\nmsbuild /t:NuGetPush /v:Normal `\n/p:NuGetExePath=$env:CustomNuGetPath `\n/p:NuGetApiKey=$ApiKey `\n/p:NuGetSource=$MyGetFeedUrl `\n/p:PackagesGlob=$PackagesGlob",
- "failOnStandardError": "true"
- }
- },
- {
- "enabled": false,
- "continueOnError": false,
- "alwaysRun": false,
- "displayName": "Create VSTS auth NuGet.Config",
- "timeoutInMinutes": 0,
- "task": {
- "id": "e213ff0f-5d5c-4791-802d-52ea3e7be1f1",
- "versionSpec": "1.*",
- "definitionType": "task"
- },
- "inputs": {
- "scriptType": "inlineScript",
- "scriptName": "",
- "arguments": "$(VstsAuthedNuGetConfigPath) $(VstsFeedUrl) $(VstsPat)",
- "inlineScript": "param($path, $url, $pat)\n\nSet-Content $path @\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<configuration>\n <packageSources>\n <add key=\"vsts-dotnet-core\" value=\"$url\" />\n </packageSources>\n <packageSourceCredentials>\n <vsts-dotnet-core>\n <add key=\"Username\" value=\"VssSessionToken\" />\n <add key=\"ClearTextPassword\" value=\"$pat\" />\n </vsts-dotnet-core>\n </packageSourceCredentials>\n</configuration>\n\"@",
- "workingFolder": "",
- "failOnStandardError": "true"
- }
- },
- {
- "enabled": false,
- "continueOnError": false,
- "alwaysRun": false,
- "displayName": "packages -> VSTS",
- "timeoutInMinutes": 0,
- "task": {
- "id": "e213ff0f-5d5c-4791-802d-52ea3e7be1f1",
- "versionSpec": "1.*",
- "definitionType": "task"
- },
- "inputs": {
- "scriptType": "inlineScript",
- "scriptName": "",
- "arguments": "",
- "inlineScript": "if ($env:ConfigurationGroup -ne \"Release\") { exit }\n& $env:CustomNuGetPath push $env:Pipeline.SourcesDirectory\\packages\\AzureTransfer\\$env:ConfigurationGroup\\$env:AzureContainerPackageGlob placeholderapikey -Source vsts-dotnet-core -ConfigFile $env:VstsAuthedNuGetConfigPath -Timeout 3600",
- "workingFolder": "",
+ "inlineScript": "param($ApiKey, $ConfigurationGroup, $PackagesGlob, $MyGetFeedUrl, $SignType=\"unset\")\n\nif ($ConfigurationGroup.ToLower() -ne \"release\") { Write-host \"Chose not to publish\"; exit }\nif ($env:SourceBranch.StartsWith(\"release/\")) { exit }\n\nmsbuild /t:NuGetPush /v:Normal `\n/p:NuGetExePath=$env:CustomNuGetPath `\n/p:NuGetApiKey=$ApiKey `\n/p:NuGetSource=$MyGetFeedUrl `\n/p:PackagesGlob=$PackagesGlob",
"failOnStandardError": "true"
}
},
@@ -267,8 +229,8 @@
"inputs": {
"scriptType": "inlineScript",
"scriptName": "",
- "arguments": "-gitHubAuthToken $(UpdatePublishedVersions.AuthToken) -root $(Pipeline.SourcesDirectory) -configGroup $(ConfigurationGroup)",
- "inlineScript": "param($gitHubAuthToken, $root, $configGroup)\nif ($configGroup -ne \"Release\") { exit }\ncd $root\n. $root\\UpdatePublishedVersions.ps1 `\n -gitHubUser dotnet-build-bot -gitHubEmail dotnet-build-bot@microsoft.com `\n -gitHubAuthToken $gitHubAuthToken `\n -versionsRepoOwner $env:VersionsRepoOwner -versionsRepo versions `\n -versionsRepoPath build-info/dotnet/$env:GitHubRepositoryName/$env:SourceBranch `\n -nupkgPath $root\\packages\\AzureTransfer\\$env:ConfigurationGroup\\$env:AzureContainerPackageGlob",
+ "arguments": "-gitHubAuthToken $(UpdatePublishedVersions.AuthToken) -root $(Pipeline.SourcesDirectory) -configGroup $(ConfigurationGroup) -SignType $(PB_SignType)",
+ "inlineScript": "param($gitHubAuthToken, $root, $configGroup, $SignType=\"unset\")\nif ($configGroup -ne \"Release\" -or $SignType.ToLower() -ne \"real\" ) { exit }\ncd $root\n. $root\\UpdatePublishedVersions.ps1 `\n -gitHubUser dotnet-build-bot -gitHubEmail dotnet-build-bot@microsoft.com `\n -gitHubAuthToken $gitHubAuthToken `\n -versionsRepoOwner $env:VersionsRepoOwner -versionsRepo versions `\n -versionsRepoPath build-info/dotnet/$env:GitHubRepositoryName/$env:SourceBranch `\n -nupkgPath $root\\packages\\AzureTransfer\\$env:ConfigurationGroup\\$env:AzureContainerPackageGlob",
"workingFolder": "",
"failOnStandardError": "true"
}
@@ -620,4 +582,4 @@
"state": "wellFormed",
"revision": 418097633
}
-} \ No newline at end of file
+}
diff --git a/clrfeatures.cmake b/clrfeatures.cmake
index 3d5d155c3a..2c22a9dce1 100644
--- a/clrfeatures.cmake
+++ b/clrfeatures.cmake
@@ -1,5 +1,4 @@
if(CLR_CMAKE_TARGET_TIZEN_LINUX)
- set(FEATURE_EVENT_TRACE 0)
set(FEATURE_GDBJIT_LANGID_CS 1)
endif()
@@ -14,10 +13,14 @@ if(NOT DEFINED FEATURE_EVENT_TRACE)
endif()
if(CLR_CMAKE_PLATFORM_LINUX)
- if(CLR_CMAKE_TARGET_ARCH_AMD64)
+ if(CLR_CMAKE_TARGET_TIZEN_LINUX)
+ set(FEATURE_EVENT_TRACE 1)
+ elseif(CLR_CMAKE_TARGET_ARCH_AMD64)
set(FEATURE_EVENT_TRACE 1)
elseif(CLR_CMAKE_TARGET_ARCH_ARM)
set(FEATURE_EVENT_TRACE 1)
+ elseif(CLR_CMAKE_TARGET_ARCH_ARM64)
+ set(FEATURE_EVENT_TRACE 1)
endif()
endif(CLR_CMAKE_PLATFORM_LINUX)
endif(NOT DEFINED FEATURE_EVENT_TRACE)
diff --git a/cross/armel/tizen-fetch.sh b/cross/armel/tizen-fetch.sh
index c7a509a750..6048ead4a6 100755
--- a/cross/armel/tizen-fetch.sh
+++ b/cross/armel/tizen-fetch.sh
@@ -154,8 +154,8 @@ fetch_tizen_pkgs()
done
}
-Inform "Initialize base"
-fetch_tizen_pkgs_init standard base
+Inform "Initialize arm 4.0-base"
+fetch_tizen_pkgs_init arm 4.0-base
Inform "fetch common packages"
fetch_tizen_pkgs armv7l gcc glibc glibc-devel
fetch_tizen_pkgs noarch linux-glibc-devel
@@ -164,12 +164,12 @@ fetch_tizen_pkgs armv7l lldb lldb-devel libuuid libuuid-devel libgcc libstdc++ l
Inform "fetch corefx packages"
fetch_tizen_pkgs armv7l libcom_err libcom_err-devel zlib zlib-devel libopenssl libopenssl-devel
-Inform "Initialize unified"
-fetch_tizen_pkgs_init standard unified
+Inform "Initialize standard 4.0-unified"
+fetch_tizen_pkgs_init standard 4.0-unified
Inform "fetch common packages"
fetch_tizen_pkgs armv7l libicu-devel
Inform "fetch coreclr packages"
-fetch_tizen_pkgs armv7l tizen-release
+fetch_tizen_pkgs armv7l tizen-release lttng-ust-devel lttng-ust userspace-rcu-devel userspace-rcu
Inform "fetch corefx packages"
fetch_tizen_pkgs armv7l gssdp gssdp-devel krb5 krb5-devel libcurl libcurl-devel
diff --git a/cross/armel/tizen/tizen-dotnet.ks b/cross/armel/tizen/tizen-dotnet.ks
index e9b4b75ca3..d67cf2bb40 100644
--- a/cross/armel/tizen/tizen-dotnet.ks
+++ b/cross/armel/tizen/tizen-dotnet.ks
@@ -4,8 +4,12 @@ timezone --utc Asia/Seoul
part / --fstype="ext4" --size=3500 --ondisk=mmcblk0 --label rootfs --fsoptions=defaults,noatime
-repo --name=mobile --baseurl=http://download.tizen.org/releases/weekly/tizen/mobile/latest/repos/arm-wayland/packages/ --ssl_verify=no
-repo --name=base --baseurl=http://download.tizen.org/releases/weekly/tizen/base/latest/repos/arm/packages/ --ssl_verify=no
+rootpw tizen
+desktop --autologinuser=root
+user --name root --groups audio,video --password 'tizen'
+
+repo --name=standard --baseurl=http://download.tizen.org/releases/daily/tizen/4.0-unified/latest/repos/standard/packages/ --ssl_verify=no
+repo --name=base --baseurl=http://download.tizen.org/releases/daily/tizen/4.0-base/latest/repos/arm/packages/ --ssl_verify=no
%packages
tar
@@ -19,10 +23,13 @@ perl
binutils
findutils
util-linux
+lttng-ust
+userspace-rcu
procps-ng
tzdata
ca-certificates
+
### Core FX
libicu
libuuid
diff --git a/dir.props b/dir.props
index f8c48d50d7..62677f7743 100644
--- a/dir.props
+++ b/dir.props
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Condition="Exists('..\dir.props')" Project="..\dir.props" />
-
+
<!--
$(OS) is set to Unix/Windows_NT. This comes from an environment variable on Windows and MSBuild on Unix.
-->
@@ -24,7 +24,7 @@
<!--
Switching to the .NET Core version of the BuildTools tasks seems to break numerous scenarios, such as VS intellisense and resource designer
- as well as runnning the build on mono. Until we can get these sorted out we will continue using the .NET 4.5 version of the tasks.
+ as well as running the build on mono. Until we can get these sorted out we will continue using the .NET 4.5 version of the tasks.
-->
<PropertyGroup>
<RunningOnCore>false</RunningOnCore>
@@ -55,7 +55,7 @@
<SourceDir>$(__SourceDir)\</SourceDir>
<SourceDir Condition="'$(__SourceDir)'==''">$(ProjectDir)src\</SourceDir>
- <!-- This name is used to create a GIT reposiitory URL https://github.com/dotnet/$(GitHubRepositoryName) used to find source code for debugging -->
+ <!-- This name is used to create a GIT repository URL https://github.com/dotnet/$(GitHubRepositoryName) used to find source code for debugging -->
<GitHubRepositoryName Condition="'$(GitHubRepositoryName)' == ''">coreclr</GitHubRepositoryName>
<PackagesDir>$(__PackagesDir)\</PackagesDir>
@@ -66,7 +66,7 @@
<BinDir>$(__BinDir)\</BinDir>
<BinDir Condition="'$(__BinDir)'==''">$(RootBinDir)Product\$(BuildOS).$(BuildArch).$(BuildType)\</BinDir>
-
+
<__IntermediatesDir Condition="'$(__IntermediatesDir)' == ''">$(RootBinDir)obj\$(BuildOS).$(BuildArch).$(BuildType)</__IntermediatesDir>
<IntermediateOutputRootPath Condition="'$(IntermediateOutputRootPath)' == ''">$(__IntermediatesDir)\</IntermediateOutputRootPath>
@@ -141,7 +141,7 @@
<ReleaseNotes>https://go.microsoft.com/fwlink/?LinkID=799421</ReleaseNotes>
<ProjectUrl>https://dot.net</ProjectUrl>
-
+
<!-- On Windows, MSbuild still runs against Desktop FX while it runs on .NET Core on non-Windows. this requires
pulling in different packaging dependencies.
-->
@@ -152,7 +152,7 @@
<MinOSForArch>win7</MinOSForArch>
<MinOSForArch Condition="'$(PackagePlatform)' == 'arm'">win8</MinOSForArch>
<MinOSForArch Condition="'$(PackagePlatform)' == 'arm64'">win10</MinOSForArch>
- <!-- This property must be set to disable local package installation -->
+ <!-- This property must be set to disable local package installation -->
<SkipInstallLocallyBuiltPackages>true</SkipInstallLocallyBuiltPackages>
<!-- Define packaging attributes for cross target components -->
diff --git a/netci.groovy b/netci.groovy
index 0b1daa632e..6a90a3141e 100755
--- a/netci.groovy
+++ b/netci.groovy
@@ -138,10 +138,54 @@ class Constants {
'gc_reliability_framework',
'illink'] + r2rJitStressScenarios
+ // Knowledge of the "validArmWindowsScenarios" scenario names is embedded in the ARM64 CI code, so when adding any,
+ // make sure that code knows how to process them.
+ def static validArmWindowsScenarios = [
+ 'default',
+ 'pri1r2r',
+ 'zapdisable',
+ 'minopts',
+ 'tailcallstress',
+ 'jitstress1',
+ 'jitstress2',
+ 'gcstress0x3',
+ 'gcstress0xc',
+ 'jitstressregs1',
+ 'jitstressregs2',
+ 'jitstressregs3',
+ 'jitstressregs4',
+ 'jitstressregs8',
+ 'jitstressregs0x10',
+ 'jitstressregs0x80',
+ 'jitstressregs0x1000',
+ 'gcstress0xc_jitstress1',
+ 'gcstress0xc_jitstress2',
+ 'minopts_zapdisable',
+ 'gcstress0x3_jitstress1',
+ 'gcstress0x3_jitstress2',
+ 'gcstress0xc_jitstress1',
+ 'gcstress0xc_jitstress2',
+ 'gcstress0x3_jitstressregs1',
+ 'gcstress0x3_jitstressregs2',
+ 'gcstress0x3_jitstressregs3',
+ 'gcstress0x3_jitstressregs4',
+ 'gcstress0x3_jitstressregs8',
+ 'gcstress0x3_jitstressregs0x10',
+ 'gcstress0x3_jitstressregs0x80',
+ 'gcstress0x3_jitstressregs0x1000',
+ 'gcstress0xc_jitstressregs1',
+ 'gcstress0xc_jitstressregs2',
+ 'gcstress0xc_jitstressregs3',
+ 'gcstress0xc_jitstressregs4',
+ 'gcstress0xc_jitstressregs8',
+ 'gcstress0xc_jitstressregs0x10',
+ 'gcstress0xc_jitstressregs0x80',
+ 'gcstress0xc_jitstressregs0x1000']
+
def static configurationList = ['Debug', 'Checked', 'Release']
// This is the set of architectures
- def static architectureList = ['arm', 'arm64', 'x64', 'x86', 'x86lb']
+ def static architectureList = ['arm', 'armlb', 'x86_arm_altjit', 'x64_arm64_altjit', 'arm64', 'x64', 'x86', 'x86lb']
}
def static setMachineAffinity(def job, def os, def architecture, def options = null) {
@@ -153,9 +197,9 @@ def static setMachineAffinity(def job, def os, def architecture, def options = n
Utilities.setMachineAffinity(job, os, 'arm64-huge-page-size');
} else if (architecture == 'arm64' && os != 'Windows_NT' && options['is_build_only'] == true) {
Utilities.setMachineAffinity(job, os, 'arm64-cross-latest');
- } else if ((architecture == 'arm') && (os == 'Ubuntu' || os == 'Ubuntu16.04' || os == 'Tizen')) {
+ } else if ((architecture == 'armlb') && (os == 'Ubuntu' || os == 'Ubuntu16.04' || os == 'Tizen')) {
Utilities.setMachineAffinity(job, 'Ubuntu', 'arm-cross-latest');
- } else if ((architecture == 'arm') && (os == 'Windows_NT') && options['use_arm64_build_machine'] == true) {
+ } else if ((architecture == 'arm' || architecture == 'armlb') && (os == 'Windows_NT') && options['use_arm64_build_machine'] == true) {
Utilities.setMachineAffinity(job, os, 'latest-arm64');
}else {
Utilities.setMachineAffinity(job, os, 'latest-or-auto');
@@ -316,6 +360,16 @@ def static genStressModeScriptStep(def os, def stressModeName, def stressModeVar
return stepScript
}
+// Append an existing script to a stress mode script already created by genStressModeScriptStep().
+// Returns string of commands to do this.
+def static appendStressModeScriptStep(def os, def appendScript, def stepScriptLocation) {
+ assert (os == 'Windows_NT')
+ def stepScript = ''
+ stepScript += "echo Appending ${appendScript} to ${stepScriptLocation}\r\n"
+ stepScript += "type ${appendScript} >> ${stepScriptLocation}\r\n"
+ return stepScript
+}
+
// Calculates the name of the build job based on some typical parameters.
//
def static getJobName(def configuration, def architecture, def os, def scenario, def isBuildOnly) {
@@ -353,6 +407,9 @@ def static getJobName(def configuration, def architecture, def os, def scenario,
}
break
case 'arm':
+ baseName = architecture.toLowerCase() + '_cross_' + configuration.toLowerCase() + '_' + os.toLowerCase()
+ break
+ case 'armlb':
// These are cross builds
if (os == 'Tizen') {
// ABI: softfp
@@ -364,6 +421,8 @@ def static getJobName(def configuration, def architecture, def os, def scenario,
break
case 'x86':
case 'x86lb':
+ case 'x86_arm_altjit':
+ case 'x64_arm64_altjit':
baseName = architecture.toLowerCase() + '_' + configuration.toLowerCase() + '_' + os.toLowerCase()
break
default:
@@ -376,6 +435,16 @@ def static getJobName(def configuration, def architecture, def os, def scenario,
}
def static addNonPRTriggers(def job, def branch, def isPR, def architecture, def os, def configuration, def scenario, def isFlowJob, def isWindowsBuildOnlyJob, def bidailyCrossList) {
+
+ // Only PR triggers for altjit jobs.
+ switch (architecture) {
+ case 'x86_arm_altjit':
+ case 'x64_arm64_altjit':
+ return
+ default:
+ break
+ }
+
// Check scenario.
switch (scenario) {
case 'default':
@@ -391,6 +460,7 @@ def static addNonPRTriggers(def job, def branch, def isPR, def architecture, def
}
break
case 'arm':
+ case 'armlb':
Utilities.addGithubPushTrigger(job)
break
case 'arm64':
@@ -587,15 +657,23 @@ def static addNonPRTriggers(def job, def branch, def isPR, def architecture, def
case 'corefx_jitstressregs0x1000':
case 'zapdisable':
if (os != 'CentOS7.1' && !(os in bidailyCrossList)) {
- assert (os == 'Windows_NT') || (os in Constants.crossList)
- Utilities.addPeriodicTrigger(job, '@daily')
- }
- break
+ assert (os == 'Windows_NT') || (os in Constants.crossList)
+ if ((architecture == 'arm64') || (architecture == 'arm') || (architecture == 'armlb')) {
+ if (os == 'Windows_NT') {
+ // We don't have enough ARM64 machines to run these more frequently than weekly.
+ Utilities.addPeriodicTrigger(job, '@weekly')
+ }
+ }
+ else {
+ Utilities.addPeriodicTrigger(job, '@daily')
+ }
+ }
+ break
case 'heapverify1':
case 'gcstress0x3':
if (os != 'CentOS7.1' && !(os in bidailyCrossList)) {
assert (os == 'Windows_NT') || (os in Constants.crossList)
- if (architecture == 'arm64') {
+ if ((architecture == 'arm64') || (architecture == 'arm') || (architecture == 'armlb')) {
if (os == 'Windows_NT') {
Utilities.addPeriodicTrigger(job, '@daily')
}
@@ -617,7 +695,7 @@ def static addNonPRTriggers(def job, def branch, def isPR, def architecture, def
// GCStress=C is currently not supported on OS X
if (os != 'CentOS7.1' && os != 'OSX10.12' && !(os in bidailyCrossList)) {
assert (os == 'Windows_NT') || (os in Constants.crossList)
- if (architecture == 'arm64') {
+ if ((architecture == 'arm64') || (architecture == 'arm') || (architecture == 'armlb')) {
// TODO: Enable a periodic trigger after tests are updated.
// Utilities.addPeriodicTrigger(job, '@daily')
// TODO: Add once external email sending is available again
@@ -637,7 +715,7 @@ def static addNonPRTriggers(def job, def branch, def isPR, def architecture, def
Utilities.addPeriodicTrigger(job, '@daily')
}
}
- break
+ break
case 'tieredcompilation':
case 'corefx_tieredcompilation':
@@ -686,18 +764,14 @@ def static addTriggers(def job, def branch, def isPR, def architecture, def os,
'JosephTremoulet',
'pgodeq',
'pgavlin',
+ 'rartemev',
'russellhadley',
'RussKeldorph',
'sandreenko',
'sdmaclea',
- 'sivarv',
'swaroop-sridhar',
- 'gkhanna79',
'jkotas',
'markwilkie',
- 'rahku',
- 'ramarag',
- 'tzwlai',
'weshaggard'
]
@@ -1072,7 +1146,7 @@ def static addTriggers(def job, def branch, def isPR, def architecture, def os,
break
case 'illink':
Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} via ILLink", "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
- break
+ break
default:
println("Unknown scenario: ${scenario}");
assert false
@@ -1086,72 +1160,78 @@ def static addTriggers(def job, def branch, def isPR, def architecture, def os,
}
break
// editor brace matching: }
+ case 'armlb':
case 'arm': // editor brace matching: {
switch (os) {
case 'Ubuntu':
case 'Ubuntu16.04':
- assert scenario == 'default'
- job.with {
- publishers {
- azureVMAgentPostBuildAction {
- agentPostBuildAction('Delete agent if the build was not successful (when idle).')
+ if (architecture == 'armlb') { // Ubuntu arm is only for armlb currently
+ assert scenario == 'default'
+ job.with {
+ publishers {
+ azureVMAgentPostBuildAction {
+ agentPostBuildAction('Delete agent if the build was not successful (when idle).')
+ }
}
}
+ if ((os == 'Ubuntu' && configuration == 'Release') || (os == 'Ubuntu16.04' && configuration == 'Debug')) {
+ Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} Cross ${configuration} Build")
+ }
+ else {
+ Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} Cross ${configuration} Build",
+ "(?i).*test\\W+${os}\\W+${architecture}\\W+Cross\\W+${configuration}\\W+Build.*")
+ }
}
- if ((os == 'Ubuntu' && configuration == 'Release') || (os == 'Ubuntu16.04' && configuration == 'Debug')) {
- Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} Cross ${configuration} Build")
- }
- else {
- Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} Cross ${configuration} Build", "(?i).*test\\W+${os}\\W+${architecture}\\W+Cross\\W+${configuration}\\W+Build.*")
- }
- break;
+ break
case 'Tizen':
- architecture='armel'
- job.with {
- publishers {
- azureVMAgentPostBuildAction {
- agentPostBuildAction('Delete agent if the build was not successful (when idle).')
+ if (architecture == 'armlb') { // Ubuntu arm is only for armlb currently
+ architecture='armel'
+ job.with {
+ publishers {
+ azureVMAgentPostBuildAction {
+ agentPostBuildAction('Delete agent if the build was not successful (when idle).')
+ }
}
}
+ // Removing the regex will cause this to run on each PR.
+ if (configuration == 'Release' || configuration == 'Debug') {
+ Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} Cross ${configuration} Build")
+ }
+ else {
+ Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} Cross ${configuration} Build",
+ "(?i).*test\\W+${os}\\W+${architecture}\\W+Cross\\W+${configuration}\\W+Build.*")
+ }
}
- // Removing the regex will cause this to run on each PR.
- if (configuration == 'Release' || configuration == 'Debug') {
- Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} Cross ${configuration} Build")
- }
- else {
- Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} Cross ${configuration} Build", "(?i).*test\\W+${os}\\W+${architecture}\\W+Cross\\W+${configuration}\\W+Build.*")
- }
- break;
+ break
case 'Windows_NT':
// Set up a private trigger
def contextString = "${os} ${architecture} Cross ${configuration}"
if (scenario != 'default')
contextString += " ${scenario}"
contextString += " Build"
- // Debug builds only.
+ // Debug configuration only does builds, no tests.
if (configuration != 'Debug') {
contextString += " and Test"
}
switch (scenario) {
case 'default':
- // For now only run Debug and Release build jobs on PR Trigger. Note this is not a private trigger.
+ // Only Checked is a default trigger.
if (configuration == 'Debug' || configuration == 'Release')
{
Utilities.addPrivateGithubPRTriggerForBranch(job, branch, contextString,
- "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}.*", null, arm64Users)
+ "(?i).*test\\W+${os}\\W+${architecture}\\W+Cross\\W+${configuration}.*", null, arm64Users)
}
else
{
- // Checked jobs will run on private trigger and run tests.
Utilities.addDefaultPrivateGithubPRTriggerForBranch(job, branch, contextString, null, arm64Users)
}
break
- case 'pri1r2r':
- case 'gcstress0x3':
- case 'gcstress0xc':
- // Stress jobs will will run on private trigger and run tests.
- Utilities.addPrivateGithubPRTriggerForBranch(job, branch, contextString,
- "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*", null, arm64Users)
+ default:
+ // Stress jobs will use this code path.
+ if (Constants.validArmWindowsScenarios.contains(scenario)) {
+ Utilities.addPrivateGithubPRTriggerForBranch(job, branch, contextString,
+ "(?i).*test\\W+${os}\\W+${architecture}\\W+Cross\\W+${configuration}\\W+${scenario}.*", null, arm64Users)
+ }
break
}
break
@@ -1163,7 +1243,7 @@ def static addTriggers(def job, def branch, def isPR, def architecture, def os,
break
// editor brace matching: }
case 'arm64': // editor brace matching: {
- assert (scenario == 'default') || (scenario == 'pri1r2r') || (scenario == 'gcstress0x3') || (scenario == 'gcstress0xc')
+ assert Constants.validArmWindowsScenarios.contains(scenario)
// Set up a private trigger
def contextString = "${os} ${architecture} Cross ${configuration}"
@@ -1181,22 +1261,26 @@ def static addTriggers(def job, def branch, def isPR, def architecture, def os,
switch (scenario) {
case 'pri1':
if (configuration == 'Release') {
- Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Priority 1 Build and Test", "(?i).*test\\W+${os}\\W+${scenario}.*")
+ Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Priority 1 Build and Test",
+ "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
}
break
case 'r2r':
if (configuration == 'Checked' || configuration == 'Release') {
- Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} R2R pri0 Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
+ Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} R2R pri0 Build & Test",
+ "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
}
break
case 'pri1r2r':
if (configuration == 'Checked' || configuration == 'Release') {
- Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} R2R pri1 Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
+ Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} R2R pri1 Build & Test",
+ "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
}
break
case 'gcstress15_pri1r2r':
if (configuration == 'Release' || configuration == 'Checked') {
- Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} GCStress 15 R2R pri1 Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
+ Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} GCStress 15 R2R pri1 Build & Test",
+ "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
}
break
case 'r2r_jitstress1':
@@ -1213,7 +1297,8 @@ def static addTriggers(def job, def branch, def isPR, def architecture, def os,
case 'r2r_jitforcerelocs':
if (configuration == 'Release' || configuration == 'Checked') {
def displayStr = getR2RStressModeDisplayName(scenario)
- Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} ${displayStr} R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
+ Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} ${displayStr} R2R Build & Test",
+ "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
}
break
default:
@@ -1223,13 +1308,13 @@ def static addTriggers(def job, def branch, def isPR, def architecture, def os,
switch (scenario) {
case 'default':
if (isFlowJob == true) {
- Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration}", "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}.*")
+ Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration}",
+ "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}.*")
}
-
// For now only run Debug jobs on PR Trigger.
else if (configuration != 'Debug') {
Utilities.addPrivateGithubPRTriggerForBranch(job, branch, contextString,
- "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}.*", null, arm64Users)
+ "(?i).*test\\W+${os}\\W+${architecture}\\W+Cross\\W+${configuration}.*", null, arm64Users)
}
else {
// Add "Checked Build And Test" and "Debug Build" to the above users' PRs since many of them
@@ -1237,11 +1322,12 @@ def static addTriggers(def job, def branch, def isPR, def architecture, def os,
Utilities.addDefaultPrivateGithubPRTriggerForBranch(job, branch, contextString, null, arm64Users)
}
break
- case 'pri1r2r':
- case 'gcstress0x3':
- case 'gcstress0xc':
- Utilities.addPrivateGithubPRTriggerForBranch(job, branch, contextString,
- "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*", null, arm64Users)
+ default:
+ // Stress jobs will use this code path.
+ if (Constants.validArmWindowsScenarios.contains(scenario)) {
+ Utilities.addPrivateGithubPRTriggerForBranch(job, branch, contextString,
+ "(?i).*test\\W+${os}\\W+${architecture}\\W+Cross\\W+${configuration}\\W+${scenario}.*", null, arm64Users)
+ }
break
}
break
@@ -1420,6 +1506,21 @@ def static addTriggers(def job, def branch, def isPR, def architecture, def os,
}
break
// editor brace matching: }
+ case 'x64_arm64_altjit':
+ case 'x86_arm_altjit': // editor brace matching: {
+ assert (os == 'Windows_NT')
+ switch (scenario) {
+ case 'default':
+ Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test",
+ "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}.*")
+ break
+ default:
+ Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} ${scenario}",
+ "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
+ break
+ }
+ break
+ // editor brace matching: }
default:
println("Unknown architecture: ${architecture}");
assert false
@@ -1439,18 +1540,28 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR
case 'x64':
case 'x86':
case 'x86lb':
+ case 'x86_arm_altjit':
+ case 'x64_arm64_altjit':
def arch = architecture
def buildOpts = ''
- if (architecture == 'x86lb') {
+ if ((architecture == 'x86lb') || (architecture == 'x86_arm_altjit')) {
arch = 'x86'
}
+ else if (architecture == 'x64_arm64_altjit') {
+ arch = 'x64'
+ }
if (scenario == 'illink') {
buildCommands += "tests\\scripts\\build_illink.cmd clone ${arch}"
}
// If it is a release build for windows, ensure PGO is used, else fail the build
- if ((lowerConfiguration == 'release') && (scenario in Constants.basicScenarios) && (architecture != 'x86lb')) {
+ if ((lowerConfiguration == 'release') &&
+ (scenario in Constants.basicScenarios) &&
+ (architecture != 'x86lb') &&
+ (architecture != 'x86_arm_altjit') &&
+ (architecture != 'x64_arm64_altjit')) {
+
buildOpts += ' enforcepgo'
}
@@ -1491,11 +1602,7 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR
assert false
}
- // If we are running a stress mode, we should write out the set of key
- // value env pairs to a file at this point and then we'll pass that to runtest.cmd
-
if (!isBuildOnly) {
- //If this is a crossgen build, pass 'crossgen' to runtest.cmd
def crossgenStr = ''
def runcrossgentestsStr = ''
def runjitstressStr = ''
@@ -1505,114 +1612,129 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR
def runjitdisasmStr = ''
def runilasmroundtripStr = ''
def gcstressStr = ''
- def runtestArguments = ''
def gcTestArguments = ''
def illinkArguments = ''
+ def testEnvStr = ''
+ def runtestArguments = ''
if (scenario == 'r2r' ||
scenario == 'pri1r2r' ||
scenario == 'gcstress15_pri1r2r' ||
Constants.r2rJitStressScenarios.indexOf(scenario) != -1) {
- crossgenStr = 'crossgen'
- runcrossgentestsStr = 'runcrossgentests'
- if (scenario == 'r2r_jitstress1'){
- runjitstressStr = 'jitstress 1'
- }
- else if (scenario == 'r2r_jitstress2') {
- runjitstressStr = 'jitstress 2'
- }
- else if (scenario == 'r2r_jitstressregs1'){
- runjitstressregsStr = 'jitstressregs 1'
- }
- else if (scenario == 'r2r_jitstressregs2') {
- runjitstressregsStr = 'jitstressregs 2'
- }
- else if (scenario == 'r2r_jitstressregs3') {
- runjitstressregsStr = 'jitstressregs 3'
- }
- else if (scenario == 'r2r_jitstressregs4') {
- runjitstressregsStr = 'jitstressregs 4'
- }
- else if (scenario == 'r2r_jitstressregs8') {
- runjitstressregsStr = 'jitstressregs 8'
- }
- else if (scenario == 'r2r_jitstressregs0x10') {
- runjitstressregsStr = 'jitstressregs 0x10'
- }
- else if (scenario == 'r2r_jitstressregs0x80') {
- runjitstressregsStr = 'jitstressregs 0x80'
- }
- else if (scenario == 'r2r_jitstressregs0x1000') {
- runjitstressregsStr = 'jitstressregs 0x1000'
- }
- else if (scenario == 'r2r_jitminopts') {
- runjitmioptsStr = 'jitminopts'
- }
- else if (scenario == 'r2r_jitforcerelocs') {
- runjitforcerelocsStr = 'jitforcerelocs'
- }
+ // If this is a crossgen build, pass 'crossgen' to runtest.cmd
+ crossgenStr = 'crossgen'
+ runcrossgentestsStr = 'runcrossgentests'
+
+ if (scenario == 'r2r_jitstress1'){
+ runjitstressStr = 'jitstress 1'
+ }
+ else if (scenario == 'r2r_jitstress2') {
+ runjitstressStr = 'jitstress 2'
+ }
+ else if (scenario == 'r2r_jitstressregs1'){
+ runjitstressregsStr = 'jitstressregs 1'
+ }
+ else if (scenario == 'r2r_jitstressregs2') {
+ runjitstressregsStr = 'jitstressregs 2'
+ }
+ else if (scenario == 'r2r_jitstressregs3') {
+ runjitstressregsStr = 'jitstressregs 3'
+ }
+ else if (scenario == 'r2r_jitstressregs4') {
+ runjitstressregsStr = 'jitstressregs 4'
+ }
+ else if (scenario == 'r2r_jitstressregs8') {
+ runjitstressregsStr = 'jitstressregs 8'
+ }
+ else if (scenario == 'r2r_jitstressregs0x10') {
+ runjitstressregsStr = 'jitstressregs 0x10'
+ }
+ else if (scenario == 'r2r_jitstressregs0x80') {
+ runjitstressregsStr = 'jitstressregs 0x80'
+ }
+ else if (scenario == 'r2r_jitstressregs0x1000') {
+ runjitstressregsStr = 'jitstressregs 0x1000'
+ }
+ else if (scenario == 'r2r_jitminopts') {
+ runjitmioptsStr = 'jitminopts'
+ }
+ else if (scenario == 'r2r_jitforcerelocs') {
+ runjitforcerelocsStr = 'jitforcerelocs'
+ }
}
- if (scenario == 'gcstress15_pri1r2r')
- {
+ else if (scenario == 'gcstress15_pri1r2r') {
gcstressStr = 'gcstresslevel 0xF'
}
-
- if (scenario == 'jitdiff')
- {
+ else if (scenario == 'jitdiff') {
runjitdisasmStr = 'jitdisasm crossgen'
}
-
- if (scenario == 'ilrt')
- {
+ else if (scenario == 'ilrt') {
runilasmroundtripStr = 'ilasmroundtrip'
}
-
- if (isLongGc(scenario)) {
+ else if (isLongGc(scenario)) {
gcTestArguments = "${scenario} sequential"
}
-
- if (scenario == 'illink')
+ else if (scenario == 'illink')
{
illinkArguments = "link %WORKSPACE%\\linker\\linker\\bin\\netcore_Release\\netcoreapp2.0\\win10-${arch}\\publish\\illink.exe"
}
- runtestArguments = "${lowerConfiguration} ${arch} ${gcstressStr} ${crossgenStr} ${runcrossgentestsStr} ${runjitstressStr} ${runjitstressregsStr} ${runjitmioptsStr} ${runjitforcerelocsStr} ${runjitdisasmStr} ${runilasmroundtripStr} ${gcTestArguments} ${illinkArguments} collectdumps"
-
+ def envScriptPath = ''
if (Constants.jitStressModeScenarios.containsKey(scenario)) {
- def stepScriptLocation = "%WORKSPACE%\\SetStressModes.bat"
- buildCommands += genStressModeScriptStep(os, scenario, Constants.jitStressModeScenarios[scenario], stepScriptLocation)
+ envScriptPath = "%WORKSPACE%\\SetStressModes.bat"
+ buildCommands += genStressModeScriptStep(os, scenario, Constants.jitStressModeScenarios[scenario], envScriptPath)
+ if (architecture == 'x86lb') {
+ buildCommands += appendStressModeScriptStep(os, "%WORKSPACE%\\tests\\legacyjit_x86_testenv.cmd", envScriptPath)
+ }
+ else if (architecture == 'x86_arm_altjit') {
+ buildCommands += appendStressModeScriptStep(os, "%WORKSPACE%\\tests\\x86_arm_altjit.cmd", envScriptPath)
+ }
+ else if (architecture == 'x64_arm64_altjit') {
+ buildCommands += appendStressModeScriptStep(os, "%WORKSPACE%\\tests\\x64_arm64_altjit.cmd", envScriptPath)
+ }
+ }
+ else if (architecture == 'x86lb') {
+ envScriptPath = "%WORKSPACE%\\tests\\legacyjit_x86_testenv.cmd"
+ }
+ else if (architecture == 'x86_arm_altjit') {
+ envScriptPath = "%WORKSPACE%\\tests\\x86_arm_altjit.cmd"
+ }
+ else if (architecture == 'x64_arm64_altjit') {
+ envScriptPath = "%WORKSPACE%\\tests\\x64_arm64_altjit.cmd"
+ }
+ if (envScriptPath != '') {
+ testEnvStr = "TestEnv ${envScriptPath}"
+ }
- if (enableCorefxTesting) {
- def workspaceRelativeFxRoot = "_/fx"
- def absoluteFxRoot = "%WORKSPACE%\\_\\fx"
+ runtestArguments = "${lowerConfiguration} ${arch} ${gcstressStr} ${crossgenStr} ${runcrossgentestsStr} ${runjitstressStr} ${runjitstressregsStr} ${runjitmioptsStr} ${runjitforcerelocsStr} ${runjitdisasmStr} ${runilasmroundtripStr} ${gcTestArguments} ${illinkArguments} collectdumps ${testEnvStr}"
- buildCommands += "python -u %WORKSPACE%\\tests\\scripts\\run-corefx-tests.py -arch ${arch} -build_type ${configuration} -fx_root ${absoluteFxRoot} -fx_branch ${branch} -env_script ${stepScriptLocation}"
+ // If we are running a stress mode, we should write out the set of key
+ // value env pairs to a file at this point and then we'll pass that to runtest.cmd
- setTestJobTimeOut(newJob, scenario)
+ if (Constants.jitStressModeScenarios.containsKey(scenario) && enableCorefxTesting) {
+ def workspaceRelativeFxRoot = "_/fx"
+ def absoluteFxRoot = "%WORKSPACE%\\_\\fx"
- // Archive and process (only) the test results
- Utilities.addArchival(newJob, "${workspaceRelativeFxRoot}/bin/**/testResults.xml")
- Utilities.addXUnitDotNETResults(newJob, "${workspaceRelativeFxRoot}/bin/**/testResults.xml")
+ buildCommands += "python -u %WORKSPACE%\\tests\\scripts\\run-corefx-tests.py -arch ${arch} -build_type ${configuration} -fx_root ${absoluteFxRoot} -fx_branch ${branch} -env_script ${envScriptPath}"
- //Archive additional build stuff to diagnose why my attempt at fault injection isn't causing CI to fail
- Utilities.addArchival(newJob, "SetStressModes.bat", "", true, false)
- Utilities.addArchival(newJob, "${workspaceRelativeFxRoot}/bin/testhost/**", "", true, false)
- }
- else {
- buildCommands += "%WORKSPACE%\\tests\\runtest.cmd ${runtestArguments} TestEnv ${stepScriptLocation}"
- }
+ setTestJobTimeOut(newJob, scenario)
+
+ // Archive and process (only) the test results
+ Utilities.addArchival(newJob, "${workspaceRelativeFxRoot}/bin/**/testResults.xml")
+ Utilities.addXUnitDotNETResults(newJob, "${workspaceRelativeFxRoot}/bin/**/testResults.xml")
+
+ //Archive additional build stuff to diagnose why my attempt at fault injection isn't causing CI to fail
+ Utilities.addArchival(newJob, "SetStressModes.bat", "", true, false)
+ Utilities.addArchival(newJob, "${workspaceRelativeFxRoot}/bin/testhost/**", "", true, false)
}
else if (isGcReliabilityFramework(scenario)) {
buildCommands += "tests\\runtest.cmd ${runtestArguments} GenerateLayoutOnly"
buildCommands += "tests\\scripts\\run-gc-reliability-framework.cmd ${arch} ${configuration}"
}
- else if (architecture == 'x64' || architecture == 'x86') {
+ else {
buildCommands += "tests\\runtest.cmd ${runtestArguments}"
}
- else if (architecture == 'x86lb') {
- buildCommands += "tests\\runtest.cmd ${runtestArguments} TestEnv %WORKSPACE%\\tests\\legacyjit_x86_testenv.cmd"
- }
}
if (!enableCorefxTesting) {
@@ -1649,32 +1771,26 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR
}
}
break
+ case 'armlb':
case 'arm':
- def validArmWindowsScenarios = [ "default",
- "pri1r2r",
- "zapdisable",
- "minopts",
- "tieredcompilation",
- "tailcallstress",
- "jitstress1",
- "jitstress2",
- "gcstress0x3",
- "gcstress0xc",
- "jitstressregs1",
- "jitstressregs2",
- "gcstress0xc_jitstress1",
- "gcstress0xc_jitstress2"]
-
- assert validArmWindowsScenarios.contains(scenario)
+ assert Constants.validArmWindowsScenarios.contains(scenario)
// Set time out
setTestJobTimeOut(newJob, scenario)
+ def buildArchitecture = 'arm'
+
if ( lowerConfiguration == "debug" ) {
// For Debug builds, we will do a P1 test build
- buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${architecture} -priority=1"
+ buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${buildArchitecture} -priority=1"
}
- else if (lowerConfiguration == "checked") {
+ else {
+ def priority = "1"
+
+ if (scenario == "default")
+ {
+ priority = "0"
+ }
if ((scenario != 'gcstress0x3') && (scenario != 'gcstress0xc'))
{
@@ -1685,18 +1801,31 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR
def machineAffinityOptions = ['use_arm64_build_machine' : true]
setMachineAffinity(newJob, os, architecture, machineAffinityOptions)
- // For checked runs we will also run testing.
- buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${architecture} -priority=1"
- buildCommands += "python tests\\scripts\\arm64_post_build.py -repo_root %WORKSPACE% -arch ${architecture} -build_type ${lowerConfiguration} -scenario ${scenario} -key_location C:\\tools\\key.txt"
- }
- else if (lowerConfiguration == "release") {
- buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${architecture}"
+
+ if (priority == "1")
+ {
+ buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${buildArchitecture} -priority=1"
+ }
+ else
+ {
+ buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${buildArchitecture}"
+ }
+
+ // Also run testing.
+ buildCommands += "python tests\\scripts\\arm64_post_build.py -repo_root %WORKSPACE% -arch ${buildArchitecture} -build_type ${lowerConfiguration} -scenario ${scenario} -testarch ${architecture} -priority ${priority} -key_location C:\\tools\\key.txt"
}
// Add archival.
Utilities.addArchival(newJob, "bin/Product/**", "bin/Product/**/.nuget/**")
break
case 'arm64':
- assert (scenario == 'default') || (scenario == 'pri1r2r') || (scenario == 'gcstress0x3') || (scenario == 'gcstress0xc')
+ assert Constants.validArmWindowsScenarios.contains(scenario)
+
+ def priority = "1"
+
+ if (scenario == "default")
+ {
+ priority = "0"
+ }
// Set time out
setTestJobTimeOut(newJob, scenario)
@@ -1706,17 +1835,22 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR
buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${architecture} toolset_dir C:\\ats2"
}
else {
- if ((scenario != 'gcstress0x3') && (scenario != 'gcstress0xc'))
- {
- // Up the timeout for arm64 checked testing only.
- // Keep the longer timeout for gcstress.
- Utilities.setJobTimeout(newJob, 240)
- }
+ if ((scenario != 'gcstress0x3') && (scenario != 'gcstress0xc')) {
+ // Up the timeout for arm64 checked testing only.
+ // Keep the longer timeout for gcstress.
+ Utilities.setJobTimeout(newJob, 240)
+ }
+
+ if (priority == "1") {
+ buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${architecture} toolset_dir C:\\ats2 -priority=1"
+ }
+ else{
+ buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${architecture} toolset_dir C:\\ats2"
+ }
- buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${architecture} toolset_dir C:\\ats2 -priority=1"
- // Test build and run are launched together.
- buildCommands += "python tests\\scripts\\arm64_post_build.py -repo_root %WORKSPACE% -arch ${architecture} -build_type ${lowerConfiguration} -scenario ${scenario} -key_location C:\\tools\\key.txt"
- //Utilities.addXUnitDotNETResults(newJob, 'bin/tests/testResults.xml')
+ // Test build and run are launched together.
+ buildCommands += "python tests\\scripts\\arm64_post_build.py -repo_root %WORKSPACE% -arch ${architecture} -build_type ${lowerConfiguration} -scenario ${scenario} -testarch ${architecture} -priority ${priority} -key_location C:\\tools\\key.txt"
+ //Utilities.addXUnitDotNETResults(newJob, 'bin/tests/testResults.xml')
}
// Add archival.
@@ -1745,7 +1879,7 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR
// build and PAL test
buildCommands += "./tests/scripts/x86_ci_script.sh --buildConfig=${lowerConfiguration}"
Utilities.addXUnitDotNETResults(newJob, '**/pal_tests.xml')
- break;
+ break
}
if (scenario == 'formatting') {
@@ -1826,7 +1960,7 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR
Utilities.addArchival(newJob, "bin/Product/**,bin/obj/*/tests/**/*.dylib,bin/obj/*/tests/**/*.so", "bin/Product/**/.nuget/**")
}
break
- case 'arm':
+ case 'armlb':
// Cross builds for ARM runs on Ubuntu, Ubuntu16.04 and Tizen currently
assert (os == 'Ubuntu') || (os == 'Ubuntu16.04') || (os == 'Tizen')
@@ -1901,8 +2035,8 @@ combinedScenarios.each { scenario ->
os = 'Windows_NT'
}
- // Tizen is only supported for arm architecture
- if (os == 'Tizen' && architecture != 'arm') {
+ // Tizen is only supported for arm legacy_backend architecture
+ if (os == 'Tizen' && architecture != 'armlb') {
return
}
@@ -1918,17 +2052,24 @@ combinedScenarios.each { scenario ->
return
}
break
- case 'arm':
+ case 'armlb':
if ((os != 'Ubuntu') && (os != 'Ubuntu16.04') && (os != 'Tizen') && (os != 'Windows_NT')) {
return
}
break
+ case 'arm':
+ if (os != 'Windows_NT') {
+ return
+ }
+ break
case 'x86':
if ((os != 'Ubuntu') && (os != 'Windows_NT')) {
return
}
break
case 'x86lb':
+ case 'x86_arm_altjit':
+ case 'x64_arm64_altjit':
if (os != 'Windows_NT') {
return
}
@@ -1943,7 +2084,7 @@ combinedScenarios.each { scenario ->
}
// Skip scenarios (blanket skipping for jit stress modes, which are good most everywhere
- // with checked builds
+ // with checked builds)
def enableCorefxTesting = false
if (Constants.jitStressModeScenarios.containsKey(scenario)) {
if (configuration != 'Checked') {
@@ -1960,29 +2101,17 @@ combinedScenarios.each { scenario ->
}
switch (architecture) {
+ case 'armlb':
case 'arm':
- if ((scenario != 'gcstress0x3') &&
- (scenario != 'gcstress0xc') &&
- (scenario != 'jitstress1') &&
- (scenario != 'jitstress2') &&
- (scenario != 'jitstressregs1') &&
- (scenario != 'jitstressregs2') &&
- (scenario != 'gcstress0xc_jitstress1') &&
- (scenario != 'gcstress0xc_jitstress2') &&
- (scenario != 'minopts') &&
- (scenario != 'tieredcompilation') &&
- (scenario != 'tailcallstress') &&
- (scenario != 'zapdisable')) {
- return
- }
- break
case 'arm64':
- if ((scenario != 'gcstress0x3') && (scenario != 'gcstress0xc')) {
+ if (!Constants.validArmWindowsScenarios.contains(scenario)) {
return
}
break
case 'x64':
case 'x86':
+ case 'x86_arm_altjit':
+ case 'x64_arm64_altjit':
// x86 ubuntu: default only
if ((os == 'Ubuntu') && (architecture == 'x86')) {
return
@@ -2060,7 +2189,7 @@ combinedScenarios.each { scenario ->
return
}
if (architecture != 'x64') {
- if ((architecture != 'arm64' && architecture != 'arm') || (configuration == 'Debug')) {
+ if ((architecture != 'arm64' && architecture != 'armlb' && architecture != 'arm') || (configuration == 'Debug')) {
return
}
}
@@ -2161,6 +2290,19 @@ combinedScenarios.each { scenario ->
}
}
+ // For altjit, don't do any scenarios that don't change compilation. That is, scenarios that only change
+ // runtime behavior, not compile-time behavior, are not interesting.
+ switch (architecture) {
+ case 'x86_arm_altjit':
+ case 'x64_arm64_altjit':
+ if (isGCStressRelatedTesting(scenario)) {
+ return
+ }
+ break
+ default:
+ break
+ }
+
// Calculate names
def lowerConfiguration = configuration.toLowerCase()
def jobName = getJobName(configuration, architecture, os, scenario, isBuildOnly)
@@ -2170,7 +2312,7 @@ combinedScenarios.each { scenario ->
def newJob = job(Utilities.getFullJobName(project, jobName, isPR, folderName)) {}
def machineAffinityOptions = architecture == 'arm64' ? ['is_build_only': true] : null
- machineAffinityOptions = architecture == 'arm' ? ['use_arm64_build_machine': false] : machineAffinityOptions
+ machineAffinityOptions = (architecture == 'arm' || architecture == 'armlb') ? ['use_arm64_build_machine': false] : machineAffinityOptions
setMachineAffinity(newJob, os, architecture, machineAffinityOptions)
// Add all the standard options
@@ -2189,7 +2331,7 @@ combinedScenarios.each { scenario ->
}
else {
// Setup corefx and Windows test binaries for Linux cross build for ubuntu-arm, ubuntu16.04-arm and tizen-armel
- if ( architecture == 'arm' && ( os == 'Ubuntu' || os == 'Ubuntu16.04' || os == 'Tizen')) {
+ if ( architecture == 'armlb' && ( os == 'Ubuntu' || os == 'Ubuntu16.04' || os == 'Tizen')) {
// Cross build for ubuntu-arm, ubuntu16.04-arm and tizen-armel
// Define the Windows Tests and Corefx build job names
def WindowTestsName = projectFolder + '/' +
diff --git a/perf.groovy b/perf.groovy
index 957af67106..3e73edf1ca 100644
--- a/perf.groovy
+++ b/perf.groovy
@@ -71,8 +71,8 @@ def static getOSGroup(def os) {
}
else {
parameters {
- stringParam('XUNIT_PERFORMANCE_MAX_ITERATION', '21', 'Sets the number of iterations to twenty one. We are doing this to limit the amount of data that we upload as 20 iterations is enought to get a good sample')
- stringParam('XUNIT_PERFORMANCE_MAX_ITERATION_INNER_SPECIFIED', '21', 'Sets the number of iterations to twenty one. We are doing this to limit the amount of data that we upload as 20 iterations is enought to get a good sample')
+ stringParam('XUNIT_PERFORMANCE_MAX_ITERATION', '21', 'Sets the number of iterations to twenty one. We are doing this to limit the amount of data that we upload as 20 iterations is enough to get a good sample')
+ stringParam('XUNIT_PERFORMANCE_MAX_ITERATION_INNER_SPECIFIED', '21', 'Sets the number of iterations to twenty one. We are doing this to limit the amount of data that we upload as 20 iterations is enough to get a good sample')
}
}
@@ -331,8 +331,8 @@ def static getFullPerfJobName(def project, def os, def isPR) {
parameters {
// Cap the maximum number of iterations to 21.
- stringParam('XUNIT_PERFORMANCE_MAX_ITERATION', '21', 'Sets the number of iterations to twenty one. We are doing this to limit the amount of data that we upload as 20 iterations is enought to get a good sample')
- stringParam('XUNIT_PERFORMANCE_MAX_ITERATION_INNER_SPECIFIED', '21', 'Sets the number of iterations to twenty one. We are doing this to limit the amount of data that we upload as 20 iterations is enought to get a good sample')
+ stringParam('XUNIT_PERFORMANCE_MAX_ITERATION', '21', 'Sets the number of iterations to twenty one. We are doing this to limit the amount of data that we upload as 20 iterations is enough to get a good sample')
+ stringParam('XUNIT_PERFORMANCE_MAX_ITERATION_INNER_SPECIFIED', '21', 'Sets the number of iterations to twenty one. We are doing this to limit the amount of data that we upload as 20 iterations is enough to get a good sample')
stringParam('PRODUCT_BUILD', '', 'Build number from which to copy down the CoreCLR Product binaries built for Linux')
}
@@ -692,6 +692,88 @@ parallel(
}
}
+// Setup size-on-disk test
+['Windows_NT'].each { os ->
+ ['x64', 'x86'].each { arch ->
+ def architecture = arch
+ def newJob = job(Utilities.getFullJobName(project, "sizeondisk_${arch}", false)) {
+
+ wrappers {
+ credentialsBinding {
+ string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
+ }
+ }
+
+ def channel = 'master'
+ def configuration = 'Release'
+ def runType = 'rolling'
+ def benchViewName = 'Dotnet Size on Disk %DATE% %TIME%'
+ def testBin = "%WORKSPACE%\\bin\\tests\\${os}.${architecture}.${configuration}"
+ def coreRoot = "${testBin}\\Tests\\Core_Root"
+ def benchViewTools = "%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools"
+
+ steps {
+ // Install nuget and get BenchView tools
+ batchFile("powershell wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile \"%WORKSPACE%\\nuget.exe\"")
+ batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"")
+ batchFile("\"%WORKSPACE%\\nuget.exe\" install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
+
+ // Generate submission metadata for BenchView
+ // Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView
+ // we have to do it all as one statement because cmd is called each time and we lose the set environment variable
+ batchFile("if \"%GIT_BRANCH:~0,7%\" == \"origin/\" (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH:origin/=%\") else (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH%\")\n" +
+ "set \"BENCHVIEWNAME=${benchViewName}\"\n" +
+ "set \"BENCHVIEWNAME=%BENCHVIEWNAME:\"=%\"\n" +
+ "py \"${benchViewTools}\\submission-metadata.py\" --name \"%BENCHVIEWNAME%\" --user \"dotnet-bot@microsoft.com\"\n" +
+ "py \"${benchViewTools}\\build.py\" git --branch %GIT_BRANCH_WITHOUT_ORIGIN% --type ${runType}")
+
+ // Generate machine data from BenchView
+ batchFile("py \"${benchViewTools}\\machinedata.py\"")
+
+ // Build CoreCLR and gnerate test layout
+ batchFile("set __TestIntermediateDir=int&&build.cmd ${configuration} ${architecture}")
+ batchFile("tests\\runtest.cmd ${configuration} ${architecture} GenerateLayoutOnly")
+
+ // Run the size on disk benchmark
+ batchFile("\"${coreRoot}\\CoreRun.exe\" \"${testBin}\\sizeondisk\\sodbench\\SoDBench\\SoDBench.exe\" -o \"%WORKSPACE%\\sodbench.csv\" --architecture ${arch} --channel ${channel}")
+
+ // From sodbench.csv, create measurment.json, then submission.json
+ batchFile("py \"${benchViewTools}\\measurement.py\" csv \"%WORKSPACE%\\sodbench.csv\" --metric \"Size on Disk\" --unit \"bytes\" --better \"desc\"")
+ batchFile("py \"${benchViewTools}\\submission.py\" measurement.json --build build.json --machine-data machinedata.json --metadata submission-metadata.json --group \"Dotnet Size on Disk\" --type ${runType} --config-name ${configuration} --architecture ${arch} --machinepool VM --config Channel ${channel}")
+
+ // If this is a PR, upload submission.json
+ batchFile("py \"${benchViewTools}\\upload.py\" submission.json --container coreclr")
+ }
+ }
+
+ Utilities.setMachineAffinity(newJob, "Windows_NT", '20170427-elevated')
+
+ def archiveSettings = new ArchivalSettings()
+ archiveSettings.addFiles('bin/toArchive/**')
+ archiveSettings.addFiles('machinedata.json')
+
+ Utilities.addArchival(newJob, archiveSettings)
+ Utilities.standardJobSetup(newJob, project, false, "*/${branch}")
+
+ // Set the cron job here. We run nightly on each flavor, regardless of code changes
+ Utilities.addPeriodicTrigger(newJob, "@daily", true /*always run*/)
+
+ newJob.with {
+ logRotator {
+ artifactDaysToKeep(30)
+ daysToKeep(30)
+ artifactNumToKeep(200)
+ numToKeep(200)
+ }
+ wrappers {
+ timeout {
+ absolute(240)
+ }
+ }
+ }
+ }
+}
+
// Setup IlLink tests
[true, false].each { isPR ->
['Windows_NT'].each { os ->
diff --git a/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.Linux.Microsoft.NETCore.Runtime.CoreCLR.props b/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.Linux.Microsoft.NETCore.Runtime.CoreCLR.props
index dd34d3dae5..69ebb80a0f 100644
--- a/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.Linux.Microsoft.NETCore.Runtime.CoreCLR.props
+++ b/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.Linux.Microsoft.NETCore.Runtime.CoreCLR.props
@@ -7,7 +7,6 @@
<_PlatformDoesNotSupportCreatedump Condition="'$(Platform)' == 'arm64'">true</_PlatformDoesNotSupportCreatedump>
<_PlatformDoesNotSupportCreatedump Condition="'$(_runtimeOSFamily)' == 'tizen'">true</_PlatformDoesNotSupportCreatedump>
<_PlatformDoesNotSupportEventTrace Condition="'$(_runtimeOSFamily)' == 'tizen'">true</_PlatformDoesNotSupportEventTrace>
- <_PlatformDoesNotSupportEventTrace Condition="'$(Platform)' == 'arm64'">true</_PlatformDoesNotSupportEventTrace>
<_PlatformDoesNotSupportEventTrace Condition="'$(Platform)' == 'x86'">true</_PlatformDoesNotSupportEventTrace>
<_PlatformDoesNotSupportSosPlugin Condition="'$(_runtimeOSFamily)' == 'android'">true</_PlatformDoesNotSupportSosPlugin>
<_PlatformDoesNotSupportSosPlugin Condition="'$(Platform)' == 'arm64'">true</_PlatformDoesNotSupportSosPlugin>
diff --git a/src/ToolBox/SOS/NETCore/SymbolReader.cs b/src/ToolBox/SOS/NETCore/SymbolReader.cs
index e0fcdb517d..7a4bb52102 100644
--- a/src/ToolBox/SOS/NETCore/SymbolReader.cs
+++ b/src/ToolBox/SOS/NETCore/SymbolReader.cs
@@ -539,7 +539,7 @@ namespace SOS
DebugInfo debugInfo = new DebugInfo();
debugInfo.lineNumber = point.StartLine;
- debugInfo.fileName = GetFileName(openedReader.Reader.GetString(openedReader.Reader.GetDocument(point.Document).Name));
+ debugInfo.fileName = openedReader.Reader.GetString(openedReader.Reader.GetDocument(point.Document).Name);
debugInfo.ilOffset = point.Offset;
points.Add(debugInfo);
}
diff --git a/src/ToolBox/SOS/Strike/disasm.cpp b/src/ToolBox/SOS/Strike/disasm.cpp
index e141f8038f..6137031410 100644
--- a/src/ToolBox/SOS/Strike/disasm.cpp
+++ b/src/ToolBox/SOS/Strike/disasm.cpp
@@ -923,7 +923,7 @@ BOOL PrintCallInfo(DWORD_PTR vEBP, DWORD_PTR IP, DumpStackFlag& DSFlag, BOOL bSy
// if AMD64 ever becomes a cross platform target this must be resolved through
// virtual dispatch rather than conditional compilation
-#ifdef _TARGET_AMD64_
+#if defined(_TARGET_AMD64_) || defined(_TARGET_X86_)
// degrade gracefully for debuggees that don't have a runtime loaded, or a DAC available
eTargetType ett = ettUnk;
if (!g_bDacBroken)
@@ -940,7 +940,7 @@ BOOL PrintCallInfo(DWORD_PTR vEBP, DWORD_PTR IP, DumpStackFlag& DSFlag, BOOL bSy
methodDesc = finalMDorIP;
}
}
-#endif // _TARGET_AMD64_
+#endif // _TARGET_AMD64_ || _TARGET_X86_
if (methodDesc == 0)
{
PrintNativeStack(IP, DSFlag.fSuppressSrcInfo);
@@ -962,14 +962,14 @@ BOOL PrintCallInfo(DWORD_PTR vEBP, DWORD_PTR IP, DumpStackFlag& DSFlag, BOOL bSy
else if ((name = HelperFuncName(IP)) != NULL) {
ExtOut(" (JitHelp: %s)", name);
}
-#ifdef _TARGET_AMD64_
+#if defined(_TARGET_AMD64_) || defined(_TARGET_X86_)
else if (ett == ettMD || ett == ettStub)
{
NameForMD_s(methodDesc, g_mdName,mdNameLen);
DMLOut("%s (stub for %S)", DMLIP(IP), g_mdName);
// fallthrough to return
}
-#endif // _TARGET_AMD64_
+#endif // _TARGET_AMD64_ || _TARGET_X86_
else
{
DMLOut(DMLIP(IP));
diff --git a/src/ToolBox/SOS/Strike/strike.cpp b/src/ToolBox/SOS/Strike/strike.cpp
index 84fde91f43..b621023d1f 100644
--- a/src/ToolBox/SOS/Strike/strike.cpp
+++ b/src/ToolBox/SOS/Strike/strike.cpp
@@ -6343,6 +6343,27 @@ public:
return bNeedUpdates;
}
+ BOOL UpdateKnownCodeAddress(TADDR mod, CLRDATA_ADDRESS bpLocation)
+ {
+ PendingBreakpoint *pCur = m_breakpoints;
+ BOOL bpSet = FALSE;
+
+ while(pCur)
+ {
+ PendingBreakpoint *pNext = pCur->pNext;
+ if (pCur->ModuleMatches(mod))
+ {
+ IssueDebuggerBPCommand(bpLocation);
+ bpSet = TRUE;
+ break;
+ }
+
+ pCur = pNext;
+ }
+
+ return bpSet;
+ }
+
void RemovePendingForModule(TADDR mod)
{
PendingBreakpoint *pCur = m_breakpoints;
@@ -6715,7 +6736,7 @@ BOOL g_stopOnNextCatch = FALSE;
// According to the latest debuggers these callbacks will not get called
// unless the user (or an extension, like SOS :-)) had previously enabled
// clrn with "sxe clrn".
-class CNotification : public IXCLRDataExceptionNotification4
+class CNotification : public IXCLRDataExceptionNotification5
{
static int s_condemnedGen;
@@ -6741,9 +6762,10 @@ public:
|| IsEqualIID(iid, IID_IXCLRDataExceptionNotification)
|| IsEqualIID(iid, IID_IXCLRDataExceptionNotification2)
|| IsEqualIID(iid, IID_IXCLRDataExceptionNotification3)
- || IsEqualIID(iid, IID_IXCLRDataExceptionNotification4))
+ || IsEqualIID(iid, IID_IXCLRDataExceptionNotification4)
+ || IsEqualIID(iid, IID_IXCLRDataExceptionNotification5))
{
- *ppvObject = static_cast<IXCLRDataExceptionNotification4*>(this);
+ *ppvObject = static_cast<IXCLRDataExceptionNotification5*>(this);
AddRef();
return S_OK;
}
@@ -6769,7 +6791,13 @@ public:
*/
STDMETHODIMP OnCodeGenerated(IXCLRDataMethodInstance* method)
{
- // Some method has been generated, make a breakpoint and remove it.
+ m_dbgStatus = DEBUG_STATUS_GO_HANDLED;
+ return S_OK;
+ }
+
+ STDMETHODIMP OnCodeGenerated2(IXCLRDataMethodInstance* method, CLRDATA_ADDRESS nativeCodeLocation)
+ {
+ // Some method has been generated, make a breakpoint.
ULONG32 len = mdNameLen;
LPWSTR szModuleName = (LPWSTR)alloca(mdNameLen * sizeof(WCHAR));
if (method->GetName(0, mdNameLen, &len, g_mdName) == S_OK)
@@ -6782,12 +6810,11 @@ public:
if (pMod->GetName(mdNameLen, &len, szModuleName) == S_OK)
{
ExtOut("JITTED %S!%S\n", szModuleName, g_mdName);
-
- // Add breakpoint, perhaps delete pending breakpoint
+
DacpGetModuleAddress dgma;
if (SUCCEEDED(dgma.Request(pMod)))
{
- g_bpoints.Update(TO_TADDR(dgma.ModulePtr), FALSE);
+ g_bpoints.UpdateKnownCodeAddress(TO_TADDR(dgma.ModulePtr), nativeCodeLocation);
}
else
{
diff --git a/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h b/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h
index 4ce775d177..29baaa8a39 100644
--- a/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h
+++ b/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h
@@ -119,6 +119,15 @@ CORINFO_METHOD_HANDLE resolveVirtualMethod(CORINFO_METHOD_HANDLE virtualMethod,
CORINFO_CLASS_HANDLE implementingClass,
CORINFO_CONTEXT_HANDLE ownerType);
+// Given T, return the type of the default EqualityComparer<T>.
+// Returns null if the type can't be determined exactly.
+CORINFO_CLASS_HANDLE getDefaultEqualityComparerClass(CORINFO_CLASS_HANDLE elemType);
+
+// Given resolved token that corresponds to an intrinsic classified as
+// a CORINFO_INTRINSIC_GetRawHandle intrinsic, fetch the handle associated
+// with the token. If this is not possible at compile-time (because the current method's
+// code is shared and the token contains generic parameters) then indicate
+// how the handle should be looked up at runtime.
void expandRawHandleIntrinsic(
CORINFO_RESOLVED_TOKEN * pResolvedToken,
CORINFO_GENERICHANDLE_RESULT * pResult);
@@ -126,8 +135,7 @@ void expandRawHandleIntrinsic(
// If a method's attributes have (getMethodAttribs) CORINFO_FLG_INTRINSIC set,
// getIntrinsicID() returns the intrinsic ID.
// *pMustExpand tells whether or not JIT must expand the intrinsic.
-CorInfoIntrinsics getIntrinsicID(CORINFO_METHOD_HANDLE method, bool* pMustExpand = NULL /* OUT */
- );
+CorInfoIntrinsics getIntrinsicID(CORINFO_METHOD_HANDLE method, bool* pMustExpand = NULL /* OUT */);
// Is the given module the System.Numerics.Vectors module?
// This defaults to false.
diff --git a/src/ToolBox/superpmi/superpmi-shared/lwmlist.h b/src/ToolBox/superpmi/superpmi-shared/lwmlist.h
index 898641c790..21f7906510 100644
--- a/src/ToolBox/superpmi/superpmi-shared/lwmlist.h
+++ b/src/ToolBox/superpmi/superpmi-shared/lwmlist.h
@@ -69,6 +69,7 @@ LWM(GetClassName, DWORDLONG, DWORD)
LWM(GetClassNumInstanceFields, DWORDLONG, DWORD)
LWM(GetClassSize, DWORDLONG, DWORD)
LWM(GetCookieForPInvokeCalliSig, GetCookieForPInvokeCalliSigValue, DLDL)
+LWM(GetDefaultEqualityComparerClass, DWORDLONG, DWORDLONG)
LWM(GetDelegateCtor, Agnostic_GetDelegateCtorIn, Agnostic_GetDelegateCtorOut)
LWM(GetEEInfo, DWORD, Agnostic_CORINFO_EE_INFO)
LWM(GetEHinfo, DLD, Agnostic_CORINFO_EH_CLAUSE)
diff --git a/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp b/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp
index 4968461996..0bf288d196 100644
--- a/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp
+++ b/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp
@@ -2149,8 +2149,8 @@ void* MethodContext::repGetHelperFtn(CorInfoHelpFunc ftnNum, void** ppIndirectio
if ((GetHelperFtn == nullptr) || (GetHelperFtn->GetIndex((DWORD)ftnNum) == -1))
{
#ifdef sparseMC
- LogDebug("Sparse - repGetHelperFtn returning 0xCAFE0002 and 0XCAFE0003");
- *ppIndirection = (void*)(size_t)0xCAFE0002;
+ LogDebug("Sparse - repGetHelperFtn returning nullptr and 0XCAFE0003");
+ *ppIndirection = nullptr;
return (void*)(size_t)0xCAFE0003;
#else
LogException(EXCEPTIONCODE_MC, "Encountered an empty LWM while looking for %08X", (DWORD)ftnNum);
@@ -3012,6 +3012,23 @@ CORINFO_METHOD_HANDLE MethodContext::repResolveVirtualMethod(CORINFO_METHOD_HAND
return (CORINFO_METHOD_HANDLE)result;
}
+void MethodContext::recGetDefaultEqualityComparerClass(CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE result)
+{
+ if (GetDefaultEqualityComparerClass == nullptr)
+ GetDefaultEqualityComparerClass = new LightWeightMap<DWORDLONG, DWORDLONG>();
+
+ GetDefaultEqualityComparerClass->Add((DWORDLONG)cls, (DWORDLONG)result);
+}
+void MethodContext::dmpGetDefaultEqualityComparerClass(DWORDLONG key, DWORDLONG value)
+{
+ printf("GetDefaultEqualityComparerClass key cls-%016llX, value cls-%016llX", key, value);
+}
+CORINFO_CLASS_HANDLE MethodContext::repGetDefaultEqualityComparerClass(CORINFO_CLASS_HANDLE cls)
+{
+ CORINFO_CLASS_HANDLE result = (CORINFO_CLASS_HANDLE)GetDefaultEqualityComparerClass->Get((DWORDLONG)cls);
+ return result;
+}
+
void MethodContext::recGetTokenTypeAsHandle(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_CLASS_HANDLE result)
{
if (GetTokenTypeAsHandle == nullptr)
diff --git a/src/ToolBox/superpmi/superpmi-shared/methodcontext.h b/src/ToolBox/superpmi/superpmi-shared/methodcontext.h
index 7f79b2b9f6..52515733d3 100644
--- a/src/ToolBox/superpmi/superpmi-shared/methodcontext.h
+++ b/src/ToolBox/superpmi/superpmi-shared/methodcontext.h
@@ -872,6 +872,11 @@ public:
CORINFO_CLASS_HANDLE implClass,
CORINFO_CONTEXT_HANDLE ownerType);
+ void recGetDefaultEqualityComparerClass(CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE result);
+ void dmpGetDefaultEqualityComparerClass(DWORDLONG key, DWORDLONG value);
+ CORINFO_CLASS_HANDLE repGetDefaultEqualityComparerClass(CORINFO_CLASS_HANDLE cls);
+
+
void recGetTokenTypeAsHandle(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_CLASS_HANDLE result);
void dmpGetTokenTypeAsHandle(const GetTokenTypeAsHandleValue& key, DWORDLONG value);
CORINFO_CLASS_HANDLE repGetTokenTypeAsHandle(CORINFO_RESOLVED_TOKEN* pResolvedToken);
@@ -1252,7 +1257,7 @@ private:
};
// ********************* Please keep this up-to-date to ease adding more ***************
-// Highest packet number: 161
+// Highest packet number: 162
// *************************************************************************************
enum mcPackets
{
@@ -1319,6 +1324,7 @@ enum mcPackets
Packet_GetIntConfigValue = 151, // Added 2/12/2015
Packet_GetStringConfigValue = 152, // Added 2/12/2015
Packet_GetCookieForPInvokeCalliSig = 48,
+ Packet_GetDefaultEqualityComparerClass = 162, // Added 9/24/2017
Packet_GetDelegateCtor = 49,
Packet_GetEEInfo = 50,
Packet_GetEHinfo = 51,
diff --git a/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp
index 2a477a07e3..6051de8840 100644
--- a/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp
+++ b/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp
@@ -236,6 +236,16 @@ CORINFO_METHOD_HANDLE interceptor_ICJI::resolveVirtualMethod(CORINFO_METHOD_HAND
return result;
}
+// Given T, return the type of the default EqualityComparer<T>.
+// Returns null if the type can't be determined exactly.
+CORINFO_CLASS_HANDLE interceptor_ICJI::getDefaultEqualityComparerClass(CORINFO_CLASS_HANDLE cls)
+{
+ mc->cr->AddCall("getDefaultEqualityComparerClass");
+ CORINFO_CLASS_HANDLE result = original_ICorJitInfo->getDefaultEqualityComparerClass(cls);
+ mc->recGetDefaultEqualityComparerClass(cls, result);
+ return result;
+}
+
void interceptor_ICJI::expandRawHandleIntrinsic(
CORINFO_RESOLVED_TOKEN * pResolvedToken,
CORINFO_GENERICHANDLE_RESULT * pResult)
diff --git a/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp
index a54ead5661..17da100dac 100644
--- a/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp
+++ b/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp
@@ -163,6 +163,14 @@ CORINFO_METHOD_HANDLE interceptor_ICJI::resolveVirtualMethod(CORINFO_METHOD_HAND
return original_ICorJitInfo->resolveVirtualMethod(virtualMethod, implementingClass, ownerType);
}
+// Given T, return the type of the default EqualityComparer<T>.
+// Returns null if the type can't be determined exactly.
+CORINFO_CLASS_HANDLE interceptor_ICJI::getDefaultEqualityComparerClass(CORINFO_CLASS_HANDLE cls)
+{
+ mcs->AddCall("getDefaultEqualityComparerClass");
+ return original_ICorJitInfo->getDefaultEqualityComparerClass(cls);
+}
+
void interceptor_ICJI::expandRawHandleIntrinsic(
CORINFO_RESOLVED_TOKEN * pResolvedToken,
CORINFO_GENERICHANDLE_RESULT * pResult)
diff --git a/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp
index 7e0ded9f0f..df4cfcfbcd 100644
--- a/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp
+++ b/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp
@@ -150,6 +150,13 @@ CORINFO_METHOD_HANDLE interceptor_ICJI::resolveVirtualMethod(CORINFO_METHOD_HAND
return original_ICorJitInfo->resolveVirtualMethod(virtualMethod, implementingClass, ownerType);
}
+// Given T, return the type of the default EqualityComparer<T>.
+// Returns null if the type can't be determined exactly.
+CORINFO_CLASS_HANDLE interceptor_ICJI::getDefaultEqualityComparerClass(CORINFO_CLASS_HANDLE cls)
+{
+ return original_ICorJitInfo->getDefaultEqualityComparerClass(cls);
+}
+
void interceptor_ICJI::expandRawHandleIntrinsic(
CORINFO_RESOLVED_TOKEN * pResolvedToken,
CORINFO_GENERICHANDLE_RESULT * pResult)
diff --git a/src/ToolBox/superpmi/superpmi/commandline.cpp b/src/ToolBox/superpmi/superpmi/commandline.cpp
index 47ba0940c2..5394cf22e7 100644
--- a/src/ToolBox/superpmi/superpmi/commandline.cpp
+++ b/src/ToolBox/superpmi/superpmi/commandline.cpp
@@ -119,11 +119,13 @@ void CommandLine::DumpHelp(const char* program)
printf(" Ignored: neither MSVCDIS nor CoreDisTools is available.\n");
#endif // USE_COREDISTOOLS
printf("\n");
- printf(" -jitoption key=value\n");
- printf(" Set the JIT option named \"key\" to \"value\" for JIT 1. NOTE: do not use a \"COMPlus_\" prefix!\n");
+ printf(" -jitoption [force] key=value\n");
+ printf(" Set the JIT option named \"key\" to \"value\" for JIT 1 if the option was not set.");
+ printf(" With optional force flag overwrites the existing value if it was already set. NOTE: do not use a \"COMPlus_\" prefix!\n");
printf("\n");
- printf(" -jit2option key=value\n");
- printf(" Set the JIT option named \"key\" to \"value\" for JIT 2. NOTE: do not use a \"COMPlus_\" prefix!\n");
+ printf(" -jit2option [force] key=value\n");
+ printf(" Set the JIT option named \"key\" to \"value\" for JIT 2 if the option was not set.");
+ printf(" With optional force flag overwrites the existing value if it was already set. NOTE: do not use a \"COMPlus_\" prefix!\n");
printf("\n");
printf("Inputs are case sensitive.\n");
printf("\n");
@@ -163,10 +165,6 @@ static bool ParseJitOption(const char* optionString, wchar_t** key, wchar_t **va
tempKey[i] = '\0';
const char* tempVal = &optionString[i + 1];
- if (tempVal[0] == '\0')
- {
- return false;
- }
const unsigned keyLen = i;
wchar_t* keyBuf = new wchar_t[keyLen + 1];
@@ -522,51 +520,22 @@ bool CommandLine::Parse(int argc, char* argv[], /* OUT */ Options* o)
return false;
}
}
- else if ((_strnicmp(&argv[i][1], "jitoption", argLen) == 0))
+ else if (_strnicmp(&argv[i][1], "jitoption", argLen) == 0)
{
i++;
-
- wchar_t *key, *value;
- if ((i >= argc) || !ParseJitOption(argv[i], &key, &value))
+ if (!AddJitOption(i, argc, argv, &o->jitOptions, &o->forceJitOptions))
{
- DumpHelp(argv[0]);
return false;
}
-
- if (o->jitOptions == nullptr)
- {
- o->jitOptions = new LightWeightMap<DWORD, DWORD>();
- }
-
- DWORD keyIndex = (DWORD)o->jitOptions->AddBuffer((unsigned char*)key, sizeof(wchar_t) * ((unsigned int)wcslen(key) + 1));
- DWORD valueIndex = (DWORD)o->jitOptions->AddBuffer((unsigned char*)value, sizeof(wchar_t) * ((unsigned int)wcslen(value) + 1));
- o->jitOptions->Add(keyIndex, valueIndex);
-
- delete[] key;
- delete[] value;
}
- else if ((_strnicmp(&argv[i][1], "jit2option", argLen) == 0))
+ else if (_strnicmp(&argv[i][1], "jit2option", argLen) == 0)
{
- i++;
-
- wchar_t *key, *value;
- if ((i >= argc) || !ParseJitOption(argv[i], &key, &value))
+ i++;
+ if (!AddJitOption(i, argc, argv, &o->jit2Options, &o->forceJit2Options))
{
- DumpHelp(argv[0]);
return false;
}
- if (o->jit2Options == nullptr)
- {
- o->jit2Options = new LightWeightMap<DWORD, DWORD>();
- }
-
- DWORD keyIndex = (DWORD)o->jit2Options->AddBuffer((unsigned char*)key, sizeof(wchar_t) * ((unsigned int)wcslen(key) + 1));
- DWORD valueIndex = (DWORD)o->jit2Options->AddBuffer((unsigned char*)value, sizeof(wchar_t) * ((unsigned int)wcslen(value) + 1));
- o->jit2Options->Add(keyIndex, valueIndex);
-
- delete[] key;
- delete[] value;
}
else
{
@@ -637,3 +606,62 @@ bool CommandLine::Parse(int argc, char* argv[], /* OUT */ Options* o)
}
return true;
}
+
+//-------------------------------------------------------------
+// AddJitOption: Parse the value that was passed with -jitOption flag.
+//
+// Arguments:
+// currArgument - current argument number. Points to the token next to -jitOption. After the function
+// points to the last parsed token
+// argc - number of all arguments
+// argv - arguments as array of char*
+// pJitOptions - a jit options map, that sets the option, if it was not already set.
+// pForceJitOptions - a jit options map, that forces the option even if it was already set.
+//
+// Returns:
+// False if an error occurred, true if the option was parsed and added.
+bool CommandLine::AddJitOption(int& currArgument, int argc, char* argv[], LightWeightMap<DWORD, DWORD>** pJitOptions, LightWeightMap<DWORD, DWORD>** pForceJitOptions)
+{
+ if (currArgument >= argc)
+ {
+ DumpHelp(argv[0]);
+ return false;
+ }
+
+ LightWeightMap<DWORD, DWORD>* targetjitOptions = nullptr;
+
+
+ if (_strnicmp(argv[currArgument], "force", strlen(argv[currArgument])) == 0)
+ {
+ if (*pForceJitOptions == nullptr)
+ {
+ *pForceJitOptions = new LightWeightMap<DWORD, DWORD>();
+ }
+ targetjitOptions = *pForceJitOptions;
+ currArgument++;
+ }
+ else
+ {
+ if (*pJitOptions == nullptr)
+ {
+ *pJitOptions = new LightWeightMap<DWORD, DWORD>();
+ }
+ targetjitOptions = *pJitOptions;
+ }
+
+ wchar_t* key;
+ wchar_t* value;
+ if ((currArgument >= argc) || !ParseJitOption(argv[currArgument], &key, &value))
+ {
+ DumpHelp(argv[0]);
+ return false;
+ }
+
+ DWORD keyIndex = (DWORD)targetjitOptions->AddBuffer((unsigned char*)key, sizeof(wchar_t) * ((unsigned int)wcslen(key) + 1));
+ DWORD valueIndex = (DWORD)targetjitOptions->AddBuffer((unsigned char*)value, sizeof(wchar_t) * ((unsigned int)wcslen(value) + 1));
+ targetjitOptions->Add(keyIndex, valueIndex);
+
+ delete[] key;
+ delete[] value;
+ return true;
+}
diff --git a/src/ToolBox/superpmi/superpmi/commandline.h b/src/ToolBox/superpmi/superpmi/commandline.h
index 0881f088b0..cf9d79cf6c 100644
--- a/src/ToolBox/superpmi/superpmi/commandline.h
+++ b/src/ToolBox/superpmi/superpmi/commandline.h
@@ -42,6 +42,8 @@ public:
, compileList(nullptr)
, offset(-1)
, increment(-1)
+ , forceJitOptions(nullptr)
+ , forceJit2Options(nullptr)
, jitOptions(nullptr)
, jit2Options(nullptr)
{
@@ -69,12 +71,16 @@ public:
char* compileList;
int offset;
int increment;
+ LightWeightMap<DWORD, DWORD>* forceJitOptions;
+ LightWeightMap<DWORD, DWORD>* forceJit2Options;
LightWeightMap<DWORD, DWORD>* jitOptions;
LightWeightMap<DWORD, DWORD>* jit2Options;
};
static bool Parse(int argc, char* argv[], /* OUT */ Options* o);
+ static bool AddJitOption(int& currArgument, int argc, char* argv[], LightWeightMap<DWORD, DWORD>** pJitOptions, LightWeightMap<DWORD, DWORD>** pForceJitOptions);
+
private:
static void DumpHelp(const char* program);
};
diff --git a/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp
index 2e78113991..7c119b86dd 100644
--- a/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp
+++ b/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp
@@ -185,6 +185,15 @@ CORINFO_METHOD_HANDLE MyICJI::resolveVirtualMethod(CORINFO_METHOD_HANDLE virtua
return result;
}
+// Given T, return the type of the default EqualityComparer<T>.
+// Returns null if the type can't be determined exactly.
+CORINFO_CLASS_HANDLE MyICJI::getDefaultEqualityComparerClass(CORINFO_CLASS_HANDLE cls)
+{
+ jitInstance->mc->cr->AddCall("getDefaultEqualityComparerClass");
+ CORINFO_CLASS_HANDLE result = jitInstance->mc->repGetDefaultEqualityComparerClass(cls);
+ return result;
+}
+
void MyICJI::expandRawHandleIntrinsic(
CORINFO_RESOLVED_TOKEN * pResolvedToken,
CORINFO_GENERICHANDLE_RESULT * pResult)
diff --git a/src/ToolBox/superpmi/superpmi/jithost.cpp b/src/ToolBox/superpmi/superpmi/jithost.cpp
index a515d51cf1..f92c6f442a 100644
--- a/src/ToolBox/superpmi/superpmi/jithost.cpp
+++ b/src/ToolBox/superpmi/superpmi/jithost.cpp
@@ -64,7 +64,23 @@ void JitHost::freeMemory(void* block, bool usePageAllocator)
int JitHost::getIntConfigValue(const wchar_t* key, int defaultValue)
{
jitInstance.mc->cr->AddCall("getIntConfigValue");
- int result = jitInstance.mc->repGetIntConfigValue(key, defaultValue);
+
+ int result = defaultValue;
+
+ const wchar_t* forceValue = jitInstance.getForceOption(key);
+
+ if (forceValue != nullptr)
+ {
+ wchar_t* endPtr;
+ result = static_cast<int>(wcstoul(forceValue, &endPtr, 16));
+ bool succeeded = (errno != ERANGE) && (endPtr != forceValue);
+ if (succeeded)
+ {
+ return result;
+ }
+ }
+
+ result = jitInstance.mc->repGetIntConfigValue(key, defaultValue);
if (result != defaultValue)
{
@@ -80,12 +96,12 @@ int JitHost::getIntConfigValue(const wchar_t* key, int defaultValue)
// If the result is the default value, probe the JIT options and then the environment. If a value is found, parse
// it as a hex integer.
- wchar_t* endPtr;
- bool succeeded;
-
const wchar_t* value = jitInstance.getOption(key);
+
+ bool succeeded;
if (value != nullptr)
{
+ wchar_t* endPtr;
result = static_cast<int>(wcstoul(value, &endPtr, 16));
succeeded = (errno != ERANGE) && (endPtr != value);
}
@@ -96,7 +112,7 @@ int JitHost::getIntConfigValue(const wchar_t* key, int defaultValue)
{
return defaultValue;
}
-
+ wchar_t* endPtr;
result = static_cast<int>(wcstoul(complus, &endPtr, 16));
succeeded = (errno != ERANGE) && (endPtr != complus);
jitInstance.freeLongLivedArray(complus);
@@ -108,9 +124,18 @@ int JitHost::getIntConfigValue(const wchar_t* key, int defaultValue)
const wchar_t* JitHost::getStringConfigValue(const wchar_t* key)
{
jitInstance.mc->cr->AddCall("getStringConfigValue");
- const wchar_t* result = jitInstance.mc->repGetStringConfigValue(key);
- // If the result is the default value, probe the JIT options and then the environment.
+ const wchar_t* result = nullptr;
+
+ // First check the force options, then mc value. If value is not presented there, probe the JIT options and then the environment.
+
+ result = jitInstance.getForceOption(key);
+
+ if (result == nullptr)
+ {
+ result = jitInstance.mc->repGetStringConfigValue(key);
+ }
+
if (result == nullptr)
{
result = jitInstance.getOption(key);
diff --git a/src/ToolBox/superpmi/superpmi/jitinstance.cpp b/src/ToolBox/superpmi/superpmi/jitinstance.cpp
index 2d84cfd658..37cb54debd 100644
--- a/src/ToolBox/superpmi/superpmi/jitinstance.cpp
+++ b/src/ToolBox/superpmi/superpmi/jitinstance.cpp
@@ -12,7 +12,7 @@
#include "errorhandling.h"
#include "spmiutil.h"
-JitInstance* JitInstance::InitJit(char* nameOfJit, bool breakOnAssert, SimpleTimer* st1, MethodContext* firstContext, LightWeightMap<DWORD, DWORD>* options)
+JitInstance* JitInstance::InitJit(char* nameOfJit, bool breakOnAssert, SimpleTimer* st1, MethodContext* firstContext, LightWeightMap<DWORD, DWORD>* forceOptions, LightWeightMap<DWORD, DWORD>* options)
{
JitInstance* jit = new JitInstance();
if (jit == nullptr)
@@ -21,6 +21,8 @@ JitInstance* JitInstance::InitJit(char* nameOfJit, bool breakOnAssert, SimpleTim
return nullptr;
}
+ jit->forceOptions = forceOptions;
+
jit->options = options;
if (st1 != nullptr)
@@ -399,8 +401,18 @@ void JitInstance::timeResult(CORINFO_METHOD_INFO info, unsigned flags)
/*-------------------------- Misc ---------------------------------------*/
+const wchar_t* JitInstance::getForceOption(const wchar_t* key)
+{
+ return getOption(key, forceOptions);
+}
+
const wchar_t* JitInstance::getOption(const wchar_t* key)
{
+ return getOption(key, options);
+}
+
+const wchar_t* JitInstance::getOption(const wchar_t* key, LightWeightMap<DWORD, DWORD>* options)
+{
if (options == nullptr)
{
return nullptr;
diff --git a/src/ToolBox/superpmi/superpmi/jitinstance.h b/src/ToolBox/superpmi/superpmi/jitinstance.h
index 0baf401803..1172b9ce69 100644
--- a/src/ToolBox/superpmi/superpmi/jitinstance.h
+++ b/src/ToolBox/superpmi/superpmi/jitinstance.h
@@ -25,6 +25,7 @@ private:
ICorJitInfo* icji;
SimpleTimer stj;
+ LightWeightMap<DWORD, DWORD>* forceOptions;
LightWeightMap<DWORD, DWORD>* options;
JitInstance(){};
@@ -43,7 +44,7 @@ public:
ICorJitCompiler* pJitInstance;
// Allocate and initialize the jit provided
- static JitInstance* InitJit(char* nameOfJit, bool breakOnAssert, SimpleTimer* st1, MethodContext* firstContext, LightWeightMap<DWORD, DWORD>* options);
+ static JitInstance* InitJit(char* nameOfJit, bool breakOnAssert, SimpleTimer* st1, MethodContext* firstContext, LightWeightMap<DWORD, DWORD>* forceOptions, LightWeightMap<DWORD, DWORD>* options);
HRESULT StartUp(char* PathToJit, bool copyJit, bool breakOnDebugBreakorAV, MethodContext* firstContext);
bool reLoad(MethodContext* firstContext);
@@ -52,7 +53,9 @@ public:
Result CompileMethod(MethodContext* MethodToCompile, int mcIndex, bool collectThroughput);
+ const wchar_t* getForceOption(const wchar_t* key);
const wchar_t* getOption(const wchar_t* key);
+ const wchar_t* getOption(const wchar_t* key, LightWeightMap<DWORD, DWORD>* options);
void* allocateArray(ULONG size);
void* allocateLongLivedArray(ULONG size);
diff --git a/src/ToolBox/superpmi/superpmi/parallelsuperpmi.cpp b/src/ToolBox/superpmi/superpmi/parallelsuperpmi.cpp
index 41b27deebc..f4c305d0d1 100644
--- a/src/ToolBox/superpmi/superpmi/parallelsuperpmi.cpp
+++ b/src/ToolBox/superpmi/superpmi/parallelsuperpmi.cpp
@@ -323,8 +323,31 @@ void MergeWorkerMCLs(char* mclFilename, char** arrWorkerMCLPath, int workerCount
LogError("Unable to write to MCL file %s.", mclFilename);
}
-// From the arguments that we parsed, construct the arguments to pass to the child processes.
#define MAX_CMDLINE_SIZE 0x1000 // 4 KB
+
+//-------------------------------------------------------------
+// addJitOptionArgument: Writes jitOption arguments to the argument string for a child spmi process.
+//
+// Arguments:
+// jitOptions - map with options
+// bytesWritten - size of the argument string in bytes
+// spmiArgs - pointer to the argument string
+// optionName - the jitOption name, can include [force] flag.
+//
+void addJitOptionArgument(LightWeightMap<DWORD, DWORD>* jitOptions, int &bytesWritten, char * spmiArgs, const char* optionName)
+{
+ if (jitOptions != nullptr)
+ {
+ for (unsigned i = 0; i < jitOptions->GetCount(); i++)
+ {
+ wchar_t* key = (wchar_t*)jitOptions->GetBuffer(jitOptions->GetKey(i));
+ wchar_t* value = (wchar_t*)jitOptions->GetBuffer(jitOptions->GetItem(i));
+ bytesWritten += sprintf_s(spmiArgs + bytesWritten, MAX_CMDLINE_SIZE - bytesWritten, " -%s %S=%S", optionName, key, value);
+ }
+ }
+}
+
+// From the arguments that we parsed, construct the arguments to pass to the child processes.
char* ConstructChildProcessArgs(const CommandLine::Options& o)
{
int bytesWritten = 0;
@@ -361,25 +384,11 @@ char* ConstructChildProcessArgs(const CommandLine::Options& o)
ADDARG_STRING(o.targetArchitecture, "-target");
ADDARG_STRING(o.compileList, "-compile");
- if (o.jitOptions != nullptr)
- {
- for (unsigned i = 0; i < o.jitOptions->GetCount(); i++)
- {
- wchar_t* key = (wchar_t*)o.jitOptions->GetBuffer(o.jitOptions->GetKey(i));
- wchar_t* value = (wchar_t*)o.jitOptions->GetBuffer(o.jitOptions->GetItem(i));
- bytesWritten += sprintf_s(spmiArgs + bytesWritten, MAX_CMDLINE_SIZE - bytesWritten, " -jitoption %S=%S", key, value);
- }
- }
+ addJitOptionArgument(o.forceJitOptions, bytesWritten, spmiArgs, "jitoption force");
+ addJitOptionArgument(o.forceJit2Options, bytesWritten, spmiArgs, "jit2option force");
- if (o.jit2Options != nullptr)
- {
- for (unsigned i = 0; i < o.jit2Options->GetCount(); i++)
- {
- wchar_t* key = (wchar_t*)o.jit2Options->GetBuffer(o.jit2Options->GetKey(i));
- wchar_t* value = (wchar_t*)o.jit2Options->GetBuffer(o.jit2Options->GetItem(i));
- bytesWritten += sprintf_s(spmiArgs + bytesWritten, MAX_CMDLINE_SIZE - bytesWritten, " -jit2option %S=%S", key, value);
- }
- }
+ addJitOptionArgument(o.jitOptions, bytesWritten, spmiArgs, "jitoption");
+ addJitOptionArgument(o.jit2Options, bytesWritten, spmiArgs, "jit2option");
ADDSTRING(o.nameOfJit);
ADDSTRING(o.nameOfJit2);
diff --git a/src/ToolBox/superpmi/superpmi/superpmi.cpp b/src/ToolBox/superpmi/superpmi/superpmi.cpp
index a8363a608d..89f1d58004 100644
--- a/src/ToolBox/superpmi/superpmi/superpmi.cpp
+++ b/src/ToolBox/superpmi/superpmi/superpmi.cpp
@@ -285,9 +285,9 @@ int __cdecl main(int argc, char* argv[])
if (jit == nullptr)
{
- SimpleTimer st4;
+ SimpleTimer stInitJit;
- jit = JitInstance::InitJit(o.nameOfJit, o.breakOnAssert, &st4, mc, o.jitOptions);
+ jit = JitInstance::InitJit(o.nameOfJit, o.breakOnAssert, &stInitJit, mc, o.forceJitOptions, o.jitOptions);
if (jit == nullptr)
{
// InitJit already printed a failure message
@@ -296,7 +296,7 @@ int __cdecl main(int argc, char* argv[])
if (o.nameOfJit2 != nullptr)
{
- jit2 = JitInstance::InitJit(o.nameOfJit2, o.breakOnAssert, &st4, mc, o.jit2Options);
+ jit2 = JitInstance::InitJit(o.nameOfJit2, o.breakOnAssert, &stInitJit, mc, o.forceJit2Options, o.jit2Options);
if (jit2 == nullptr)
{
// InitJit already printed a failure message
diff --git a/src/classlibnative/float/floatdouble.cpp b/src/classlibnative/float/floatdouble.cpp
index ba90a57f88..f554082ae6 100644
--- a/src/classlibnative/float/floatdouble.cpp
+++ b/src/classlibnative/float/floatdouble.cpp
@@ -132,6 +132,15 @@ FCIMPL1_V(double, COMDouble::Floor, double x)
return (double)floor(x);
FCIMPLEND
+/*=====================================FMod=====================================
+**
+==============================================================================*/
+FCIMPL2_VV(double, COMDouble::FMod, double x, double y)
+ FCALL_CONTRACT;
+
+ return (double)fmod(x, y);
+FCIMPLEND
+
/*=====================================Log======================================
**
==============================================================================*/
@@ -153,10 +162,10 @@ FCIMPLEND
/*=====================================ModF=====================================
**
==============================================================================*/
-FCIMPL1(double, COMDouble::ModF, double* iptr)
+FCIMPL2_VI(double, COMDouble::ModF, double x, double* intptr)
FCALL_CONTRACT;
- return (double)modf(*iptr, iptr);
+ return (double)modf(x, intptr);
FCIMPLEND
/*=====================================Pow======================================
@@ -168,30 +177,6 @@ FCIMPL2_VV(double, COMDouble::Pow, double x, double y)
return (double)pow(x, y);
FCIMPLEND
-/*====================================Round=====================================
-**
-==============================================================================*/
-FCIMPL1_V(double, COMDouble::Round, double x)
- FCALL_CONTRACT;
-
- // If the number has no fractional part do nothing
- // This shortcut is necessary to workaround precision loss in borderline cases on some platforms
- if (x == (double)((INT64)x)) {
- return x;
- }
-
- // We had a number that was equally close to 2 integers.
- // We need to return the even one.
-
- double flrTempVal = floor(x + 0.5);
-
- if ((x == (floor(x) + 0.5)) && (fmod(flrTempVal, 2.0) != 0)) {
- flrTempVal -= 1.0;
- }
-
- return _copysign(flrTempVal, x);
-FCIMPLEND
-
/*=====================================Sin======================================
**
==============================================================================*/
diff --git a/src/classlibnative/float/floatsingle.cpp b/src/classlibnative/float/floatsingle.cpp
index ba48aea709..b56174794d 100644
--- a/src/classlibnative/float/floatsingle.cpp
+++ b/src/classlibnative/float/floatsingle.cpp
@@ -130,6 +130,15 @@ FCIMPL1_V(float, COMSingle::Floor, float x)
return (float)floorf(x);
FCIMPLEND
+/*=====================================FMod=====================================
+**
+==============================================================================*/
+FCIMPL2_VV(float, COMSingle::FMod, float x, float y)
+ FCALL_CONTRACT;
+
+ return (float)fmodf(x, y);
+FCIMPLEND
+
/*=====================================Log======================================
**
==============================================================================*/
@@ -151,10 +160,10 @@ FCIMPLEND
/*=====================================ModF=====================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::ModF, float* iptr)
+FCIMPL2_VI(float, COMSingle::ModF, float x, float* intptr)
FCALL_CONTRACT;
- return (float)modff(*iptr, iptr);
+ return (float)modff(x, intptr);
FCIMPLEND
/*=====================================Pow======================================
@@ -166,30 +175,6 @@ FCIMPL2_VV(float, COMSingle::Pow, float x, float y)
return (float)powf(x, y);
FCIMPLEND
-/*====================================Round=====================================
-**
-==============================================================================*/
-FCIMPL1_V(float, COMSingle::Round, float x)
- FCALL_CONTRACT;
-
- // If the number has no fractional part do nothing
- // This shortcut is necessary to workaround precision loss in borderline cases on some platforms
- if (x == (float)((INT32)x)) {
- return x;
- }
-
- // We had a number that was equally close to 2 integers.
- // We need to return the even one.
-
- float flrTempVal = floorf(x + 0.5f);
-
- if ((x == (floorf(x) + 0.5f)) && (fmod(flrTempVal, 2.0f) != 0)) {
- flrTempVal -= 1.0f;
- }
-
- return _copysignf(flrTempVal, x);
-FCIMPLEND
-
/*=====================================Sin======================================
**
==============================================================================*/
diff --git a/src/classlibnative/inc/floatdouble.h b/src/classlibnative/inc/floatdouble.h
index 16403c1f36..f7412a22f1 100644
--- a/src/classlibnative/inc/floatdouble.h
+++ b/src/classlibnative/inc/floatdouble.h
@@ -20,11 +20,11 @@ public:
FCDECL1_V(static double, Cosh, double x);
FCDECL1_V(static double, Exp, double x);
FCDECL1_V(static double, Floor, double x);
+ FCDECL2_VV(static double, FMod, double x, double y);
FCDECL1_V(static double, Log, double x);
FCDECL1_V(static double, Log10, double x);
- FCDECL1(static double, ModF, double* iptr);
+ FCDECL2_VI(static double, ModF, double x, double* intptr);
FCDECL2_VV(static double, Pow, double x, double y);
- FCDECL1_V(static double, Round, double x);
FCDECL1_V(static double, Sin, double x);
FCDECL1_V(static double, Sinh, double x);
FCDECL1_V(static double, Sqrt, double x);
diff --git a/src/classlibnative/inc/floatsingle.h b/src/classlibnative/inc/floatsingle.h
index 8296e2d37a..0124768a05 100644
--- a/src/classlibnative/inc/floatsingle.h
+++ b/src/classlibnative/inc/floatsingle.h
@@ -20,11 +20,11 @@ public:
FCDECL1_V(static float, Cosh, float x);
FCDECL1_V(static float, Exp, float x);
FCDECL1_V(static float, Floor, float x);
+ FCDECL2_VV(static float, FMod, float x, float y);
FCDECL1_V(static float, Log, float x);
FCDECL1_V(static float, Log10, float x);
- FCDECL1(static float, ModF, float* iptr);
+ FCDECL2_VI(static float, ModF, float x, float* intptr);
FCDECL2_VV(static float, Pow, float x, float y);
- FCDECL1_V(static float, Round, float x);
FCDECL1_V(static float, Sin, float x);
FCDECL1_V(static float, Sinh, float x);
FCDECL1_V(static float, Sqrt, float x);
diff --git a/src/debug/daccess/daccess.cpp b/src/debug/daccess/daccess.cpp
index 12825e040f..5bfbf6151e 100644
--- a/src/debug/daccess/daccess.cpp
+++ b/src/debug/daccess/daccess.cpp
@@ -4389,6 +4389,7 @@ ClrDataAccess::TranslateExceptionRecordToNotification(
GcEvtArgs pubGcEvtArgs;
ULONG32 notifyType = 0;
DWORD catcherNativeOffset = 0;
+ TADDR nativeCodeLocation = NULL;
DAC_ENTER();
@@ -4451,11 +4452,11 @@ ClrDataAccess::TranslateExceptionRecordToNotification(
break;
}
- case DACNotify::JIT_NOTIFICATION:
+ case DACNotify::JIT_NOTIFICATION2:
{
TADDR methodDescPtr;
- if (DACNotify::ParseJITNotification(exInfo, methodDescPtr))
+ if(DACNotify::ParseJITNotification(exInfo, methodDescPtr, nativeCodeLocation))
{
// Try and find the right appdomain
MethodDesc* methodDesc = PTR_MethodDesc(methodDescPtr);
@@ -4488,7 +4489,7 @@ ClrDataAccess::TranslateExceptionRecordToNotification(
}
break;
}
-
+
case DACNotify::EXCEPTION_NOTIFICATION:
{
TADDR threadPtr;
@@ -4594,6 +4595,13 @@ ClrDataAccess::TranslateExceptionRecordToNotification(
notify4 = NULL;
}
+ IXCLRDataExceptionNotification5* notify5;
+ if (notify->QueryInterface(__uuidof(IXCLRDataExceptionNotification5),
+ (void**)&notify5) != S_OK)
+ {
+ notify5 = NULL;
+ }
+
switch(notifyType)
{
case DACNotify::MODULE_LOAD_NOTIFICATION:
@@ -4604,8 +4612,13 @@ ClrDataAccess::TranslateExceptionRecordToNotification(
notify->OnModuleUnloaded(pubModule);
break;
- case DACNotify::JIT_NOTIFICATION:
+ case DACNotify::JIT_NOTIFICATION2:
notify->OnCodeGenerated(pubMethodInst);
+
+ if (notify5)
+ {
+ notify5->OnCodeGenerated2(pubMethodInst, TO_CDADDR(nativeCodeLocation));
+ }
break;
case DACNotify::EXCEPTION_NOTIFICATION:
@@ -4647,6 +4660,14 @@ ClrDataAccess::TranslateExceptionRecordToNotification(
{
notify3->Release();
}
+ if (notify4)
+ {
+ notify4->Release();
+ }
+ if (notify5)
+ {
+ notify5->Release();
+ }
}
if (pubModule)
diff --git a/src/debug/shared/arm/primitives.cpp b/src/debug/shared/arm/primitives.cpp
index e9d0bbd59b..8771dd946d 100644
--- a/src/debug/shared/arm/primitives.cpp
+++ b/src/debug/shared/arm/primitives.cpp
@@ -80,8 +80,15 @@ void CORDbgSetDebuggerREGDISPLAYFromContext(DebuggerREGDISPLAY *pDRD,
void SetDebuggerREGDISPLAYFromREGDISPLAY(DebuggerREGDISPLAY* pDRD, REGDISPLAY* pRD)
{
SUPPORTS_DAC_HOST_ONLY;
-
+ // CORDbgSetDebuggerREGDISPLAYFromContext() checks the context flags. In cases where we don't have a filter
+ // context from the thread, we initialize a CONTEXT on the stack and use that to do our stack walking. We never
+ // initialize the context flags in such cases. Since this function is called from the stackwalker, we can
+ // guarantee that the integer, control, and floating point sections are valid. So we set the flags here and
+ // restore them afterwards.
+ DWORD contextFlags = pRD->pCurrentContext->ContextFlags;
+ pRD->pCurrentContext->ContextFlags = CONTEXT_FULL;
CORDbgSetDebuggerREGDISPLAYFromContext(pDRD, reinterpret_cast<DT_CONTEXT*>(pRD->pCurrentContext));
+ pRD->pCurrentContext->ContextFlags = contextFlags;
pDRD->SP = pRD->SP;
pDRD->PC = (SIZE_T)*(pRD->pPC);
diff --git a/src/debug/shared/i386/primitives.cpp b/src/debug/shared/i386/primitives.cpp
index ab22a5d4b1..6152aa2e25 100644
--- a/src/debug/shared/i386/primitives.cpp
+++ b/src/debug/shared/i386/primitives.cpp
@@ -93,7 +93,7 @@ void SetDebuggerREGDISPLAYFromREGDISPLAY(DebuggerREGDISPLAY* pDRD, REGDISPLAY* p
pDRD->Ebx = (pRD->GetEbxLocation() == NULL ? 0 : *pRD->GetEbxLocation());
pDRD->Edx = (pRD->GetEdxLocation() == NULL ? 0 : *pRD->GetEdxLocation());
pDRD->Ecx = (pRD->GetEcxLocation() == NULL ? 0 : *pRD->GetEcxLocation());
- pDRD->Eax = (pRD->GetEsiLocation() == NULL ? 0 : *pRD->GetEaxLocation());
+ pDRD->Eax = (pRD->GetEaxLocation() == NULL ? 0 : *pRD->GetEaxLocation());
#if defined(USE_REMOTE_REGISTER_ADDRESS)
pDRD->pFP = PushedRegAddr(pRD, FPAddress);
diff --git a/src/dlls/mscoree/mscorwks_unixexports.src b/src/dlls/mscoree/mscorwks_unixexports.src
index 0da8942a2b..a3ca37c3f2 100644
--- a/src/dlls/mscoree/mscorwks_unixexports.src
+++ b/src/dlls/mscoree/mscorwks_unixexports.src
@@ -105,4 +105,5 @@ SetThreadGroupAffinity
SetThreadAffinityMask
GetThreadGroupAffinity
GetCurrentProcessorNumberEx
+SetThreadIdealProcessorEx
diff --git a/src/gc/env/gcenv.object.h b/src/gc/env/gcenv.object.h
index 4261c1a148..4d611e562d 100644
--- a/src/gc/env/gcenv.object.h
+++ b/src/gc/env/gcenv.object.h
@@ -53,7 +53,7 @@ public:
{
m_baseSize = 3 * sizeof(void *);
m_componentSize = 1;
- m_flags = 0;
+ m_flags = MTFlag_HasComponentSize | MTFlag_IsArray;
}
uint32_t GetBaseSize()
diff --git a/src/gc/gc.cpp b/src/gc/gc.cpp
index 89454c6bb0..cb5e7d098e 100644
--- a/src/gc/gc.cpp
+++ b/src/gc/gc.cpp
@@ -13351,7 +13351,6 @@ try_again:
org_hp->alloc_context_count--;
max_hp->alloc_context_count++;
acontext->set_alloc_heap(GCHeap::GetHeap(max_hp->heap_number));
-#if !defined(FEATURE_PAL)
if (CPUGroupInfo::CanEnableGCCPUGroups())
{ //only set ideal processor when max_hp and org_hp are in the same cpu
//group. DO NOT MOVE THREADS ACROSS CPU GROUPS
@@ -13385,7 +13384,6 @@ try_again:
org_hp->heap_number));
}
}
-#endif // !FEATURE_PAL
dprintf (3, ("Switching context %p (home heap %d) ",
acontext,
acontext->get_home_heap()->pGenGCHeap->heap_number));
@@ -15882,45 +15880,71 @@ start_no_gc_region_status gc_heap::prepare_for_no_gc_region (uint64_t total_size
save_data_for_no_gc();
settings.pause_mode = pause_no_gc;
current_no_gc_region_info.start_status = start_no_gc_success;
-
- size_t allocation_no_gc_loh = 0;
- size_t allocation_no_gc_soh = 0;
- size_t size_per_heap = 0;
- total_size = (size_t)((float)total_size * 1.05);
+ uint64_t allocation_no_gc_loh = 0;
+ uint64_t allocation_no_gc_soh = 0;
+ assert(total_size != 0);
if (loh_size_known)
{
- loh_size = (size_t)((float)loh_size * 1.05);
- allocation_no_gc_loh = (size_t)loh_size;
- allocation_no_gc_soh = (size_t)(total_size - loh_size);
+ assert(loh_size != 0);
+ assert(loh_size <= total_size);
+ allocation_no_gc_loh = loh_size;
+ allocation_no_gc_soh = total_size - loh_size;
}
else
{
- allocation_no_gc_soh = (size_t)total_size;
- allocation_no_gc_loh = (size_t)total_size;
+ allocation_no_gc_soh = total_size;
+ allocation_no_gc_loh = total_size;
}
int soh_align_const = get_alignment_constant (TRUE);
- size_t max_soh_allocated = (soh_segment_size - segment_info_size - eph_gen_starts_size);
+ size_t max_soh_allocated = soh_segment_size - segment_info_size - eph_gen_starts_size;
+ size_t size_per_heap = 0;
+ const double scale_factor = 1.05;
int num_heaps = 1;
#ifdef MULTIPLE_HEAPS
num_heaps = n_heaps;
-#endif //MULTIPLE_HEAPS
- size_t total_allowed_soh_allocation = max_soh_allocated * num_heaps;
+#endif // MULTIPLE_HEAPS
- if (allocation_no_gc_soh > total_allowed_soh_allocation)
+ uint64_t total_allowed_soh_allocation = max_soh_allocated * num_heaps;
+ // [LOCALGC TODO]
+ // In theory, the upper limit here is the physical memory of the machine, not
+ // SIZE_T_MAX. This is not true today because total_physical_mem can be
+ // larger than SIZE_T_MAX if running in wow64 on a machine with more than
+ // 4GB of RAM. Once Local GC code divergence is resolved and code is flowing
+ // more freely between branches, it would be good to clean this up to use
+ // total_physical_mem instead of SIZE_T_MAX.
+ assert(total_allowed_soh_allocation <= SIZE_T_MAX);
+ uint64_t total_allowed_loh_allocation = SIZE_T_MAX;
+ uint64_t total_allowed_soh_alloc_scaled = allocation_no_gc_soh > 0 ? static_cast<uint64_t>(total_allowed_soh_allocation / scale_factor) : 0;
+ uint64_t total_allowed_loh_alloc_scaled = allocation_no_gc_loh > 0 ? static_cast<uint64_t>(total_allowed_loh_allocation / scale_factor) : 0;
+
+ if (allocation_no_gc_soh > total_allowed_soh_alloc_scaled ||
+ allocation_no_gc_loh > total_allowed_loh_alloc_scaled)
{
status = start_no_gc_too_large;
goto done;
}
+ if (allocation_no_gc_soh > 0)
+ {
+ allocation_no_gc_soh = static_cast<uint64_t>(allocation_no_gc_soh * scale_factor);
+ allocation_no_gc_soh = min (allocation_no_gc_soh, total_allowed_soh_alloc_scaled);
+ }
+
+ if (allocation_no_gc_loh > 0)
+ {
+ allocation_no_gc_loh = static_cast<uint64_t>(allocation_no_gc_loh * scale_factor);
+ allocation_no_gc_loh = min (allocation_no_gc_loh, total_allowed_loh_alloc_scaled);
+ }
+
if (disallow_full_blocking)
current_no_gc_region_info.minimal_gc_p = TRUE;
if (allocation_no_gc_soh != 0)
{
- current_no_gc_region_info.soh_allocation_size = allocation_no_gc_soh;
+ current_no_gc_region_info.soh_allocation_size = static_cast<size_t>(allocation_no_gc_soh);
size_per_heap = current_no_gc_region_info.soh_allocation_size;
#ifdef MULTIPLE_HEAPS
size_per_heap /= n_heaps;
@@ -15936,7 +15960,7 @@ start_no_gc_region_status gc_heap::prepare_for_no_gc_region (uint64_t total_size
if (allocation_no_gc_loh != 0)
{
- current_no_gc_region_info.loh_allocation_size = allocation_no_gc_loh;
+ current_no_gc_region_info.loh_allocation_size = static_cast<size_t>(allocation_no_gc_loh);
size_per_heap = current_no_gc_region_info.loh_allocation_size;
#ifdef MULTIPLE_HEAPS
size_per_heap /= n_heaps;
diff --git a/src/inc/clrconfigvalues.h b/src/inc/clrconfigvalues.h
index 1e27c729f8..7b096b438f 100644
--- a/src/inc/clrconfigvalues.h
+++ b/src/inc/clrconfigvalues.h
@@ -472,7 +472,7 @@ CONFIG_DWORD_INFO_EX(INTERNAL_JitNoCSE, W("JitNoCSE"), 0, "", CLRConfig::REGUTIL
CONFIG_DWORD_INFO_EX(INTERNAL_JitNoCSE2, W("JitNoCSE2"), 0, "", CLRConfig::REGUTIL_default)
CONFIG_DWORD_INFO_EX(INTERNAL_JitNoHoist, W("JitNoHoist"), 0, "", CLRConfig::REGUTIL_default)
-RETAIL_CONFIG_DWORD_INFO_EX(INTERNAL_JitNoInline, W("JitNoInline"), 0, "Disables inlining of all methods", CLRConfig::REGUTIL_default)
+CONFIG_DWORD_INFO_EX(INTERNAL_JitNoInline, W("JitNoInline"), 0, "Disables inlining of all methods", CLRConfig::REGUTIL_default)
RETAIL_CONFIG_DWORD_INFO_EX(INTERNAL_JitAggressiveInlining, W("JitAggressiveInlining"), 0, "Aggressive inlining of all methods", CLRConfig::REGUTIL_default)
CONFIG_STRING_INFO_EX(INTERNAL_JitNoProcedureSplitting, W("JitNoProcedureSplitting"), "Disallow procedure splitting for specified methods", CLRConfig::REGUTIL_default)
@@ -943,7 +943,12 @@ RETAIL_CONFIG_DWORD_INFO(INTERNAL_ThreadPool_ForceMaxWorkerThreads, W("ThreadPoo
RETAIL_CONFIG_DWORD_INFO(INTERNAL_ThreadPool_DisableStarvationDetection, W("ThreadPool_DisableStarvationDetection"), 0, "Disables the ThreadPool feature that forces new threads to be added when workitems run for too long")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_ThreadPool_DebugBreakOnWorkerStarvation, W("ThreadPool_DebugBreakOnWorkerStarvation"), 0, "Breaks into the debugger if the ThreadPool detects work queue starvation")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_ThreadPool_EnableWorkerTracking, W("ThreadPool_EnableWorkerTracking"), 0, "Enables extra expensive tracking of how many workers threads are working simultaneously")
-RETAIL_CONFIG_DWORD_INFO(INTERNAL_ThreadPool_UnfairSemaphoreSpinLimit, W("ThreadPool_UnfairSemaphoreSpinLimit"), 50, "Per processor limit used when calculating spin duration in UnfairSemaphore::Wait")
+#ifdef _TARGET_ARM64_
+// Spinning scheme is currently different on ARM64, see CLRLifoSemaphore::Wait(DWORD, UINT32, UINT32)
+RETAIL_CONFIG_DWORD_INFO(INTERNAL_ThreadPool_UnfairSemaphoreSpinLimit, W("ThreadPool_UnfairSemaphoreSpinLimit"), 0x32, "Maximum number of spins per processor a thread pool worker thread performs before waiting for work")
+#else // !_TARGET_ARM64_
+RETAIL_CONFIG_DWORD_INFO(INTERNAL_ThreadPool_UnfairSemaphoreSpinLimit, W("ThreadPool_UnfairSemaphoreSpinLimit"), 0x46, "Maximum number of spins a thread pool worker thread performs before waiting for work")
+#endif // _TARGET_ARM64_
RETAIL_CONFIG_DWORD_INFO(EXTERNAL_Thread_UseAllCpuGroups, W("Thread_UseAllCpuGroups"), 0, "Specifies if to automatically distribute thread across CPU Groups")
CONFIG_DWORD_INFO(INTERNAL_ThreadpoolTickCountAdjustment, W("ThreadpoolTickCountAdjustment"), 0, "")
diff --git a/src/inc/corinfo.h b/src/inc/corinfo.h
index 3171d6b00d..aa024e0547 100644
--- a/src/inc/corinfo.h
+++ b/src/inc/corinfo.h
@@ -213,11 +213,11 @@ TODO: Talk about initializing strutures before use
#define SELECTANY extern __declspec(selectany)
#endif
-SELECTANY const GUID JITEEVersionIdentifier = { /* 7f70c266-eada-427b-be8a-be1260e34b1b */
- 0x7f70c266,
- 0xeada,
- 0x427b,
- {0xbe, 0x8a, 0xbe, 0x12, 0x60, 0xe3, 0x4b, 0x1b}
+SELECTANY const GUID JITEEVersionIdentifier = { /* 76a743cd-8a07-471e-9ac4-cd5806a8ffac */
+ 0x76a743cd,
+ 0x8a07,
+ 0x471e,
+ {0x9a, 0xc4, 0xcd, 0x58, 0x06, 0xa8, 0xff, 0xac}
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -2085,6 +2085,12 @@ public:
CORINFO_CONTEXT_HANDLE ownerType = NULL /* IN */
) = 0;
+ // Given T, return the type of the default EqualityComparer<T>.
+ // Returns null if the type can't be determined exactly.
+ virtual CORINFO_CLASS_HANDLE getDefaultEqualityComparerClass(
+ CORINFO_CLASS_HANDLE elemType
+ ) = 0;
+
// Given resolved token that corresponds to an intrinsic classified as
// a CORINFO_INTRINSIC_GetRawHandle intrinsic, fetch the handle associated
// with the token. If this is not possible at compile-time (because the current method's
diff --git a/src/inc/jithelpers.h b/src/inc/jithelpers.h
index b45948ac59..43b75293ae 100644
--- a/src/inc/jithelpers.h
+++ b/src/inc/jithelpers.h
@@ -134,17 +134,10 @@
JITHELPER(CORINFO_HELP_ENDCATCH, JIT_EndCatch, CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB)
#endif
-#ifdef _TARGET_AMD64_
- DYNAMICJITHELPER(CORINFO_HELP_MON_ENTER, JIT_MonEnterWorker, CORINFO_HELP_SIG_REG_ONLY)
- DYNAMICJITHELPER(CORINFO_HELP_MON_EXIT, JIT_MonExitWorker, CORINFO_HELP_SIG_REG_ONLY)
- DYNAMICJITHELPER(CORINFO_HELP_MON_ENTER_STATIC, JIT_MonEnterStatic,CORINFO_HELP_SIG_REG_ONLY)
- DYNAMICJITHELPER(CORINFO_HELP_MON_EXIT_STATIC, JIT_MonExitStatic,CORINFO_HELP_SIG_REG_ONLY)
-#else
JITHELPER(CORINFO_HELP_MON_ENTER, JIT_MonEnterWorker, CORINFO_HELP_SIG_REG_ONLY)
JITHELPER(CORINFO_HELP_MON_EXIT, JIT_MonExitWorker, CORINFO_HELP_SIG_REG_ONLY)
JITHELPER(CORINFO_HELP_MON_ENTER_STATIC, JIT_MonEnterStatic,CORINFO_HELP_SIG_REG_ONLY)
JITHELPER(CORINFO_HELP_MON_EXIT_STATIC, JIT_MonExitStatic,CORINFO_HELP_SIG_REG_ONLY)
-#endif
JITHELPER(CORINFO_HELP_GETCLASSFROMMETHODPARAM, JIT_GetClassFromMethodParam, CORINFO_HELP_SIG_REG_ONLY)
JITHELPER(CORINFO_HELP_GETSYNCFROMCLASSHANDLE, JIT_GetSyncFromClassHandle, CORINFO_HELP_SIG_REG_ONLY)
diff --git a/src/inc/xclrdata.idl b/src/inc/xclrdata.idl
index 952aea4378..fb3f19ade4 100644
--- a/src/inc/xclrdata.idl
+++ b/src/inc/xclrdata.idl
@@ -2536,3 +2536,17 @@ interface IXCLRDataExceptionNotification4 : IXCLRDataExceptionNotification3
*/
HRESULT ExceptionCatcherEnter([in] IXCLRDataMethodInstance* catchingMethod, DWORD catcherNativeOffset);
}
+
+[
+ object,
+ local,
+ uuid(e77a39ea-3548-44d9-b171-8569ed1a9423)
+]
+interface IXCLRDataExceptionNotification5 : IXCLRDataExceptionNotification4
+{
+ /*
+ * New code was generated for a method. The given address is the start address of
+ * the native newly jitted code.
+ */
+ HRESULT OnCodeGenerated2([in] IXCLRDataMethodInstance* method, [in] CLRDATA_ADDRESS nativeCodeLocation);
+} \ No newline at end of file
diff --git a/src/jit/ICorJitInfo_API_names.h b/src/jit/ICorJitInfo_API_names.h
index 34a8bc0626..fe86ea2e06 100644
--- a/src/jit/ICorJitInfo_API_names.h
+++ b/src/jit/ICorJitInfo_API_names.h
@@ -168,5 +168,6 @@ DEF_CLR_API(getModuleNativeEntryPointRange)
DEF_CLR_API(getExpectedTargetArchitecture)
DEF_CLR_API(resolveVirtualMethod)
DEF_CLR_API(expandRawHandleIntrinsic)
+DEF_CLR_API(getDefaultEqualityComparerClass)
#undef DEF_CLR_API
diff --git a/src/jit/ICorJitInfo_API_wrapper.hpp b/src/jit/ICorJitInfo_API_wrapper.hpp
index 78177e16d7..69311a5917 100644
--- a/src/jit/ICorJitInfo_API_wrapper.hpp
+++ b/src/jit/ICorJitInfo_API_wrapper.hpp
@@ -1620,6 +1620,16 @@ CORINFO_METHOD_HANDLE WrapICorJitInfo::resolveVirtualMethod(
return result;
}
+CORINFO_CLASS_HANDLE WrapICorJitInfo::getDefaultEqualityComparerClass(
+ CORINFO_CLASS_HANDLE elemType)
+{
+ API_ENTER(getDefaultEqualityComparerClass);
+ CORINFO_CLASS_HANDLE result = wrapHnd->getDefaultEqualityComparerClass(elemType);
+ API_LEAVE(getDefaultEqualityComparerClass);
+ return result;
+}
+
+
void WrapICorJitInfo::expandRawHandleIntrinsic(
CORINFO_RESOLVED_TOKEN * pResolvedToken,
CORINFO_GENERICHANDLE_RESULT * pResult)
diff --git a/src/jit/codegenarm.cpp b/src/jit/codegenarm.cpp
index 26c6854d06..bc91b5d8d2 100644
--- a/src/jit/codegenarm.cpp
+++ b/src/jit/codegenarm.cpp
@@ -772,15 +772,6 @@ instruction CodeGen::genGetInsForOper(genTreeOps oper, var_types type)
return ins;
}
-// Generates CpBlk code by performing a loop unroll
-// Preconditions:
-// The size argument of the CpBlk node is a constant and <= 64 bytes.
-// This may seem small but covers >95% of the cases in several framework assemblies.
-void CodeGen::genCodeForCpBlkUnroll(GenTreeBlk* cpBlkNode)
-{
- NYI_ARM("genCodeForCpBlkUnroll");
-}
-
// Generate code for InitBlk by performing a loop unroll
// Preconditions:
// a) Both the size and fill byte value are integer constants.
@@ -1555,7 +1546,7 @@ void CodeGen::genIntToFloatCast(GenTreePtr treeNode)
assert(genIsValidIntReg(op1->gtRegNum)); // Must be a valid int reg.
var_types dstType = treeNode->CastToType();
- var_types srcType = op1->TypeGet();
+ var_types srcType = genActualType(op1->TypeGet());
assert(!varTypeIsFloating(srcType) && varTypeIsFloating(dstType));
// force the srcType to unsigned if GT_UNSIGNED flag is set
@@ -1565,9 +1556,6 @@ void CodeGen::genIntToFloatCast(GenTreePtr treeNode)
}
// We only expect a srcType whose size is EA_4BYTE.
- // For conversions from small types (byte/sbyte/int16/uint16) to float/double,
- // we expect the front-end or lowering phase to have generated two levels of cast.
- //
emitAttr srcSize = EA_ATTR(genTypeSize(srcType));
noway_assert(srcSize == EA_4BYTE);
diff --git a/src/jit/codegenarm64.cpp b/src/jit/codegenarm64.cpp
index 640478b4e7..8d21ae3b56 100644
--- a/src/jit/codegenarm64.cpp
+++ b/src/jit/codegenarm64.cpp
@@ -1292,7 +1292,7 @@ BasicBlock* CodeGen::genCallFinally(BasicBlock* block)
if ((block->bbNext == nullptr) || !BasicBlock::sameEHRegion(block, block->bbNext))
{
- instGen(INS_BREAKPOINT); // This should never get executed
+ instGen(INS_bkpt); // This should never get executed
}
}
else
@@ -1463,7 +1463,7 @@ void CodeGen::genSetRegToConst(regNumber targetReg, var_types targetType, GenTre
case GT_CNS_DBL:
{
emitter* emit = getEmitter();
- emitAttr size = emitTypeSize(tree);
+ emitAttr size = emitActualTypeSize(tree);
GenTreeDblCon* dblConst = tree->AsDblCon();
double constValue = dblConst->gtDblCon.gtDconVal;
@@ -1509,7 +1509,7 @@ void CodeGen::genCodeForMulHi(GenTreeOp* treeNode)
regNumber targetReg = treeNode->gtRegNum;
var_types targetType = treeNode->TypeGet();
emitter* emit = getEmitter();
- emitAttr attr = emitTypeSize(treeNode);
+ emitAttr attr = emitActualTypeSize(treeNode);
unsigned isUnsigned = (treeNode->gtFlags & GTF_UNSIGNED);
GenTreePtr op1 = treeNode->gtGetOp1();
@@ -1558,10 +1558,28 @@ void CodeGen::genCodeForBinary(GenTree* treeNode)
GenTreePtr op2 = treeNode->gtGetOp2();
instruction ins = genGetInsForOper(treeNode->OperGet(), targetType);
+ if ((treeNode->gtFlags & GTF_SET_FLAGS) != 0)
+ {
+ switch (oper)
+ {
+ case GT_ADD:
+ ins = INS_adds;
+ break;
+ case GT_SUB:
+ ins = INS_subs;
+ break;
+ case GT_AND:
+ ins = INS_ands;
+ break;
+ default:
+ noway_assert(!"Unexpected BinaryOp with GTF_SET_FLAGS set");
+ }
+ }
+
// The arithmetic node must be sitting in a register (since it's not contained)
assert(targetReg != REG_NA);
- regNumber r = emit->emitInsTernary(ins, emitTypeSize(treeNode), treeNode, op1, op2);
+ regNumber r = emit->emitInsTernary(ins, emitActualTypeSize(treeNode), treeNode, op1, op2);
assert(r == targetReg);
genProduceReg(treeNode);
@@ -1798,7 +1816,7 @@ void CodeGen::genReturn(GenTreePtr treeNode)
if (movRequired)
{
- emitAttr attr = emitTypeSize(targetType);
+ emitAttr attr = emitActualTypeSize(targetType);
getEmitter()->emitIns_R_R(INS_mov, attr, retReg, op1->gtRegNum);
}
}
@@ -1849,7 +1867,7 @@ void CodeGen::genLclHeap(GenTreePtr tree)
BasicBlock* esp_check = genCreateTempLabel();
emitJumpKind jmpEqual = genJumpKindForOper(GT_EQ, CK_SIGNED);
inst_JMP(jmpEqual, esp_check);
- getEmitter()->emitIns(INS_BREAKPOINT);
+ getEmitter()->emitIns(INS_bkpt);
genDefineTempLabel(esp_check);
}
#endif
@@ -1888,7 +1906,7 @@ void CodeGen::genLclHeap(GenTreePtr tree)
// If 0 bail out by returning null in targetReg
genConsumeRegAndCopy(size, targetReg);
endLabel = genCreateTempLabel();
- getEmitter()->emitIns_R_R(INS_TEST, easz, targetReg, targetReg);
+ getEmitter()->emitIns_R_R(INS_tst, easz, targetReg, targetReg);
emitJumpKind jmpEqual = genJumpKindForOper(GT_EQ, CK_SIGNED);
inst_JMP(jmpEqual, endLabel);
@@ -1912,7 +1930,7 @@ void CodeGen::genLclHeap(GenTreePtr tree)
// Align to STACK_ALIGN
// regCnt will be the total number of bytes to localloc
inst_RV_IV(INS_add, regCnt, (STACK_ALIGN - 1), emitActualTypeSize(type));
- inst_RV_IV(INS_AND, regCnt, ~(STACK_ALIGN - 1), emitActualTypeSize(type));
+ inst_RV_IV(INS_and, regCnt, ~(STACK_ALIGN - 1), emitActualTypeSize(type));
}
stackAdjustment = 0;
@@ -2184,7 +2202,7 @@ void CodeGen::genCodeForNegNot(GenTree* tree)
// The src must be a register.
regNumber operandReg = genConsumeReg(operand);
- getEmitter()->emitIns_R_R(ins, emitTypeSize(tree), targetReg, operandReg);
+ getEmitter()->emitIns_R_R(ins, emitActualTypeSize(tree), targetReg, operandReg);
genProduceReg(tree);
}
@@ -2379,25 +2397,6 @@ void CodeGen::genCodeForInitBlkUnroll(GenTreeBlk* initBlkNode)
}
}
-// Generate code for a load from some address + offset
-// base: tree node which can be either a local address or arbitrary node
-// offset: distance from the base from which to load
-void CodeGen::genCodeForLoadOffset(instruction ins, emitAttr size, regNumber dst, GenTree* base, unsigned offset)
-{
- emitter* emit = getEmitter();
-
- if (base->OperIsLocalAddr())
- {
- if (base->gtOper == GT_LCL_FLD_ADDR)
- offset += base->gtLclFld.gtLclOffs;
- emit->emitIns_R_S(ins, size, dst, base->gtLclVarCommon.gtLclNum, offset);
- }
- else
- {
- emit->emitIns_R_R_I(ins, size, dst, base->gtRegNum, offset);
- }
-}
-
// Generate code for a load pair from some address + offset
// base: tree node which can be either a local address or arbitrary node
// offset: distance from the base from which to load
@@ -2418,25 +2417,6 @@ void CodeGen::genCodeForLoadPairOffset(regNumber dst, regNumber dst2, GenTree* b
}
}
-// Generate code for a store to some address + offset
-// base: tree node which can be either a local address or arbitrary node
-// offset: distance from the base from which to load
-void CodeGen::genCodeForStoreOffset(instruction ins, emitAttr size, regNumber src, GenTree* base, unsigned offset)
-{
- emitter* emit = getEmitter();
-
- if (base->OperIsLocalAddr())
- {
- if (base->gtOper == GT_LCL_FLD_ADDR)
- offset += base->gtLclFld.gtLclOffs;
- emit->emitIns_S_R(ins, size, src, base->gtLclVarCommon.gtLclNum, offset);
- }
- else
- {
- emit->emitIns_R_R_I(ins, size, src, base->gtRegNum, offset);
- }
-}
-
// Generate code for a store pair to some address + offset
// base: tree node which can be either a local address or arbitrary node
// offset: distance from the base from which to load
@@ -2457,114 +2437,6 @@ void CodeGen::genCodeForStorePairOffset(regNumber src, regNumber src2, GenTree*
}
}
-// Generates CpBlk code by performing a loop unroll
-// Preconditions:
-// The size argument of the CpBlk node is a constant and <= 64 bytes.
-// This may seem small but covers >95% of the cases in several framework assemblies.
-void CodeGen::genCodeForCpBlkUnroll(GenTreeBlk* cpBlkNode)
-{
- // Make sure we got the arguments of the cpblk operation in the right registers
- unsigned size = cpBlkNode->Size();
- GenTreePtr dstAddr = cpBlkNode->Addr();
- GenTreePtr source = cpBlkNode->Data();
- GenTreePtr srcAddr = nullptr;
-
- assert((size != 0) && (size <= CPBLK_UNROLL_LIMIT));
-
- emitter* emit = getEmitter();
-
- if (dstAddr->isUsedFromReg())
- {
- genConsumeReg(dstAddr);
- }
-
- if (cpBlkNode->gtFlags & GTF_BLK_VOLATILE)
- {
- // issue a full memory barrier before a volatile CpBlkUnroll operation
- instGen_MemoryBarrier();
- }
-
- if (source->gtOper == GT_IND)
- {
- srcAddr = source->gtGetOp1();
- if (srcAddr->isUsedFromReg())
- {
- genConsumeReg(srcAddr);
- }
- }
- else
- {
- noway_assert(source->IsLocal());
- // TODO-Cleanup: Consider making the addrForm() method in Rationalize public, e.g. in GenTree.
- // OR: transform source to GT_IND(GT_LCL_VAR_ADDR)
- if (source->OperGet() == GT_LCL_VAR)
- {
- source->SetOper(GT_LCL_VAR_ADDR);
- }
- else
- {
- assert(source->OperGet() == GT_LCL_FLD);
- source->SetOper(GT_LCL_FLD_ADDR);
- }
- srcAddr = source;
- }
-
- unsigned offset = 0;
-
- // Grab the integer temp register to emit the loads and stores.
- regNumber tmpReg = cpBlkNode->ExtractTempReg(RBM_ALLINT);
-
- if (size >= 2 * REGSIZE_BYTES)
- {
- regNumber tmp2Reg = cpBlkNode->ExtractTempReg(RBM_ALLINT);
-
- size_t slots = size / (2 * REGSIZE_BYTES);
-
- while (slots-- > 0)
- {
- // Load
- genCodeForLoadPairOffset(tmpReg, tmp2Reg, srcAddr, offset);
- // Store
- genCodeForStorePairOffset(tmpReg, tmp2Reg, dstAddr, offset);
- offset += 2 * REGSIZE_BYTES;
- }
- }
-
- // Fill the remainder (15 bytes or less) if there's one.
- if ((size & 0xf) != 0)
- {
- if ((size & 8) != 0)
- {
- genCodeForLoadOffset(INS_ldr, EA_8BYTE, tmpReg, srcAddr, offset);
- genCodeForStoreOffset(INS_str, EA_8BYTE, tmpReg, dstAddr, offset);
- offset += 8;
- }
- if ((size & 4) != 0)
- {
- genCodeForLoadOffset(INS_ldr, EA_4BYTE, tmpReg, srcAddr, offset);
- genCodeForStoreOffset(INS_str, EA_4BYTE, tmpReg, dstAddr, offset);
- offset += 4;
- }
- if ((size & 2) != 0)
- {
- genCodeForLoadOffset(INS_ldrh, EA_2BYTE, tmpReg, srcAddr, offset);
- genCodeForStoreOffset(INS_strh, EA_2BYTE, tmpReg, dstAddr, offset);
- offset += 2;
- }
- if ((size & 1) != 0)
- {
- genCodeForLoadOffset(INS_ldrb, EA_1BYTE, tmpReg, srcAddr, offset);
- genCodeForStoreOffset(INS_strb, EA_1BYTE, tmpReg, dstAddr, offset);
- }
- }
-
- if (cpBlkNode->gtFlags & GTF_BLK_VOLATILE)
- {
- // issue a INS_BARRIER_ISHLD after a volatile CpBlkUnroll operation
- instGen_MemoryBarrier(INS_BARRIER_ISHLD);
- }
-}
-
// Generate code for CpObj nodes wich copy structs that have interleaved
// GC pointers.
// For this case we'll generate a sequence of loads/stores in the case of struct
@@ -2749,7 +2621,7 @@ void CodeGen::genTableBasedSwitch(GenTree* treeNode)
getEmitter()->emitIns_R_R_R(INS_add, EA_PTRSIZE, baseReg, baseReg, tmpReg);
// br baseReg
- getEmitter()->emitIns_R(INS_br, emitTypeSize(TYP_I_IMPL), baseReg);
+ getEmitter()->emitIns_R(INS_br, emitActualTypeSize(TYP_I_IMPL), baseReg);
}
// emits the table and an instruction to get the address of the first element
@@ -2784,7 +2656,7 @@ void CodeGen::genJumpTable(GenTree* treeNode)
// Access to inline data is 'abstracted' by a special type of static member
// (produced by eeFindJitDataOffs) which the emitter recognizes as being a reference
// to constant data, not a real static field.
- getEmitter()->emitIns_R_C(INS_adr, emitTypeSize(TYP_I_IMPL), treeNode->gtRegNum, REG_NA,
+ getEmitter()->emitIns_R_C(INS_adr, emitActualTypeSize(TYP_I_IMPL), treeNode->gtRegNum, REG_NA,
compiler->eeFindJitDataOffs(jmpTabBase), 0);
genProduceReg(treeNode);
}
@@ -2840,7 +2712,7 @@ void CodeGen::genLockedInstructions(GenTreeOp* treeNode)
default:
unreached();
}
- getEmitter()->emitInsBinary(ins, emitTypeSize(data), &i, data);
+ getEmitter()->emitInsBinary(ins, emitActualTypeSize(data), &i, data);
if (treeNode->gtRegNum != REG_NA)
{
@@ -3232,7 +3104,7 @@ void CodeGen::genIntToFloatCast(GenTreePtr treeNode)
assert(genIsValidIntReg(op1->gtRegNum)); // Must be a valid int reg.
var_types dstType = treeNode->CastToType();
- var_types srcType = op1->TypeGet();
+ var_types srcType = genActualType(op1->TypeGet());
assert(!varTypeIsFloating(srcType) && varTypeIsFloating(dstType));
// force the srcType to unsigned if GT_UNSIGNED flag is set
@@ -3242,9 +3114,6 @@ void CodeGen::genIntToFloatCast(GenTreePtr treeNode)
}
// We should never see a srcType whose size is neither EA_4BYTE or EA_8BYTE
- // For conversions from small types (byte/sbyte/int16/uint16) to float/double,
- // we expect the front-end or lowering phase to have generated two levels of cast.
- //
emitAttr srcSize = EA_ATTR(genTypeSize(srcType));
noway_assert((srcSize == EA_4BYTE) || (srcSize == EA_8BYTE));
@@ -3279,7 +3148,7 @@ void CodeGen::genIntToFloatCast(GenTreePtr treeNode)
genConsumeOperands(treeNode->AsOp());
- getEmitter()->emitIns_R_R(ins, emitTypeSize(dstType), treeNode->gtRegNum, op1->gtRegNum, cvtOption);
+ getEmitter()->emitIns_R_R(ins, emitActualTypeSize(dstType), treeNode->gtRegNum, op1->gtRegNum, cvtOption);
genProduceReg(treeNode);
}
@@ -3376,9 +3245,6 @@ void CodeGen::genFloatToIntCast(GenTreePtr treeNode)
// Assumptions:
// GT_CKFINITE node has reserved an internal register.
//
-// TODO-ARM64-CQ - mark the operand as contained if known to be in
-// memory (e.g. field or an array element).
-//
void CodeGen::genCkfinite(GenTreePtr treeNode)
{
assert(treeNode->OperGet() == GT_CKFINITE);
@@ -3394,8 +3260,8 @@ void CodeGen::genCkfinite(GenTreePtr treeNode)
regNumber intReg = treeNode->GetSingleTempReg();
regNumber fpReg = genConsumeReg(op1);
- emit->emitIns_R_R(ins_Copy(targetType), emitTypeSize(treeNode), intReg, fpReg);
- emit->emitIns_R_R_I(INS_lsr, emitTypeSize(targetType), intReg, intReg, shiftAmount);
+ emit->emitIns_R_R(ins_Copy(targetType), emitActualTypeSize(treeNode), intReg, fpReg);
+ emit->emitIns_R_R_I(INS_lsr, emitActualTypeSize(targetType), intReg, intReg, shiftAmount);
// Mask of exponent with all 1's and check if the exponent is all 1's
emit->emitIns_R_R_I(INS_and, EA_4BYTE, intReg, intReg, expMask);
@@ -3408,13 +3274,13 @@ void CodeGen::genCkfinite(GenTreePtr treeNode)
// if it is a finite value copy it to targetReg
if (treeNode->gtRegNum != fpReg)
{
- emit->emitIns_R_R(ins_Copy(targetType), emitTypeSize(treeNode), treeNode->gtRegNum, fpReg);
+ emit->emitIns_R_R(ins_Copy(targetType), emitActualTypeSize(treeNode), treeNode->gtRegNum, fpReg);
}
genProduceReg(treeNode);
}
//------------------------------------------------------------------------
-// genCodeForCompare: Produce code for a GT_EQ/GT_NE/GT_LT/GT_LE/GT_GE/GT_GT node.
+// genCodeForCompare: Produce code for a GT_EQ/GT_NE/GT_LT/GT_LE/GT_GE/GT_GT/GT_TEST_EQ/GT_TEST_NE node.
//
// Arguments:
// tree - the node
@@ -3424,31 +3290,63 @@ void CodeGen::genCodeForCompare(GenTreeOp* tree)
regNumber targetReg = tree->gtRegNum;
emitter* emit = getEmitter();
- // TODO-ARM64-CQ: Check if we can use the currently set flags.
- // TODO-ARM64-CQ: Check for the case where we can simply transfer the carry bit to a register
- // (signed < or >= where targetReg != REG_NA)
-
GenTreePtr op1 = tree->gtOp1;
GenTreePtr op2 = tree->gtOp2;
- var_types op1Type = op1->TypeGet();
- var_types op2Type = op2->TypeGet();
+ var_types op1Type = genActualType(op1->TypeGet());
+ var_types op2Type = genActualType(op2->TypeGet());
assert(!op1->isUsedFromMemory());
assert(!op2->isUsedFromMemory());
+ // Case of op1 == 0 or op1 != 0:
+ // Optimize generation of 'test' instruction if op1 sets flags.
+ //
+ // This behavior is designed to match the unexpected behavior
+ // of XARCH genCompareInt();
+ //
+ // TODO-Cleanup Review GTF_USE_FLAGS usage
+ // https://github.com/dotnet/coreclr/issues/14093
+ if ((tree->gtFlags & GTF_USE_FLAGS) != 0)
+ {
+ // op1 must set flags
+ assert(op1->gtSetFlags());
+
+ // Must be compare against zero.
+ assert(!tree->OperIs(GT_TEST_EQ, GT_TEST_NE));
+ assert(op2->IsIntegralConst(0));
+ assert(op2->isContained());
+
+ // Just consume the operands
+ genConsumeOperands(tree);
+
+ // No need to generate compare instruction since
+ // op1 sets flags
+
+ // Are we evaluating this into a register?
+ if (targetReg != REG_NA)
+ {
+ genSetRegToCond(targetReg, tree);
+ genProduceReg(tree);
+ }
+
+ return;
+ }
+
genConsumeOperands(tree);
- emitAttr cmpSize = EA_UNKNOWN;
+ emitAttr cmpSize = EA_ATTR(genTypeSize(op1Type));
+
+ assert(genTypeSize(op1Type) == genTypeSize(op2Type));
if (varTypeIsFloating(op1Type))
{
assert(varTypeIsFloating(op2Type));
assert(!op1->isContained());
assert(op1Type == op2Type);
- cmpSize = EA_ATTR(genTypeSize(op1Type));
if (op2->IsIntegralConst(0))
{
+ assert(op2->isContained());
emit->emitIns_R_F(INS_fcmp, cmpSize, op1->gtRegNum, 0.0);
}
else
@@ -3463,35 +3361,6 @@ void CodeGen::genCodeForCompare(GenTreeOp* tree)
// We don't support swapping op1 and op2 to generate cmp reg, imm
assert(!op1->isContainedIntOrIImmed());
- // TODO-ARM64-CQ: the second register argument of a CMP can be sign/zero
- // extended as part of the instruction (using "CMP (extended register)").
- // We should use that if possible, swapping operands
- // (and reversing the condition) if necessary.
- unsigned op1Size = genTypeSize(op1Type);
- unsigned op2Size = genTypeSize(op2Type);
-
- if ((op1Size < 4) || (op1Size < op2Size))
- {
- // We need to sign/zero extend op1 up to 32 or 64 bits.
- instruction ins = ins_Move_Extend(op1Type, true);
- inst_RV_RV(ins, op1->gtRegNum, op1->gtRegNum);
- }
-
- if (!op2->isContainedIntOrIImmed())
- {
- if ((op2Size < 4) || (op2Size < op1Size))
- {
- // We need to sign/zero extend op2 up to 32 or 64 bits.
- instruction ins = ins_Move_Extend(op2Type, true);
- inst_RV_RV(ins, op2->gtRegNum, op2->gtRegNum);
- }
- }
- cmpSize = EA_4BYTE;
- if ((op1Size == EA_8BYTE) || (op2Size == EA_8BYTE))
- {
- cmpSize = EA_8BYTE;
- }
-
instruction ins = tree->OperIs(GT_TEST_EQ, GT_TEST_NE) ? INS_tst : INS_cmp;
if (op2->isContainedIntOrIImmed())
@@ -3513,6 +3382,80 @@ void CodeGen::genCodeForCompare(GenTreeOp* tree)
}
}
+//------------------------------------------------------------------------
+// genCodeForJumpCompare: Generates code for jmpCompare statement.
+//
+// A GT_JCMP node is created when a comparison and conditional branch
+// can be executed in a single instruction.
+//
+// Arm64 has a few instructions with this behavior.
+// - cbz/cbnz -- Compare and branch register zero/not zero
+// - tbz/tbnz -- Test and branch register bit zero/not zero
+//
+// The cbz/cbnz supports the normal +/- 1MB branch range for conditional branches
+// The tbz/tbnz supports a smaller +/- 32KB branch range
+//
+// A GT_JCMP cbz/cbnz node is created when there is a GT_EQ or GT_NE
+// integer/unsigned comparison against #0 which is used by a GT_JTRUE
+// condition jump node.
+//
+// A GT_JCMP tbz/tbnz node is created when there is a GT_TEST_EQ or GT_TEST_NE
+// integer/unsigned comparison against against a mask with a single bit set
+// which is used by a GT_JTRUE condition jump node.
+//
+// This node is repsonsible for consuming the register, and emitting the
+// appropriate fused compare/test and branch instruction
+//
+// Two flags guide code generation
+// GTF_JCMP_TST -- Set if this is a tbz/tbnz rather than cbz/cbnz
+// GTF_JCMP_EQ -- Set if this is cbz/tbz rather than cbnz/tbnz
+//
+// Arguments:
+// tree - The GT_JCMP tree node.
+//
+// Return Value:
+// None
+//
+void CodeGen::genCodeForJumpCompare(GenTreeOp* tree)
+{
+ assert(compiler->compCurBB->bbJumpKind == BBJ_COND);
+
+ GenTree* op1 = tree->gtGetOp1();
+ GenTree* op2 = tree->gtGetOp2();
+
+ assert(tree->OperIs(GT_JCMP));
+ assert(!varTypeIsFloating(tree));
+ assert(!op1->isUsedFromMemory());
+ assert(!op2->isUsedFromMemory());
+ assert(op2->IsCnsIntOrI());
+ assert(op2->isContained());
+
+ genConsumeOperands(tree);
+
+ regNumber reg = op1->gtRegNum;
+ emitAttr attr = emitActualTypeSize(op1->TypeGet());
+
+ if (tree->gtFlags & GTF_JCMP_TST)
+ {
+ ssize_t compareImm = op2->gtIntCon.IconValue();
+
+ assert(isPow2(compareImm));
+
+ instruction ins = (tree->gtFlags & GTF_JCMP_EQ) ? INS_tbz : INS_tbnz;
+ int imm = genLog2((size_t)compareImm);
+
+ getEmitter()->emitIns_J_R_I(ins, attr, compiler->compCurBB->bbJumpDest, reg, imm);
+ }
+ else
+ {
+ assert(op2->IsIntegralConst(0));
+
+ instruction ins = (tree->gtFlags & GTF_JCMP_EQ) ? INS_cbz : INS_cbnz;
+
+ getEmitter()->emitIns_J_R(ins, attr, compiler->compCurBB->bbJumpDest, reg);
+ }
+}
+
int CodeGenInterface::genSPtoFPdelta()
{
int delta;
diff --git a/src/jit/codegenarmarch.cpp b/src/jit/codegenarmarch.cpp
index f9081e89c1..22aed1056d 100644
--- a/src/jit/codegenarmarch.cpp
+++ b/src/jit/codegenarmarch.cpp
@@ -154,6 +154,42 @@ void CodeGen::genCodeForTreeNode(GenTreePtr treeNode)
genCodeForCast(treeNode->AsOp());
break;
+ case GT_BITCAST:
+ {
+ GenTree* op1 = treeNode->gtOp.gtOp1;
+ if (varTypeIsFloating(treeNode) != varTypeIsFloating(op1))
+ {
+#ifdef _TARGET_ARM64_
+ inst_RV_RV(INS_fmov, targetReg, genConsumeReg(op1), targetType);
+#else // !_TARGET_ARM64_
+ if (varTypeIsFloating(treeNode))
+ {
+ NYI_ARM("genRegCopy from 'int' to 'float'");
+ }
+ else
+ {
+ assert(varTypeIsFloating(op1));
+
+ if (op1->TypeGet() == TYP_FLOAT)
+ {
+ inst_RV_RV(INS_vmov_f2i, targetReg, genConsumeReg(op1), targetType);
+ }
+ else
+ {
+ regNumber otherReg = (regNumber)treeNode->AsMultiRegOp()->gtOtherReg;
+ assert(otherReg != REG_NA);
+ inst_RV_RV_RV(INS_vmov_d2i, targetReg, otherReg, genConsumeReg(op1), EA_8BYTE);
+ }
+ }
+#endif // !_TARGET_ARM64_
+ }
+ else
+ {
+ inst_RV_RV(ins_Copy(targetType), targetReg, genConsumeReg(op1), targetType);
+ }
+ }
+ break;
+
case GT_LCL_FLD_ADDR:
case GT_LCL_VAR_ADDR:
genCodeForLclAddr(treeNode);
@@ -246,7 +282,11 @@ void CodeGen::genCodeForTreeNode(GenTreePtr treeNode)
genCodeForJumpTrue(treeNode);
break;
-#ifdef _TARGET_ARM_
+#ifdef _TARGET_ARM64_
+ case GT_JCMP:
+ genCodeForJumpCompare(treeNode->AsOp());
+ break;
+#endif // _TARGET_ARM64_
case GT_JCC:
genCodeForJcc(treeNode->AsCC());
@@ -256,8 +296,6 @@ void CodeGen::genCodeForTreeNode(GenTreePtr treeNode)
genCodeForSetcc(treeNode->AsCC());
break;
-#endif // _TARGET_ARM_
-
case GT_RETURNTRAP:
genCodeForReturnTrap(treeNode->AsOp());
break;
@@ -272,9 +310,8 @@ void CodeGen::genCodeForTreeNode(GenTreePtr treeNode)
case GT_LIST:
case GT_FIELD_LIST:
- case GT_ARGPLACE:
// Should always be marked contained.
- assert(!"LIST, FIELD_LIST and ARGPLACE nodes should always be marked contained.");
+ assert(!"LIST, FIELD_LIST nodes should always be marked contained.");
break;
case GT_PUTARG_STK:
@@ -450,24 +487,35 @@ void CodeGen::genIntrinsic(GenTreePtr treeNode)
assert(varTypeIsFloating(srcNode));
assert(srcNode->TypeGet() == treeNode->TypeGet());
- // Right now only Abs/Round/Sqrt are treated as math intrinsics.
+ // Right now only Abs/Ceiling/Floor/Round/Sqrt are treated as math intrinsics.
//
switch (treeNode->gtIntrinsic.gtIntrinsicId)
{
case CORINFO_INTRINSIC_Abs:
genConsumeOperands(treeNode->AsOp());
- getEmitter()->emitInsBinary(INS_ABS, emitTypeSize(treeNode), treeNode, srcNode);
+ getEmitter()->emitInsBinary(INS_ABS, emitActualTypeSize(treeNode), treeNode, srcNode);
+ break;
+
+#ifdef _TARGET_ARM64_
+ case CORINFO_INTRINSIC_Ceiling:
+ genConsumeOperands(treeNode->AsOp());
+ getEmitter()->emitInsBinary(INS_frintp, emitActualTypeSize(treeNode), treeNode, srcNode);
break;
+ case CORINFO_INTRINSIC_Floor:
+ genConsumeOperands(treeNode->AsOp());
+ getEmitter()->emitInsBinary(INS_frintm, emitActualTypeSize(treeNode), treeNode, srcNode);
+ break;
+#endif
case CORINFO_INTRINSIC_Round:
NYI_ARM("genIntrinsic for round - not implemented yet");
genConsumeOperands(treeNode->AsOp());
- getEmitter()->emitInsBinary(INS_ROUND, emitTypeSize(treeNode), treeNode, srcNode);
+ getEmitter()->emitInsBinary(INS_ROUND, emitActualTypeSize(treeNode), treeNode, srcNode);
break;
case CORINFO_INTRINSIC_Sqrt:
genConsumeOperands(treeNode->AsOp());
- getEmitter()->emitInsBinary(INS_SQRT, emitTypeSize(treeNode), treeNode, srcNode);
+ getEmitter()->emitInsBinary(INS_SQRT, emitActualTypeSize(treeNode), treeNode, srcNode);
break;
default:
@@ -1098,7 +1146,7 @@ void CodeGen::genPutArgSplit(GenTreePutArgSplit* treeNode)
if (targetReg == addrReg && idx != treeNode->gtNumRegs - 1)
{
assert(targetReg != baseReg);
- emit->emitIns_R_R(INS_mov, emitTypeSize(type), baseReg, addrReg);
+ emit->emitIns_R_R(INS_mov, emitActualTypeSize(type), baseReg, addrReg);
addrReg = baseReg;
}
@@ -1229,7 +1277,16 @@ void CodeGen::genRangeCheck(GenTreePtr oper)
jmpKind = genJumpKindForOper(GT_GE, CK_UNSIGNED);
}
- getEmitter()->emitInsBinary(INS_cmp, EA_4BYTE, src1, src2);
+ var_types bndsChkType = genActualType(src2->TypeGet());
+#if DEBUG
+ // Bounds checks can only be 32 or 64 bit sized comparisons.
+ assert(bndsChkType == TYP_INT || bndsChkType == TYP_LONG);
+
+ // The type of the bounds check should always wide enough to compare against the index.
+ assert(emitTypeSize(bndsChkType) >= emitActualTypeSize(src1->TypeGet()));
+#endif // DEBUG
+
+ getEmitter()->emitInsBinary(INS_cmp, emitActualTypeSize(bndsChkType), src1, src2);
genJumpToThrowHlpBlk(jmpKind, SCK_RNGCHK_FAIL, bndsChk->gtIndRngFailBB);
}
@@ -1467,7 +1524,7 @@ void CodeGen::genCodeForShift(GenTreePtr tree)
var_types targetType = tree->TypeGet();
genTreeOps oper = tree->OperGet();
instruction ins = genGetInsForOper(oper, targetType);
- emitAttr size = emitTypeSize(tree);
+ emitAttr size = emitActualTypeSize(tree);
assert(tree->gtRegNum != REG_NA);
@@ -1597,7 +1654,7 @@ void CodeGen::genCodeForIndexAddr(GenTreeIndexAddr* node)
#endif
// Generate the range check.
- getEmitter()->emitInsBinary(INS_cmp, emitTypeSize(TYP_I_IMPL), index, &arrLen);
+ getEmitter()->emitInsBinary(INS_cmp, emitActualTypeSize(TYP_I_IMPL), index, &arrLen);
genJumpToThrowHlpBlk(genJumpKindForOper(GT_GE, CK_UNSIGNED), SCK_RNGCHK_FAIL, node->gtIndRngFailBB);
}
@@ -1606,7 +1663,8 @@ void CodeGen::genCodeForIndexAddr(GenTreeIndexAddr* node)
{
case 1:
// dest = base + index
- getEmitter()->emitIns_R_R_R(INS_add, emitTypeSize(node), node->gtRegNum, base->gtRegNum, index->gtRegNum);
+ getEmitter()->emitIns_R_R_R(INS_add, emitActualTypeSize(node), node->gtRegNum, base->gtRegNum,
+ index->gtRegNum);
break;
case 2:
@@ -1618,7 +1676,7 @@ void CodeGen::genCodeForIndexAddr(GenTreeIndexAddr* node)
BitScanForward(&lsl, node->gtElemSize);
// dest = base + index * scale
- genScaledAdd(emitTypeSize(node), node->gtRegNum, base->gtRegNum, index->gtRegNum, lsl);
+ genScaledAdd(emitActualTypeSize(node), node->gtRegNum, base->gtRegNum, index->gtRegNum, lsl);
break;
}
@@ -1628,14 +1686,14 @@ void CodeGen::genCodeForIndexAddr(GenTreeIndexAddr* node)
CodeGen::genSetRegToIcon(tmpReg, (ssize_t)node->gtElemSize, TYP_INT);
// dest = index * tmp + base
- getEmitter()->emitIns_R_R_R_R(INS_MULADD, emitTypeSize(node), node->gtRegNum, index->gtRegNum, tmpReg,
+ getEmitter()->emitIns_R_R_R_R(INS_MULADD, emitActualTypeSize(node), node->gtRegNum, index->gtRegNum, tmpReg,
base->gtRegNum);
break;
}
}
// dest = dest + elemOffs
- getEmitter()->emitIns_R_R_I(INS_add, emitTypeSize(node), node->gtRegNum, node->gtRegNum, node->gtElemOffset);
+ getEmitter()->emitIns_R_R_I(INS_add, emitActualTypeSize(node), node->gtRegNum, node->gtRegNum, node->gtElemOffset);
gcInfo.gcMarkRegSetNpt(base->gtGetRegMask());
@@ -1752,6 +1810,153 @@ void CodeGen::genCodeForCpBlk(GenTreeBlk* cpBlkNode)
}
}
+//----------------------------------------------------------------------------------
+// genCodeForCpBlkUnroll: Generates CpBlk code by performing a loop unroll
+//
+// Arguments:
+// cpBlkNode - Copy block node
+//
+// Return Value:
+// None
+//
+// Assumption:
+// The size argument of the CpBlk node is a constant and <= CPBLK_UNROLL_LIMIT bytes.
+//
+void CodeGen::genCodeForCpBlkUnroll(GenTreeBlk* cpBlkNode)
+{
+ // Make sure we got the arguments of the cpblk operation in the right registers
+ unsigned size = cpBlkNode->Size();
+ GenTreePtr dstAddr = cpBlkNode->Addr();
+ GenTreePtr source = cpBlkNode->Data();
+ GenTreePtr srcAddr = nullptr;
+
+ assert((size != 0) && (size <= CPBLK_UNROLL_LIMIT));
+
+ emitter* emit = getEmitter();
+
+ if (dstAddr->isUsedFromReg())
+ {
+ genConsumeReg(dstAddr);
+ }
+
+ if (cpBlkNode->gtFlags & GTF_BLK_VOLATILE)
+ {
+ // issue a full memory barrier before a volatile CpBlkUnroll operation
+ instGen_MemoryBarrier();
+ }
+
+ if (source->gtOper == GT_IND)
+ {
+ srcAddr = source->gtGetOp1();
+ if (srcAddr->isUsedFromReg())
+ {
+ genConsumeReg(srcAddr);
+ }
+ }
+ else
+ {
+ noway_assert(source->IsLocal());
+ // TODO-Cleanup: Consider making the addrForm() method in Rationalize public, e.g. in GenTree.
+ // OR: transform source to GT_IND(GT_LCL_VAR_ADDR)
+ if (source->OperGet() == GT_LCL_VAR)
+ {
+ source->SetOper(GT_LCL_VAR_ADDR);
+ }
+ else
+ {
+ assert(source->OperGet() == GT_LCL_FLD);
+ source->SetOper(GT_LCL_FLD_ADDR);
+ }
+ srcAddr = source;
+ }
+
+ unsigned offset = 0;
+
+ // Grab the integer temp register to emit the loads and stores.
+ regNumber tmpReg = cpBlkNode->ExtractTempReg(RBM_ALLINT);
+
+#ifdef _TARGET_ARM64_
+ if (size >= 2 * REGSIZE_BYTES)
+ {
+ regNumber tmp2Reg = cpBlkNode->ExtractTempReg(RBM_ALLINT);
+
+ size_t slots = size / (2 * REGSIZE_BYTES);
+
+ while (slots-- > 0)
+ {
+ // Load
+ genCodeForLoadPairOffset(tmpReg, tmp2Reg, srcAddr, offset);
+ // Store
+ genCodeForStorePairOffset(tmpReg, tmp2Reg, dstAddr, offset);
+ offset += 2 * REGSIZE_BYTES;
+ }
+ }
+
+ // Fill the remainder (15 bytes or less) if there's one.
+ if ((size & 0xf) != 0)
+ {
+ if ((size & 8) != 0)
+ {
+ genCodeForLoadOffset(INS_ldr, EA_8BYTE, tmpReg, srcAddr, offset);
+ genCodeForStoreOffset(INS_str, EA_8BYTE, tmpReg, dstAddr, offset);
+ offset += 8;
+ }
+ if ((size & 4) != 0)
+ {
+ genCodeForLoadOffset(INS_ldr, EA_4BYTE, tmpReg, srcAddr, offset);
+ genCodeForStoreOffset(INS_str, EA_4BYTE, tmpReg, dstAddr, offset);
+ offset += 4;
+ }
+ if ((size & 2) != 0)
+ {
+ genCodeForLoadOffset(INS_ldrh, EA_2BYTE, tmpReg, srcAddr, offset);
+ genCodeForStoreOffset(INS_strh, EA_2BYTE, tmpReg, dstAddr, offset);
+ offset += 2;
+ }
+ if ((size & 1) != 0)
+ {
+ genCodeForLoadOffset(INS_ldrb, EA_1BYTE, tmpReg, srcAddr, offset);
+ genCodeForStoreOffset(INS_strb, EA_1BYTE, tmpReg, dstAddr, offset);
+ }
+ }
+#else // !_TARGET_ARM64_
+ size_t slots = size / REGSIZE_BYTES;
+ while (slots-- > 0)
+ {
+ genCodeForLoadOffset(INS_ldr, EA_4BYTE, tmpReg, srcAddr, offset);
+ genCodeForStoreOffset(INS_str, EA_4BYTE, tmpReg, dstAddr, offset);
+ offset += REGSIZE_BYTES;
+ }
+
+ // Fill the remainder (3 bytes or less) if there's one.
+ if ((size & 0x03) != 0)
+ {
+ if ((size & 2) != 0)
+ {
+ genCodeForLoadOffset(INS_ldrh, EA_2BYTE, tmpReg, srcAddr, offset);
+ genCodeForStoreOffset(INS_strh, EA_2BYTE, tmpReg, dstAddr, offset);
+ offset += 2;
+ }
+ if ((size & 1) != 0)
+ {
+ genCodeForLoadOffset(INS_ldrb, EA_1BYTE, tmpReg, srcAddr, offset);
+ genCodeForStoreOffset(INS_strb, EA_1BYTE, tmpReg, dstAddr, offset);
+ }
+ }
+#endif // !_TARGET_ARM64_
+
+ if (cpBlkNode->gtFlags & GTF_BLK_VOLATILE)
+ {
+#ifdef _TARGET_ARM64_
+ // issue a INS_BARRIER_ISHLD after a volatile CpBlkUnroll operation
+ instGen_MemoryBarrier(INS_BARRIER_ISHLD);
+#else
+ // issue a full memory barrier after a volatile CpBlk operation
+ instGen_MemoryBarrier();
+#endif // !_TARGET_ARM64_
+ }
+}
+
// Generates code for InitBlk by calling the VM memset helper function.
// Preconditions:
// a) The size argument of the InitBlk is not an integer constant.
@@ -1796,6 +2001,44 @@ void CodeGen::genCodeForInitBlk(GenTreeBlk* initBlkNode)
genEmitHelperCall(CORINFO_HELP_MEMSET, 0, EA_UNKNOWN);
}
+// Generate code for a load from some address + offset
+// base: tree node which can be either a local address or arbitrary node
+// offset: distance from the base from which to load
+void CodeGen::genCodeForLoadOffset(instruction ins, emitAttr size, regNumber dst, GenTree* base, unsigned offset)
+{
+ emitter* emit = getEmitter();
+
+ if (base->OperIsLocalAddr())
+ {
+ if (base->gtOper == GT_LCL_FLD_ADDR)
+ offset += base->gtLclFld.gtLclOffs;
+ emit->emitIns_R_S(ins, size, dst, base->gtLclVarCommon.gtLclNum, offset);
+ }
+ else
+ {
+ emit->emitIns_R_R_I(ins, size, dst, base->gtRegNum, offset);
+ }
+}
+
+// Generate code for a store to some address + offset
+// base: tree node which can be either a local address or arbitrary node
+// offset: distance from the base from which to load
+void CodeGen::genCodeForStoreOffset(instruction ins, emitAttr size, regNumber src, GenTree* base, unsigned offset)
+{
+ emitter* emit = getEmitter();
+
+ if (base->OperIsLocalAddr())
+ {
+ if (base->gtOper == GT_LCL_FLD_ADDR)
+ offset += base->gtLclFld.gtLclOffs;
+ emit->emitIns_S_R(ins, size, src, base->gtLclVarCommon.gtLclNum, offset);
+ }
+ else
+ {
+ emit->emitIns_R_R_I(ins, size, src, base->gtRegNum, offset);
+ }
+}
+
//------------------------------------------------------------------------
// genRegCopy: Generate a register copy.
//
@@ -2105,48 +2348,27 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
assert(callType == CT_HELPER || callType == CT_USER_FUNC);
void* addr = nullptr;
- if (callType == CT_HELPER)
- {
-// Direct call to a helper method.
#ifdef FEATURE_READYTORUN_COMPILER
- if (call->gtEntryPoint.addr != NULL)
- {
- addr = call->gtEntryPoint.addr;
- assert(call->gtEntryPoint.accessType == IAT_VALUE);
- }
- else
+ if (call->gtEntryPoint.addr != NULL)
+ {
+ assert(call->gtEntryPoint.accessType == IAT_VALUE);
+ addr = call->gtEntryPoint.addr;
+ }
+ else
#endif // FEATURE_READYTORUN_COMPILER
- {
- CorInfoHelpFunc helperNum = compiler->eeGetHelperNum(methHnd);
- noway_assert(helperNum != CORINFO_HELP_UNDEF);
-
- void* pAddr = nullptr;
- addr = compiler->compGetHelperFtn(helperNum, (void**)&pAddr);
+ if (callType == CT_HELPER)
+ {
+ CorInfoHelpFunc helperNum = compiler->eeGetHelperNum(methHnd);
+ noway_assert(helperNum != CORINFO_HELP_UNDEF);
- if (addr == nullptr)
- {
- addr = pAddr;
- }
- }
+ void* pAddr = nullptr;
+ addr = compiler->compGetHelperFtn(helperNum, (void**)&pAddr);
+ assert(pAddr == nullptr);
}
else
{
// Direct call to a non-virtual user function.
- CORINFO_ACCESS_FLAGS aflags = CORINFO_ACCESS_ANY;
- if (call->IsSameThis())
- {
- aflags = (CORINFO_ACCESS_FLAGS)(aflags | CORINFO_ACCESS_THIS);
- }
-
- if ((call->NeedsNullCheck()) == 0)
- {
- aflags = (CORINFO_ACCESS_FLAGS)(aflags | CORINFO_ACCESS_NONNULL);
- }
-
- CORINFO_CONST_LOOKUP addrInfo;
- compiler->info.compCompHnd->getFunctionEntryPoint(methHnd, &addrInfo, aflags);
-
- addr = addrInfo.addr;
+ addr = call->gtDirectCallAddress;
}
assert(addr != nullptr);
@@ -2879,12 +3101,12 @@ void CodeGen::genFloatToFloatCast(GenTreePtr treeNode)
insOpts cvtOption = (srcType == TYP_FLOAT) ? INS_OPTS_S_TO_D // convert Single to Double
: INS_OPTS_D_TO_S; // convert Double to Single
- getEmitter()->emitIns_R_R(INS_fcvt, emitTypeSize(treeNode), treeNode->gtRegNum, op1->gtRegNum, cvtOption);
+ getEmitter()->emitIns_R_R(INS_fcvt, emitActualTypeSize(treeNode), treeNode->gtRegNum, op1->gtRegNum, cvtOption);
}
else if (treeNode->gtRegNum != op1->gtRegNum)
{
// If double to double cast or float to float cast. Emit a move instruction.
- getEmitter()->emitIns_R_R(INS_mov, emitTypeSize(treeNode), treeNode->gtRegNum, op1->gtRegNum);
+ getEmitter()->emitIns_R_R(INS_mov, emitActualTypeSize(treeNode), treeNode->gtRegNum, op1->gtRegNum);
}
#endif // _TARGET_*
@@ -3112,8 +3334,6 @@ void CodeGen::genCodeForJumpTrue(GenTreePtr tree)
}
}
-#if defined(_TARGET_ARM_)
-
//------------------------------------------------------------------------
// genCodeForJcc: Produce code for a GT_JCC node.
//
@@ -3153,6 +3373,9 @@ void CodeGen::genCodeForSetcc(GenTreeCC* setcc)
// Make sure nobody is setting GTF_RELOP_NAN_UN on this node as it is ignored.
assert((setcc->gtFlags & GTF_RELOP_NAN_UN) == 0);
+#ifdef _TARGET_ARM64_
+ inst_SET(jumpKind, dstReg);
+#else
// Emit code like that:
// ...
// bgt True
@@ -3174,12 +3397,11 @@ void CodeGen::genCodeForSetcc(GenTreeCC* setcc)
genDefineTempLabel(labelTrue);
getEmitter()->emitIns_R_I(INS_mov, emitActualTypeSize(setcc->TypeGet()), dstReg, 1);
genDefineTempLabel(labelNext);
+#endif
genProduceReg(setcc);
}
-#endif // defined(_TARGET_ARM_)
-
//------------------------------------------------------------------------
// genCodeForStoreBlk: Produce code for a GT_STORE_OBJ/GT_STORE_DYN_BLK/GT_STORE_BLK node.
//
diff --git a/src/jit/codegenlinear.cpp b/src/jit/codegenlinear.cpp
index 657d7799c1..1ee288b505 100644
--- a/src/jit/codegenlinear.cpp
+++ b/src/jit/codegenlinear.cpp
@@ -1112,7 +1112,6 @@ void CodeGen::genConsumeRegAndCopy(GenTree* node, regNumber needReg)
void CodeGen::genNumberOperandUse(GenTree* const operand, int& useNum) const
{
assert(operand != nullptr);
- assert(operand->gtUseNum == -1);
// Ignore argument placeholders.
if (operand->OperGet() == GT_ARGPLACE)
@@ -1120,6 +1119,8 @@ void CodeGen::genNumberOperandUse(GenTree* const operand, int& useNum) const
return;
}
+ assert(operand->gtUseNum == -1);
+
if (!operand->isContained() && !operand->IsCopyOrReload())
{
operand->gtUseNum = useNum;
diff --git a/src/jit/codegenlinear.h b/src/jit/codegenlinear.h
index f3f6e9d560..2cee11dcdb 100644
--- a/src/jit/codegenlinear.h
+++ b/src/jit/codegenlinear.h
@@ -266,6 +266,9 @@ void genCallInstruction(GenTreeCall* call);
void genJmpMethod(GenTreePtr jmp);
BasicBlock* genCallFinally(BasicBlock* block);
void genCodeForJumpTrue(GenTreePtr tree);
+#ifdef _TARGET_ARM64_
+void genCodeForJumpCompare(GenTreeOp* tree);
+#endif // _TARGET_ARM64_
#if FEATURE_EH_FUNCLETS
void genEHCatchRet(BasicBlock* block);
diff --git a/src/jit/codegenxarch.cpp b/src/jit/codegenxarch.cpp
index 8e772e2819..58c6c10222 100644
--- a/src/jit/codegenxarch.cpp
+++ b/src/jit/codegenxarch.cpp
@@ -1917,9 +1917,8 @@ void CodeGen::genCodeForTreeNode(GenTreePtr treeNode)
case GT_LIST:
case GT_FIELD_LIST:
- case GT_ARGPLACE:
// Should always be marked contained.
- assert(!"LIST, FIELD_LIST and ARGPLACE nodes should always be marked contained.");
+ assert(!"LIST, FIELD_LIST nodes should always be marked contained.");
break;
case GT_SWAP:
@@ -5508,11 +5507,7 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
void* pAddr = nullptr;
addr = compiler->compGetHelperFtn(helperNum, (void**)&pAddr);
-
- if (addr == nullptr)
- {
- addr = pAddr;
- }
+ assert(pAddr == nullptr);
// tracking of region protected by the monitor in synchronized methods
if (compiler->info.compFlags & CORINFO_FLG_SYNCH)
@@ -5526,6 +5521,8 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
addr = call->gtDirectCallAddress;
}
+ assert(addr != nullptr);
+
// Non-virtual direct calls to known addresses
// clang-format off
@@ -6249,6 +6246,9 @@ void CodeGen::genCompareInt(GenTreePtr treeNode)
// Case of op1 == 0 or op1 != 0:
// Optimize generation of 'test' instruction if op1 sets flags.
//
+ // TODO-Cleanup Review GTF_USE_FLAGS usage
+ // https://github.com/dotnet/coreclr/issues/14093
+ //
// Note that if LSRA has inserted any GT_RELOAD/GT_COPY before
// op1, it will not modify the flags set by codegen of op1.
// Similarly op1 could also be reg-optional at its use and
@@ -6305,9 +6305,7 @@ void CodeGen::genCompareInt(GenTreePtr treeNode)
genConsumeOperands(tree);
- // TODO-CQ: We should be able to support swapping op1 and op2 to generate cmp reg, imm.
- // https://github.com/dotnet/coreclr/issues/7270
- assert(!op1->isContainedIntOrIImmed()); // We no longer support
+ assert(!op1->isContainedIntOrIImmed());
assert(!varTypeIsFloating(op2Type));
instruction ins;
diff --git a/src/jit/compiler.h b/src/jit/compiler.h
index 86917d9481..21a2697f2f 100644
--- a/src/jit/compiler.h
+++ b/src/jit/compiler.h
@@ -2033,6 +2033,8 @@ public:
GenTree* gtNewPutArgReg(var_types type, GenTreePtr arg, regNumber argReg);
+ GenTree* gtNewBitCastNode(var_types type, GenTreePtr arg);
+
protected:
void gtBlockOpInit(GenTreePtr result, GenTreePtr dst, GenTreePtr srcOrFillVal, bool isVolatile);
@@ -2218,7 +2220,12 @@ public:
// Note when inlining, this looks for calls back to the root method.
bool gtIsRecursiveCall(GenTreeCall* call)
{
- return (call->gtCallMethHnd == impInlineRoot()->info.compMethodHnd);
+ return gtIsRecursiveCall(call->gtCallMethHnd);
+ }
+
+ bool gtIsRecursiveCall(CORINFO_METHOD_HANDLE callMethodHandle)
+ {
+ return (callMethodHandle == impInlineRoot()->info.compMethodHnd);
}
//-------------------------------------------------------------------------
@@ -2890,6 +2897,13 @@ public:
CORINFO_CLASS_HANDLE impGetStringClass();
CORINFO_CLASS_HANDLE impGetObjectClass();
+ // Returns underlying type of handles returned by ldtoken instruction
+ inline var_types GetRuntimeHandleUnderlyingType()
+ {
+ // RuntimeTypeHandle is backed by raw pointer on CoreRT and by object reference on other runtimes
+ return IsTargetAbi(CORINFO_CORERT_ABI) ? TYP_I_IMPL : TYP_REF;
+ }
+
//=========================================================================
// PROTECTED
//=========================================================================
@@ -2952,12 +2966,13 @@ protected:
IL_OFFSET rawILOffset);
void impDevirtualizeCall(GenTreeCall* call,
- GenTreePtr thisObj,
CORINFO_METHOD_HANDLE* method,
unsigned* methodFlags,
CORINFO_CONTEXT_HANDLE* contextHandle,
CORINFO_CONTEXT_HANDLE* exactContextHandle);
+ CORINFO_CLASS_HANDLE impGetSpecialIntrinsicExactReturnType(CORINFO_METHOD_HANDLE specialIntrinsicHandle);
+
bool impMethodInfo_hasRetBuffArg(CORINFO_METHOD_INFO* methInfo);
GenTreePtr impFixupCallStructReturn(GenTreeCall* call, CORINFO_CLASS_HANDLE retClsHnd);
@@ -2995,6 +3010,11 @@ protected:
bool isJitIntrinsic,
CorInfoIntrinsics* pIntrinsicID,
bool* isSpecialIntrinsic = nullptr);
+ GenTree* impMathIntrinsic(CORINFO_METHOD_HANDLE method,
+ CORINFO_SIG_INFO* sig,
+ var_types callType,
+ CorInfoIntrinsics intrinsicID,
+ bool tailCall);
NamedIntrinsic lookupNamedIntrinsic(CORINFO_METHOD_HANDLE method);
GenTreePtr impArrayAccessIntrinsic(CORINFO_CLASS_HANDLE clsHnd,
CORINFO_SIG_INFO* sig,
@@ -8324,10 +8344,8 @@ public:
unsigned compArgsCount; // Number of arguments (incl. implicit and hidden)
#if FEATURE_FASTTAILCALL
- unsigned compArgRegCount; // Number of incoming integer argument registers used for incoming arguments
- unsigned compFloatArgRegCount; // Number of incoming floating argument registers used for incoming arguments
- size_t compArgStackSize; // Incoming argument stack size in bytes
-#endif // FEATURE_FASTTAILCALL
+ size_t compArgStackSize; // Incoming argument stack size in bytes
+#endif // FEATURE_FASTTAILCALL
unsigned compRetBuffArg; // position of hidden return param var (0, 1) (BAD_VAR_NUM means not present);
int compTypeCtxtArg; // position of hidden param for type context for generic code (CORINFO_CALLCONV_PARAMTYPE)
@@ -10275,23 +10293,8 @@ const instruction INS_SQRT = INS_vsqrt;
#ifdef _TARGET_ARM64_
-const instruction INS_SHIFT_LEFT_LOGICAL = INS_lsl;
-const instruction INS_SHIFT_RIGHT_LOGICAL = INS_lsr;
-const instruction INS_SHIFT_RIGHT_ARITHM = INS_asr;
-
-const instruction INS_AND = INS_and;
-const instruction INS_OR = INS_orr;
-const instruction INS_XOR = INS_eor;
-const instruction INS_NEG = INS_neg;
-const instruction INS_TEST = INS_tst;
-const instruction INS_MUL = INS_mul;
-const instruction INS_MULADD = INS_madd;
-const instruction INS_SIGNED_DIVIDE = INS_sdiv;
-const instruction INS_UNSIGNED_DIVIDE = INS_udiv;
-const instruction INS_BREAKPOINT = INS_bkpt;
-const instruction INS_ADDC = INS_adc;
-const instruction INS_SUBC = INS_sbc;
-const instruction INS_NOT = INS_mvn;
+const instruction INS_MULADD = INS_madd;
+const instruction INS_BREAKPOINT = INS_bkpt;
const instruction INS_ABS = INS_fabs;
const instruction INS_ROUND = INS_frintn;
diff --git a/src/jit/earlyprop.cpp b/src/jit/earlyprop.cpp
index d4d0e3ee41..8cb51a3fbd 100644
--- a/src/jit/earlyprop.cpp
+++ b/src/jit/earlyprop.cpp
@@ -289,13 +289,41 @@ bool Compiler::optEarlyPropRewriteTree(GenTreePtr tree)
{
assert(actualVal->IsCnsIntOrI());
- if (actualVal->gtIntCon.gtIconVal > INT32_MAX)
+ if ((actualVal->AsIntCon()->IconValue() < 0) || (actualVal->AsIntCon()->IconValue() > INT32_MAX))
{
- // Don't propagate array lengths that are beyond the maximum value of a GT_ARR_LENGTH.
+ // Don't propagate array lengths that are beyond the maximum value of a GT_ARR_LENGTH or negative.
// node. CORINFO_HELP_NEWARR_1_OBJ helper call allows to take a long integer as the
// array length argument, but the type of GT_ARR_LENGTH is always INT32.
return false;
}
+
+ // When replacing GT_ARR_LENGTH nodes with constants we can end up with GT_ARR_BOUNDS_CHECK
+ // nodes that have constant operands and thus can be trivially proved to be useless. It's
+ // better to remove these range checks here, otherwise they'll pass through assertion prop
+ // (creating useless (c1 < c2)-like assertions) and reach RangeCheck where they are finally
+ // removed. Common patterns like new int[] { x, y, z } benefit from this.
+
+ if ((tree->gtNext != nullptr) && tree->gtNext->OperIs(GT_ARR_BOUNDS_CHECK))
+ {
+ GenTreeBoundsChk* check = tree->gtNext->AsBoundsChk();
+
+ if ((check->gtArrLen == tree) && check->gtIndex->IsCnsIntOrI() &&
+ (check->gtIndex->AsIntCon()->IconValue() >= 0) &&
+ (check->gtIndex->AsIntCon()->IconValue() < actualVal->AsIntCon()->IconValue()))
+ {
+ GenTree* comma = check->gtGetParent(nullptr);
+
+ if ((comma != nullptr) && comma->OperIs(GT_COMMA) && (comma->gtGetOp1() == check))
+ {
+ GenTree* next = check->gtNext;
+ optRemoveRangeCheck(comma, root);
+ // Both `tree` and `check` have been removed from the statement. Ensure that optEarlyProp
+ // can process the rest of the statment by changing tree->gtNext appropriately.
+ tree->gtNext = next;
+ return true;
+ }
+ }
+ }
}
else if (propKind == optPropKind::OPK_OBJ_GETTYPE)
{
diff --git a/src/jit/emit.cpp b/src/jit/emit.cpp
index f579aee5ba..4fc97bbd44 100644
--- a/src/jit/emit.cpp
+++ b/src/jit/emit.cpp
@@ -3646,9 +3646,11 @@ AGAIN:
if (emitIsCondJump(jmp))
{
- ssz = JCC_SIZE_SMALL;
- nsd = JCC_DIST_SMALL_MAX_NEG;
- psd = JCC_DIST_SMALL_MAX_POS;
+ ssz = JCC_SIZE_SMALL;
+ bool isTest = (jmp->idIns() == INS_tbz) || (jmp->idIns() == INS_tbnz);
+
+ nsd = (isTest) ? TB_DIST_SMALL_MAX_NEG : JCC_DIST_SMALL_MAX_POS;
+ psd = (isTest) ? TB_DIST_SMALL_MAX_POS : JCC_DIST_SMALL_MAX_POS;
}
else if (emitIsUncondJump(jmp))
{
@@ -3656,10 +3658,6 @@ AGAIN:
assert(jmp->idjShort);
ssz = JMP_SIZE_SMALL;
}
- else if (emitIsCmpJump(jmp))
- {
- NYI("branch shortening compare-and-branch instructions");
- }
else if (emitIsLoadLabel(jmp))
{
ssz = LBL_SIZE_SMALL;
diff --git a/src/jit/emit.h b/src/jit/emit.h
index a9dc076958..8c2b825fe7 100644
--- a/src/jit/emit.h
+++ b/src/jit/emit.h
@@ -2382,11 +2382,12 @@ inline emitAttr emitTypeSize(T type)
extern const unsigned short emitTypeActSz[TYP_COUNT];
-inline emitAttr emitActualTypeSize(var_types type)
+template <class T>
+inline emitAttr emitActualTypeSize(T type)
{
- assert(type < TYP_COUNT);
- assert(emitTypeActSz[type] > 0);
- return (emitAttr)emitTypeActSz[type];
+ assert(TypeGet(type) < TYP_COUNT);
+ assert(emitTypeActSz[TypeGet(type)] > 0);
+ return (emitAttr)emitTypeActSz[TypeGet(type)];
}
/*****************************************************************************
diff --git a/src/jit/emitarm64.cpp b/src/jit/emitarm64.cpp
index 6c9d61ca25..d901f8a8cf 100644
--- a/src/jit/emitarm64.cpp
+++ b/src/jit/emitarm64.cpp
@@ -6691,7 +6691,20 @@ void emitter::emitSetShortJump(instrDescJmp* id)
insFormat fmt = IF_NONE;
if (emitIsCondJump(id))
{
- fmt = IF_BI_0B;
+ switch (id->idIns())
+ {
+ case INS_cbz:
+ case INS_cbnz:
+ fmt = IF_BI_1A;
+ break;
+ case INS_tbz:
+ case INS_tbnz:
+ fmt = IF_BI_1B;
+ break;
+ default:
+ fmt = IF_BI_0B;
+ break;
+ }
}
else if (emitIsLoadLabel(id))
{
@@ -6784,7 +6797,81 @@ void emitter::emitIns_R_D(instruction ins, emitAttr attr, unsigned offs, regNumb
void emitter::emitIns_J_R(instruction ins, emitAttr attr, BasicBlock* dst, regNumber reg)
{
- NYI("emitIns_J_R");
+ assert((ins == INS_cbz) || (ins == INS_cbnz));
+
+ assert(dst != nullptr);
+ assert((dst->bbFlags & BBF_JMP_TARGET) != 0);
+
+ insFormat fmt = IF_LARGEJMP;
+
+ instrDescJmp* id = emitNewInstrJmp();
+
+ id->idIns(ins);
+ id->idInsFmt(fmt);
+ id->idReg1(reg);
+ id->idjShort = false;
+ id->idOpSize(EA_SIZE(attr));
+
+ id->idAddr()->iiaBBlabel = dst;
+ id->idjKeepLong = emitComp->fgInDifferentRegions(emitComp->compCurBB, dst);
+
+ /* Record the jump's IG and offset within it */
+
+ id->idjIG = emitCurIG;
+ id->idjOffs = emitCurIGsize;
+
+ /* Append this jump to this IG's jump list */
+
+ id->idjNext = emitCurIGjmpList;
+ emitCurIGjmpList = id;
+
+#if EMITTER_STATS
+ emitTotalIGjmps++;
+#endif
+
+ dispIns(id);
+ appendToCurIG(id);
+}
+
+void emitter::emitIns_J_R_I(instruction ins, emitAttr attr, BasicBlock* dst, regNumber reg, int imm)
+{
+ assert((ins == INS_tbz) || (ins == INS_tbnz));
+
+ assert(dst != nullptr);
+ assert((dst->bbFlags & BBF_JMP_TARGET) != 0);
+ assert((EA_SIZE(attr) == EA_4BYTE) || (EA_SIZE(attr) == EA_8BYTE));
+ assert(imm < ((EA_SIZE(attr) == EA_4BYTE) ? 32 : 64));
+
+ insFormat fmt = IF_LARGEJMP;
+
+ instrDescJmp* id = emitNewInstrJmp();
+
+ id->idIns(ins);
+ id->idInsFmt(fmt);
+ id->idReg1(reg);
+ id->idjShort = false;
+ id->idSmallCns(imm);
+ id->idOpSize(EA_SIZE(attr));
+
+ id->idAddr()->iiaBBlabel = dst;
+ id->idjKeepLong = emitComp->fgInDifferentRegions(emitComp->compCurBB, dst);
+
+ /* Record the jump's IG and offset within it */
+
+ id->idjIG = emitCurIG;
+ id->idjOffs = emitCurIGsize;
+
+ /* Append this jump to this IG's jump list */
+
+ id->idjNext = emitCurIGjmpList;
+ emitCurIGjmpList = id;
+
+#if EMITTER_STATS
+ emitTotalIGjmps++;
+#endif
+
+ dispIns(id);
+ appendToCurIG(id);
}
void emitter::emitIns_J(instruction ins, BasicBlock* dst, int instrCount)
@@ -8253,7 +8340,7 @@ BYTE* emitter::emitOutputLJ(insGroup* ig, BYTE* dst, instrDesc* i)
// Short conditional/unconditional jump
assert(!id->idjKeepLong);
assert(emitJumpCrossHotColdBoundary(srcOffs, dstOffs) == false);
- assert((fmt == IF_BI_0A) || (fmt == IF_BI_0B));
+ assert((fmt == IF_BI_0A) || (fmt == IF_BI_0B) || (fmt == IF_BI_1A) || (fmt == IF_BI_1B));
}
else
{
@@ -8278,13 +8365,39 @@ BYTE* emitter::emitOutputLJ(insGroup* ig, BYTE* dst, instrDesc* i)
// the correct offset. Note also that this works for both integer and floating-point conditions, because
// the condition inversion takes ordered/unordered into account, preserving NaN behavior. For example,
// "GT" (greater than) is inverted to "LE" (less than, equal, or unordered).
+
+ instruction reverseIns;
+ insFormat reverseFmt;
+
+ switch (ins)
+ {
+ case INS_cbz:
+ reverseIns = INS_cbnz;
+ reverseFmt = IF_BI_1A;
+ break;
+ case INS_cbnz:
+ reverseIns = INS_cbz;
+ reverseFmt = IF_BI_1A;
+ break;
+ case INS_tbz:
+ reverseIns = INS_tbnz;
+ reverseFmt = IF_BI_1B;
+ break;
+ case INS_tbnz:
+ reverseIns = INS_tbz;
+ reverseFmt = IF_BI_1B;
+ break;
+ default:
+ reverseIns = emitJumpKindToIns(emitReverseJumpKind(emitInsToJumpKind(ins)));
+ reverseFmt = IF_BI_0B;
+ }
+
dst =
emitOutputShortBranch(dst,
- emitJumpKindToIns(emitReverseJumpKind(
- emitInsToJumpKind(ins))), // reverse the conditional instruction
- IF_BI_0B,
+ reverseIns, // reverse the conditional instruction
+ reverseFmt,
8, /* 8 bytes from start of this large conditional pseudo-instruction to L_not. */
- nullptr /* only used for tbz/tbnzcbz/cbnz */);
+ id);
// Now, pretend we've got a normal unconditional branch, and fall through to the code to emit that.
ins = INS_b;
@@ -11335,11 +11448,11 @@ regNumber emitter::emitInsTernary(instruction ins, emitAttr attr, GenTree* dst,
bool isMulOverflow = false;
if (dst->gtOverflowEx())
{
- if (ins == INS_add)
+ if ((ins == INS_add) || (ins == INS_adds))
{
ins = INS_adds;
}
- else if (ins == INS_sub)
+ else if ((ins == INS_sub) || (ins == INS_subs))
{
ins = INS_subs;
}
diff --git a/src/jit/emitarm64.h b/src/jit/emitarm64.h
index ebebf51bdd..87d99952cf 100644
--- a/src/jit/emitarm64.h
+++ b/src/jit/emitarm64.h
@@ -781,6 +781,8 @@ void emitIns_R_D(instruction ins, emitAttr attr, unsigned offs, regNumber reg);
void emitIns_J_R(instruction ins, emitAttr attr, BasicBlock* dst, regNumber reg);
+void emitIns_J_R_I(instruction ins, emitAttr attr, BasicBlock* dst, regNumber reg, int imm);
+
void emitIns_I_AR(
instruction ins, emitAttr attr, int val, regNumber reg, int offs, int memCookie = 0, void* clsCookie = NULL);
@@ -856,17 +858,8 @@ BYTE* emitOutputShortConstant(
inline bool emitIsCondJump(instrDesc* jmp)
{
- return ((jmp->idInsFmt() == IF_BI_0B) || (jmp->idInsFmt() == IF_LARGEJMP));
-}
-
-/*****************************************************************************
- *
- * Given an instrDesc, return true if it's a compare and jump.
- */
-
-inline bool emitIsCmpJump(instrDesc* jmp)
-{
- return ((jmp->idInsFmt() == IF_BI_1A) || (jmp->idInsFmt() == IF_BI_1B));
+ return ((jmp->idInsFmt() == IF_BI_0B) || (jmp->idInsFmt() == IF_BI_1A) || (jmp->idInsFmt() == IF_BI_1B) ||
+ (jmp->idInsFmt() == IF_LARGEJMP));
}
/*****************************************************************************
diff --git a/src/jit/emitxarch.cpp b/src/jit/emitxarch.cpp
index 889e07e314..1e82d6f3e9 100644
--- a/src/jit/emitxarch.cpp
+++ b/src/jit/emitxarch.cpp
@@ -73,7 +73,7 @@ bool emitter::IsAVXInstruction(instruction ins)
// TODO-XArch-Cleanup: This is a temporary solution for now. Eventually this needs to
// be formalized by adding an additional field to instruction table to
// to indicate whether a 3-operand instruction.
-bool emitter::IsThreeOperandBinaryAVXInstruction(instruction ins)
+bool emitter::IsDstDstSrcAVXInstruction(instruction ins)
{
return IsAVXInstruction(ins) &&
(ins == INS_cvtsi2ss || ins == INS_cvtsi2sd || ins == INS_cvtss2sd || ins == INS_cvtsd2ss ||
@@ -84,13 +84,12 @@ bool emitter::IsThreeOperandBinaryAVXInstruction(instruction ins)
ins == INS_xorps || ins == INS_xorpd || ins == INS_dpps || ins == INS_dppd || ins == INS_haddpd ||
ins == INS_por || ins == INS_pand || ins == INS_pandn || ins == INS_pcmpeqd || ins == INS_pcmpgtd ||
ins == INS_pcmpeqw || ins == INS_pcmpgtw || ins == INS_pcmpeqb || ins == INS_pcmpgtb ||
- ins == INS_pcmpeqq || ins == INS_pcmpgtq || ins == INS_pmulld || ins == INS_pmullw ||
-
- ins == INS_shufps || ins == INS_shufpd || ins == INS_minps || ins == INS_minss || ins == INS_minpd ||
- ins == INS_minsd || ins == INS_divps || ins == INS_divpd || ins == INS_maxps || ins == INS_maxpd ||
- ins == INS_maxss || ins == INS_maxsd || ins == INS_andnps || ins == INS_andnpd || ins == INS_paddb ||
- ins == INS_paddw || ins == INS_paddd || ins == INS_paddq || ins == INS_psubb || ins == INS_psubw ||
- ins == INS_psubd || ins == INS_psubq || ins == INS_pmuludq || ins == INS_pxor || ins == INS_insertps ||
+ ins == INS_pcmpeqq || ins == INS_pcmpgtq || ins == INS_pmulld || ins == INS_pmullw || ins == INS_shufps ||
+ ins == INS_shufpd || ins == INS_minps || ins == INS_minss || ins == INS_minpd || ins == INS_minsd ||
+ ins == INS_divps || ins == INS_divpd || ins == INS_maxps || ins == INS_maxpd || ins == INS_maxss ||
+ ins == INS_maxsd || ins == INS_andnps || ins == INS_andnpd || ins == INS_paddb || ins == INS_paddw ||
+ ins == INS_paddd || ins == INS_paddq || ins == INS_psubb || ins == INS_psubw || ins == INS_psubd ||
+ ins == INS_psubq || ins == INS_pmuludq || ins == INS_pxor || ins == INS_insertps ||
ins == INS_vinsertf128 || ins == INS_punpckldq || ins == INS_phaddd || ins == INS_pminub ||
ins == INS_pminsw || ins == INS_pminsb || ins == INS_pminsd || ins == INS_pminuw || ins == INS_pminud ||
ins == INS_pmaxub || ins == INS_pmaxsw || ins == INS_pmaxsb || ins == INS_pmaxsd || ins == INS_pmaxuw ||
@@ -100,16 +99,15 @@ bool emitter::IsThreeOperandBinaryAVXInstruction(instruction ins)
ins == INS_packusdw || ins == INS_vperm2i128);
}
-// Returns true if the AVX instruction is a move operator that requires 3 operands.
-// When we emit an instruction with only two operands, we will duplicate the source
-// register in the vvvv field. This is because these merge sources into the dest.
+// Returns true if the AVX instruction requires 3 operands that duplicate the source
+// register in the vvvv field.
// TODO-XArch-Cleanup: This is a temporary solution for now. Eventually this needs to
// be formalized by adding an additional field to instruction table to
// to indicate whether a 3-operand instruction.
-bool emitter::IsThreeOperandMoveAVXInstruction(instruction ins)
+bool emitter::IsDstSrcSrcAVXInstruction(instruction ins)
{
return IsAVXInstruction(ins) && (ins == INS_movlpd || ins == INS_movlps || ins == INS_movhpd || ins == INS_movhps ||
- ins == INS_movss || ins == INS_movlhps);
+ ins == INS_movss || ins == INS_movlhps || ins == INS_sqrtss || ins == INS_sqrtsd);
}
// ------------------------------------------------------------------------------
@@ -7608,7 +7606,7 @@ BYTE* emitter::emitOutputAM(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc)
code = AddVexPrefixIfNeededAndNotPresent(ins, code, size);
// For this format, moves do not support a third operand, so we only need to handle the binary ops.
- if (IsThreeOperandBinaryAVXInstruction(ins))
+ if (IsDstDstSrcAVXInstruction(ins))
{
// Encode source operand reg in 'vvvv' bits in 1's complement form
// The order of operands are reversed, therefore use reg2 as the source.
@@ -9248,12 +9246,12 @@ BYTE* emitter::emitOutputRR(BYTE* dst, instrDesc* id)
//
// TODO-XArch-CQ: Eventually we need to support 3 operand instruction formats. For
// now we use the single source as source1 and source2.
- if (IsThreeOperandBinaryAVXInstruction(ins))
+ if (IsDstDstSrcAVXInstruction(ins))
{
// encode source/dest operand reg in 'vvvv' bits in 1's complement form
code = insEncodeReg3456(ins, reg1, size, code);
}
- else if (IsThreeOperandMoveAVXInstruction(ins))
+ else if (IsDstSrcSrcAVXInstruction(ins))
{
// encode source operand reg in 'vvvv' bits in 1's complement form
code = insEncodeReg3456(ins, reg2, size, code);
@@ -10806,7 +10804,7 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp)
if (TakesVexPrefix(ins))
{
- if (IsThreeOperandBinaryAVXInstruction(ins))
+ if (IsDstDstSrcAVXInstruction(ins))
{
// Encode source/dest operand reg in 'vvvv' bits in 1's complement form
// This code will have to change when we support 3 operands.
@@ -10816,7 +10814,7 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp)
// (see x64 manual Table 2-9. Instructions with a VEX.vvvv destination)
code = insEncodeReg3456(ins, id->idReg1(), size, code);
}
- else if (IsThreeOperandMoveAVXInstruction(ins))
+ else if (IsDstSrcSrcAVXInstruction(ins))
{
// This is a "merge" move instruction.
// Encode source operand reg in 'vvvv' bits in 1's complement form
@@ -11058,7 +11056,7 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp)
// TODO-XArch-CQ: Eventually we need to support 3 operand instruction formats. For
// now we use the single source as source1 and source2.
// For this format, moves do not support a third operand, so we only need to handle the binary ops.
- if (IsThreeOperandBinaryAVXInstruction(ins))
+ if (IsDstDstSrcAVXInstruction(ins))
{
// encode source operand reg in 'vvvv' bits in 1's compliement form
code = insEncodeReg3456(ins, id->idReg1(), size, code);
@@ -11081,7 +11079,7 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp)
// TODO-XArch-CQ: Eventually we need to support 3 operand instruction formats. For
// now we use the single source as source1 and source2.
// For this format, moves do not support a third operand, so we only need to handle the binary ops.
- if (IsThreeOperandBinaryAVXInstruction(ins))
+ if (IsDstDstSrcAVXInstruction(ins))
{
// encode source operand reg in 'vvvv' bits in 1's compliement form
code = insEncodeReg3456(ins, id->idReg1(), size, code);
@@ -11139,7 +11137,7 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp)
// TODO-XArch-CQ: Eventually we need to support 3 operand instruction formats. For
// now we use the single source as source1 and source2.
// For this format, moves do not support a third operand, so we only need to handle the binary ops.
- if (IsThreeOperandBinaryAVXInstruction(ins))
+ if (IsDstDstSrcAVXInstruction(ins))
{
// encode source operand reg in 'vvvv' bits in 1's compliement form
code = insEncodeReg3456(ins, id->idReg1(), size, code);
@@ -11161,7 +11159,7 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp)
// TODO-XArch-CQ: Eventually we need to support 3 operand instruction formats. For
// now we use the single source as source1 and source2.
// For this format, moves do not support a third operand, so we only need to handle the binary ops.
- if (IsThreeOperandBinaryAVXInstruction(ins))
+ if (IsDstDstSrcAVXInstruction(ins))
{
// encode source operand reg in 'vvvv' bits in 1's compliement form
code = insEncodeReg3456(ins, id->idReg1(), size, code);
@@ -11185,7 +11183,7 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp)
// TODO-XArch-CQ: Eventually we need to support 3 operand instruction formats. For
// now we use the single source as source1 and source2.
// For this format, moves do not support a third operand, so we only need to handle the binary ops.
- if (IsThreeOperandBinaryAVXInstruction(ins))
+ if (IsDstDstSrcAVXInstruction(ins))
{
// encode source operand reg in 'vvvv' bits in 1's compliement form
code = insEncodeReg3456(ins, id->idReg1(), size, code);
diff --git a/src/jit/emitxarch.h b/src/jit/emitxarch.h
index d439f7e7f2..2bafe85133 100644
--- a/src/jit/emitxarch.h
+++ b/src/jit/emitxarch.h
@@ -179,11 +179,11 @@ void SetContains256bitAVX(bool value)
contains256bitAVXInstruction = value;
}
-bool IsThreeOperandBinaryAVXInstruction(instruction ins);
-bool IsThreeOperandMoveAVXInstruction(instruction ins);
+bool IsDstDstSrcAVXInstruction(instruction ins);
+bool IsDstSrcSrcAVXInstruction(instruction ins);
bool IsThreeOperandAVXInstruction(instruction ins)
{
- return (IsThreeOperandBinaryAVXInstruction(ins) || IsThreeOperandMoveAVXInstruction(ins));
+ return (IsDstDstSrcAVXInstruction(ins) || IsDstSrcSrcAVXInstruction(ins));
}
bool Is4ByteAVXInstruction(instruction ins);
#else // !FEATURE_AVX_SUPPORT
@@ -203,11 +203,11 @@ bool hasVexPrefix(code_t code)
{
return false;
}
-bool IsThreeOperandBinaryAVXInstruction(instruction ins)
+bool IsDstDstSrcAVXInstruction(instruction ins)
{
return false;
}
-bool IsThreeOperandMoveAVXInstruction(instruction ins)
+bool IsDstSrcSrcAVXInstruction(instruction ins)
{
return false;
}
diff --git a/src/jit/flowgraph.cpp b/src/jit/flowgraph.cpp
index 83f3a78bd5..06e0d3f712 100644
--- a/src/jit/flowgraph.cpp
+++ b/src/jit/flowgraph.cpp
@@ -7056,6 +7056,19 @@ GenTreeCall* Compiler::fgGetStaticsCCtorHelper(CORINFO_CLASS_HANDLE cls, CorInfo
GenTreeCall* result = gtNewHelperCallNode(helper, type, argList);
result->gtFlags |= callFlags;
+ // If we're importing the special EqualityComparer<T>.Default
+ // intrinsic, flag the helper call. Later during inlining, we can
+ // remove the helper call if the associated field lookup is unused.
+ if ((info.compFlags & CORINFO_FLG_JIT_INTRINSIC) != 0)
+ {
+ NamedIntrinsic ni = lookupNamedIntrinsic(info.compMethodHnd);
+ if (ni == NI_System_Collections_Generic_EqualityComparer_get_Default)
+ {
+ JITDUMP("\nmarking helper call [06%u] as special dce...\n", result->gtTreeID);
+ result->gtCallMoreFlags |= GTF_CALL_M_HELPER_SPECIAL_DCE;
+ }
+ }
+
return result;
}
@@ -8185,7 +8198,7 @@ private:
// returns that constant (up to the limit on number of returns); in
// `returnConstants` we track the constant values returned by these
// merged constant return blocks.
- ssize_t returnConstants[ReturnCountHardLimit];
+ INT64 returnConstants[ReturnCountHardLimit];
// Indicators of where in the lexical block list we'd like to place
// each constant return block.
@@ -8361,7 +8374,7 @@ private:
if (returnConst != nullptr)
{
returnExpr = comp->gtNewOperNode(GT_RETURN, returnConst->gtType, returnConst);
- returnConstants[index] = returnConst->IconValue();
+ returnConstants[index] = returnConst->IntegralValue();
}
else if (comp->compMethodHasRetVal())
{
@@ -8629,7 +8642,7 @@ private:
//
BasicBlock* FindConstReturnBlock(GenTreeIntConCommon* constExpr, unsigned searchLimit, unsigned* index)
{
- ssize_t constVal = constExpr->IconValue();
+ INT64 constVal = constExpr->IntegralValue();
for (unsigned i = 0; i < searchLimit; ++i)
{
@@ -9952,6 +9965,7 @@ inline bool OperIsControlFlow(genTreeOps oper)
switch (oper)
{
case GT_JTRUE:
+ case GT_JCMP:
case GT_JCC:
case GT_SWITCH:
case GT_LABEL:
@@ -22233,7 +22247,7 @@ Compiler::fgWalkResult Compiler::fgUpdateInlineReturnExpressionPlaceHolder(GenTr
CORINFO_METHOD_HANDLE method = call->gtCallMethHnd;
unsigned methodFlags = 0;
CORINFO_CONTEXT_HANDLE context = nullptr;
- comp->impDevirtualizeCall(call, tree, &method, &methodFlags, &context, nullptr);
+ comp->impDevirtualizeCall(call, &method, &methodFlags, &context, nullptr);
}
}
}
@@ -22928,8 +22942,8 @@ GenTreePtr Compiler::fgInlinePrependStatements(InlineInfo* inlineInfo)
GenTreeStmt* callStmt = inlineInfo->iciStmt;
IL_OFFSETX callILOffset = callStmt->gtStmtILoffsx;
GenTreeStmt* postStmt = callStmt->gtNextStmt;
- GenTreePtr afterStmt = callStmt; // afterStmt is the place where the new statements should be inserted after.
- GenTreePtr newStmt = nullptr;
+ GenTree* afterStmt = callStmt; // afterStmt is the place where the new statements should be inserted after.
+ GenTree* newStmt = nullptr;
GenTreeCall* call = inlineInfo->iciCall->AsCall();
noway_assert(call->gtOper == GT_CALL);
@@ -23074,6 +23088,8 @@ GenTreePtr Compiler::fgInlinePrependStatements(InlineInfo* inlineInfo)
if (argInfo.argHasSideEff)
{
noway_assert(argInfo.argIsUsed == false);
+ newStmt = nullptr;
+ bool append = true;
if (argNode->gtOper == GT_OBJ || argNode->gtOper == GT_MKREFANY)
{
@@ -23084,16 +23100,92 @@ GenTreePtr Compiler::fgInlinePrependStatements(InlineInfo* inlineInfo)
}
else
{
- newStmt = gtNewStmt(gtUnusedValNode(argNode), callILOffset);
+ // In some special cases, unused args with side effects can
+ // trigger further changes.
+ //
+ // (1) If the arg is a static field access and the field access
+ // was produced by a call to EqualityComparer<T>.get_Default, the
+ // helper call to ensure the field has a value can be suppressed.
+ // This helper call is marked as a "Special DCE" helper during
+ // importation, over in fgGetStaticsCCtorHelper.
+ //
+ // (2) NYI. If, after tunneling through GT_RET_VALs, we find that
+ // the actual arg expression has no side effects, we can skip
+ // appending all together. This will help jit TP a bit.
+ //
+ // Chase through any GT_RET_EXPRs to find the actual argument
+ // expression.
+ GenTree* actualArgNode = argNode;
+ while (actualArgNode->gtOper == GT_RET_EXPR)
+ {
+ actualArgNode = actualArgNode->gtRetExpr.gtInlineCandidate;
+ }
+
+ // For case (1)
+ //
+ // Look for the following tree shapes
+ // prejit: (IND (ADD (CONST, CALL(special dce helper...))))
+ // jit : (COMMA (CALL(special dce helper...), (FIELD ...)))
+ if (actualArgNode->gtOper == GT_COMMA)
+ {
+ // Look for (COMMA (CALL(special dce helper...), (FIELD ...)))
+ GenTree* op1 = actualArgNode->gtOp.gtOp1;
+ GenTree* op2 = actualArgNode->gtOp.gtOp2;
+ if (op1->IsCall() && ((op1->gtCall.gtCallMoreFlags & GTF_CALL_M_HELPER_SPECIAL_DCE) != 0) &&
+ (op2->gtOper == GT_FIELD) && ((op2->gtFlags & GTF_EXCEPT) == 0))
+ {
+ JITDUMP("\nPerforming special dce on unused arg [%06u]:"
+ " actual arg [%06u] helper call [%06u]\n",
+ argNode->gtTreeID, actualArgNode->gtTreeID, op1->gtTreeID);
+ // Drop the whole tree
+ append = false;
+ }
+ }
+ else if (actualArgNode->gtOper == GT_IND)
+ {
+ // Look for (IND (ADD (CONST, CALL(special dce helper...))))
+ GenTree* addr = actualArgNode->gtOp.gtOp1;
+
+ if (addr->gtOper == GT_ADD)
+ {
+ GenTree* op1 = addr->gtOp.gtOp1;
+ GenTree* op2 = addr->gtOp.gtOp2;
+ if (op1->IsCall() &&
+ ((op1->gtCall.gtCallMoreFlags & GTF_CALL_M_HELPER_SPECIAL_DCE) != 0) &&
+ op2->IsCnsIntOrI())
+ {
+ // Drop the whole tree
+ JITDUMP("\nPerforming special dce on unused arg [%06u]:"
+ " actual arg [%06u] helper call [%06u]\n",
+ argNode->gtTreeID, actualArgNode->gtTreeID, op1->gtTreeID);
+ append = false;
+ }
+ }
+ }
}
- afterStmt = fgInsertStmtAfter(block, afterStmt, newStmt);
-#ifdef DEBUG
- if (verbose)
+ if (!append)
{
- gtDispTree(afterStmt);
+ assert(newStmt == nullptr);
+ JITDUMP("Arg tree side effects were discardable, not appending anything for arg\n");
}
+ else
+ {
+ // If we don't have something custom to append,
+ // just append the arg node as an unused value.
+ if (newStmt == nullptr)
+ {
+ newStmt = gtNewStmt(gtUnusedValNode(argNode), callILOffset);
+ }
+
+ afterStmt = fgInsertStmtAfter(block, afterStmt, newStmt);
+#ifdef DEBUG
+ if (verbose)
+ {
+ gtDispTree(afterStmt);
+ }
#endif // DEBUG
+ }
}
else if (argNode->IsBoxedValue())
{
diff --git a/src/jit/gentree.cpp b/src/jit/gentree.cpp
index 8aa255f520..7b17eb0f24 100644
--- a/src/jit/gentree.cpp
+++ b/src/jit/gentree.cpp
@@ -1308,6 +1308,16 @@ AGAIN:
return false;
}
break;
+#ifdef FEATURE_SIMD
+ case GT_SIMD:
+ if ((op1->AsSIMD()->gtSIMDIntrinsicID != op2->AsSIMD()->gtSIMDIntrinsicID) ||
+ (op1->AsSIMD()->gtSIMDBaseType != op2->AsSIMD()->gtSIMDBaseType) ||
+ (op1->AsSIMD()->gtSIMDSize != op2->AsSIMD()->gtSIMDSize))
+ {
+ return false;
+ }
+ break;
+#endif // FEATURE_SIMD
// For the ones below no extra argument matters for comparison.
case GT_QMARK:
@@ -1895,7 +1905,6 @@ AGAIN:
hash =
genTreeHashAdd(hash, static_cast<unsigned>(reinterpret_cast<uintptr_t>(tree->gtObj.gtClass)));
break;
-
// For the ones below no extra argument matters for comparison.
case GT_BOX:
break;
@@ -2542,6 +2551,15 @@ GenTreePtr Compiler::gtReverseCond(GenTree* tree)
GenTreeCC* cc = tree->AsCC();
cc->gtCondition = GenTree::ReverseRelop(cc->gtCondition);
}
+ else if (tree->OperIs(GT_JCMP))
+ {
+ // Flip the GTF_JCMP_EQ
+ //
+ // This causes switching
+ // cbz <=> cbnz
+ // tbz <=> tbnz
+ tree->gtFlags ^= GTF_JCMP_EQ;
+ }
else
{
tree = gtNewOperNode(GT_NOT, TYP_INT, tree);
@@ -6415,6 +6433,7 @@ GenTreeLclFld* Compiler::gtNewLclFldNode(unsigned lnum, var_types type, unsigned
}
GenTreePtr Compiler::gtNewInlineCandidateReturnExpr(GenTreePtr inlineCandidate, var_types type)
+
{
assert(GenTree::s_gtNodeSizes[GT_RET_EXPR] == TREE_NODE_SZ_LARGE);
@@ -7058,7 +7077,7 @@ GenTree* Compiler::gtNewBlkOpNode(
// Returns the newly created PutArgReg node.
//
// Notes:
-// The node is generated as GenTreeMultiRegOp on armel, as GenTreeOp on all the other archs
+// The node is generated as GenTreeMultiRegOp on RyuJIT/armel, GenTreeOp on all the other archs.
//
GenTreePtr Compiler::gtNewPutArgReg(var_types type, GenTreePtr arg, regNumber argReg)
{
@@ -7076,6 +7095,35 @@ GenTreePtr Compiler::gtNewPutArgReg(var_types type, GenTreePtr arg, regNumber ar
return node;
}
+//------------------------------------------------------------------------
+// gtNewBitCastNode: Creates a new BitCast node.
+//
+// Arguments:
+// type - The actual type of the argument
+// arg - The argument node
+// argReg - The register that the argument will be passed in
+//
+// Return Value:
+// Returns the newly created BitCast node.
+//
+// Notes:
+// The node is generated as GenTreeMultiRegOp on RyuJIT/armel, as GenTreeOp on all the other archs.
+//
+GenTreePtr Compiler::gtNewBitCastNode(var_types type, GenTreePtr arg)
+{
+ assert(arg != nullptr);
+
+ GenTreePtr node = nullptr;
+#if !defined(LEGACY_BACKEND) && defined(ARM_SOFTFP)
+ // A BITCAST could be a MultiRegOp on armel since we could move a double register to two int registers.
+ node = new (this, GT_PUTARG_REG) GenTreeMultiRegOp(GT_BITCAST, type, arg, nullptr);
+#else
+ node = gtNewOperNode(GT_BITCAST, type, arg);
+#endif
+
+ return node;
+}
+
/*****************************************************************************
*
* Clones the given tree value and returns a copy of the given tree.
@@ -7113,6 +7161,10 @@ GenTreePtr Compiler::gtClone(GenTree* tree, bool complexOK)
}
break;
+ case GT_CNS_LNG:
+ copy = gtNewLconNode(tree->gtLngCon.gtLconVal);
+ break;
+
case GT_LCL_VAR:
// Remember that the LclVar node has been cloned. The flag will be set
// on 'copy' as well.
@@ -8258,23 +8310,7 @@ bool GenTree::gtSetFlags() const
return false;
}
-#if FEATURE_SET_FLAGS
- assert(OperIsSimple());
-
- if ((gtFlags & GTF_SET_FLAGS) && gtOper != GT_IND)
- {
- // GTF_SET_FLAGS is not valid on GT_IND and is overlaid with GTF_NONFAULTING_IND
- return true;
- }
- else
- {
- return false;
- }
-
-#else // !FEATURE_SET_FLAGS
-
-#ifdef LEGACY_BACKEND
-#ifdef _TARGET_XARCH_
+#if defined(LEGACY_BACKEND) && !FEATURE_SET_FLAGS && defined(_TARGET_XARCH_)
// Return true if/when the codegen for this node will set the flags
//
//
@@ -8290,13 +8326,11 @@ bool GenTree::gtSetFlags() const
{
return true;
}
-#else
- // Otherwise for other architectures we should return false
- return false;
-#endif
+#else // !(defined(LEGACY_BACKEND) && !FEATURE_SET_FLAGS && defined(_TARGET_XARCH_))
-#else // !LEGACY_BACKEND
-#ifdef _TARGET_XARCH_
+#if FEATURE_SET_FLAGS
+ assert(OperIsSimple());
+#endif
if (((gtFlags & GTF_SET_FLAGS) != 0) && (gtOper != GT_IND))
{
// GTF_SET_FLAGS is not valid on GT_IND and is overlaid with GTF_NONFAULTING_IND
@@ -8306,12 +8340,7 @@ bool GenTree::gtSetFlags() const
{
return false;
}
-#else
- unreached();
-#endif
-#endif // !LEGACY_BACKEND
-
-#endif // !FEATURE_SET_FLAGS
+#endif // !(defined(LEGACY_BACKEND) && !FEATURE_SET_FLAGS && defined(_TARGET_XARCH_))
}
bool GenTree::gtRequestSetFlags()
@@ -9868,6 +9897,11 @@ void Compiler::gtDispNode(GenTreePtr tree, IndentStack* indentStack, __in __in_z
}
goto DASH;
+ case GT_JCMP:
+ printf((tree->gtFlags & GTF_JCMP_TST) ? "T" : "C");
+ printf((tree->gtFlags & GTF_JCMP_EQ) ? "EQ" : "NE");
+ goto DASH;
+
default:
DASH:
printf("-");
@@ -10780,6 +10814,9 @@ void Compiler::gtDispLeaf(GenTree* tree, IndentStack* indentStack)
case GT_SETCC:
printf(" cond=%s", GenTree::OpName(tree->AsCC()->gtCondition));
break;
+ case GT_JCMP:
+ printf(" cond=%s%s", (tree->gtFlags & GTF_JCMP_TST) ? "TEST_" : "",
+ (tree->gtFlags & GTF_JCMP_EQ) ? "EQ" : "NE");
default:
assert(!"don't know how to display tree leaf node");
@@ -12525,13 +12562,38 @@ GenTree* Compiler::gtTryRemoveBoxUpstreamEffects(GenTree* op, BoxRemovalOptions
GenTree* boxTypeHandle = nullptr;
if (options == BR_REMOVE_AND_NARROW_WANT_TYPE_HANDLE)
{
- // Note we might see GenTreeAllocObj here, if impImportAndPushBox
- // starts using it instead of a bare helper call.
- GenTree* asgSrc = asg->gtOp.gtOp2;
- assert(asgSrc->IsCall());
- GenTreeCall* newobjCall = asgSrc->AsCall();
- GenTreeArgList* newobjArgs = newobjCall->gtCallArgs->AsArgList();
- boxTypeHandle = newobjArgs->Current();
+ GenTree* asgSrc = asg->gtOp.gtOp2;
+ genTreeOps asgSrcOper = asgSrc->OperGet();
+
+ // Allocation may be via AllocObj or via helper call, depending
+ // on when this is invoked and whether the jit is using AllocObj
+ // for R2R allocations.
+ if (asgSrcOper == GT_ALLOCOBJ)
+ {
+ GenTreeAllocObj* allocObj = asgSrc->AsAllocObj();
+ boxTypeHandle = allocObj->gtOp.gtOp1;
+ }
+ else if (asgSrcOper == GT_CALL)
+ {
+ GenTreeCall* newobjCall = asgSrc->AsCall();
+ GenTree* newobjArgs = newobjCall->gtCallArgs;
+
+ // In R2R expansions the handle may not be an explicit operand to the helper,
+ // so we can't remove the box.
+ if (newobjArgs == nullptr)
+ {
+ assert(newobjCall->IsHelperCall(this, CORINFO_HELP_READYTORUN_NEW));
+ JITDUMP("bailing; newobj via R2R helper\n");
+ return nullptr;
+ }
+
+ boxTypeHandle = newobjArgs->AsArgList()->Current();
+ }
+ else
+ {
+ unreached();
+ }
+
assert(boxTypeHandle != nullptr);
}
@@ -12776,6 +12838,7 @@ GenTree* Compiler::gtOptimizeEnumHasFlag(GenTree* thisOp, GenTree* flagOp)
if (thisVal->IsIntegralConst())
{
thisValOpt = gtClone(thisVal);
+ assert(thisValOpt != nullptr);
}
else
{
@@ -12788,8 +12851,10 @@ GenTree* Compiler::gtOptimizeEnumHasFlag(GenTree* thisOp, GenTree* flagOp)
if (flagVal->IsIntegralConst())
{
- flagValOpt = gtClone(flagVal);
+ flagValOpt = gtClone(flagVal);
+ assert(flagValOpt != nullptr);
flagValOptCopy = gtClone(flagVal);
+ assert(flagValOptCopy != nullptr);
}
else
{
@@ -15580,9 +15645,19 @@ bool GenTree::canBeContained() const
{
assert(IsLIR());
+ if (gtHasReg())
+ {
+ return false;
+ }
+
// It is not possible for nodes that do not produce values or that are not containable values
// to be contained.
- return (OperKind() & (GTK_NOVALUE | GTK_NOCONTAIN)) == 0;
+ if ((OperKind() & (GTK_NOVALUE | GTK_NOCONTAIN)) != 0)
+ {
+ return false;
+ }
+
+ return true;
}
//------------------------------------------------------------------------
@@ -15607,7 +15682,7 @@ bool GenTree::isContained() const
const bool isMarkedContained = ((gtFlags & GTF_CONTAINED) != 0);
#ifdef DEBUG
- if (!canBeContained() || gtHasReg())
+ if (!canBeContained())
{
assert(!isMarkedContained);
}
@@ -15628,20 +15703,10 @@ bool GenTree::isContained() const
assert(!isMarkedContained);
}
-#if !defined(_TARGET_64BIT_)
- if (OperGet() == GT_LONG)
- {
- // GT_LONG nodes are normally contained. The only exception is when the result
- // of a TYP_LONG operation is not used and this can only happen if the GT_LONG
- // has no parent.
- assert(isMarkedContained || (gtGetParent(nullptr) == nullptr));
- }
-#endif
-
// if it's contained it better have a user
if (isMarkedContained)
{
- assert((gtNext != nullptr) || OperIsLocal());
+ assert(gtNext != nullptr);
}
#endif // DEBUG
return isMarkedContained;
diff --git a/src/jit/gentree.h b/src/jit/gentree.h
index a8911d0333..82e5d70b94 100644
--- a/src/jit/gentree.h
+++ b/src/jit/gentree.h
@@ -991,6 +991,9 @@ public:
#define GTF_RELOP_ZTT 0x08000000 // GT_<relop> -- Loop test cloned for converting while-loops into do-while
// with explicit "loop test" in the header block.
+#define GTF_JCMP_EQ 0x80000000 // GTF_JCMP_EQ -- Branch on equal rather than not equal
+#define GTF_JCMP_TST 0x40000000 // GTF_JCMP_TST -- Use bit test instruction rather than compare against zero instruction
+
#define GTF_RET_MERGED 0x80000000 // GT_RETURN -- This is a return generated during epilog merging.
#define GTF_QMARK_CAST_INSTOF 0x80000000 // GT_QMARK -- Is this a top (not nested) level qmark created for
@@ -1145,9 +1148,8 @@ public:
// NOPs may only be present in LIR if they do not produce a value.
return IsNothingNode();
- case GT_ARGPLACE:
case GT_LIST:
- // ARGPLACE and LIST nodes may not be present in a block's LIR sequence, but they may
+ // LIST nodes may not be present in a block's LIR sequence, but they may
// be present as children of an LIR node.
return (gtNext == nullptr) && (gtPrev == nullptr);
@@ -1633,7 +1635,7 @@ public:
bool OperIsConditionalJump() const
{
- return (gtOper == GT_JTRUE) || (gtOper == GT_JCC);
+ return (gtOper == GT_JTRUE) || (gtOper == GT_JCMP) || (gtOper == GT_JCC);
}
static bool OperIsBoundsCheck(genTreeOps op)
@@ -2544,6 +2546,7 @@ struct GenTreeIntConCommon : public GenTree
inline void SetLngValue(INT64 val);
inline ssize_t IconValue();
inline void SetIconValue(ssize_t val);
+ inline INT64 IntegralValue();
GenTreeIntConCommon(genTreeOps oper, var_types type DEBUGARG(bool largeNode = false))
: GenTree(oper, type DEBUGARG(largeNode))
@@ -2780,6 +2783,15 @@ inline void GenTreeIntConCommon::SetIconValue(ssize_t val)
AsIntCon()->gtIconVal = val;
}
+inline INT64 GenTreeIntConCommon::IntegralValue()
+{
+#ifdef _TARGET_64BIT_
+ return LngValue();
+#else
+ return gtOper == GT_CNS_LNG ? LngValue() : (INT64)IconValue();
+#endif // _TARGET_64BIT_
+}
+
/* gtDblCon -- double constant (GT_CNS_DBL) */
struct GenTreeDblCon : public GenTree
@@ -3645,6 +3657,8 @@ struct GenTreeCall final : public GenTree
// to restore real function address and load hidden argument
// as the first argument for calli. It is CoreRT replacement for instantiating
// stubs, because executable code cannot be generated at runtime.
+#define GTF_CALL_M_HELPER_SPECIAL_DCE 0x00020000 // GT_CALL -- this helper call can be removed if it is part of a comma and
+ // the comma result is unused.
// clang-format on
@@ -4988,7 +5002,7 @@ protected:
struct GenTreeRetExpr : public GenTree
{
- GenTreePtr gtInlineCandidate;
+ GenTree* gtInlineCandidate;
CORINFO_CLASS_HANDLE gtRetClsHnd;
@@ -6044,7 +6058,7 @@ inline bool GenTree::IsMultiRegNode() const
}
#if !defined(LEGACY_BACKEND) && defined(_TARGET_ARM_)
- if (gtOper == GT_MUL_LONG || gtOper == GT_PUTARG_REG || gtOper == GT_COPY || OperIsPutArgSplit())
+ if (gtOper == GT_MUL_LONG || gtOper == GT_PUTARG_REG || gtOper == GT_BITCAST || OperIsPutArgSplit())
{
return true;
}
diff --git a/src/jit/gtlist.h b/src/jit/gtlist.h
index 314660ff3d..939f00c334 100644
--- a/src/jit/gtlist.h
+++ b/src/jit/gtlist.h
@@ -64,7 +64,11 @@ GTNODE(CMPXCHG , GenTreeCmpXchg ,0,GTK_SPECIAL)
GTNODE(MEMORYBARRIER , GenTree ,0,GTK_LEAF|GTK_NOVALUE)
GTNODE(CAST , GenTreeCast ,0,GTK_UNOP|GTK_EXOP) // conversion to another type
+#if !defined(LEGACY_BACKEND) && defined(_TARGET_ARM_)
+GTNODE(BITCAST , GenTreeMultiRegOp ,0,GTK_UNOP) // reinterpretation of bits as another type
+#else
GTNODE(BITCAST , GenTreeUnOp ,0,GTK_UNOP) // reinterpretation of bits as another type
+#endif
GTNODE(CKFINITE , GenTreeOp ,0,GTK_UNOP|GTK_NOCONTAIN) // Check for NaN
GTNODE(LCLHEAP , GenTreeOp ,0,GTK_UNOP|GTK_NOCONTAIN) // alloca()
GTNODE(JMP , GenTreeVal ,0,GTK_LEAF|GTK_NOVALUE) // Jump to another function
@@ -221,6 +225,7 @@ GTNODE(SIMD , GenTreeSIMD ,0,GTK_BINOP|GTK_EXOP) // SIMD
GTNODE(CMP , GenTreeOp ,0,GTK_BINOP|GTK_NOVALUE) // Sets the condition flags according to the compare result.
// N.B. Not a relop, it does not produce a value and it cannot be reversed.
+GTNODE(JCMP , GenTreeOp ,0,GTK_BINOP|GTK_NOVALUE) // Makes a comparison and jump if the condition specified. Does not set flags
GTNODE(JCC , GenTreeCC ,0,GTK_LEAF|GTK_NOVALUE) // Checks the condition flags and branch if the condition specified
// by GenTreeCC::gtCondition is true.
GTNODE(SETCC , GenTreeCC ,0,GTK_LEAF) // Checks the condition flags and produces 1 if the condition specified
@@ -289,27 +294,27 @@ GTNODE(SWITCH_TABLE , GenTreeOp ,0, GTK_BINOP|GTK_NOVALUE) // Jump
// Nodes used only within the code generator:
//-----------------------------------------------------------------------------
-GTNODE(REG_VAR , GenTreeLclVar ,0,GTK_LEAF|GTK_LOCAL) // register variable
-GTNODE(CLS_VAR , GenTreeClsVar ,0,GTK_LEAF) // static data member
-GTNODE(CLS_VAR_ADDR , GenTreeClsVar ,0,GTK_LEAF) // static data member address
-GTNODE(ARGPLACE , GenTreeArgPlace ,0,GTK_LEAF) // placeholder for a register arg
-GTNODE(NULLCHECK , GenTreeOp ,0,GTK_UNOP|GTK_NOVALUE) // null checks the source
-GTNODE(PHYSREG , GenTreePhysReg ,0,GTK_LEAF) // read from a physical register
-GTNODE(EMITNOP , GenTree ,0,GTK_LEAF|GTK_NOVALUE) // emitter-placed nop
-GTNODE(PINVOKE_PROLOG , GenTree ,0,GTK_LEAF|GTK_NOVALUE) // pinvoke prolog seq
-GTNODE(PINVOKE_EPILOG , GenTree ,0,GTK_LEAF|GTK_NOVALUE) // pinvoke epilog seq
+GTNODE(REG_VAR , GenTreeLclVar ,0,GTK_LEAF|GTK_LOCAL) // register variable
+GTNODE(CLS_VAR , GenTreeClsVar ,0,GTK_LEAF) // static data member
+GTNODE(CLS_VAR_ADDR , GenTreeClsVar ,0,GTK_LEAF) // static data member address
+GTNODE(ARGPLACE , GenTreeArgPlace ,0,GTK_LEAF|GTK_NOVALUE|GTK_NOTLIR) // placeholder for a register arg
+GTNODE(NULLCHECK , GenTreeOp ,0,GTK_UNOP|GTK_NOVALUE) // null checks the source
+GTNODE(PHYSREG , GenTreePhysReg ,0,GTK_LEAF) // read from a physical register
+GTNODE(EMITNOP , GenTree ,0,GTK_LEAF|GTK_NOVALUE) // emitter-placed nop
+GTNODE(PINVOKE_PROLOG , GenTree ,0,GTK_LEAF|GTK_NOVALUE) // pinvoke prolog seq
+GTNODE(PINVOKE_EPILOG , GenTree ,0,GTK_LEAF|GTK_NOVALUE) // pinvoke epilog seq
#if !defined(LEGACY_BACKEND) && defined(_TARGET_ARM_)
-GTNODE(PUTARG_REG , GenTreeMultiRegOp ,0,GTK_UNOP) // operator that places outgoing arg in register
+GTNODE(PUTARG_REG , GenTreeMultiRegOp ,0,GTK_UNOP) // operator that places outgoing arg in register
#else
-GTNODE(PUTARG_REG , GenTreeOp ,0,GTK_UNOP) // operator that places outgoing arg in register
+GTNODE(PUTARG_REG , GenTreeOp ,0,GTK_UNOP) // operator that places outgoing arg in register
#endif
-GTNODE(PUTARG_STK , GenTreePutArgStk ,0,GTK_UNOP|GTK_NOVALUE) // operator that places outgoing arg in stack
+GTNODE(PUTARG_STK , GenTreePutArgStk ,0,GTK_UNOP|GTK_NOVALUE) // operator that places outgoing arg in stack
#if !defined(LEGACY_BACKEND) && defined(_TARGET_ARM_)
-GTNODE(PUTARG_SPLIT , GenTreePutArgSplit ,0,GTK_UNOP) // operator that places outgoing arg in registers with stack (split struct in ARM32)
+GTNODE(PUTARG_SPLIT , GenTreePutArgSplit ,0,GTK_UNOP) // operator that places outgoing arg in registers with stack (split struct in ARM32)
#endif // !LEGACY_BACKEND && _TARGET_ARM_
-GTNODE(RETURNTRAP , GenTreeOp ,0,GTK_UNOP|GTK_NOVALUE) // a conditional call to wait on gc
-GTNODE(SWAP , GenTreeOp ,0,GTK_BINOP|GTK_NOVALUE) // op1 and op2 swap (registers)
-GTNODE(IL_OFFSET , GenTreeStmt ,0,GTK_LEAF|GTK_NOVALUE) // marks an IL offset for debugging purposes
+GTNODE(RETURNTRAP , GenTreeOp ,0,GTK_UNOP|GTK_NOVALUE) // a conditional call to wait on gc
+GTNODE(SWAP , GenTreeOp ,0,GTK_BINOP|GTK_NOVALUE) // op1 and op2 swap (registers)
+GTNODE(IL_OFFSET , GenTreeStmt ,0,GTK_LEAF|GTK_NOVALUE) // marks an IL offset for debugging purposes
/*****************************************************************************/
#undef GTNODE
diff --git a/src/jit/gtstructs.h b/src/jit/gtstructs.h
index 1661809f6c..853ccebe9f 100644
--- a/src/jit/gtstructs.h
+++ b/src/jit/gtstructs.h
@@ -108,7 +108,7 @@ GTSTRUCT_1(AllocObj , GT_ALLOCOBJ)
GTSTRUCT_2(CC , GT_JCC, GT_SETCC)
#if !defined(LEGACY_BACKEND) && defined(_TARGET_ARM_)
#ifdef ARM_SOFTFP
-GTSTRUCT_2(MultiRegOp , GT_MUL_LONG, GT_PUTARG_REG)
+GTSTRUCT_3(MultiRegOp , GT_MUL_LONG, GT_PUTARG_REG, GT_BITCAST)
#else
GTSTRUCT_1(MultiRegOp , GT_MUL_LONG)
#endif
diff --git a/src/jit/importer.cpp b/src/jit/importer.cpp
index d06bd49975..fcf3ddc1ef 100644
--- a/src/jit/importer.cpp
+++ b/src/jit/importer.cpp
@@ -3360,97 +3360,7 @@ GenTreePtr Compiler::impIntrinsic(GenTreePtr newobjThis,
case CORINFO_INTRINSIC_Exp:
case CORINFO_INTRINSIC_Ceiling:
case CORINFO_INTRINSIC_Floor:
-
- // These are math intrinsics
-
- assert(callType != TYP_STRUCT);
-
- op1 = nullptr;
-
-#if defined(LEGACY_BACKEND)
- if (IsTargetIntrinsic(intrinsicID))
-#elif !defined(_TARGET_X86_)
- // Intrinsics that are not implemented directly by target instructions will
- // be re-materialized as users calls in rationalizer. For prefixed tail calls,
- // don't do this optimization, because
- // a) For back compatibility reasons on desktop.Net 4.6 / 4.6.1
- // b) It will be non-trivial task or too late to re-materialize a surviving
- // tail prefixed GT_INTRINSIC as tail call in rationalizer.
- if (!IsIntrinsicImplementedByUserCall(intrinsicID) || !tailCall)
-#else
- // On x86 RyuJIT, importing intrinsics that are implemented as user calls can cause incorrect calculation
- // of the depth of the stack if these intrinsics are used as arguments to another call. This causes bad
- // code generation for certain EH constructs.
- if (!IsIntrinsicImplementedByUserCall(intrinsicID))
-#endif
- {
- switch (sig->numArgs)
- {
- case 1:
- op1 = impPopStack().val;
-
-#if FEATURE_X87_DOUBLES
-
- // X87 stack doesn't differentiate between float/double
- // so it doesn't need a cast, but everybody else does
- // Just double check it is at least a FP type
- noway_assert(varTypeIsFloating(op1));
-
-#else // FEATURE_X87_DOUBLES
-
- if (op1->TypeGet() != callType)
- {
- op1 = gtNewCastNode(callType, op1, callType);
- }
-
-#endif // FEATURE_X87_DOUBLES
-
- op1 = new (this, GT_INTRINSIC)
- GenTreeIntrinsic(genActualType(callType), op1, intrinsicID, method);
- break;
-
- case 2:
- op2 = impPopStack().val;
- op1 = impPopStack().val;
-
-#if FEATURE_X87_DOUBLES
-
- // X87 stack doesn't differentiate between float/double
- // so it doesn't need a cast, but everybody else does
- // Just double check it is at least a FP type
- noway_assert(varTypeIsFloating(op2));
- noway_assert(varTypeIsFloating(op1));
-
-#else // FEATURE_X87_DOUBLES
-
- if (op2->TypeGet() != callType)
- {
- op2 = gtNewCastNode(callType, op2, callType);
- }
- if (op1->TypeGet() != callType)
- {
- op1 = gtNewCastNode(callType, op1, callType);
- }
-
-#endif // FEATURE_X87_DOUBLES
-
- op1 = new (this, GT_INTRINSIC)
- GenTreeIntrinsic(genActualType(callType), op1, op2, intrinsicID, method);
- break;
-
- default:
- NO_WAY("Unsupported number of args for Math Instrinsic");
- }
-
-#ifndef LEGACY_BACKEND
- if (IsIntrinsicImplementedByUserCall(intrinsicID))
- {
- op1->gtFlags |= GTF_CALL;
- }
-#endif
- }
-
- retNode = op1;
+ retNode = impMathIntrinsic(method, sig, callType, intrinsicID, tailCall);
break;
#ifdef _TARGET_XARCH_
@@ -3828,7 +3738,7 @@ GenTreePtr Compiler::impIntrinsic(GenTreePtr newobjThis,
switch (ni)
{
- case NI_Enum_HasFlag:
+ case NI_System_Enum_HasFlag:
{
GenTree* thisOp = impStackTop(1).val;
GenTree* flagOp = impStackTop(0).val;
@@ -3850,6 +3760,25 @@ GenTreePtr Compiler::impIntrinsic(GenTreePtr newobjThis,
break;
}
+ case NI_MathF_Round:
+ case NI_Math_Round:
+ {
+ // Math.Round and MathF.Round used to be a traditional JIT intrinsic. In order
+ // to simplify the transition, we will just treat it as if it was still the
+ // old intrinsic, CORINFO_INTRINSIC_Round. This should end up flowing properly
+ // everywhere else.
+
+ retNode = impMathIntrinsic(method, sig, callType, CORINFO_INTRINSIC_Round, tailCall);
+ break;
+ }
+
+ case NI_System_Collections_Generic_EqualityComparer_get_Default:
+ {
+ // Flag for later handling during devirtualization.
+ isSpecial = true;
+ break;
+ }
+
default:
break;
}
@@ -3873,6 +3802,112 @@ GenTreePtr Compiler::impIntrinsic(GenTreePtr newobjThis,
return retNode;
}
+GenTree* Compiler::impMathIntrinsic(CORINFO_METHOD_HANDLE method,
+ CORINFO_SIG_INFO* sig,
+ var_types callType,
+ CorInfoIntrinsics intrinsicID,
+ bool tailCall)
+{
+ GenTree* op1;
+ GenTree* op2;
+
+ assert(callType != TYP_STRUCT);
+ assert((intrinsicID == CORINFO_INTRINSIC_Sin) || (intrinsicID == CORINFO_INTRINSIC_Sqrt) ||
+ (intrinsicID == CORINFO_INTRINSIC_Abs) || (intrinsicID == CORINFO_INTRINSIC_Cos) ||
+ (intrinsicID == CORINFO_INTRINSIC_Round) || (intrinsicID == CORINFO_INTRINSIC_Cosh) ||
+ (intrinsicID == CORINFO_INTRINSIC_Sinh) || (intrinsicID == CORINFO_INTRINSIC_Tan) ||
+ (intrinsicID == CORINFO_INTRINSIC_Tanh) || (intrinsicID == CORINFO_INTRINSIC_Asin) ||
+ (intrinsicID == CORINFO_INTRINSIC_Acos) || (intrinsicID == CORINFO_INTRINSIC_Atan) ||
+ (intrinsicID == CORINFO_INTRINSIC_Atan2) || (intrinsicID == CORINFO_INTRINSIC_Log10) ||
+ (intrinsicID == CORINFO_INTRINSIC_Pow) || (intrinsicID == CORINFO_INTRINSIC_Exp) ||
+ (intrinsicID == CORINFO_INTRINSIC_Ceiling) || (intrinsicID == CORINFO_INTRINSIC_Floor));
+
+ op1 = nullptr;
+
+#if defined(LEGACY_BACKEND)
+ if (IsTargetIntrinsic(intrinsicID))
+#elif !defined(_TARGET_X86_)
+ // Intrinsics that are not implemented directly by target instructions will
+ // be re-materialized as users calls in rationalizer. For prefixed tail calls,
+ // don't do this optimization, because
+ // a) For back compatibility reasons on desktop.Net 4.6 / 4.6.1
+ // b) It will be non-trivial task or too late to re-materialize a surviving
+ // tail prefixed GT_INTRINSIC as tail call in rationalizer.
+ if (!IsIntrinsicImplementedByUserCall(intrinsicID) || !tailCall)
+#else
+ // On x86 RyuJIT, importing intrinsics that are implemented as user calls can cause incorrect calculation
+ // of the depth of the stack if these intrinsics are used as arguments to another call. This causes bad
+ // code generation for certain EH constructs.
+ if (!IsIntrinsicImplementedByUserCall(intrinsicID))
+#endif
+ {
+ switch (sig->numArgs)
+ {
+ case 1:
+ op1 = impPopStack().val;
+
+#if FEATURE_X87_DOUBLES
+
+ // X87 stack doesn't differentiate between float/double
+ // so it doesn't need a cast, but everybody else does
+ // Just double check it is at least a FP type
+ noway_assert(varTypeIsFloating(op1));
+
+#else // FEATURE_X87_DOUBLES
+
+ if (op1->TypeGet() != callType)
+ {
+ op1 = gtNewCastNode(callType, op1, callType);
+ }
+
+#endif // FEATURE_X87_DOUBLES
+
+ op1 = new (this, GT_INTRINSIC) GenTreeIntrinsic(genActualType(callType), op1, intrinsicID, method);
+ break;
+
+ case 2:
+ op2 = impPopStack().val;
+ op1 = impPopStack().val;
+
+#if FEATURE_X87_DOUBLES
+
+ // X87 stack doesn't differentiate between float/double
+ // so it doesn't need a cast, but everybody else does
+ // Just double check it is at least a FP type
+ noway_assert(varTypeIsFloating(op2));
+ noway_assert(varTypeIsFloating(op1));
+
+#else // FEATURE_X87_DOUBLES
+
+ if (op2->TypeGet() != callType)
+ {
+ op2 = gtNewCastNode(callType, op2, callType);
+ }
+ if (op1->TypeGet() != callType)
+ {
+ op1 = gtNewCastNode(callType, op1, callType);
+ }
+
+#endif // FEATURE_X87_DOUBLES
+
+ op1 = new (this, GT_INTRINSIC) GenTreeIntrinsic(genActualType(callType), op1, op2, intrinsicID, method);
+ break;
+
+ default:
+ NO_WAY("Unsupported number of args for Math Instrinsic");
+ }
+
+#ifndef LEGACY_BACKEND
+ if (IsIntrinsicImplementedByUserCall(intrinsicID))
+ {
+ op1->gtFlags |= GTF_CALL;
+ }
+#endif
+ }
+
+ return op1;
+}
+
//------------------------------------------------------------------------
// lookupNamedIntrinsic: map method to jit named intrinsic value
//
@@ -3895,14 +3930,31 @@ NamedIntrinsic Compiler::lookupNamedIntrinsic(CORINFO_METHOD_HANDLE method)
const char* namespaceName = nullptr;
const char* methodName = info.compCompHnd->getMethodNameFromMetadata(method, &className, &namespaceName);
- if ((namespaceName != nullptr) && strcmp(namespaceName, "System") == 0)
+ if ((namespaceName == nullptr) || (className == nullptr) || (methodName == nullptr))
{
- if ((className != nullptr) && strcmp(className, "Enum") == 0)
+ return result;
+ }
+
+ if (strcmp(namespaceName, "System") == 0)
+ {
+ if ((strcmp(className, "Enum") == 0) && (strcmp(methodName, "HasFlag") == 0))
{
- if ((methodName != nullptr) && strcmp(methodName, "HasFlag") == 0)
- {
- result = NI_Enum_HasFlag;
- }
+ result = NI_System_Enum_HasFlag;
+ }
+ else if ((strcmp(className, "MathF") == 0) && (strcmp(methodName, "Round") == 0))
+ {
+ result = NI_MathF_Round;
+ }
+ else if ((strcmp(className, "Math") == 0) && (strcmp(methodName, "Round") == 0))
+ {
+ result = NI_Math_Round;
+ }
+ }
+ else if (strcmp(namespaceName, "System.Collections.Generic") == 0)
+ {
+ if ((strcmp(className, "EqualityComparer`1") == 0) && (strcmp(methodName, "get_Default") == 0))
+ {
+ result = NI_System_Collections_Generic_EqualityComparer_get_Default;
}
}
@@ -5449,12 +5501,13 @@ void Compiler::impImportAndPushBox(CORINFO_RESOLVED_TOKEN* pResolvedToken)
return;
}
- op1 = gtNewHelperCallNode(info.compCompHnd->getNewHelper(pResolvedToken, info.compMethodHnd), TYP_REF,
- gtNewArgList(op2));
+ op1 = gtNewAllocObjNode(info.compCompHnd->getNewHelper(pResolvedToken, info.compMethodHnd),
+ pResolvedToken->hClass, TYP_REF, op2);
}
- /* Remember that this basic block contains 'new' of an object */
+ /* Remember that this basic block contains 'new' of an object, and so does this method */
compCurBB->bbFlags |= BBF_HAS_NEWOBJ;
+ optMethodFlags |= OMF_HAS_NEWOBJ;
GenTreePtr asg = gtNewTempAssign(impBoxTemp, op1);
@@ -6992,7 +7045,7 @@ var_types Compiler::impImportCall(OPCODE opcode,
exactContextNeedsRuntimeLookup = callInfo->exactContextNeedsRuntimeLookup == TRUE;
// Recursive call is treated as a loop to the begining of the method.
- if (methHnd == info.compMethodHnd)
+ if (gtIsRecursiveCall(methHnd))
{
#ifdef DEBUG
if (verbose)
@@ -7702,29 +7755,25 @@ var_types Compiler::impImportCall(OPCODE opcode,
}
}
- /* Is this a virtual or interface call? */
+ // Store the "this" value in the call
+ call->gtFlags |= obj->gtFlags & GTF_GLOB_EFFECT;
+ call->gtCall.gtCallObjp = obj;
+ // Is this a virtual or interface call?
if ((call->gtFlags & GTF_CALL_VIRT_KIND_MASK) != GTF_CALL_NONVIRT)
{
- /* only true object pointers can be virtual */
+ // only true object pointers can be virtual
assert(obj->gtType == TYP_REF);
// See if we can devirtualize.
- impDevirtualizeCall(call->AsCall(), obj, &callInfo->hMethod, &callInfo->methodFlags,
- &callInfo->contextHandle, &exactContextHnd);
+ impDevirtualizeCall(call->AsCall(), &callInfo->hMethod, &callInfo->methodFlags, &callInfo->contextHandle,
+ &exactContextHnd);
}
- else
+
+ if (impIsThis(obj))
{
- if (impIsThis(obj))
- {
- call->gtCall.gtCallMoreFlags |= GTF_CALL_M_NONVIRT_SAME_THIS;
- }
+ call->gtCall.gtCallMoreFlags |= GTF_CALL_M_NONVIRT_SAME_THIS;
}
-
- /* Store the "this" value in the call */
-
- call->gtFlags |= obj->gtFlags & GTF_GLOB_EFFECT;
- call->gtCall.gtCallObjp = obj;
}
//-------------------------------------------------------------------------
@@ -14235,7 +14284,7 @@ void Compiler::impImportBlockCode(BasicBlock* block)
op1 = gtNewHelperCallNode(CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE_MAYBENULL, TYP_STRUCT, helperArgs);
// The handle struct is returned in register
- op1->gtCall.gtReturnType = TYP_REF;
+ op1->gtCall.gtReturnType = GetRuntimeHandleUnderlyingType();
tiRetVal = typeInfo(TI_STRUCT, impGetTypeHandleClass());
}
@@ -14275,7 +14324,7 @@ void Compiler::impImportBlockCode(BasicBlock* block)
op1 = gtNewHelperCallNode(helper, TYP_STRUCT, helperArgs);
// The handle struct is returned in register
- op1->gtCall.gtReturnType = TYP_REF;
+ op1->gtCall.gtReturnType = GetRuntimeHandleUnderlyingType();
tiRetVal = verMakeTypeInfo(tokenType);
impPushOnStack(op1, tiRetVal);
@@ -17646,7 +17695,7 @@ void Compiler::impInlineRecordArgInfo(InlineInfo* pInlineInfo,
inlCurArgInfo->argIsInvariant = true;
if (inlCurArgInfo->argIsThis && (curArgVal->gtOper == GT_CNS_INT) && (curArgVal->gtIntCon.gtIconVal == 0))
{
- /* Abort, but do not mark as not inlinable */
+ // Abort inlining at this call site
inlineResult->NoteFatal(InlineObservation::CALLSITE_ARG_HAS_NULL_THIS);
return;
}
@@ -18700,6 +18749,8 @@ bool Compiler::IsTargetIntrinsic(CorInfoIntrinsics intrinsicId)
case CORINFO_INTRINSIC_Sqrt:
case CORINFO_INTRINSIC_Abs:
case CORINFO_INTRINSIC_Round:
+ case CORINFO_INTRINSIC_Floor:
+ case CORINFO_INTRINSIC_Ceiling:
return true;
default:
@@ -18789,9 +18840,8 @@ bool Compiler::IsMathIntrinsic(GenTreePtr tree)
//
// Arguments:
// call -- the call node to examine/modify
-// thisObj -- the value of 'this' for the call
// method -- [IN/OUT] the method handle for call. Updated iff call devirtualized.
-// methodAttribs -- [IN/OUT] flags for the method to call. Updated iff call devirtualized.
+// methodFlags -- [IN/OUT] flags for the method to call. Updated iff call devirtualized.
// contextHandle -- [IN/OUT] context handle for the call. Updated iff call devirtualized.
// exactContextHnd -- [OUT] updated context handle iff call devirtualized
//
@@ -18813,7 +18863,6 @@ bool Compiler::IsMathIntrinsic(GenTreePtr tree)
// the 'this obj' of a subsequent virtual call.
//
void Compiler::impDevirtualizeCall(GenTreeCall* call,
- GenTreePtr thisObj,
CORINFO_METHOD_HANDLE* method,
unsigned* methodFlags,
CORINFO_CONTEXT_HANDLE* contextHandle,
@@ -18898,9 +18947,41 @@ void Compiler::impDevirtualizeCall(GenTreeCall* call,
}
// See what we know about the type of 'this' in the call.
- bool isExact = false;
- bool objIsNonNull = false;
- CORINFO_CLASS_HANDLE objClass = gtGetClassHandle(thisObj, &isExact, &objIsNonNull);
+ GenTree* thisObj = call->gtCallObjp->gtEffectiveVal(false);
+ GenTree* actualThisObj = nullptr;
+ bool isExact = false;
+ bool objIsNonNull = false;
+ CORINFO_CLASS_HANDLE objClass = gtGetClassHandle(thisObj, &isExact, &objIsNonNull);
+
+ // See if we have special knowlege that can get us a type or a better type.
+ if ((objClass == nullptr) || !isExact)
+ {
+ actualThisObj = thisObj;
+
+ // Walk back through any return expression placeholders
+ while (actualThisObj->OperGet() == GT_RET_EXPR)
+ {
+ actualThisObj = actualThisObj->gtRetExpr.gtInlineCandidate;
+ }
+
+ // See if we landed on a call to a special intrinsic method
+ if (actualThisObj->IsCall())
+ {
+ GenTreeCall* thisObjCall = actualThisObj->AsCall();
+ if ((thisObjCall->gtCallMoreFlags & GTF_CALL_M_SPECIAL_INTRINSIC) != 0)
+ {
+ assert(thisObjCall->gtCallType == CT_USER_FUNC);
+ CORINFO_METHOD_HANDLE specialIntrinsicHandle = thisObjCall->gtCallMethHnd;
+ CORINFO_CLASS_HANDLE specialObjClass = impGetSpecialIntrinsicExactReturnType(specialIntrinsicHandle);
+ if (specialObjClass != nullptr)
+ {
+ objClass = specialObjClass;
+ isExact = true;
+ objIsNonNull = true;
+ }
+ }
+ }
+ }
// Bail if we know nothing.
if (objClass == nullptr)
@@ -19123,6 +19204,64 @@ void Compiler::impDevirtualizeCall(GenTreeCall* call,
}
//------------------------------------------------------------------------
+// impGetSpecialIntrinsicExactReturnType: Look for special cases where a call
+// to an intrinsic returns an exact type
+//
+// Arguments:
+// methodHnd -- handle for the special intrinsic method
+//
+// Returns:
+// Exact class handle returned by the intrinsic call, if known.
+// Nullptr if not known, or not likely to lead to beneficial optimization.
+
+CORINFO_CLASS_HANDLE Compiler::impGetSpecialIntrinsicExactReturnType(CORINFO_METHOD_HANDLE methodHnd)
+{
+ JITDUMP("Special intrinsic: looking for exact type returned by %s\n", eeGetMethodFullName(methodHnd));
+
+ CORINFO_CLASS_HANDLE result = nullptr;
+
+ // See what intrinisc we have...
+ const NamedIntrinsic ni = lookupNamedIntrinsic(methodHnd);
+ switch (ni)
+ {
+ case NI_System_Collections_Generic_EqualityComparer_get_Default:
+ {
+ // Expect one class generic parameter; figure out which it is.
+ CORINFO_SIG_INFO sig;
+ info.compCompHnd->getMethodSig(methodHnd, &sig);
+ assert(sig.sigInst.classInstCount == 1);
+ CORINFO_CLASS_HANDLE typeHnd = sig.sigInst.classInst[0];
+ assert(typeHnd != nullptr);
+ const DWORD typeAttribs = info.compCompHnd->getClassAttribs(typeHnd);
+ const bool isFinalType = ((typeAttribs & CORINFO_FLG_FINAL) != 0);
+
+ // If we do not have a final type, devirt & inlining is
+ // unlikely to result in much simplification.
+ if (isFinalType)
+ {
+ result = info.compCompHnd->getDefaultEqualityComparerClass(typeHnd);
+ JITDUMP("Special intrinsic for type %s: return type is %s\n", eeGetClassName(typeHnd),
+ result != nullptr ? eeGetClassName(result) : "unknown");
+ }
+ else
+ {
+ JITDUMP("Special intrinsic for type %s: type not final, so deferring opt\n", eeGetClassName(typeHnd));
+ }
+
+ break;
+ }
+
+ default:
+ {
+ JITDUMP("This special intrinsic not handled, sorry...\n");
+ break;
+ }
+ }
+
+ return result;
+}
+
+//------------------------------------------------------------------------
// impAllocateToken: create CORINFO_RESOLVED_TOKEN into jit-allocated memory and init it.
//
// Arguments:
diff --git a/src/jit/instr.cpp b/src/jit/instr.cpp
index e250902472..e9b001cc4a 100644
--- a/src/jit/instr.cpp
+++ b/src/jit/instr.cpp
@@ -3714,14 +3714,32 @@ instruction CodeGen::ins_FloatCopy(var_types type)
instruction CodeGen::ins_CopyIntToFloat(var_types srcType, var_types dstType)
{
- // Not used and not implemented
- unreached();
+ assert((dstType == TYP_FLOAT) || (dstType == TYP_DOUBLE));
+ assert((srcType == TYP_INT) || (srcType == TYP_UINT) || (srcType == TYP_LONG) || (srcType == TYP_ULONG));
+
+ if ((srcType == TYP_LONG) || (srcType == TYP_ULONG))
+ {
+ return INS_vmov_i2d;
+ }
+ else
+ {
+ return INS_vmov_i2f;
+ }
}
instruction CodeGen::ins_CopyFloatToInt(var_types srcType, var_types dstType)
{
- // Not used and not implemented
- unreached();
+ assert((srcType == TYP_FLOAT) || (srcType == TYP_DOUBLE));
+ assert((dstType == TYP_INT) || (dstType == TYP_UINT) || (dstType == TYP_LONG) || (dstType == TYP_ULONG));
+
+ if ((dstType == TYP_LONG) || (dstType == TYP_ULONG))
+ {
+ return INS_vmov_d2i;
+ }
+ else
+ {
+ return INS_vmov_f2i;
+ }
}
instruction CodeGen::ins_FloatCompare(var_types type)
diff --git a/src/jit/lclvars.cpp b/src/jit/lclvars.cpp
index b46948773c..e5165bad31 100644
--- a/src/jit/lclvars.cpp
+++ b/src/jit/lclvars.cpp
@@ -235,60 +235,6 @@ void Compiler::lvaInitTypeRef()
lvaInitArgs(&varDscInfo);
-#if FEATURE_FASTTAILCALL
-
- //-------------------------------------------------------------------------
- // Calculate the argument register usage.
- //
- // This will later be used for fastTailCall determination
- //-------------------------------------------------------------------------
-
- unsigned argRegCount = 0;
- unsigned floatingRegCount = 0;
- size_t stackSize = 0;
-
- auto incrementRegCount = [&floatingRegCount, &argRegCount](LclVarDsc* varDsc) {
- if (varDsc->lvIsHfa())
- {
- floatingRegCount += varDsc->lvHfaSlots();
- }
- else
- {
- varDsc->IsFloatRegType() ? ++floatingRegCount : ++argRegCount;
- }
- };
-
- unsigned argNum;
- LclVarDsc* curDsc;
-
- for (curDsc = lvaTable, argNum = 0; argNum < varDscInfo.varNum; argNum++, curDsc++)
- {
- if (curDsc->lvIsRegArg)
- {
- incrementRegCount(curDsc);
-#if FEATURE_MULTIREG_ARGS
- if (curDsc->lvOtherArgReg != REG_NA)
- {
- incrementRegCount(curDsc);
- }
-#endif // FEATURE_MULTIREG_ARGS
- }
- else
- {
- stackSize += curDsc->lvArgStackSize();
- }
- }
-
- //-------------------------------------------------------------------------
- // Save the register usage information and stack size.
- //-------------------------------------------------------------------------
-
- info.compArgRegCount = argRegCount;
- info.compFloatArgRegCount = floatingRegCount;
- info.compArgStackSize = stackSize;
-
-#endif // FEATURE_FASTTAILCALL
-
//-------------------------------------------------------------------------
// Finally the local variables
//-------------------------------------------------------------------------
@@ -410,6 +356,13 @@ void Compiler::lvaInitArgs(InitVarDscInfo* varDscInfo)
codeGen->floatRegState.rsCalleeRegArgCount = varDscInfo->floatRegArgNum;
#endif // FEATURE_STACK_FP_X87
+#if FEATURE_FASTTAILCALL
+ // Save the stack usage information
+ // We can get register usage information using codeGen->intRegState and
+ // codeGen->floatRegState
+ info.compArgStackSize = varDscInfo->stackArgSize;
+#endif // FEATURE_FASTTAILCALL
+
// The total argument size must be aligned.
noway_assert((compArgSize % sizeof(void*)) == 0);
@@ -978,7 +931,6 @@ void Compiler::lvaInitUserArgs(InitVarDscInfo* varDscInfo)
else
{
#if defined(_TARGET_ARM_)
-
varDscInfo->setAllRegArgUsed(argType);
if (varTypeIsFloating(argType))
{
@@ -994,6 +946,10 @@ void Compiler::lvaInitUserArgs(InitVarDscInfo* varDscInfo)
varDscInfo->setAllRegArgUsed(argType);
#endif // _TARGET_XXX_
+
+#if FEATURE_FASTTAILCALL
+ varDscInfo->stackArgSize += (unsigned)roundUp(argSize, TARGET_POINTER_SIZE);
+#endif // FEATURE_FASTTAILCALL
}
#ifdef FEATURE_UNIX_AMD64_STRUCT_PASSING
@@ -1090,6 +1046,9 @@ void Compiler::lvaInitGenericsCtxt(InitVarDscInfo* varDscInfo)
// For the RyuJIT backend, we need to mark these as being on the stack,
// as this is not done elsewhere in the case that canEnreg returns false.
varDsc->lvOnFrame = true;
+#if FEATURE_FASTTAILCALL
+ varDscInfo->stackArgSize += TARGET_POINTER_SIZE;
+#endif // FEATURE_FASTTAILCALL
}
#endif // !LEGACY_BACKEND
@@ -1163,6 +1122,9 @@ void Compiler::lvaInitVarArgsHandle(InitVarDscInfo* varDscInfo)
// For the RyuJIT backend, we need to mark these as being on the stack,
// as this is not done elsewhere in the case that canEnreg returns false.
varDsc->lvOnFrame = true;
+#if FEATURE_FASTTAILCALL
+ varDscInfo->stackArgSize += TARGET_POINTER_SIZE;
+#endif // FEATURE_FASTTAILCALL
}
#endif // !LEGACY_BACKEND
@@ -7332,6 +7294,14 @@ Compiler::fgWalkResult Compiler::lvaStressLclFldCB(GenTreePtr* pTree, fgWalkData
// Calculate padding
unsigned padding = LCL_FLD_PADDING(lclNum);
+#ifdef _TARGET_ARM_
+ // We need to support alignment requirements to access memory on ARM
+ unsigned alignment = 1;
+ pComp->codeGen->InferOpSizeAlign(tree, &alignment);
+ alignment = roundUp(alignment, TARGET_POINTER_SIZE);
+ padding = roundUp(padding, alignment);
+#endif // _TARGET_ARM_
+
// Change the variable to a TYP_BLK
if (varType != TYP_BLK)
{
diff --git a/src/jit/lir.cpp b/src/jit/lir.cpp
index ecfe6c5dbd..a2343ad313 100644
--- a/src/jit/lir.cpp
+++ b/src/jit/lir.cpp
@@ -1407,6 +1407,105 @@ LIR::ReadOnlyRange LIR::Range::GetRangeOfOperandTrees(GenTree* root, bool* isClo
#ifdef DEBUG
//------------------------------------------------------------------------
+// CheckLclVarSemanticsHelper checks lclVar semantics.
+//
+// Specifically, ensure that an unaliasable lclVar is not redefined between the
+// point at which a use appears in linear order and the point at which it is used by its user.
+// This ensures that it is always safe to treat a lclVar use as happening at the user (rather than at
+// the lclVar node).
+class CheckLclVarSemanticsHelper
+{
+public:
+ //------------------------------------------------------------------------
+ // CheckLclVarSemanticsHelper constructor: Init arguments for the helper.
+ //
+ // This needs unusedDefs because unused lclVar reads may otherwise appear as outstanding reads
+ // and produce false indications that a write to a lclVar occurs while outstanding reads of that lclVar
+ // exist.
+ //
+ // Arguments:
+ // compiler - A compiler context.
+ // range - a range to do the check.
+ // unusedDefs - map of defs that do no have users.
+ //
+ CheckLclVarSemanticsHelper(Compiler* compiler,
+ const LIR::Range* range,
+ SmallHashTable<GenTreePtr, bool, 32U>& unusedDefs)
+ : compiler(compiler), range(range), unusedDefs(unusedDefs), unusedLclVarReads(compiler)
+ {
+ }
+
+ //------------------------------------------------------------------------
+ // Check: do the check.
+ // Return Value:
+ // 'true' if the Local variables semantics for the specified range is legal.
+ bool Check()
+ {
+ for (GenTreePtr node : *range)
+ {
+ if (!node->isContained()) // a contained node reads operands in the parent.
+ {
+ UseNodeOperands(node);
+ }
+
+ AliasSet::NodeInfo nodeInfo(compiler, node);
+ if (nodeInfo.IsLclVarRead() && !unusedDefs.Contains(node))
+ {
+ int count = 0;
+ unusedLclVarReads.TryGetValue(nodeInfo.LclNum(), &count);
+ unusedLclVarReads.AddOrUpdate(nodeInfo.LclNum(), count + 1);
+ }
+
+ // If this node is a lclVar write, it must be to a lclVar that does not have an outstanding read.
+ assert(!nodeInfo.IsLclVarWrite() || !unusedLclVarReads.Contains(nodeInfo.LclNum()));
+ }
+
+ return true;
+ }
+
+private:
+ //------------------------------------------------------------------------
+ // UseNodeOperands: mark the node's operands as used.
+ //
+ // Arguments:
+ // node - the node to use operands from.
+ void UseNodeOperands(GenTreePtr node)
+ {
+ for (GenTreePtr operand : node->Operands())
+ {
+ if (!operand->IsLIR())
+ {
+ // ARGPLACE nodes are not represented in the LIR sequence. Ignore them.
+ assert(operand->OperIs(GT_ARGPLACE));
+ continue;
+ }
+ if (operand->isContained())
+ {
+ UseNodeOperands(operand);
+ }
+ AliasSet::NodeInfo operandInfo(compiler, operand);
+ if (operandInfo.IsLclVarRead())
+ {
+ int count;
+ const bool removed = unusedLclVarReads.TryRemove(operandInfo.LclNum(), &count);
+ assert(removed);
+
+ if (count > 1)
+ {
+ unusedLclVarReads.AddOrUpdate(operandInfo.LclNum(), count - 1);
+ }
+ }
+ }
+ }
+
+private:
+ Compiler* compiler;
+ const LIR::Range* range;
+ SmallHashTable<GenTree*, bool, 32U>& unusedDefs;
+ SmallHashTable<int, int, 32U> unusedLclVarReads;
+};
+
+//------------------------------------------------------------------------
// LIR::Range::CheckLIR: Performs a set of correctness checks on the LIR
// contained in this range.
//
@@ -1501,20 +1600,16 @@ bool LIR::Range::CheckLIR(Compiler* compiler, bool checkUnusedValues) const
assert(!(checkUnusedValues && def->IsUnusedValue()) && "operands should never be marked as unused values");
- if (def->OperGet() == GT_ARGPLACE)
- {
- // ARGPLACE nodes are not represented in the LIR sequence. Ignore them.
- continue;
- }
- else if (!def->IsValue())
+ if (!def->IsValue())
{
// Stack arguments do not produce a value, but they are considered children of the call.
// It may be useful to remove these from being call operands, but that may also impact
// other code that relies on being able to reach all the operands from a call node.
// The GT_NOP case is because sometimes we eliminate stack argument stores as dead, but
// instead of removing them we replace with a NOP.
+ // ARGPLACE nodes are not represented in the LIR sequence. Ignore them.
assert((node->OperGet() == GT_CALL) &&
- (def->OperIsStore() || (def->OperGet() == GT_PUTARG_STK) || (def->OperGet() == GT_NOP)));
+ (def->OperIsStore() || def->OperIs(GT_PUTARG_STK, GT_NOP, GT_ARGPLACE)));
continue;
}
@@ -1565,44 +1660,8 @@ bool LIR::Range::CheckLIR(Compiler* compiler, bool checkUnusedValues) const
}
}
- // Check lclVar semantics: specifically, ensure that an unaliasable lclVar is not redefined between the
- // point at which a use appears in linear order and the point at which that use is consumed by its user.
- // This ensures that it is always safe to treat a lclVar use as happening at the user (rather than at
- // the lclVar node).
- //
- // This happens as a second pass because unused lclVar reads may otherwise appear as outstanding reads
- // and produce false indications that a write to a lclVar occurs while outstanding reads of that lclVar
- // exist.
- SmallHashTable<int, int, 32> unconsumedLclVarReads(compiler);
- for (GenTree* node : *this)
- {
- for (GenTree* operand : node->Operands())
- {
- AliasSet::NodeInfo operandInfo(compiler, operand);
- if (operandInfo.IsLclVarRead())
- {
- int count;
- const bool removed = unconsumedLclVarReads.TryRemove(operandInfo.LclNum(), &count);
- assert(removed);
-
- if (count > 1)
- {
- unconsumedLclVarReads.AddOrUpdate(operandInfo.LclNum(), count - 1);
- }
- }
- }
-
- AliasSet::NodeInfo nodeInfo(compiler, node);
- if (nodeInfo.IsLclVarRead() && !unusedDefs.Contains(node))
- {
- int count = 0;
- unconsumedLclVarReads.TryGetValue(nodeInfo.LclNum(), &count);
- unconsumedLclVarReads.AddOrUpdate(nodeInfo.LclNum(), count + 1);
- }
-
- // If this node is a lclVar write, it must be to a lclVar that does not have an outstanding read.
- assert(!nodeInfo.IsLclVarWrite() || !unconsumedLclVarReads.Contains(nodeInfo.LclNum()));
- }
+ CheckLclVarSemanticsHelper checkLclVarSemanticsHelper(compiler, this, unusedDefs);
+ assert(checkLclVarSemanticsHelper.Check());
return true;
}
diff --git a/src/jit/liveness.cpp b/src/jit/liveness.cpp
index fdec25bb02..90aa0d1c7c 100644
--- a/src/jit/liveness.cpp
+++ b/src/jit/liveness.cpp
@@ -1603,8 +1603,6 @@ void Compiler::fgComputeLifeCall(VARSET_TP& life, GenTreeCall* call)
}
}
- /* GC refs cannot be enregistered accross an unmanaged call */
-
// TODO: we should generate the code for saving to/restoring
// from the inlined N/Direct frame instead.
@@ -2184,6 +2182,7 @@ void Compiler::fgComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VARSET_VALAR
#if defined(FEATURE_SIMD)
case GT_SIMD_CHK:
#endif // FEATURE_SIMD
+ case GT_JCMP:
case GT_CMP:
case GT_JCC:
case GT_JTRUE:
diff --git a/src/jit/lower.cpp b/src/jit/lower.cpp
index 5a8f423355..d82676e540 100644
--- a/src/jit/lower.cpp
+++ b/src/jit/lower.cpp
@@ -44,6 +44,7 @@ void Lowering::MakeSrcContained(GenTreePtr parentNode, GenTreePtr childNode)
assert(!parentNode->OperIsLeaf());
assert(childNode->canBeContained());
childNode->SetContained();
+ assert(childNode->isContained());
}
//------------------------------------------------------------------------
@@ -187,6 +188,7 @@ GenTree* Lowering::LowerNode(GenTree* node)
case GT_TEST_EQ:
case GT_TEST_NE:
case GT_CMP:
+ case GT_JCMP:
LowerCompare(node);
break;
@@ -210,7 +212,7 @@ GenTree* Lowering::LowerNode(GenTree* node)
LowerCast(node);
break;
-#ifdef _TARGET_XARCH_
+#if defined(_TARGET_XARCH_) || defined(_TARGET_ARM64_)
case GT_ARR_BOUNDS_CHECK:
#ifdef FEATURE_SIMD
case GT_SIMD_CHK:
@@ -240,7 +242,7 @@ GenTree* Lowering::LowerNode(GenTree* node)
case GT_LSH:
case GT_RSH:
case GT_RSZ:
-#ifdef _TARGET_XARCH_
+#if defined(_TARGET_XARCH_) || defined(_TARGET_ARM64_)
LowerShift(node->AsOp());
#else
ContainCheckShiftRotate(node->AsOp());
@@ -548,6 +550,21 @@ GenTree* Lowering::LowerSwitch(GenTree* node)
flowList* oldEdge = comp->fgRemoveRefPred(jumpTab[jumpCnt - 1], afterDefaultCondBlock);
comp->fgAddRefPred(jumpTab[jumpCnt - 1], originalSwitchBB, oldEdge);
+ bool useJumpSequence = jumpCnt < minSwitchTabJumpCnt;
+
+#if defined(_TARGET_UNIX_) && defined(_TARGET_ARM_)
+ // Force using an inlined jumping instead switch table generation.
+ // Switch jump table is generated with incorrect values in CoreRT case,
+ // so any large switch will crash after loading to PC any such value.
+ // I think this is due to the fact that we use absolute addressing
+ // instead of relative. But in CoreRT is used as a rule relative
+ // addressing when we generate an executable.
+ // This bug is also present in Legacy JIT.
+ // See also https://github.com/dotnet/coreclr/issues/13194
+ // Also https://github.com/dotnet/coreclr/pull/13197
+ useJumpSequence = useJumpSequence || comp->IsTargetAbi(CORINFO_CORERT_ABI);
+#endif // defined(_TARGET_UNIX_) && defined(_TARGET_ARM_)
+
// If we originally had 2 unique successors, check to see whether there is a unique
// non-default case, in which case we can eliminate the switch altogether.
// Note that the single unique successor case is handled above.
@@ -593,7 +610,7 @@ GenTree* Lowering::LowerSwitch(GenTree* node)
// If the number of possible destinations is small enough, we proceed to expand the switch
// into a series of conditional branches, otherwise we follow the jump table based switch
// transformation.
- else if ((jumpCnt < minSwitchTabJumpCnt) || comp->compStressCompile(Compiler::STRESS_SWITCH_CMP_BR_EXPANSION, 50))
+ else if (useJumpSequence || comp->compStressCompile(Compiler::STRESS_SWITCH_CMP_BR_EXPANSION, 50))
{
// Lower the switch into a series of compare and branch IR trees.
//
@@ -761,7 +778,7 @@ void Lowering::ReplaceArgWithPutArgOrCopy(GenTree** argSlot, GenTree* putArgOrCo
{
assert(argSlot != nullptr);
assert(*argSlot != nullptr);
- assert(putArgOrCopy->OperIsPutArg() || putArgOrCopy->OperIs(GT_COPY));
+ assert(putArgOrCopy->OperIsPutArg() || putArgOrCopy->OperIs(GT_BITCAST));
GenTree* arg = *argSlot;
@@ -1294,12 +1311,15 @@ void Lowering::LowerArg(GenTreeCall* call, GenTreePtr* ppArg)
{
var_types intType = (type == TYP_DOUBLE) ? TYP_LONG : TYP_INT;
- GenTreePtr intArg = new (comp, GT_COPY) GenTreeCopyOrReload(GT_COPY, intType, arg);
-
- if (comp->opts.compUseSoftFP)
+ GenTreePtr intArg = comp->gtNewBitCastNode(intType, arg);
+ intArg->gtRegNum = info->regNum;
+#ifdef ARM_SOFTFP
+ if (intType == TYP_LONG)
{
- intArg->gtFlags |= GTF_VAR_DEATH;
+ assert(info->numRegs == 2);
+ intArg->AsMultiRegOp()->gtOtherReg = REG_NEXT(info->regNum);
}
+#endif // ARM_SOFTFP
info->node = intArg;
ReplaceArgWithPutArgOrCopy(ppArg, intArg);
@@ -2347,7 +2367,7 @@ void Lowering::LowerCompare(GenTree* cmp)
}
#endif
-#ifdef _TARGET_AMD64_
+#ifdef _TARGET_64BIT_
if (cmp->gtGetOp1()->TypeGet() != cmp->gtGetOp2()->TypeGet())
{
bool op1Is64Bit = (genTypeSize(cmp->gtGetOp1()->TypeGet()) == 8);
@@ -2368,7 +2388,11 @@ void Lowering::LowerCompare(GenTree* cmp)
GenTree* longOp = op1Is64Bit ? cmp->gtOp.gtOp1 : cmp->gtOp.gtOp2;
GenTree** smallerOpUse = op2Is64Bit ? &cmp->gtOp.gtOp1 : &cmp->gtOp.gtOp2;
- var_types smallerType = (*smallerOpUse)->TypeGet();
+#ifdef _TARGET_AMD64_
+ var_types smallerType = (*smallerOpUse)->TypeGet();
+#elif defined(_TARGET_ARM64_)
+ var_types smallerType = genActualType((*smallerOpUse)->TypeGet());
+#endif // _TARGET_AMD64_
assert(genTypeSize(smallerType) < 8);
@@ -2389,7 +2413,7 @@ void Lowering::LowerCompare(GenTree* cmp)
}
}
}
-#endif // _TARGET_AMD64_
+#endif // _TARGET_64BIT_
#if defined(_TARGET_XARCH_) || defined(_TARGET_ARM64_)
if (cmp->gtGetOp2()->IsIntegralConst())
@@ -2411,7 +2435,9 @@ void Lowering::LowerCompare(GenTree* cmp)
op2->gtType = op1Type;
}
- else if (op1->OperIs(GT_CAST) && !op1->gtOverflow())
+ else
+#endif
+ if (op1->OperIs(GT_CAST) && !op1->gtOverflow())
{
GenTreeCast* cast = op1->AsCast();
var_types castToType = cast->CastToType();
@@ -2429,12 +2455,26 @@ void Lowering::LowerCompare(GenTree* cmp)
// situations. In particular this include CALL, sometimes the JIT unnecessarilly widens
// the result of bool returning calls.
//
+ bool removeCast =
+#ifdef _TARGET_ARM64_
+ (op2Value == 0) && cmp->OperIs(GT_EQ, GT_NE, GT_GT) &&
+#endif
+ (castOp->OperIs(GT_CALL, GT_LCL_VAR) || castOp->OperIsLogical() || IsContainableMemoryOp(castOp));
- if (castOp->OperIs(GT_CALL, GT_LCL_VAR) || castOp->OperIsLogical() || IsContainableMemoryOp(castOp))
+ if (removeCast)
{
assert(!castOp->gtOverflowEx()); // Must not be an overflow checking operation
+#ifdef _TARGET_ARM64_
+ bool cmpEq = cmp->OperIs(GT_EQ);
+
+ cmp->SetOperRaw(cmpEq ? GT_TEST_EQ : GT_TEST_NE);
+ op2->SetIconValue(0xff);
+ op2->gtType = castOp->gtType;
+#else
castOp->gtType = castToType;
+ op2->gtType = castToType;
+#endif
// If we have any contained memory ops on castOp, they must now not be contained.
if (castOp->OperIsLogical())
{
@@ -2450,15 +2490,12 @@ void Lowering::LowerCompare(GenTree* cmp)
}
}
cmp->gtOp.gtOp1 = castOp;
- op2->gtType = castToType;
BlockRange().Remove(cast);
}
}
}
- else
-#endif
- if (op1->OperIs(GT_AND) && cmp->OperIs(GT_EQ, GT_NE))
+ else if (op1->OperIs(GT_AND) && cmp->OperIs(GT_EQ, GT_NE))
{
//
// Transform ((x AND y) EQ|NE 0) into (x TEST_EQ|TEST_NE y) when possible.
@@ -3785,7 +3822,12 @@ GenTree* Lowering::LowerVirtualStubCall(GenTreeCall* call)
// on x64 we must materialize the target using specific registers.
addr->gtRegNum = comp->virtualStubParamInfo->GetReg();
+// On ARM we must use a proper address in R12(thunk register) without dereferencing.
+// So for the jump we use the default register.
+// TODO: specifying register probably unnecessary for other platforms, too.
+#if !defined(_TARGET_UNIX_) && !defined(_TARGET_ARM_)
indir->gtRegNum = REG_JUMP_THUNK_PARAM;
+#endif
indir->gtFlags |= GTF_IND_REQ_ADDR_IN_REG;
#endif
result = indir;
@@ -4577,6 +4619,53 @@ GenTree* Lowering::LowerSignedDivOrMod(GenTreePtr node)
return next;
}
+//------------------------------------------------------------------------
+// LowerShift: Lower shift nodes
+//
+// Arguments:
+// shift - the shift node (GT_LSH, GT_RSH or GT_RSZ)
+//
+// Notes:
+// Remove unnecessary shift count masking, xarch shift instructions
+// mask the shift count to 5 bits (or 6 bits for 64 bit operations).
+
+void Lowering::LowerShift(GenTreeOp* shift)
+{
+ assert(shift->OperIs(GT_LSH, GT_RSH, GT_RSZ));
+
+ size_t mask = 0x1f;
+#ifdef _TARGET_64BIT_
+ if (varTypeIsLong(shift->TypeGet()))
+ {
+ mask = 0x3f;
+ }
+#else
+ assert(!varTypeIsLong(shift->TypeGet()));
+#endif
+
+ for (GenTree* andOp = shift->gtGetOp2(); andOp->OperIs(GT_AND); andOp = andOp->gtGetOp1())
+ {
+ GenTree* maskOp = andOp->gtGetOp2();
+
+ if (!maskOp->IsCnsIntOrI())
+ {
+ break;
+ }
+
+ if ((static_cast<size_t>(maskOp->AsIntCon()->IconValue()) & mask) != mask)
+ {
+ break;
+ }
+
+ shift->gtOp2 = andOp->gtGetOp1();
+ BlockRange().Remove(andOp);
+ BlockRange().Remove(maskOp);
+ // The parent was replaced, clear contain and regOpt flag.
+ shift->gtOp2->ClearContained();
+ }
+ ContainCheckShiftRotate(shift);
+}
+
void Lowering::WidenSIMD12IfNecessary(GenTreeLclVarCommon* node)
{
#ifdef FEATURE_SIMD
@@ -5266,6 +5355,7 @@ void Lowering::ContainCheckNode(GenTree* node)
case GT_TEST_EQ:
case GT_TEST_NE:
case GT_CMP:
+ case GT_JCMP:
ContainCheckCompare(node->AsOp());
break;
diff --git a/src/jit/lowerarmarch.cpp b/src/jit/lowerarmarch.cpp
index 64c7886a64..8986f2f23e 100644
--- a/src/jit/lowerarmarch.cpp
+++ b/src/jit/lowerarmarch.cpp
@@ -130,6 +130,10 @@ bool Lowering::IsContainableImmed(GenTree* parentNode, GenTree* childNode)
case GT_TEST_NE:
return emitter::emitIns_valid_imm_for_alu(immVal, size);
break;
+ case GT_JCMP:
+ assert(((parentNode->gtFlags & GTF_JCMP_TST) == 0) ? (immVal == 0) : isPow2(immVal));
+ return true;
+ break;
#elif defined(_TARGET_ARM_)
case GT_EQ:
case GT_NE:
@@ -351,18 +355,15 @@ void Lowering::LowerBlockStore(GenTreeBlk* blkNode)
}
else // CopyBlk
{
-#ifdef _TARGET_ARM64_
// In case of a CpBlk with a constant size and less than CPBLK_UNROLL_LIMIT size
// we should unroll the loop to improve CQ.
// For reference see the code in lowerxarch.cpp.
- // TODO-ARM-CQ: cpblk loop unrolling is currently not implemented.
if ((size != 0) && (size <= INITBLK_UNROLL_LIMIT))
{
blkNode->gtBlkOpKind = GenTreeBlk::BlkOpKindUnroll;
}
else
-#endif // _TARGET_ARM64_
{
// In case we have a constant integer this means we went beyond
// CPBLK_UNROLL_LIMIT bytes of size, still we should never have the case of
@@ -393,13 +394,7 @@ void Lowering::LowerBlockStore(GenTreeBlk* blkNode)
// None.
//
// Notes:
-// Casts from small int type to float/double are transformed as follows:
-// GT_CAST(byte, float/double) = GT_CAST(GT_CAST(byte, int32), float/double)
-// GT_CAST(sbyte, float/double) = GT_CAST(GT_CAST(sbyte, int32), float/double)
-// GT_CAST(int16, float/double) = GT_CAST(GT_CAST(int16, int32), float/double)
-// GT_CAST(uint16, float/double) = GT_CAST(GT_CAST(uint16, int32), float/double)
-//
-// Similarly casts from float/double to a smaller int type are transformed as follows:
+// Casts from float/double to a smaller int type are transformed as follows:
// GT_CAST(float/double, byte) = GT_CAST(GT_CAST(float/double, int32), byte)
// GT_CAST(float/double, sbyte) = GT_CAST(GT_CAST(float/double, int32), sbyte)
// GT_CAST(float/double, int16) = GT_CAST(GT_CAST(double/double, int32), int16)
@@ -419,7 +414,7 @@ void Lowering::LowerCast(GenTree* tree)
GenTreePtr op1 = tree->gtOp.gtOp1;
var_types dstType = tree->CastToType();
- var_types srcType = op1->TypeGet();
+ var_types srcType = genActualType(op1->TypeGet());
var_types tmpType = TYP_UNDEF;
if (varTypeIsFloating(srcType))
@@ -427,15 +422,10 @@ void Lowering::LowerCast(GenTree* tree)
noway_assert(!tree->gtOverflow());
}
- // Case of src is a small type and dst is a floating point type.
- if (varTypeIsSmall(srcType) && varTypeIsFloating(dstType))
- {
- // These conversions can never be overflow detecting ones.
- noway_assert(!tree->gtOverflow());
- tmpType = TYP_INT;
- }
+ assert(!varTypeIsSmall(srcType));
+
// case of src is a floating point type and dst is a small type.
- else if (varTypeIsFloating(srcType) && varTypeIsSmall(dstType))
+ if (varTypeIsFloating(srcType) && varTypeIsSmall(dstType))
{
NYI_ARM("Lowering for cast from float to small type"); // Not tested yet.
tmpType = TYP_INT;
@@ -506,22 +496,7 @@ void Lowering::LowerRotate(GenTreePtr tree)
//
void Lowering::ContainCheckCallOperands(GenTreeCall* call)
{
- GenTree* ctrlExpr = call->gtControlExpr;
- // If there is an explicit this pointer, we don't want that node to produce anything
- // as it is redundant
- if (call->gtCallObjp != nullptr)
- {
- GenTreePtr thisPtrNode = call->gtCallObjp;
-
- if (thisPtrNode->canBeContained())
- {
- MakeSrcContained(call, thisPtrNode);
- if (thisPtrNode->gtOper == GT_PUTARG_REG)
- {
- MakeSrcContained(call, thisPtrNode->gtOp.gtOp1);
- }
- }
- }
+ // There are no contained operands for arm.
}
//------------------------------------------------------------------------
@@ -719,7 +694,68 @@ void Lowering::ContainCheckCast(GenTreeCast* node)
//
void Lowering::ContainCheckCompare(GenTreeOp* cmp)
{
- ContainCheckBinary(cmp);
+ if (CheckImmedAndMakeContained(cmp, cmp->gtOp2))
+ {
+#ifdef _TARGET_ARM64_
+ GenTreePtr op1 = cmp->gtOp.gtOp1;
+ GenTreePtr op2 = cmp->gtOp.gtOp2;
+
+ // If op1 codegen can set flags op2 is an immediate 0
+ // we don't need to generate cmp instruction,
+ // provided we don't have another GenTree node between op1
+ // and cmp that could potentially modify flags.
+ //
+ // TODO-CQ: right now the below peep is inexpensive and
+ // gets the benefit in most of cases because in majority
+ // of cases op1, op2 and cmp would be in that order in
+ // execution. In general we should be able to check that all
+ // the nodes that come after op1 in execution order do not
+ // modify the flags so that it is safe to avoid generating a
+ // test instruction. Such a check requires that on each
+ // GenTree node we need to set the info whether its codegen
+ // will modify flags.
+ if (op2->IsIntegralConst(0) && (op1->gtNext == op2) && (op2->gtNext == cmp) &&
+ !cmp->OperIs(GT_TEST_EQ, GT_TEST_NE) && op1->OperIs(GT_ADD, GT_AND, GT_SUB))
+ {
+ assert(!op1->gtSetFlags());
+ op1->gtFlags |= GTF_SET_FLAGS;
+ cmp->gtFlags |= GTF_USE_FLAGS;
+ }
+
+ if (!varTypeIsFloating(cmp) && op2->IsCnsIntOrI() && ((cmp->gtFlags & GTF_USE_FLAGS) == 0))
+ {
+ LIR::Use cmpUse;
+ bool useJCMP = false;
+ uint64_t flags = 0;
+
+ if (cmp->OperIs(GT_EQ, GT_NE) && op2->IsIntegralConst(0) && BlockRange().TryGetUse(cmp, &cmpUse) &&
+ cmpUse.User()->OperIs(GT_JTRUE))
+ {
+ // Codegen will use cbz or cbnz in codegen which do not affect the flag register
+ flags = cmp->OperIs(GT_EQ) ? GTF_JCMP_EQ : 0;
+ useJCMP = true;
+ }
+ else if (cmp->OperIs(GT_TEST_EQ, GT_TEST_NE) && isPow2(op2->gtIntCon.IconValue()) &&
+ BlockRange().TryGetUse(cmp, &cmpUse) && cmpUse.User()->OperIs(GT_JTRUE))
+ {
+ // Codegen will use tbz or tbnz in codegen which do not affect the flag register
+ flags = GTF_JCMP_TST | (cmp->OperIs(GT_TEST_EQ) ? GTF_JCMP_EQ : 0);
+ useJCMP = true;
+ }
+
+ if (useJCMP)
+ {
+ cmp->gtLsraInfo.isNoRegCompare = true;
+ cmp->SetOper(GT_JCMP);
+
+ cmp->gtFlags &= ~(GTF_JCMP_TST | GTF_JCMP_EQ);
+ cmp->gtFlags |= flags;
+
+ BlockRange().Remove(cmpUse.User());
+ }
+ }
+#endif // _TARGET_ARM64_
+ }
}
//------------------------------------------------------------------------
diff --git a/src/jit/lowerxarch.cpp b/src/jit/lowerxarch.cpp
index 20a08750a6..bb45279887 100644
--- a/src/jit/lowerxarch.cpp
+++ b/src/jit/lowerxarch.cpp
@@ -36,53 +36,6 @@ void Lowering::LowerRotate(GenTree* tree)
}
//------------------------------------------------------------------------
-// LowerShift: Lower shift nodes
-//
-// Arguments:
-// shift - the shift node (GT_LSH, GT_RSH or GT_RSZ)
-//
-// Notes:
-// Remove unnecessary shift count masking, xarch shift instructions
-// mask the shift count to 5 bits (or 6 bits for 64 bit operations).
-
-void Lowering::LowerShift(GenTreeOp* shift)
-{
- assert(shift->OperIs(GT_LSH, GT_RSH, GT_RSZ));
-
- size_t mask = 0x1f;
-#ifdef _TARGET_AMD64_
- if (varTypeIsLong(shift->TypeGet()))
- {
- mask = 0x3f;
- }
-#else
- assert(!varTypeIsLong(shift->TypeGet()));
-#endif
-
- for (GenTree* andOp = shift->gtGetOp2(); andOp->OperIs(GT_AND); andOp = andOp->gtGetOp1())
- {
- GenTree* maskOp = andOp->gtGetOp2();
-
- if (!maskOp->IsCnsIntOrI())
- {
- break;
- }
-
- if ((static_cast<size_t>(maskOp->AsIntCon()->IconValue()) & mask) != mask)
- {
- break;
- }
-
- shift->gtOp2 = andOp->gtGetOp1();
- BlockRange().Remove(andOp);
- BlockRange().Remove(maskOp);
- // The parent was replaced, clear contain and regOpt flag.
- shift->gtOp2->ClearContained();
- }
- ContainCheckShiftRotate(shift);
-}
-
-//------------------------------------------------------------------------
// LowerStoreLoc: Lower a store of a lclVar
//
// Arguments:
@@ -1373,25 +1326,10 @@ void Lowering::ContainCheckCallOperands(GenTreeCall* call)
#endif // _TARGET_X86_
if (ctrlExpr->isIndir())
{
- MakeSrcContained(call, ctrlExpr);
// We may have cases where we have set a register target on the ctrlExpr, but if it
// contained we must clear it.
ctrlExpr->gtRegNum = REG_NA;
- }
- }
- }
- // If there is an explicit this pointer, we don't want that node to produce anything
- // as it is redundant
- if (call->gtCallObjp != nullptr)
- {
- GenTreePtr thisPtrNode = call->gtCallObjp;
-
- if (thisPtrNode->canBeContained())
- {
- MakeSrcContained(call, thisPtrNode);
- if (thisPtrNode->gtOper == GT_PUTARG_REG)
- {
- MakeSrcContained(call, thisPtrNode->gtOp.gtOp1);
+ MakeSrcContained(call, ctrlExpr);
}
}
}
@@ -1921,9 +1859,6 @@ void Lowering::ContainCheckCompare(GenTreeOp* cmp)
}
else if (op1->IsCnsIntOrI())
{
- // TODO-CQ: We should be able to support swapping op1 and op2 to generate cmp reg, imm,
- // but there is currently an assert in CodeGen::genCompareInt().
- // https://github.com/dotnet/coreclr/issues/7270
SetRegOptional(op2);
}
else
diff --git a/src/jit/lsra.cpp b/src/jit/lsra.cpp
index 47e6d327e3..db6e699134 100644
--- a/src/jit/lsra.cpp
+++ b/src/jit/lsra.cpp
@@ -134,18 +134,12 @@ void lsraAssignRegToTree(GenTreePtr tree, regNumber reg, unsigned regIdx)
tree->gtRegNum = reg;
}
#if defined(_TARGET_ARM_)
- else if (tree->OperGet() == GT_MUL_LONG || tree->OperGet() == GT_PUTARG_REG)
+ else if (tree->OperGet() == GT_MUL_LONG || tree->OperGet() == GT_PUTARG_REG || tree->OperGet() == GT_BITCAST)
{
assert(regIdx == 1);
GenTreeMultiRegOp* mul = tree->AsMultiRegOp();
mul->gtOtherReg = reg;
}
- else if (tree->OperGet() == GT_COPY)
- {
- assert(regIdx == 1);
- GenTreeCopyOrReload* copy = tree->AsCopyOrReload();
- copy->gtOtherRegs[0] = (regNumberSmall)reg;
- }
else if (tree->OperGet() == GT_PUTARG_SPLIT)
{
GenTreePutArgSplit* putArg = tree->AsPutArgSplit();
@@ -182,14 +176,23 @@ unsigned LinearScan::getWeight(RefPosition* refPos)
GenTreeLclVarCommon* lclCommon = treeNode->AsLclVarCommon();
LclVarDsc* varDsc = &(compiler->lvaTable[lclCommon->gtLclNum]);
weight = varDsc->lvRefCntWtd;
+ if (refPos->getInterval()->isSpilled)
+ {
+ // Decrease the weight if the interval has already been spilled.
+ weight -= BB_UNITY_WEIGHT;
+ }
}
else
{
// Non-candidate local ref or non-lcl tree node.
// These are considered to have two references in the basic block:
- // a def and a use and hence weighted ref count is 2 times
+ // a def and a use and hence weighted ref count would be 2 times
// the basic block weight in which they appear.
- weight = 2 * this->blockInfo[refPos->bbNum].weight;
+ // However, it is generally more harmful to spill tree temps, so we
+ // double that.
+ const unsigned TREE_TEMP_REF_COUNT = 2;
+ const unsigned TREE_TEMP_BOOST_FACTOR = 2;
+ weight = TREE_TEMP_REF_COUNT * TREE_TEMP_BOOST_FACTOR * blockInfo[refPos->bbNum].weight;
}
}
else
@@ -198,7 +201,7 @@ unsigned LinearScan::getWeight(RefPosition* refPos)
// reference in the basic block and hence their weighted
// refcount is equal to the block weight in which they
// appear.
- weight = this->blockInfo[refPos->bbNum].weight;
+ weight = blockInfo[refPos->bbNum].weight;
}
return weight;
@@ -1366,6 +1369,9 @@ void LinearScan::setBlockSequence()
verifiedAllBBs = false;
hasCriticalEdges = false;
BasicBlock* nextBlock;
+ // We use a bbNum of 0 for entry RefPositions.
+ // The other information in blockInfo[0] will never be used.
+ blockInfo[0].weight = BB_UNITY_WEIGHT;
for (BasicBlock* block = compiler->fgFirstBB; block != nullptr; block = nextBlock)
{
blockSequence[bbSeqCount] = block;
@@ -1375,11 +1381,12 @@ void LinearScan::setBlockSequence()
// Initialize the blockInfo.
// predBBNum will be set later. 0 is never used as a bbNum.
+ assert(block->bbNum != 0);
blockInfo[block->bbNum].predBBNum = 0;
// We check for critical edges below, but initialize to false.
blockInfo[block->bbNum].hasCriticalInEdge = false;
blockInfo[block->bbNum].hasCriticalOutEdge = false;
- blockInfo[block->bbNum].weight = block->bbWeight;
+ blockInfo[block->bbNum].weight = block->getBBWeight(compiler);
#if TRACK_LSRA_STATS
blockInfo[block->bbNum].spillCount = 0;
@@ -3066,7 +3073,7 @@ bool LinearScan::buildKillPositionsForNode(GenTree* tree, LsraLocation currentLo
}
}
- if (tree->IsCall() && (tree->gtFlags & GTF_CALL_UNMANAGED) != 0)
+ if (killGCRefs(tree))
{
RefPosition* pos = newRefPosition((Interval*)nullptr, currentLoc, RefTypeKillGCRefs, tree,
(allRegs(TYP_REF) & ~RBM_ARG_REGS));
@@ -3077,6 +3084,35 @@ bool LinearScan::buildKillPositionsForNode(GenTree* tree, LsraLocation currentLo
return false;
}
+//------------------------------------------------------------------------
+// killGCRefs:
+// Given some tree node return does it need all GC refs to be spilled from
+// callee save registers.
+//
+// Arguments:
+// tree - the tree for which we ask about gc refs.
+//
+// Return Value:
+// true - tree kills GC refs on callee save registers
+// false - tree doesn't affect GC refs on callee save registers
+bool LinearScan::killGCRefs(GenTree* tree)
+{
+ if (tree->IsCall())
+ {
+ if ((tree->gtFlags & GTF_CALL_UNMANAGED) != 0)
+ {
+ return true;
+ }
+
+ if (tree->AsCall()->gtCallMethHnd == compiler->eeFindHelper(CORINFO_HELP_JIT_PINVOKE_BEGIN))
+ {
+ assert(compiler->opts.ShouldUsePInvokeHelpers());
+ return true;
+ }
+ }
+ return false;
+}
+
//----------------------------------------------------------------------------
// defineNewInternalTemp: Defines a ref position for an internal temp.
//
@@ -3547,7 +3583,7 @@ static int ComputeOperandDstCount(GenTree* operand)
// If an operand has no destination registers but does have source registers, it must be a store
// or a compare.
assert(operand->OperIsStore() || operand->OperIsBlkOp() || operand->OperIsPutArgStk() ||
- operand->OperIsCompare() || operand->OperIs(GT_CMP) || operand->IsSIMDEqualityOrInequality());
+ operand->OperIsCompare() || operand->OperIs(GT_CMP, GT_JCMP) || operand->IsSIMDEqualityOrInequality());
return 0;
}
else if (!operand->OperIsFieldListHead() && (operand->OperIsStore() || operand->TypeGet() == TYP_VOID))
@@ -4026,7 +4062,7 @@ void LinearScan::buildRefPositionsForNode(GenTree* tree,
// for Use position of v02 also needs to take into account
// of kill set of its consuming node.
unsigned minRegCountForUsePos = minRegCount;
- if (delayRegFree)
+ if (delayRegFree && (lsraStressMask != 0))
{
regMaskTP killMask = getKillSetForNode(tree);
if (killMask != RBM_NONE)
@@ -4038,7 +4074,8 @@ void LinearScan::buildRefPositionsForNode(GenTree* tree,
regMaskTP candidates = getUseCandidates(useNode);
#ifdef _TARGET_ARM_
- if (useNode->OperIsPutArgSplit() || (compiler->opts.compUseSoftFP && useNode->OperIsPutArgReg()))
+ if (useNode->OperIsPutArgSplit() ||
+ (compiler->opts.compUseSoftFP && (useNode->OperIsPutArgReg() || useNode->OperGet() == GT_BITCAST)))
{
// get i-th candidate, set bits in useCandidates must be in sequential order.
candidates = genFindLowestReg(candidates & ~currCandidates);
@@ -4116,9 +4153,6 @@ void LinearScan::buildRefPositionsForNode(GenTree* tree,
// push defs
LocationInfoList locationInfoList;
LsraLocation defLocation = currentLoc + 1;
-#ifdef ARM_SOFTFP
- regMaskTP remainingUseCandidates = useCandidates;
-#endif
for (int i = 0; i < produce; i++)
{
regMaskTP currCandidates = candidates;
@@ -4142,10 +4176,10 @@ void LinearScan::buildRefPositionsForNode(GenTree* tree,
}
#ifdef ARM_SOFTFP
// If oper is GT_PUTARG_REG, set bits in useCandidates must be in sequential order.
- else if (tree->OperIsMultiRegOp() || tree->OperGet() == GT_COPY)
+ else if (tree->OperIsMultiRegOp() || tree->OperGet() == GT_BITCAST)
{
- useCandidates = genFindLowestReg(remainingUseCandidates);
- remainingUseCandidates &= ~useCandidates;
+ currCandidates = genFindLowestReg(candidates);
+ candidates &= ~currCandidates;
}
#endif // ARM_SOFTFP
#endif // _TARGET_ARM_
@@ -4591,8 +4625,9 @@ void LinearScan::buildIntervals()
}
curBBNum = blockSequence[bbSeqCount - 1]->bbNum;
- // Next, create ParamDef RefPositions for all the tracked parameters,
- // in order of their varIndex
+ // Next, create ParamDef RefPositions for all the tracked parameters, in order of their varIndex.
+ // Assign these RefPositions to the (nonexistent) BB0.
+ curBBNum = 0;
LclVarDsc* argDsc;
unsigned int lclNum;
@@ -5913,9 +5948,24 @@ bool LinearScan::checkActiveInterval(Interval* interval, LsraLocation refLocatio
else
{
RefPosition* nextAssignedRef = recentAssignedRef->nextRefPosition;
+#ifdef _TARGET_ARM_
+ // This function is invoked only from allocateBusyReg() through checkActiveIntervals().
+ //
+ // For ARM32, when we try to allocate a double register which consists of two float registers,
+ // tryAllocateFreeReg() may fail to allocate a double register even if one of two float
+ // reigsters is assigned to a inactive constant interval.
+ // https://github.com/dotnet/coreclr/pull/14080
+ //
+ // Therefore an inactive constant interval may be encountered here.
+ assert(nextAssignedRef != nullptr || interval->isConstant);
+ if (nextAssignedRef != nullptr)
+ assert(nextAssignedRef->nodeLocation == refLocation ||
+ (nextAssignedRef->nodeLocation + 1 == refLocation && nextAssignedRef->delayRegFree));
+#else // !_TARGET_ARM_
assert(nextAssignedRef != nullptr);
assert(nextAssignedRef->nodeLocation == refLocation ||
(nextAssignedRef->nodeLocation + 1 == refLocation && nextAssignedRef->delayRegFree));
+#endif // !_TARGET_ARM_
}
}
return false;
@@ -10057,6 +10107,28 @@ void LinearScan::handleOutgoingCriticalEdges(BasicBlock* block)
switchRegs |= genRegMask(op2->gtRegNum);
}
+#ifdef _TARGET_ARM64_
+ // Next, if this blocks ends with a JCMP, we have to make sure not to copy
+ // into the register that it uses or modify the local variable it must consume
+ LclVarDsc* jcmpLocalVarDsc = nullptr;
+ if (block->bbJumpKind == BBJ_COND)
+ {
+ GenTree* lastNode = LIR::AsRange(block).LastNode();
+
+ if (lastNode->OperIs(GT_JCMP))
+ {
+ GenTree* op1 = lastNode->gtGetOp1();
+ switchRegs |= genRegMask(op1->gtRegNum);
+
+ if (op1->IsLocal())
+ {
+ GenTreeLclVarCommon* lcl = op1->AsLclVarCommon();
+ jcmpLocalVarDsc = &compiler->lvaTable[lcl->gtLclNum];
+ }
+ }
+ }
+#endif
+
VarToRegMap sameVarToRegMap = sharedCriticalVarToRegMap;
regMaskTP sameWriteRegs = RBM_NONE;
regMaskTP diffReadRegs = RBM_NONE;
@@ -10130,6 +10202,13 @@ void LinearScan::handleOutgoingCriticalEdges(BasicBlock* block)
sameToReg = REG_NA;
}
+#ifdef _TARGET_ARM64_
+ if (jcmpLocalVarDsc && (jcmpLocalVarDsc->lvVarIndex == outResolutionSetVarIndex))
+ {
+ sameToReg = REG_NA;
+ }
+#endif
+
// If the var is live only at those blocks connected by a split edge and not live-in at some of the
// target blocks, we will resolve it the same way as if it were in diffResolutionSet and resolution
// will be deferred to the handling of split edges, which means copy will only be at those target(s).
diff --git a/src/jit/lsra.h b/src/jit/lsra.h
index 767dff16a8..d149b3207a 100644
--- a/src/jit/lsra.h
+++ b/src/jit/lsra.h
@@ -69,8 +69,8 @@ struct LsraBlockInfo
{
// bbNum of the predecessor to use for the register location of live-in variables.
// 0 for fgFirstBB.
- BasicBlock::weight_t weight;
unsigned int predBBNum;
+ BasicBlock::weight_t weight;
bool hasCriticalInEdge;
bool hasCriticalOutEdge;
@@ -777,6 +777,8 @@ private:
// Given some tree node add refpositions for all the registers this node kills
bool buildKillPositionsForNode(GenTree* tree, LsraLocation currentLoc);
+ bool killGCRefs(GenTree* tree);
+
regMaskTP allRegs(RegisterType rt);
regMaskTP allRegs(GenTree* tree);
regMaskTP allMultiRegCallNodeRegs(GenTreeCall* tree);
diff --git a/src/jit/lsraarm.cpp b/src/jit/lsraarm.cpp
index 09246b6e93..f35a23a72b 100644
--- a/src/jit/lsraarm.cpp
+++ b/src/jit/lsraarm.cpp
@@ -279,17 +279,6 @@ void LinearScan::TreeNodeInfoInit(GenTree* tree)
{
castOpType = genUnsignedType(castOpType);
}
-#ifdef DEBUG
- if (!tree->gtOverflow() && (varTypeIsFloating(castToType) || varTypeIsFloating(castOpType)))
- {
- // If converting to float/double, the operand must be 4 or 8 byte in size.
- if (varTypeIsFloating(castToType))
- {
- unsigned opSize = genTypeSize(castOpType);
- assert(opSize == 4 || opSize == 8);
- }
- }
-#endif // DEBUG
if (varTypeIsLong(castOpType))
{
@@ -452,19 +441,11 @@ void LinearScan::TreeNodeInfoInit(GenTree* tree)
break;
case GT_LONG:
- if (tree->IsUnusedValue())
- {
- // An unused GT_LONG node needs to consume its sources.
- info->srcCount = 2;
- info->dstCount = 0;
- }
- else
- {
- // Passthrough. Should have been marked contained.
- info->srcCount = 0;
- assert(info->dstCount == 0);
- }
+ assert(tree->IsUnusedValue()); // Contained nodes are already processed, only unused GT_LONG can reach here.
+ // An unused GT_LONG node needs to consume its sources.
+ info->srcCount = 2;
+ info->dstCount = 0;
break;
case GT_CNS_DBL:
@@ -663,6 +644,7 @@ void LinearScan::TreeNodeInfoInit(GenTree* tree)
if (compiler->codeGen->gcInfo.gcIsWriteBarrierAsgNode(tree))
{
+ info->srcCount = 2;
TreeNodeInfoInitGCWriteBarrier(tree);
break;
}
@@ -708,18 +690,7 @@ void LinearScan::TreeNodeInfoInit(GenTree* tree)
case GT_COPY:
info->srcCount = 1;
-#ifdef ARM_SOFTFP
- // This case currently only occurs for double types that are passed as TYP_LONG;
- // actual long types would have been decomposed by now.
- if (tree->TypeGet() == TYP_LONG)
- {
- info->dstCount = 2;
- }
- else
-#endif
- {
- assert(info->dstCount == 1);
- }
+ assert(info->dstCount == 1);
break;
case GT_PUTARG_SPLIT:
@@ -734,6 +705,28 @@ void LinearScan::TreeNodeInfoInit(GenTree* tree)
TreeNodeInfoInitPutArgReg(tree->AsUnOp());
break;
+ case GT_BITCAST:
+ {
+ info->srcCount = 1;
+ assert(info->dstCount == 1);
+ regNumber argReg = tree->gtRegNum;
+ regMaskTP argMask = genRegMask(argReg);
+#ifdef ARM_SOFTFP
+ // If type of node is `long` then it is actually `double`.
+ // The actual `long` types must have been transformed as a field list with two fields.
+ if (tree->TypeGet() == TYP_LONG)
+ {
+ info->dstCount++;
+ assert(genRegArgNext(argReg) == REG_NEXT(argReg));
+ argMask |= genRegMask(REG_NEXT(argReg));
+ }
+#endif // ARM_SOFTFP
+ info->setDstCandidates(this, argMask);
+ info->setSrcCandidates(this, argMask);
+ tree->AsUnOp()->gtOp1->gtLsraInfo.isTgtPref = true;
+ }
+ break;
+
default:
#ifdef DEBUG
char message[256];
diff --git a/src/jit/lsraarm64.cpp b/src/jit/lsraarm64.cpp
index cea80e2093..83f6d64983 100644
--- a/src/jit/lsraarm64.cpp
+++ b/src/jit/lsraarm64.cpp
@@ -260,9 +260,9 @@ void LinearScan::TreeNodeInfoInit(GenTree* tree)
case GT_INTRINSIC:
{
- // TODO-ARM64-NYI
- // Right now only Abs/Round/Sqrt are treated as math intrinsics
noway_assert((tree->gtIntrinsic.gtIntrinsicId == CORINFO_INTRINSIC_Abs) ||
+ (tree->gtIntrinsic.gtIntrinsicId == CORINFO_INTRINSIC_Ceiling) ||
+ (tree->gtIntrinsic.gtIntrinsicId == CORINFO_INTRINSIC_Floor) ||
(tree->gtIntrinsic.gtIntrinsicId == CORINFO_INTRINSIC_Round) ||
(tree->gtIntrinsic.gtIntrinsicId == CORINFO_INTRINSIC_Sqrt));
@@ -302,17 +302,7 @@ void LinearScan::TreeNodeInfoInit(GenTree* tree)
{
castOpType = genUnsignedType(castOpType);
}
-#ifdef DEBUG
- if (!tree->gtOverflow() && (varTypeIsFloating(castToType) || varTypeIsFloating(castOpType)))
- {
- // If converting to float/double, the operand must be 4 or 8 byte in size.
- if (varTypeIsFloating(castToType))
- {
- unsigned opSize = genTypeSize(castOpType);
- assert(opSize == 4 || opSize == 8);
- }
- }
-#endif // DEBUG
+
// Some overflow checks need a temp reg
Lowering::CastInfo castInfo;
@@ -364,6 +354,7 @@ void LinearScan::TreeNodeInfoInit(GenTree* tree)
case GT_GT:
case GT_TEST_EQ:
case GT_TEST_NE:
+ case GT_JCMP:
TreeNodeInfoInitCmp(tree);
break;
diff --git a/src/jit/lsraarmarch.cpp b/src/jit/lsraarmarch.cpp
index ac722e27bf..53e223dab6 100644
--- a/src/jit/lsraarmarch.cpp
+++ b/src/jit/lsraarmarch.cpp
@@ -400,13 +400,15 @@ void LinearScan::TreeNodeInfoInitCall(GenTreeCall* call)
// computed into a register.
if (call->IsFastTailCall())
{
- NYI_ARM("tail call");
-
#ifdef _TARGET_ARM64_
// Fast tail call - make sure that call target is always computed in IP0
// so that epilog sequence can generate "br xip0" to achieve fast tail call.
ctrlExpr->gtLsraInfo.setSrcCandidates(this, genRegMask(REG_IP0));
-#endif // _TARGET_ARM64_
+#else // !_TARGET_ARM64_
+ // Fast tail call - make sure that call target is always computed in r12
+ // so that epilog sequence can generate "br r12" to achieve fast tail call.
+ ctrlExpr->gtLsraInfo.setSrcCandidates(this, RBM_R12);
+#endif // !_TARGET_ARM64_
}
}
#ifdef _TARGET_ARM_
@@ -890,24 +892,20 @@ void LinearScan::TreeNodeInfoInitBlockStore(GenTreeBlk* blkNode)
if (blkNode->gtBlkOpKind == GenTreeBlk::BlkOpKindUnroll)
{
- // TODO-ARM-CQ: cpblk loop unrolling is currently not implemented.
// In case of a CpBlk with a constant size and less than CPBLK_UNROLL_LIMIT size
// we should unroll the loop to improve CQ.
// For reference see the code in lsraxarch.cpp.
- NYI_ARM("cpblk loop unrolling is currently not implemented.");
-
-#ifdef _TARGET_ARM64_
internalIntCount = 1;
internalIntCandidates = RBM_ALLINT;
+#ifdef _TARGET_ARM64_
if (size >= 2 * REGSIZE_BYTES)
{
// We will use ldp/stp to reduce code size and improve performance
// so we need to reserve an extra internal register
internalIntCount++;
}
-
#endif // _TARGET_ARM64_
}
else
diff --git a/src/jit/lsraxarch.cpp b/src/jit/lsraxarch.cpp
index 280e2f36f0..8ac8e235b5 100644
--- a/src/jit/lsraxarch.cpp
+++ b/src/jit/lsraxarch.cpp
@@ -193,18 +193,11 @@ void LinearScan::TreeNodeInfoInit(GenTree* tree)
#if !defined(_TARGET_64BIT_)
case GT_LONG:
- if (tree->IsUnusedValue())
- {
- // An unused GT_LONG node needs to consume its sources.
- info->srcCount = 2;
- info->dstCount = 0;
- }
- else
- {
- // Passthrough. Should have been marked contained.
- info->srcCount = 0;
- assert(info->dstCount == 0);
- }
+ assert(tree->IsUnusedValue()); // Contained nodes are already processed, only unused GT_LONG can reach here.
+
+ // An unused GT_LONG node needs to consume its sources.
+ info->srcCount = 2;
+ info->dstCount = 0;
break;
#endif // !defined(_TARGET_64BIT_)
@@ -2671,20 +2664,6 @@ void LinearScan::TreeNodeInfoInitCmp(GenTreePtr tree)
info->srcCount += GetOperandSourceCount(op1);
}
info->srcCount += GetOperandSourceCount(op2);
-
-#if !defined(_TARGET_64BIT_)
- // Long compares will consume GT_LONG nodes, each of which produces two results.
- // Thus for each long operand there will be an additional source.
- // TODO-X86-CQ: Mark hiOp2 and loOp2 as contained if it is a constant or a memory op.
- if (varTypeIsLong(op1Type))
- {
- info->srcCount++;
- }
- if (varTypeIsLong(op2Type))
- {
- info->srcCount++;
- }
-#endif // !defined(_TARGET_64BIT_)
}
//------------------------------------------------------------------------
diff --git a/src/jit/morph.cpp b/src/jit/morph.cpp
index 822510833b..1d04913242 100644
--- a/src/jit/morph.cpp
+++ b/src/jit/morph.cpp
@@ -502,6 +502,9 @@ OPTIMIZECAST:
/* Reset the call flag */
tree->gtFlags &= ~GTF_CALL;
+ /* Reset the assignment flag */
+ tree->gtFlags &= ~GTF_ASG;
+
/* unless we have an overflow cast, reset the except flag */
if (!tree->gtOverflow())
{
@@ -2459,6 +2462,8 @@ void fgArgInfo::EvalArgsToTemps()
noway_assert(parent->OperIsList());
noway_assert(parent->gtOp.gtOp1 == argx);
+ parent->gtFlags |= (setupArg->gtFlags & GTF_ALL_EFFECT);
+
parent->gtOp.gtOp1 = setupArg;
}
else
@@ -2482,9 +2487,13 @@ void fgArgInfo::EvalArgsToTemps()
noway_assert(tmpRegArgNext->OperIsList());
noway_assert(tmpRegArgNext->Current());
tmpRegArgNext->gtOp.gtOp2 = compiler->gtNewArgList(defArg);
- tmpRegArgNext = tmpRegArgNext->Rest();
+
+ tmpRegArgNext->gtFlags |= (defArg->gtFlags & GTF_ALL_EFFECT);
+ tmpRegArgNext = tmpRegArgNext->Rest();
}
+ tmpRegArgNext->gtFlags |= (defArg->gtFlags & GTF_ALL_EFFECT);
+
curArgTabEntry->node = defArg;
curArgTabEntry->lateArgInx = regArgInx++;
}
@@ -7244,8 +7253,8 @@ bool Compiler::fgCanFastTailCall(GenTreeCall* callee)
// Note that callee being a vararg method is not a problem since we can account the params being passed.
unsigned nCallerArgs = info.compArgsCount;
- size_t callerArgRegCount = info.compArgRegCount;
- size_t callerFloatArgRegCount = info.compFloatArgRegCount;
+ size_t callerArgRegCount = codeGen->intRegState.rsCalleeRegArgCount;
+ size_t callerFloatArgRegCount = codeGen->floatRegState.rsCalleeRegArgCount;
// Count the callee args including implicit and hidden.
// Note that GenericContext and VarargCookie are added by importer while
@@ -8856,7 +8865,7 @@ NO_TAIL_CALL:
// Check for a new-style jit intrinsic.
const NamedIntrinsic ni = lookupNamedIntrinsic(call->gtCallMethHnd);
- if (ni == NI_Enum_HasFlag)
+ if (ni == NI_System_Enum_HasFlag)
{
GenTree* thisOp = call->gtCallObjp;
GenTree* flagOp = call->gtCallArgs->gtOp.gtOp1;
@@ -14276,6 +14285,13 @@ GenTreePtr Compiler::fgMorphSmpOp(GenTreePtr tree, MorphAddrContext* mac)
/* Both tree and op1 are GT_COMMA nodes */
/* Change the tree's op1 to the throw node: op1->gtOp.gtOp1 */
tree->gtOp.gtOp1 = throwNode;
+
+ // Possibly reset the assignment flag
+ if (((throwNode->gtFlags & GTF_ASG) == 0) && ((op2 == nullptr) || ((op2->gtFlags & GTF_ASG) == 0)))
+ {
+ tree->gtFlags &= ~GTF_ASG;
+ }
+
return tree;
}
else if (oper != GT_NOP)
diff --git a/src/jit/namedintrinsiclist.h b/src/jit/namedintrinsiclist.h
index cf81afc119..fa75cc27b6 100644
--- a/src/jit/namedintrinsiclist.h
+++ b/src/jit/namedintrinsiclist.h
@@ -9,8 +9,11 @@
enum NamedIntrinsic
{
- NI_Illegal = 0,
- NI_Enum_HasFlag = 1
+ NI_Illegal = 0,
+ NI_System_Enum_HasFlag = 1,
+ NI_MathF_Round = 2,
+ NI_Math_Round = 3,
+ NI_System_Collections_Generic_EqualityComparer_get_Default = 4
};
#endif // _NAMEDINTRINSICLIST_H_
diff --git a/src/jit/rationalize.cpp b/src/jit/rationalize.cpp
index 257e02d491..a5ae268207 100644
--- a/src/jit/rationalize.cpp
+++ b/src/jit/rationalize.cpp
@@ -922,8 +922,8 @@ Compiler::fgWalkResult Rationalizer::RewriteNode(GenTree** useEdge, ArrayStack<G
#endif // FEATURE_SIMD
default:
- // CMP, SETCC and JCC nodes should not be present in HIR.
- assert(!node->OperIs(GT_CMP, GT_SETCC, GT_JCC));
+ // JCMP, CMP, SETCC and JCC nodes should not be present in HIR.
+ assert(!node->OperIs(GT_CMP, GT_SETCC, GT_JCC, GT_JCMP));
break;
}
diff --git a/src/jit/register_arg_convention.h b/src/jit/register_arg_convention.h
index 5073732a3e..758c764ea3 100644
--- a/src/jit/register_arg_convention.h
+++ b/src/jit/register_arg_convention.h
@@ -26,6 +26,11 @@ struct InitVarDscInfo
bool anyFloatStackArgs;
#endif // _TARGET_ARM_
+#if FEATURE_FASTTAILCALL
+ // It is used to calculate argument stack size information in byte
+ unsigned stackArgSize;
+#endif // FEATURE_FASTTAILCALL
+
public:
// set to initial values
void Init(LclVarDsc* lvaTable, bool _hasRetBufArg)
@@ -42,6 +47,10 @@ public:
fltArgSkippedRegMask = RBM_NONE;
anyFloatStackArgs = false;
#endif // _TARGET_ARM_
+
+#if FEATURE_FASTTAILCALL
+ stackArgSize = 0;
+#endif // FEATURE_FASTTAILCALL
}
// return ref to current register arg for this type
diff --git a/src/jit/simd.cpp b/src/jit/simd.cpp
index bd711dd04d..329a1d281f 100644
--- a/src/jit/simd.cpp
+++ b/src/jit/simd.cpp
@@ -691,7 +691,8 @@ GenTreePtr Compiler::impSIMDPopStack(var_types type, bool expectAddr)
}
else if (tree->gtType == TYP_BYREF)
{
- assert(tree->IsLocal() || (tree->gtOper == GT_ADDR) && varTypeIsSIMD(tree->gtGetOp1()));
+ assert(tree->IsLocal() || (tree->OperGet() == GT_RET_EXPR) ||
+ (tree->gtOper == GT_ADDR) && varTypeIsSIMD(tree->gtGetOp1()));
}
return tree;
diff --git a/src/jit/simdcodegenxarch.cpp b/src/jit/simdcodegenxarch.cpp
index ef50aaecc0..b7c9b29088 100644
--- a/src/jit/simdcodegenxarch.cpp
+++ b/src/jit/simdcodegenxarch.cpp
@@ -680,7 +680,7 @@ void CodeGen::genSIMDScalarMove(
if (srcReg != targetReg)
{
instruction ins = ins_Store(baseType);
- if (getEmitter()->IsThreeOperandMoveAVXInstruction(ins))
+ if (getEmitter()->IsDstSrcSrcAVXInstruction(ins))
{
// In general, when we use a three-operands move instruction, we want to merge the src with
// itself. This is an exception in that we actually want the "merge" behavior, so we must
@@ -709,7 +709,7 @@ void CodeGen::genSIMDScalarMove(
if (srcReg != targetReg)
{
instruction ins = ins_Copy(baseType);
- assert(!getEmitter()->IsThreeOperandMoveAVXInstruction(ins));
+ assert(!getEmitter()->IsDstSrcSrcAVXInstruction(ins));
inst_RV_RV(ins, targetReg, srcReg, baseType, emitTypeSize(baseType));
}
break;
diff --git a/src/jit/target.h b/src/jit/target.h
index 68b27f22f9..fd28796bd2 100644
--- a/src/jit/target.h
+++ b/src/jit/target.h
@@ -1183,6 +1183,10 @@ typedef unsigned short regPairNoSmall; // arm: need 12 bits
#define ROUND_FLOAT 0 // Do not round intermed float expression results
#define CPU_HAS_BYTE_REGS 0
#define CPU_USES_BLOCK_MOVE 0
+
+ #define CPBLK_UNROLL_LIMIT 32 // Upper bound to let the code generator to loop unroll CpBlk.
+ #define INITBLK_UNROLL_LIMIT 32 // Upper bound to let the code generator to loop unroll InitBlk.
+
#define FEATURE_WRITE_BARRIER 1 // Generate the proper WriteBarrier calls for GC
#define FEATURE_FIXED_OUT_ARGS 1 // Preallocate the outgoing arg area in the prolog
#define FEATURE_STRUCTPROMOTE 1 // JIT Optimization to promote fields of structs into registers
@@ -1529,7 +1533,7 @@ typedef unsigned short regPairNoSmall; // arm: need 12 bits
#define FEATURE_MULTIREG_STRUCT_PROMOTE 1 // True when we want to promote fields of a multireg struct into registers
#define FEATURE_FASTTAILCALL 1 // Tail calls made as epilog+jmp
#define FEATURE_TAILCALL_OPT 1 // opportunistic Tail calls (i.e. without ".tail" prefix) made as fast tail calls.
- #define FEATURE_SET_FLAGS 1 // Set to true to force the JIT to mark the trees with GTF_SET_FLAGS when the flags need to be set
+ #define FEATURE_SET_FLAGS 0 // Set to true to force the JIT to mark the trees with GTF_SET_FLAGS when the flags need to be set
#define FEATURE_MULTIREG_ARGS_OR_RET 1 // Support for passing and/or returning single values in more than one register
#define FEATURE_MULTIREG_ARGS 1 // Support for passing a single argument in more than one register
#define FEATURE_MULTIREG_RET 1 // Support for returning a single value in more than one register
@@ -1804,6 +1808,9 @@ typedef unsigned short regPairNoSmall; // arm: need 12 bits
#define JCC_DIST_SMALL_MAX_NEG (-1048576)
#define JCC_DIST_SMALL_MAX_POS (+1048575)
+ #define TB_DIST_SMALL_MAX_NEG (-32768)
+ #define TB_DIST_SMALL_MAX_POS (+32767)
+
#define JCC_SIZE_SMALL (4)
#define JCC_SIZE_LARGE (8)
diff --git a/src/jit/utils.cpp b/src/jit/utils.cpp
index ffc9a753bf..85aec5464c 100644
--- a/src/jit/utils.cpp
+++ b/src/jit/utils.cpp
@@ -1769,13 +1769,16 @@ unsigned __int64 FloatingPointUtils::convertDoubleToUInt64(double d)
// Rounds a double-precision floating-point value to the nearest integer,
// and rounds midpoint values to the nearest even number.
-// Note this should align with classlib in floatdouble.cpp
-// Specializing for x86 using a x87 instruction is optional since
-// this outcome is identical across targets.
double FloatingPointUtils::round(double x)
{
+ // ************************************************************************************
+ // IMPORTANT: Do not change this implementation without also updating Math.Round(double),
+ // MathF.Round(float), and FloatingPointUtils::round(float)
+ // ************************************************************************************
+
// If the number has no fractional part do nothing
// This shortcut is necessary to workaround precision loss in borderline cases on some platforms
+
if (x == (double)((INT64)x))
{
return x;
@@ -1784,10 +1787,9 @@ double FloatingPointUtils::round(double x)
// We had a number that was equally close to 2 integers.
// We need to return the even one.
- double tempVal = (x + 0.5);
- double flrTempVal = floor(tempVal);
+ double flrTempVal = floor(x + 0.5);
- if ((flrTempVal == tempVal) && (fmod(tempVal, 2.0) != 0))
+ if ((x == (floor(x) + 0.5)) && (fmod(flrTempVal, 2.0) != 0))
{
flrTempVal -= 1.0;
}
@@ -1809,13 +1811,16 @@ double FloatingPointUtils::round(double x)
// Rounds a single-precision floating-point value to the nearest integer,
// and rounds midpoint values to the nearest even number.
-// Note this should align with classlib in floatsingle.cpp
-// Specializing for x86 using a x87 instruction is optional since
-// this outcome is identical across targets.
float FloatingPointUtils::round(float x)
{
+ // ************************************************************************************
+ // IMPORTANT: Do not change this implementation without also updating MathF.Round(float),
+ // Math.Round(double), and FloatingPointUtils::round(double)
+ // ************************************************************************************
+
// If the number has no fractional part do nothing
// This shortcut is necessary to workaround precision loss in borderline cases on some platforms
+
if (x == (float)((INT32)x))
{
return x;
@@ -1824,10 +1829,9 @@ float FloatingPointUtils::round(float x)
// We had a number that was equally close to 2 integers.
// We need to return the even one.
- float tempVal = (x + 0.5f);
- float flrTempVal = floorf(tempVal);
+ float flrTempVal = floorf(x + 0.5f);
- if ((flrTempVal == tempVal) && (fmodf(tempVal, 2.0f) != 0))
+ if ((x == (floorf(x) + 0.5f)) && (fmodf(flrTempVal, 2.0f) != 0))
{
flrTempVal -= 1.0f;
}
diff --git a/src/jit/valuenum.cpp b/src/jit/valuenum.cpp
index e4990d635a..473f0cec8e 100644
--- a/src/jit/valuenum.cpp
+++ b/src/jit/valuenum.cpp
@@ -3514,6 +3514,12 @@ ValueNum ValueNumStore::EvalMathFuncUnary(var_types typ, CorInfoIntrinsics gtMat
case CORINFO_INTRINSIC_Abs:
res = fabs(arg0Val);
break;
+ case CORINFO_INTRINSIC_Ceiling:
+ res = ceil(arg0Val);
+ break;
+ case CORINFO_INTRINSIC_Floor:
+ res = floor(arg0Val);
+ break;
case CORINFO_INTRINSIC_Round:
res = FloatingPointUtils::round(arg0Val);
break;
@@ -3544,6 +3550,12 @@ ValueNum ValueNumStore::EvalMathFuncUnary(var_types typ, CorInfoIntrinsics gtMat
case CORINFO_INTRINSIC_Abs:
res = fabsf(arg0Val);
break;
+ case CORINFO_INTRINSIC_Ceiling:
+ res = ceilf(arg0Val);
+ break;
+ case CORINFO_INTRINSIC_Floor:
+ res = floorf(arg0Val);
+ break;
case CORINFO_INTRINSIC_Round:
res = FloatingPointUtils::round(arg0Val);
break;
diff --git a/src/mscorlib/System.Private.CoreLib.csproj b/src/mscorlib/System.Private.CoreLib.csproj
index f7206f98f5..77758fbcea 100644
--- a/src/mscorlib/System.Private.CoreLib.csproj
+++ b/src/mscorlib/System.Private.CoreLib.csproj
@@ -266,12 +266,14 @@
<Compile Include="$(BclSourcesRoot)\System\Runtime\Intrinsics\Vector256.cs" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="$(BclSourcesRoot)\System\Runtime\Intrinsics\X86\Enums.cs" />
+ </ItemGroup>
+ <ItemGroup Condition="'$(Platform)' == 'amd64' OR '$(Platform)' == 'x86'">
<Compile Include="$(BclSourcesRoot)\System\Runtime\Intrinsics\X86\Aes.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\Intrinsics\X86\Avx.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\Intrinsics\X86\Avx2.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\Intrinsics\X86\Bmi1.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\Intrinsics\X86\Bmi2.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Runtime\Intrinsics\X86\Enums.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\Intrinsics\X86\Fma.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\Intrinsics\X86\Lzcnt.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\Intrinsics\X86\Pclmulqdq.cs" />
@@ -283,6 +285,23 @@
<Compile Include="$(BclSourcesRoot)\System\Runtime\Intrinsics\X86\Sse42.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\Intrinsics\X86\Ssse3.cs" />
</ItemGroup>
+ <ItemGroup Condition="'$(Platform)' != 'amd64' AND '$(Platform)' != 'x86'">
+ <Compile Include="$(BclSourcesRoot)\System\Runtime\Intrinsics\X86\Aes.PlatformNotSupported.cs" />
+ <Compile Include="$(BclSourcesRoot)\System\Runtime\Intrinsics\X86\Avx.PlatformNotSupported.cs" />
+ <Compile Include="$(BclSourcesRoot)\System\Runtime\Intrinsics\X86\Avx2.PlatformNotSupported.cs" />
+ <Compile Include="$(BclSourcesRoot)\System\Runtime\Intrinsics\X86\Bmi1.PlatformNotSupported.cs" />
+ <Compile Include="$(BclSourcesRoot)\System\Runtime\Intrinsics\X86\Bmi2.PlatformNotSupported.cs" />
+ <Compile Include="$(BclSourcesRoot)\System\Runtime\Intrinsics\X86\Fma.PlatformNotSupported.cs" />
+ <Compile Include="$(BclSourcesRoot)\System\Runtime\Intrinsics\X86\Lzcnt.PlatformNotSupported.cs" />
+ <Compile Include="$(BclSourcesRoot)\System\Runtime\Intrinsics\X86\Pclmulqdq.PlatformNotSupported.cs" />
+ <Compile Include="$(BclSourcesRoot)\System\Runtime\Intrinsics\X86\Popcnt.PlatformNotSupported.cs" />
+ <Compile Include="$(BclSourcesRoot)\System\Runtime\Intrinsics\X86\Sse.PlatformNotSupported.cs" />
+ <Compile Include="$(BclSourcesRoot)\System\Runtime\Intrinsics\X86\Sse2.PlatformNotSupported.cs" />
+ <Compile Include="$(BclSourcesRoot)\System\Runtime\Intrinsics\X86\Sse3.PlatformNotSupported.cs" />
+ <Compile Include="$(BclSourcesRoot)\System\Runtime\Intrinsics\X86\Sse41.PlatformNotSupported.cs" />
+ <Compile Include="$(BclSourcesRoot)\System\Runtime\Intrinsics\X86\Sse42.PlatformNotSupported.cs" />
+ <Compile Include="$(BclSourcesRoot)\System\Runtime\Intrinsics\X86\Ssse3.PlatformNotSupported.cs" />
+ </ItemGroup>
<ItemGroup>
<Compile Include="$(BclSourcesRoot)\System\AppContext\AppContext.cs" />
<Compile Include="$(BclSourcesRoot)\System\AppContext\AppContextSwitches.cs" />
@@ -329,14 +348,12 @@
<Compile Include="$(BclSourcesRoot)\System\InsufficientMemoryException.cs" />
<Compile Include="$(BclSourcesRoot)\System\IntPtr.cs" />
<Compile Include="$(BclSourcesRoot)\System\Internal.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Math.cs" />
- <Compile Include="$(BclSourcesRoot)\System\MathF.cs" />
+ <Compile Include="$(BclSourcesRoot)\System\Math.CoreCLR.cs" />
+ <Compile Include="$(BclSourcesRoot)\System\MathF.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\mda.cs" />
<Compile Include="$(BclSourcesRoot)\System\MissingFieldException.cs" />
<Compile Include="$(BclSourcesRoot)\System\MissingMemberException.cs" />
<Compile Include="$(BclSourcesRoot)\System\Number.cs" />
- <Compile Include="$(BclSourcesRoot)\System\ParseNumbers.cs" />
- <Compile Include="$(BclSourcesRoot)\System\ResId.cs" />
<Compile Include="$(BclSourcesRoot)\System\RtType.cs" />
<Compile Include="$(BclSourcesRoot)\System\RuntimeArgumentHandle.cs" />
<Compile Include="$(BclSourcesRoot)\System\RuntimeHandles.cs" />
@@ -582,8 +599,6 @@
<Compile Include="$(BclSourcesRoot)\System\Collections\Generic\ComparerHelpers.cs" />
<Compile Include="$(BclSourcesRoot)\System\Collections\Generic\Dictionary.cs" />
<Compile Include="$(BclSourcesRoot)\System\Collections\Generic\EqualityComparer.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Collections\Generic\DebugView.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Collections\Generic\List.cs" />
<Compile Include="$(BclSourcesRoot)\System\Collections\Generic\ArraySortHelper.cs" />
<Compile Include="$(BclSourcesRoot)\System\Collections\ObjectModel\ReadOnlyDictionary.cs" />
<Compile Include="$(BclSourcesRoot)\System\Collections\Concurrent\ConcurrentStack.cs" />
diff --git a/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems b/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems
index a13543ea93..0831e58af5 100644
--- a/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems
+++ b/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems
@@ -54,8 +54,10 @@
<Compile Include="$(MSBuildThisFileDirectory)System\CLSCompliantAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Collections\DictionaryEntry.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Collections\Generic\ICollection.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\Collections\Generic\ICollectionDebugView.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Collections\Generic\IComparer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Collections\Generic\IDictionary.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\Collections\Generic\IDictionaryDebugView.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Collections\Generic\IEnumerable.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Collections\Generic\IEnumerator.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Collections\Generic\IEqualityComparer.cs" />
@@ -65,6 +67,7 @@
<Compile Include="$(MSBuildThisFileDirectory)System\Collections\Generic\IReadOnlyList.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Collections\Generic\KeyNotFoundException.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Collections\Generic\KeyValuePair.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\Collections\Generic\List.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Collections\ICollection.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Collections\IComparer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Collections\IDictionary.cs" />
@@ -195,9 +198,12 @@
<Compile Include="$(MSBuildThisFileDirectory)System\Int32.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Int64.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Lazy.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\Math.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\MathF.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\MarshalByRefObject.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\MemberAccessException.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Memory.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\MemoryDebugView.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\MethodAccessException.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\MidpointRounding.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\MissingMethodException.cs" />
@@ -213,6 +219,7 @@
<Compile Include="$(MSBuildThisFileDirectory)System\OverflowException.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\ParamArrayAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\ParamsArray.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\ParseNumbers.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\PlatformNotSupportedException.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Progress.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Random.cs" />
diff --git a/src/mscorlib/shared/System/Boolean.cs b/src/mscorlib/shared/System/Boolean.cs
index a6ffb6de83..70edd94e3b 100644
--- a/src/mscorlib/shared/System/Boolean.cs
+++ b/src/mscorlib/shared/System/Boolean.cs
@@ -12,7 +12,6 @@
**
===========================================================*/
-using System.Diagnostics.Contracts;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
diff --git a/src/mscorlib/shared/System/Buffers/MemoryHandle.cs b/src/mscorlib/shared/System/Buffers/MemoryHandle.cs
index fcdc7fe17f..bcbb527b50 100644
--- a/src/mscorlib/shared/System/Buffers/MemoryHandle.cs
+++ b/src/mscorlib/shared/System/Buffers/MemoryHandle.cs
@@ -21,6 +21,18 @@ namespace System.Buffers
_handle = handle;
}
+ internal void AddOffset(int offset)
+ {
+ if (_pointer == null)
+ {
+ ThrowHelper.ThrowArgumentNullException(ExceptionArgument.pointer);
+ }
+ else
+ {
+ _pointer = (void*)((byte*)_pointer + offset);
+ }
+ }
+
[CLSCompliant(false)]
public void* PinnedPointer => _pointer;
diff --git a/src/mscorlib/shared/System/Buffers/OwnedMemory.cs b/src/mscorlib/shared/System/Buffers/OwnedMemory.cs
index e3a89f7ef4..f75a29aa80 100644
--- a/src/mscorlib/shared/System/Buffers/OwnedMemory.cs
+++ b/src/mscorlib/shared/System/Buffers/OwnedMemory.cs
@@ -11,9 +11,9 @@ namespace System.Buffers
{
public abstract int Length { get; }
- public abstract Span<T> AsSpan();
+ public abstract Span<T> Span { get; }
- public Memory<T> AsMemory
+ public Memory<T> Memory
{
get
{
diff --git a/src/mscorlib/shared/System/Byte.cs b/src/mscorlib/shared/System/Byte.cs
index a0f8ff8c29..e087bd4a43 100644
--- a/src/mscorlib/shared/System/Byte.cs
+++ b/src/mscorlib/shared/System/Byte.cs
@@ -185,28 +185,24 @@ namespace System
[Pure]
public override String ToString()
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatInt32(m_value, null, NumberFormatInfo.CurrentInfo);
}
[Pure]
public String ToString(String format)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatInt32(m_value, format, NumberFormatInfo.CurrentInfo);
}
[Pure]
public String ToString(IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatInt32(m_value, null, NumberFormatInfo.GetInstance(provider));
}
[Pure]
public String ToString(String format, IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatInt32(m_value, format, NumberFormatInfo.GetInstance(provider));
}
diff --git a/src/mscorlib/shared/System/Char.cs b/src/mscorlib/shared/System/Char.cs
index bce2714067..1152369869 100644
--- a/src/mscorlib/shared/System/Char.cs
+++ b/src/mscorlib/shared/System/Char.cs
@@ -154,14 +154,12 @@ namespace System
[Pure]
public override String ToString()
{
- Contract.Ensures(Contract.Result<String>() != null);
return Char.ToString(m_value);
}
[Pure]
public String ToString(IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Char.ToString(m_value);
}
@@ -182,7 +180,6 @@ namespace System
{
throw new ArgumentNullException(nameof(s));
}
- Contract.EndContractBlock();
if (s.Length != 1)
{
@@ -405,7 +402,6 @@ namespace System
{
if (culture == null)
throw new ArgumentNullException(nameof(culture));
- Contract.EndContractBlock();
return culture.TextInfo.ToUpper(c);
}
@@ -438,7 +434,6 @@ namespace System
{
if (culture == null)
throw new ArgumentNullException(nameof(culture));
- Contract.EndContractBlock();
return culture.TextInfo.ToLower(c);
}
@@ -562,7 +557,6 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(index));
}
- Contract.EndContractBlock();
char c = s[index];
if (IsLatin1(c))
{
@@ -580,7 +574,6 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(index));
}
- Contract.EndContractBlock();
char c = s[index];
if (IsLatin1(c))
{
@@ -597,7 +590,6 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(index));
}
- Contract.EndContractBlock();
char c = s[index];
if (IsLatin1(c))
{
@@ -619,7 +611,6 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(index));
}
- Contract.EndContractBlock();
char c = s[index];
if (IsLatin1(c))
{
@@ -636,7 +627,6 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(index));
}
- Contract.EndContractBlock();
char c = s[index];
if (IsLatin1(c))
{
@@ -687,7 +677,6 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(index));
}
- Contract.EndContractBlock();
char c = s[index];
if (IsLatin1(c))
{
@@ -716,7 +705,6 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(index));
}
- Contract.EndContractBlock();
char c = s[index];
if (IsLatin1(c))
{
@@ -766,7 +754,6 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(index));
}
- Contract.EndContractBlock();
char c = s[index];
if (IsLatin1(c))
{
@@ -792,7 +779,6 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(index));
}
- Contract.EndContractBlock();
return (IsSurrogate(s[index]));
}
@@ -830,7 +816,6 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(index));
}
- Contract.EndContractBlock();
char c = s[index];
if (IsLatin1(c))
{
@@ -848,7 +833,6 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(index));
}
- Contract.EndContractBlock();
char c = s[index];
if (IsLatin1(c))
{
@@ -870,7 +854,6 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(index));
}
- Contract.EndContractBlock();
if (IsLatin1(s[index]))
{
@@ -897,7 +880,6 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(index));
}
- Contract.EndContractBlock();
if (IsLatin1(s[index]))
{
return (GetLatin1UnicodeCategory(s[index]));
@@ -918,7 +900,6 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(index));
}
- Contract.EndContractBlock();
return CharUnicodeInfo.GetNumericValue(s, index);
}
@@ -943,7 +924,6 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(index));
}
- Contract.EndContractBlock();
return (IsHighSurrogate(s[index]));
}
@@ -967,7 +947,6 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(index));
}
- Contract.EndContractBlock();
return (IsLowSurrogate(s[index]));
}
@@ -985,7 +964,6 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(index));
}
- Contract.EndContractBlock();
if (index + 1 < s.Length)
{
return (IsSurrogatePair(s[index], s[index + 1]));
@@ -1024,7 +1002,6 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(utf32), SR.ArgumentOutOfRange_InvalidUTF32);
}
- Contract.EndContractBlock();
if (utf32 < UNICODE_PLANE01_START)
{
@@ -1059,7 +1036,6 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(lowSurrogate), SR.ArgumentOutOfRange_InvalidLowSurrogate);
}
- Contract.EndContractBlock();
return (((highSurrogate - CharUnicodeInfo.HIGH_SURROGATE_START) * 0x400) + (lowSurrogate - CharUnicodeInfo.LOW_SURROGATE_START) + UNICODE_PLANE01_START);
}
@@ -1082,7 +1058,6 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index);
}
- Contract.EndContractBlock();
// Check if the character at index is a high surrogate.
int temp1 = (int)s[index] - CharUnicodeInfo.HIGH_SURROGATE_START;
if (temp1 >= 0 && temp1 <= 0x7ff)
diff --git a/src/mscorlib/shared/System/Collections/Generic/ICollection.cs b/src/mscorlib/shared/System/Collections/Generic/ICollection.cs
index 52852aa1fb..78ee5cb1f5 100644
--- a/src/mscorlib/shared/System/Collections/Generic/ICollection.cs
+++ b/src/mscorlib/shared/System/Collections/Generic/ICollection.cs
@@ -4,7 +4,6 @@
using System;
using System.Runtime.CompilerServices;
-using System.Diagnostics.Contracts;
namespace System.Collections.Generic
{
diff --git a/src/mscorlib/shared/System/Collections/Generic/ICollectionDebugView.cs b/src/mscorlib/shared/System/Collections/Generic/ICollectionDebugView.cs
new file mode 100644
index 0000000000..9916e857e2
--- /dev/null
+++ b/src/mscorlib/shared/System/Collections/Generic/ICollectionDebugView.cs
@@ -0,0 +1,34 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Diagnostics;
+
+namespace System.Collections.Generic
+{
+ internal sealed class ICollectionDebugView<T>
+ {
+ private readonly ICollection<T> _collection;
+
+ public ICollectionDebugView(ICollection<T> collection)
+ {
+ if (collection == null)
+ {
+ throw new ArgumentNullException(nameof(collection));
+ }
+
+ _collection = collection;
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
+ public T[] Items
+ {
+ get
+ {
+ T[] items = new T[_collection.Count];
+ _collection.CopyTo(items, 0);
+ return items;
+ }
+ }
+ }
+}
diff --git a/src/mscorlib/shared/System/Collections/Generic/IDictionary.cs b/src/mscorlib/shared/System/Collections/Generic/IDictionary.cs
index a73a2f55bd..05677da3b2 100644
--- a/src/mscorlib/shared/System/Collections/Generic/IDictionary.cs
+++ b/src/mscorlib/shared/System/Collections/Generic/IDictionary.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System;
-using System.Diagnostics.Contracts;
namespace System.Collections.Generic
{
diff --git a/src/mscorlib/shared/System/Collections/Generic/IDictionaryDebugView.cs b/src/mscorlib/shared/System/Collections/Generic/IDictionaryDebugView.cs
new file mode 100644
index 0000000000..4721642fee
--- /dev/null
+++ b/src/mscorlib/shared/System/Collections/Generic/IDictionaryDebugView.cs
@@ -0,0 +1,80 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Diagnostics;
+
+namespace System.Collections.Generic
+{
+ internal sealed class IDictionaryDebugView<K, V>
+ {
+ private readonly IDictionary<K, V> _dict;
+
+ public IDictionaryDebugView(IDictionary<K, V> dictionary)
+ {
+ if (dictionary == null)
+ throw new ArgumentNullException(nameof(dictionary));
+
+ _dict = dictionary;
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
+ public KeyValuePair<K, V>[] Items
+ {
+ get
+ {
+ KeyValuePair<K, V>[] items = new KeyValuePair<K, V>[_dict.Count];
+ _dict.CopyTo(items, 0);
+ return items;
+ }
+ }
+ }
+
+ internal sealed class DictionaryKeyCollectionDebugView<TKey, TValue>
+ {
+ private readonly ICollection<TKey> _collection;
+
+ public DictionaryKeyCollectionDebugView(ICollection<TKey> collection)
+ {
+ if (collection == null)
+ throw new ArgumentNullException(nameof(collection));
+
+ _collection = collection;
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
+ public TKey[] Items
+ {
+ get
+ {
+ TKey[] items = new TKey[_collection.Count];
+ _collection.CopyTo(items, 0);
+ return items;
+ }
+ }
+ }
+
+ internal sealed class DictionaryValueCollectionDebugView<TKey, TValue>
+ {
+ private readonly ICollection<TValue> _collection;
+
+ public DictionaryValueCollectionDebugView(ICollection<TValue> collection)
+ {
+ if (collection == null)
+ throw new ArgumentNullException(nameof(collection));
+
+ _collection = collection;
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
+ public TValue[] Items
+ {
+ get
+ {
+ TValue[] items = new TValue[_collection.Count];
+ _collection.CopyTo(items, 0);
+ return items;
+ }
+ }
+ }
+}
diff --git a/src/mscorlib/shared/System/Collections/Generic/IEnumerable.cs b/src/mscorlib/shared/System/Collections/Generic/IEnumerable.cs
index 84264d5cf0..ddb798e8a6 100644
--- a/src/mscorlib/shared/System/Collections/Generic/IEnumerable.cs
+++ b/src/mscorlib/shared/System/Collections/Generic/IEnumerable.cs
@@ -6,7 +6,6 @@ using System;
using System.Collections;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
-using System.Diagnostics.Contracts;
namespace System.Collections.Generic
{
diff --git a/src/mscorlib/shared/System/Collections/Generic/IList.cs b/src/mscorlib/shared/System/Collections/Generic/IList.cs
index 43d6659da9..2abc7b9142 100644
--- a/src/mscorlib/shared/System/Collections/Generic/IList.cs
+++ b/src/mscorlib/shared/System/Collections/Generic/IList.cs
@@ -5,7 +5,6 @@
using System;
using System.Collections;
using System.Runtime.CompilerServices;
-using System.Diagnostics.Contracts;
namespace System.Collections.Generic
{
diff --git a/src/mscorlib/shared/System/Collections/Generic/IReadOnlyCollection.cs b/src/mscorlib/shared/System/Collections/Generic/IReadOnlyCollection.cs
index 09ee89f035..9eea39de22 100644
--- a/src/mscorlib/shared/System/Collections/Generic/IReadOnlyCollection.cs
+++ b/src/mscorlib/shared/System/Collections/Generic/IReadOnlyCollection.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System;
-using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
namespace System.Collections.Generic
diff --git a/src/mscorlib/shared/System/Collections/Generic/IReadOnlyDictionary.cs b/src/mscorlib/shared/System/Collections/Generic/IReadOnlyDictionary.cs
index 169e2958bb..300b996611 100644
--- a/src/mscorlib/shared/System/Collections/Generic/IReadOnlyDictionary.cs
+++ b/src/mscorlib/shared/System/Collections/Generic/IReadOnlyDictionary.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System;
-using System.Diagnostics.Contracts;
namespace System.Collections.Generic
{
diff --git a/src/mscorlib/shared/System/Collections/Generic/IReadOnlyList.cs b/src/mscorlib/shared/System/Collections/Generic/IReadOnlyList.cs
index 00b5be65ff..7193805b06 100644
--- a/src/mscorlib/shared/System/Collections/Generic/IReadOnlyList.cs
+++ b/src/mscorlib/shared/System/Collections/Generic/IReadOnlyList.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System;
-using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
namespace System.Collections.Generic
diff --git a/src/mscorlib/src/System/Collections/Generic/List.cs b/src/mscorlib/shared/System/Collections/Generic/List.cs
index 2031ddc6ed..56bbea895e 100644
--- a/src/mscorlib/src/System/Collections/Generic/List.cs
+++ b/src/mscorlib/shared/System/Collections/Generic/List.cs
@@ -2,21 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-/*============================================================
-**
-**
-**
-**
-** Purpose: Implements a generic, dynamically sized list as an
-** array.
-**
-**
-===========================================================*/
-
-using System;
-using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Collections.ObjectModel;
+using System.Diagnostics;
using System.Runtime.CompilerServices;
namespace System.Collections.Generic
@@ -27,30 +14,29 @@ namespace System.Collections.Generic
// of the List is automatically increased as required by reallocating the
// internal array.
//
- [DebuggerTypeProxy(typeof(Mscorlib_CollectionDebugView<>))]
+ [DebuggerTypeProxy(typeof(ICollectionDebugView<>))]
[DebuggerDisplay("Count = {Count}")]
[Serializable]
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
public class List<T> : IList<T>, System.Collections.IList, IReadOnlyList<T>
{
- private const int _defaultCapacity = 4;
+ private const int DefaultCapacity = 4;
private T[] _items; // Do not rename (binary serialization)
- [ContractPublicPropertyName("Count")]
private int _size; // Do not rename (binary serialization)
private int _version; // Do not rename (binary serialization)
[NonSerialized]
- private Object _syncRoot;
+ private object _syncRoot;
- private static readonly T[] _emptyArray = new T[0];
+ private static readonly T[] s_emptyArray = new T[0];
// Constructs a List. The list is initially empty and has a capacity
// of zero. Upon adding the first element to the list the capacity is
- // increased to _defaultCapacity, and then increased in multiples of two
+ // increased to DefaultCapacity, and then increased in multiples of two
// as required.
public List()
{
- _items = _emptyArray;
+ _items = s_emptyArray;
}
// Constructs a List with a given initial capacity. The list is
@@ -59,11 +45,11 @@ namespace System.Collections.Generic
//
public List(int capacity)
{
- if (capacity < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.capacity, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
+ if (capacity < 0)
+ ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.capacity, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
if (capacity == 0)
- _items = _emptyArray;
+ _items = s_emptyArray;
else
_items = new T[capacity];
}
@@ -76,7 +62,6 @@ namespace System.Collections.Generic
{
if (collection == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection);
- Contract.EndContractBlock();
ICollection<T> c = collection as ICollection<T>;
if (c != null)
@@ -84,7 +69,7 @@ namespace System.Collections.Generic
int count = c.Count;
if (count == 0)
{
- _items = _emptyArray;
+ _items = s_emptyArray;
}
else
{
@@ -96,7 +81,7 @@ namespace System.Collections.Generic
else
{
_size = 0;
- _items = _emptyArray;
+ _items = s_emptyArray;
AddEnumerable(collection);
}
}
@@ -109,7 +94,6 @@ namespace System.Collections.Generic
{
get
{
- Contract.Ensures(Contract.Result<int>() >= 0);
return _items.Length;
}
set
@@ -118,7 +102,6 @@ namespace System.Collections.Generic
{
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.value, ExceptionResource.ArgumentOutOfRange_SmallCapacity);
}
- Contract.EndContractBlock();
if (value != _items.Length)
{
@@ -133,7 +116,7 @@ namespace System.Collections.Generic
}
else
{
- _items = _emptyArray;
+ _items = s_emptyArray;
}
}
}
@@ -144,7 +127,6 @@ namespace System.Collections.Generic
{
get
{
- Contract.Ensures(Contract.Result<int>() >= 0);
return _size;
}
}
@@ -154,7 +136,6 @@ namespace System.Collections.Generic
get { return false; }
}
-
// Is this List read-only?
bool ICollection<T>.IsReadOnly
{
@@ -173,19 +154,19 @@ namespace System.Collections.Generic
}
// Synchronization root for this object.
- Object System.Collections.ICollection.SyncRoot
+ object System.Collections.ICollection.SyncRoot
{
get
{
if (_syncRoot == null)
{
- System.Threading.Interlocked.CompareExchange<Object>(ref _syncRoot, new Object(), null);
+ System.Threading.Interlocked.CompareExchange<object>(ref _syncRoot, new object(), null);
}
return _syncRoot;
}
}
+
// Sets or Gets the element at the given index.
- //
public T this[int index]
{
get
@@ -195,7 +176,6 @@ namespace System.Collections.Generic
{
ThrowHelper.ThrowArgumentOutOfRange_IndexException();
}
- Contract.EndContractBlock();
return _items[index];
}
@@ -205,7 +185,6 @@ namespace System.Collections.Generic
{
ThrowHelper.ThrowArgumentOutOfRange_IndexException();
}
- Contract.EndContractBlock();
_items[index] = value;
_version++;
}
@@ -218,7 +197,7 @@ namespace System.Collections.Generic
return ((value is T) || (value == null && default(T) == null));
}
- Object System.Collections.IList.this[int index]
+ object System.Collections.IList.this[int index]
{
get
{
@@ -242,6 +221,7 @@ namespace System.Collections.Generic
// Adds the given object to the end of this list. The size of the list is
// increased by one. If required, the capacity of the list is doubled
// before adding the new element.
+ //
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Add(T item)
{
@@ -285,21 +265,17 @@ namespace System.Collections.Generic
return Count - 1;
}
-
// Adds the elements of the given collection to the end of this list. If
// required, the capacity of the list is increased to twice the previous
// capacity or the new size, whichever is larger.
//
public void AddRange(IEnumerable<T> collection)
{
- Contract.Ensures(Count >= Contract.OldValue(Count));
-
InsertRange(_size, collection);
}
public ReadOnlyCollection<T> AsReadOnly()
{
- Contract.Ensures(Contract.Result<ReadOnlyCollection<T>>() != null);
return new ReadOnlyCollection<T>(this);
}
@@ -331,21 +307,17 @@ namespace System.Collections.Generic
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
if (_size - index < count)
ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen);
- Contract.Ensures(Contract.Result<int>() <= index + count);
- Contract.EndContractBlock();
return Array.BinarySearch<T>(_items, index, count, item, comparer);
}
public int BinarySearch(T item)
{
- Contract.Ensures(Contract.Result<int>() <= Count);
return BinarySearch(0, Count, item, null);
}
public int BinarySearch(T item, IComparer<T> comparer)
{
- Contract.Ensures(Contract.Result<int>() <= Count);
return BinarySearch(0, Count, item, comparer);
}
@@ -374,7 +346,7 @@ namespace System.Collections.Generic
// Contains returns true if the specified element is in the List.
// It does a linear, O(n) search. Equality is determined by calling
// EqualityComparer<T>.Default.Equals().
-
+ //
public bool Contains(T item)
{
// PERF: IndexOf calls Array.IndexOf, which internally
@@ -388,7 +360,7 @@ namespace System.Collections.Generic
return _size != 0 && IndexOf(item) != -1;
}
- bool System.Collections.IList.Contains(Object item)
+ bool System.Collections.IList.Contains(object item)
{
if (IsCompatibleObject(item))
{
@@ -404,8 +376,6 @@ namespace System.Collections.Generic
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.converter);
}
- Contract.EndContractBlock();
-
List<TOutput> list = new List<TOutput>(_size);
for (int i = 0; i < _size; i++)
{
@@ -417,7 +387,6 @@ namespace System.Collections.Generic
// Copies this List into array, which must be of a
// compatible array type.
- //
public void CopyTo(T[] array)
{
CopyTo(array, 0);
@@ -425,14 +394,12 @@ namespace System.Collections.Generic
// Copies this List into array, which must be of a
// compatible array type.
- //
void System.Collections.ICollection.CopyTo(Array array, int arrayIndex)
{
if ((array != null) && (array.Rank != 1))
{
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankMultiDimNotSupported);
}
- Contract.EndContractBlock();
try
{
@@ -455,7 +422,6 @@ namespace System.Collections.Generic
{
ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen);
}
- Contract.EndContractBlock();
// Delegate rest of error checking to Array.Copy.
Array.Copy(_items, index, array, arrayIndex, count);
@@ -471,11 +437,12 @@ namespace System.Collections.Generic
// value. If the current capacity of the list is less than min, the
// capacity is increased to twice the current capacity or to min,
// whichever is larger.
+ //
private void EnsureCapacity(int min)
{
if (_items.Length < min)
{
- int newCapacity = _items.Length == 0 ? _defaultCapacity : _items.Length * 2;
+ int newCapacity = _items.Length == 0 ? DefaultCapacity : _items.Length * 2;
// Allow the list to grow to maximum possible capacity (~2G elements) before encountering overflow.
// Note that this check works even when _items.Length overflowed thanks to the (uint) cast
if ((uint)newCapacity > Array.MaxArrayLength) newCapacity = Array.MaxArrayLength;
@@ -495,7 +462,6 @@ namespace System.Collections.Generic
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match);
}
- Contract.EndContractBlock();
for (int i = 0; i < _size; i++)
{
@@ -513,7 +479,6 @@ namespace System.Collections.Generic
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match);
}
- Contract.EndContractBlock();
List<T> list = new List<T>();
for (int i = 0; i < _size; i++)
@@ -528,15 +493,11 @@ namespace System.Collections.Generic
public int FindIndex(Predicate<T> match)
{
- Contract.Ensures(Contract.Result<int>() >= -1);
- Contract.Ensures(Contract.Result<int>() < Count);
return FindIndex(0, _size, match);
}
public int FindIndex(int startIndex, Predicate<T> match)
{
- Contract.Ensures(Contract.Result<int>() >= -1);
- Contract.Ensures(Contract.Result<int>() < startIndex + Count);
return FindIndex(startIndex, _size - startIndex, match);
}
@@ -556,9 +517,6 @@ namespace System.Collections.Generic
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match);
}
- Contract.Ensures(Contract.Result<int>() >= -1);
- Contract.Ensures(Contract.Result<int>() < startIndex + count);
- Contract.EndContractBlock();
int endIndex = startIndex + count;
for (int i = startIndex; i < endIndex; i++)
@@ -574,7 +532,6 @@ namespace System.Collections.Generic
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match);
}
- Contract.EndContractBlock();
for (int i = _size - 1; i >= 0; i--)
{
@@ -588,15 +545,11 @@ namespace System.Collections.Generic
public int FindLastIndex(Predicate<T> match)
{
- Contract.Ensures(Contract.Result<int>() >= -1);
- Contract.Ensures(Contract.Result<int>() < Count);
return FindLastIndex(_size - 1, _size, match);
}
public int FindLastIndex(int startIndex, Predicate<T> match)
{
- Contract.Ensures(Contract.Result<int>() >= -1);
- Contract.Ensures(Contract.Result<int>() <= startIndex);
return FindLastIndex(startIndex, startIndex + 1, match);
}
@@ -606,9 +559,6 @@ namespace System.Collections.Generic
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match);
}
- Contract.Ensures(Contract.Result<int>() >= -1);
- Contract.Ensures(Contract.Result<int>() <= startIndex);
- Contract.EndContractBlock();
if (_size == 0)
{
@@ -620,7 +570,7 @@ namespace System.Collections.Generic
}
else
{
- // Make sure we're not out of range
+ // Make sure we're not out of range
if ((uint)startIndex >= (uint)_size)
{
ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index();
@@ -650,7 +600,6 @@ namespace System.Collections.Generic
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.action);
}
- Contract.EndContractBlock();
int version = _version;
@@ -703,8 +652,6 @@ namespace System.Collections.Generic
{
ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen);
}
- Contract.Ensures(Contract.Result<List<T>>() != null);
- Contract.EndContractBlock();
List<T> list = new List<T>(count);
Array.Copy(_items, index, list._items, 0, count);
@@ -723,12 +670,10 @@ namespace System.Collections.Generic
//
public int IndexOf(T item)
{
- Contract.Ensures(Contract.Result<int>() >= -1);
- Contract.Ensures(Contract.Result<int>() < Count);
return Array.IndexOf(_items, item, 0, _size);
}
- int System.Collections.IList.IndexOf(Object item)
+ int System.Collections.IList.IndexOf(object item)
{
if (IsCompatibleObject(item))
{
@@ -750,9 +695,6 @@ namespace System.Collections.Generic
{
if (index > _size)
ThrowHelper.ThrowArgumentOutOfRange_IndexException();
- Contract.Ensures(Contract.Result<int>() >= -1);
- Contract.Ensures(Contract.Result<int>() < Count);
- Contract.EndContractBlock();
return Array.IndexOf(_items, item, index, _size - index);
}
@@ -770,10 +712,8 @@ namespace System.Collections.Generic
if (index > _size)
ThrowHelper.ThrowArgumentOutOfRange_IndexException();
- if (count < 0 || index > _size - count) ThrowHelper.ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count();
- Contract.Ensures(Contract.Result<int>() >= -1);
- Contract.Ensures(Contract.Result<int>() < Count);
- Contract.EndContractBlock();
+ if (count < 0 || index > _size - count)
+ ThrowHelper.ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count();
return Array.IndexOf(_items, item, index, count);
}
@@ -789,7 +729,6 @@ namespace System.Collections.Generic
{
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_ListInsert);
}
- Contract.EndContractBlock();
if (_size == _items.Length) EnsureCapacity(_size + 1);
if (index < _size)
{
@@ -830,7 +769,6 @@ namespace System.Collections.Generic
{
ThrowHelper.ThrowArgumentOutOfRange_IndexException();
}
- Contract.EndContractBlock();
ICollection<T> c = collection as ICollection<T>;
if (c != null)
@@ -888,8 +826,6 @@ namespace System.Collections.Generic
//
public int LastIndexOf(T item)
{
- Contract.Ensures(Contract.Result<int>() >= -1);
- Contract.Ensures(Contract.Result<int>() < Count);
if (_size == 0)
{ // Special case for empty list
return -1;
@@ -913,9 +849,6 @@ namespace System.Collections.Generic
{
if (index >= _size)
ThrowHelper.ThrowArgumentOutOfRange_IndexException();
- Contract.Ensures(Contract.Result<int>() >= -1);
- Contract.Ensures(((Count == 0) && (Contract.Result<int>() == -1)) || ((Count > 0) && (Contract.Result<int>() <= index)));
- Contract.EndContractBlock();
return LastIndexOf(item, index, index + 1);
}
@@ -939,9 +872,6 @@ namespace System.Collections.Generic
{
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
}
- Contract.Ensures(Contract.Result<int>() >= -1);
- Contract.Ensures(((Count == 0) && (Contract.Result<int>() == -1)) || ((Count > 0) && (Contract.Result<int>() <= index)));
- Contract.EndContractBlock();
if (_size == 0)
{ // Special case for empty list
@@ -963,7 +893,6 @@ namespace System.Collections.Generic
// Removes the element at the given index. The size of the list is
// decreased by one.
- //
public bool Remove(T item)
{
int index = IndexOf(item);
@@ -976,7 +905,7 @@ namespace System.Collections.Generic
return false;
}
- void System.Collections.IList.Remove(Object item)
+ void System.Collections.IList.Remove(object item)
{
if (IsCompatibleObject(item))
{
@@ -985,16 +914,13 @@ namespace System.Collections.Generic
}
// This method removes all items which matches the predicate.
- // The complexity is O(n).
+ // The complexity is O(n).
public int RemoveAll(Predicate<T> match)
{
if (match == null)
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match);
}
- Contract.Ensures(Contract.Result<int>() >= 0);
- Contract.Ensures(Contract.Result<int>() <= Contract.OldValue(Count));
- Contract.EndContractBlock();
int freeIndex = 0; // the first free slot in items array
@@ -1028,14 +954,12 @@ namespace System.Collections.Generic
// Removes the element at the given index. The size of the list is
// decreased by one.
- //
public void RemoveAt(int index)
{
if ((uint)index >= (uint)_size)
{
ThrowHelper.ThrowArgumentOutOfRange_IndexException();
}
- Contract.EndContractBlock();
_size--;
if (index < _size)
{
@@ -1049,7 +973,6 @@ namespace System.Collections.Generic
}
// Removes a range of elements from this list.
- //
public void RemoveRange(int index, int count)
{
if (index < 0)
@@ -1064,7 +987,6 @@ namespace System.Collections.Generic
if (_size - index < count)
ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen);
- Contract.EndContractBlock();
if (count > 0)
{
@@ -1093,7 +1015,7 @@ namespace System.Collections.Generic
// method, an element in the range given by index and count
// which was previously located at index i will now be located at
// index index + (index + count - i - 1).
- //
+ //
public void Reverse(int index, int count)
{
if (index < 0)
@@ -1108,7 +1030,6 @@ namespace System.Collections.Generic
if (_size - index < count)
ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen);
- Contract.EndContractBlock();
if (count > 1)
{
@@ -1153,7 +1074,6 @@ namespace System.Collections.Generic
if (_size - index < count)
ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen);
- Contract.EndContractBlock();
if (count > 1)
{
@@ -1168,7 +1088,6 @@ namespace System.Collections.Generic
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.comparison);
}
- Contract.EndContractBlock();
if (_size > 1)
{
@@ -1181,12 +1100,9 @@ namespace System.Collections.Generic
// This requires copying the List, which is an O(n) operation.
public T[] ToArray()
{
- Contract.Ensures(Contract.Result<T[]>() != null);
- Contract.Ensures(Contract.Result<T[]>().Length == Count);
-
if (_size == 0)
{
- return _emptyArray;
+ return s_emptyArray;
}
T[] array = new T[_size];
@@ -1218,7 +1134,6 @@ namespace System.Collections.Generic
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match);
}
- Contract.EndContractBlock();
for (int i = 0; i < _size; i++)
{
@@ -1257,17 +1172,17 @@ namespace System.Collections.Generic
public struct Enumerator : IEnumerator<T>, System.Collections.IEnumerator
{
- private List<T> list;
- private int index;
- private int version;
- private T current;
+ private List<T> _list;
+ private int _index;
+ private int _version;
+ private T _current;
internal Enumerator(List<T> list)
{
- this.list = list;
- index = 0;
- version = list._version;
- current = default(T);
+ _list = list;
+ _index = 0;
+ _version = list._version;
+ _current = default(T);
}
public void Dispose()
@@ -1276,12 +1191,12 @@ namespace System.Collections.Generic
public bool MoveNext()
{
- List<T> localList = list;
+ List<T> localList = _list;
- if (version == localList._version && ((uint)index < (uint)localList._size))
+ if (_version == localList._version && ((uint)_index < (uint)localList._size))
{
- current = localList._items[index];
- index++;
+ _current = localList._items[_index];
+ _index++;
return true;
}
return MoveNextRare();
@@ -1289,13 +1204,13 @@ namespace System.Collections.Generic
private bool MoveNextRare()
{
- if (version != list._version)
+ if (_version != _list._version)
{
ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumFailedVersion();
}
- index = list._size + 1;
- current = default(T);
+ _index = _list._size + 1;
+ _current = default(T);
return false;
}
@@ -1303,15 +1218,15 @@ namespace System.Collections.Generic
{
get
{
- return current;
+ return _current;
}
}
- Object System.Collections.IEnumerator.Current
+ object System.Collections.IEnumerator.Current
{
get
{
- if (index == 0 || index == list._size + 1)
+ if (_index == 0 || _index == _list._size + 1)
{
ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumOpCantHappen();
}
@@ -1321,15 +1236,14 @@ namespace System.Collections.Generic
void System.Collections.IEnumerator.Reset()
{
- if (version != list._version)
+ if (_version != _list._version)
{
ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumFailedVersion();
}
- index = 0;
- current = default(T);
+ _index = 0;
+ _current = default(T);
}
}
}
}
-
diff --git a/src/mscorlib/shared/System/Collections/ICollection.cs b/src/mscorlib/shared/System/Collections/ICollection.cs
index 8fd6a96b48..f0149020d2 100644
--- a/src/mscorlib/shared/System/Collections/ICollection.cs
+++ b/src/mscorlib/shared/System/Collections/ICollection.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System;
-using System.Diagnostics.Contracts;
namespace System.Collections
{
diff --git a/src/mscorlib/shared/System/Collections/IDictionary.cs b/src/mscorlib/shared/System/Collections/IDictionary.cs
index 8bc7fcf125..b934c2399c 100644
--- a/src/mscorlib/shared/System/Collections/IDictionary.cs
+++ b/src/mscorlib/shared/System/Collections/IDictionary.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System;
-using System.Diagnostics.Contracts;
namespace System.Collections
{
diff --git a/src/mscorlib/shared/System/Collections/IEnumerable.cs b/src/mscorlib/shared/System/Collections/IEnumerable.cs
index 91aec62423..e5edeff266 100644
--- a/src/mscorlib/shared/System/Collections/IEnumerable.cs
+++ b/src/mscorlib/shared/System/Collections/IEnumerable.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System;
-using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
namespace System.Collections
@@ -12,7 +11,6 @@ namespace System.Collections
{
// Returns an IEnumerator for this enumerable Object. The enumerator provides
// a simple way to access all the contents of a collection.
- [Pure]
IEnumerator GetEnumerator();
}
}
diff --git a/src/mscorlib/shared/System/Collections/IList.cs b/src/mscorlib/shared/System/Collections/IList.cs
index bb2e221cc1..0110eca1f5 100644
--- a/src/mscorlib/shared/System/Collections/IList.cs
+++ b/src/mscorlib/shared/System/Collections/IList.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System;
-using System.Diagnostics.Contracts;
namespace System.Collections
{
diff --git a/src/mscorlib/shared/System/Collections/ListDictionaryInternal.cs b/src/mscorlib/shared/System/Collections/ListDictionaryInternal.cs
index 681e51a329..28593d3c82 100644
--- a/src/mscorlib/shared/System/Collections/ListDictionaryInternal.cs
+++ b/src/mscorlib/shared/System/Collections/ListDictionaryInternal.cs
@@ -12,7 +12,6 @@
**
===========================================================*/
-using System.Diagnostics.Contracts;
namespace System.Collections
{
@@ -46,7 +45,6 @@ namespace System.Collections
{
throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key);
}
- Contract.EndContractBlock();
DictionaryNode node = head;
while (node != null)
@@ -65,7 +63,6 @@ namespace System.Collections
{
throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key);
}
- Contract.EndContractBlock();
version++;
@@ -167,7 +164,6 @@ namespace System.Collections
{
throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key);
}
- Contract.EndContractBlock();
version++;
@@ -215,7 +211,6 @@ namespace System.Collections
{
throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key);
}
- Contract.EndContractBlock();
for (DictionaryNode node = head; node != null; node = node.next)
{
if (node.key.Equals(key))
@@ -239,7 +234,6 @@ namespace System.Collections
if (array.Length - index < this.Count)
throw new ArgumentException(SR.ArgumentOutOfRange_Index, nameof(index));
- Contract.EndContractBlock();
for (DictionaryNode node = head; node != null; node = node.next)
{
@@ -264,7 +258,6 @@ namespace System.Collections
{
throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key);
}
- Contract.EndContractBlock();
version++;
DictionaryNode last = null;
DictionaryNode node;
@@ -403,7 +396,6 @@ namespace System.Collections
throw new ArgumentException(SR.Arg_RankMultiDimNotSupported);
if (index < 0)
throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
if (array.Length - index < list.Count)
throw new ArgumentException(SR.ArgumentOutOfRange_Index, nameof(index));
for (DictionaryNode node = list.head; node != null; node = node.next)
diff --git a/src/mscorlib/shared/System/Collections/ObjectModel/Collection.cs b/src/mscorlib/shared/System/Collections/ObjectModel/Collection.cs
index 75e88eccb3..1e1b2c7959 100644
--- a/src/mscorlib/shared/System/Collections/ObjectModel/Collection.cs
+++ b/src/mscorlib/shared/System/Collections/ObjectModel/Collection.cs
@@ -8,7 +8,7 @@ using System.Diagnostics;
namespace System.Collections.ObjectModel
{
[Serializable]
- [DebuggerTypeProxy(typeof(Mscorlib_CollectionDebugView<>))]
+ [DebuggerTypeProxy(typeof(ICollectionDebugView<>))]
[DebuggerDisplay("Count = {Count}")]
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
public class Collection<T> : IList<T>, IList, IReadOnlyList<T>
diff --git a/src/mscorlib/shared/System/Collections/ObjectModel/ReadOnlyCollection.cs b/src/mscorlib/shared/System/Collections/ObjectModel/ReadOnlyCollection.cs
index f1d2a0969b..dbf88d8b8d 100644
--- a/src/mscorlib/shared/System/Collections/ObjectModel/ReadOnlyCollection.cs
+++ b/src/mscorlib/shared/System/Collections/ObjectModel/ReadOnlyCollection.cs
@@ -8,7 +8,7 @@ using System.Diagnostics;
namespace System.Collections.ObjectModel
{
[Serializable]
- [DebuggerTypeProxy(typeof(Mscorlib_CollectionDebugView<>))]
+ [DebuggerTypeProxy(typeof(ICollectionDebugView<>))]
[DebuggerDisplay("Count = {Count}")]
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
public class ReadOnlyCollection<T> : IList<T>, IList, IReadOnlyList<T>
diff --git a/src/mscorlib/shared/System/Convert.cs b/src/mscorlib/shared/System/Convert.cs
index 02fbbdbc3e..4a60164f94 100644
--- a/src/mscorlib/shared/System/Convert.cs
+++ b/src/mscorlib/shared/System/Convert.cs
@@ -11,7 +11,6 @@ using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System
{
@@ -158,7 +157,6 @@ namespace System
// the object does not implement IConvertible), the result is TypeCode.Object.
// Otherwise, the result is the type code of the object, as determined by
// the object's implementation of IConvertible.
- [Pure]
public static TypeCode GetTypeCode(object value)
{
if (value == null) return TypeCode.Empty;
@@ -172,7 +170,6 @@ namespace System
// Returns true if the given object is a database null. This operation
// corresponds to "value.GetTypeCode() == TypeCode.DBNull".
- [Pure]
public static bool IsDBNull(object value)
{
if (value == System.DBNull.Value) return true;
@@ -263,7 +260,6 @@ namespace System
{
throw new ArgumentNullException(nameof(targetType));
}
- Contract.EndContractBlock();
if (ReferenceEquals(value.GetType(), targetType))
{
@@ -324,7 +320,6 @@ namespace System
{
throw new ArgumentNullException(nameof(conversionType));
}
- Contract.EndContractBlock();
if (value == null)
{
@@ -541,7 +536,6 @@ namespace System
public static char ToChar(sbyte value)
{
if (value < 0) ThrowCharOverflowException();
- Contract.EndContractBlock();
return (char)value;
}
@@ -553,7 +547,6 @@ namespace System
public static char ToChar(short value)
{
if (value < 0) ThrowCharOverflowException();
- Contract.EndContractBlock();
return (char)value;
}
@@ -566,7 +559,6 @@ namespace System
public static char ToChar(int value)
{
if (value < 0 || value > Char.MaxValue) ThrowCharOverflowException();
- Contract.EndContractBlock();
return (char)value;
}
@@ -574,14 +566,12 @@ namespace System
public static char ToChar(uint value)
{
if (value > Char.MaxValue) ThrowCharOverflowException();
- Contract.EndContractBlock();
return (char)value;
}
public static char ToChar(long value)
{
if (value < 0 || value > Char.MaxValue) ThrowCharOverflowException();
- Contract.EndContractBlock();
return (char)value;
}
@@ -589,7 +579,6 @@ namespace System
public static char ToChar(ulong value)
{
if (value > Char.MaxValue) ThrowCharOverflowException();
- Contract.EndContractBlock();
return (char)value;
}
@@ -606,7 +595,6 @@ namespace System
{
if (value == null)
throw new ArgumentNullException(nameof(value));
- Contract.EndContractBlock();
if (value.Length != 1)
throw new FormatException(SR.Format_NeedSingleChar);
@@ -674,7 +662,6 @@ namespace System
public static sbyte ToSByte(char value)
{
if (value > SByte.MaxValue) ThrowSByteOverflowException();
- Contract.EndContractBlock();
return (sbyte)value;
}
@@ -682,7 +669,6 @@ namespace System
public static sbyte ToSByte(byte value)
{
if (value > SByte.MaxValue) ThrowSByteOverflowException();
- Contract.EndContractBlock();
return (sbyte)value;
}
@@ -690,7 +676,6 @@ namespace System
public static sbyte ToSByte(short value)
{
if (value < SByte.MinValue || value > SByte.MaxValue) ThrowSByteOverflowException();
- Contract.EndContractBlock();
return (sbyte)value;
}
@@ -698,7 +683,6 @@ namespace System
public static sbyte ToSByte(ushort value)
{
if (value > SByte.MaxValue) ThrowSByteOverflowException();
- Contract.EndContractBlock();
return (sbyte)value;
}
@@ -706,7 +690,6 @@ namespace System
public static sbyte ToSByte(int value)
{
if (value < SByte.MinValue || value > SByte.MaxValue) ThrowSByteOverflowException();
- Contract.EndContractBlock();
return (sbyte)value;
}
@@ -714,7 +697,6 @@ namespace System
public static sbyte ToSByte(uint value)
{
if (value > SByte.MaxValue) ThrowSByteOverflowException();
- Contract.EndContractBlock();
return (sbyte)value;
}
@@ -722,7 +704,6 @@ namespace System
public static sbyte ToSByte(long value)
{
if (value < SByte.MinValue || value > SByte.MaxValue) ThrowSByteOverflowException();
- Contract.EndContractBlock();
return (sbyte)value;
}
@@ -730,7 +711,6 @@ namespace System
public static sbyte ToSByte(ulong value)
{
if (value > (ulong)SByte.MaxValue) ThrowSByteOverflowException();
- Contract.EndContractBlock();
return (sbyte)value;
}
@@ -800,7 +780,6 @@ namespace System
public static byte ToByte(char value)
{
if (value > Byte.MaxValue) ThrowByteOverflowException();
- Contract.EndContractBlock();
return (byte)value;
}
@@ -808,14 +787,12 @@ namespace System
public static byte ToByte(sbyte value)
{
if (value < Byte.MinValue) ThrowByteOverflowException();
- Contract.EndContractBlock();
return (byte)value;
}
public static byte ToByte(short value)
{
if (value < Byte.MinValue || value > Byte.MaxValue) ThrowByteOverflowException();
- Contract.EndContractBlock();
return (byte)value;
}
@@ -823,14 +800,12 @@ namespace System
public static byte ToByte(ushort value)
{
if (value > Byte.MaxValue) ThrowByteOverflowException();
- Contract.EndContractBlock();
return (byte)value;
}
public static byte ToByte(int value)
{
if (value < Byte.MinValue || value > Byte.MaxValue) ThrowByteOverflowException();
- Contract.EndContractBlock();
return (byte)value;
}
@@ -838,14 +813,12 @@ namespace System
public static byte ToByte(uint value)
{
if (value > Byte.MaxValue) ThrowByteOverflowException();
- Contract.EndContractBlock();
return (byte)value;
}
public static byte ToByte(long value)
{
if (value < Byte.MinValue || value > Byte.MaxValue) ThrowByteOverflowException();
- Contract.EndContractBlock();
return (byte)value;
}
@@ -853,7 +826,6 @@ namespace System
public static byte ToByte(ulong value)
{
if (value > Byte.MaxValue) ThrowByteOverflowException();
- Contract.EndContractBlock();
return (byte)value;
}
@@ -915,7 +887,6 @@ namespace System
public static short ToInt16(char value)
{
if (value > Int16.MaxValue) ThrowInt16OverflowException();
- Contract.EndContractBlock();
return (short)value;
}
@@ -934,14 +905,12 @@ namespace System
public static short ToInt16(ushort value)
{
if (value > Int16.MaxValue) ThrowInt16OverflowException();
- Contract.EndContractBlock();
return (short)value;
}
public static short ToInt16(int value)
{
if (value < Int16.MinValue || value > Int16.MaxValue) ThrowInt16OverflowException();
- Contract.EndContractBlock();
return (short)value;
}
@@ -949,7 +918,6 @@ namespace System
public static short ToInt16(uint value)
{
if (value > Int16.MaxValue) ThrowInt16OverflowException();
- Contract.EndContractBlock();
return (short)value;
}
@@ -961,7 +929,6 @@ namespace System
public static short ToInt16(long value)
{
if (value < Int16.MinValue || value > Int16.MaxValue) ThrowInt16OverflowException();
- Contract.EndContractBlock();
return (short)value;
}
@@ -969,7 +936,6 @@ namespace System
public static short ToInt16(ulong value)
{
if (value > (ulong)Int16.MaxValue) ThrowInt16OverflowException();
- Contract.EndContractBlock();
return (short)value;
}
@@ -1042,7 +1008,6 @@ namespace System
public static ushort ToUInt16(sbyte value)
{
if (value < 0) ThrowUInt16OverflowException();
- Contract.EndContractBlock();
return (ushort)value;
}
@@ -1056,7 +1021,6 @@ namespace System
public static ushort ToUInt16(short value)
{
if (value < 0) ThrowUInt16OverflowException();
- Contract.EndContractBlock();
return (ushort)value;
}
@@ -1064,7 +1028,6 @@ namespace System
public static ushort ToUInt16(int value)
{
if (value < 0 || value > UInt16.MaxValue) ThrowUInt16OverflowException();
- Contract.EndContractBlock();
return (ushort)value;
}
@@ -1078,7 +1041,6 @@ namespace System
public static ushort ToUInt16(uint value)
{
if (value > UInt16.MaxValue) ThrowUInt16OverflowException();
- Contract.EndContractBlock();
return (ushort)value;
}
@@ -1087,7 +1049,6 @@ namespace System
public static ushort ToUInt16(long value)
{
if (value < 0 || value > UInt16.MaxValue) ThrowUInt16OverflowException();
- Contract.EndContractBlock();
return (ushort)value;
}
@@ -1095,7 +1056,6 @@ namespace System
public static ushort ToUInt16(ulong value)
{
if (value > UInt16.MaxValue) ThrowUInt16OverflowException();
- Contract.EndContractBlock();
return (ushort)value;
}
@@ -1191,7 +1151,6 @@ namespace System
public static int ToInt32(uint value)
{
if (value > Int32.MaxValue) ThrowInt32OverflowException();
- Contract.EndContractBlock();
return (int)value;
}
@@ -1203,7 +1162,6 @@ namespace System
public static int ToInt32(long value)
{
if (value < Int32.MinValue || value > Int32.MaxValue) ThrowInt32OverflowException();
- Contract.EndContractBlock();
return (int)value;
}
@@ -1211,7 +1169,6 @@ namespace System
public static int ToInt32(ulong value)
{
if (value > Int32.MaxValue) ThrowInt32OverflowException();
- Contract.EndContractBlock();
return (int)value;
}
@@ -1304,7 +1261,6 @@ namespace System
public static uint ToUInt32(sbyte value)
{
if (value < 0) ThrowUInt32OverflowException();
- Contract.EndContractBlock();
return (uint)value;
}
@@ -1318,7 +1274,6 @@ namespace System
public static uint ToUInt32(short value)
{
if (value < 0) ThrowUInt32OverflowException();
- Contract.EndContractBlock();
return (uint)value;
}
@@ -1332,7 +1287,6 @@ namespace System
public static uint ToUInt32(int value)
{
if (value < 0) ThrowUInt32OverflowException();
- Contract.EndContractBlock();
return (uint)value;
}
@@ -1346,7 +1300,6 @@ namespace System
public static uint ToUInt32(long value)
{
if (value < 0 || value > UInt32.MaxValue) ThrowUInt32OverflowException();
- Contract.EndContractBlock();
return (uint)value;
}
@@ -1354,7 +1307,6 @@ namespace System
public static uint ToUInt32(ulong value)
{
if (value > UInt32.MaxValue) ThrowUInt32OverflowException();
- Contract.EndContractBlock();
return (uint)value;
}
@@ -1468,7 +1420,6 @@ namespace System
public static long ToInt64(ulong value)
{
if (value > Int64.MaxValue) ThrowInt64OverflowException();
- Contract.EndContractBlock();
return (long)value;
}
@@ -1546,7 +1497,6 @@ namespace System
public static ulong ToUInt64(sbyte value)
{
if (value < 0) ThrowUInt64OverflowException();
- Contract.EndContractBlock();
return (ulong)value;
}
@@ -1560,7 +1510,6 @@ namespace System
public static ulong ToUInt64(short value)
{
if (value < 0) ThrowUInt64OverflowException();
- Contract.EndContractBlock();
return (ulong)value;
}
@@ -1574,7 +1523,6 @@ namespace System
public static ulong ToUInt64(int value)
{
if (value < 0) ThrowUInt64OverflowException();
- Contract.EndContractBlock();
return (ulong)value;
}
@@ -1588,7 +1536,6 @@ namespace System
public static ulong ToUInt64(long value)
{
if (value < 0) ThrowUInt64OverflowException();
- Contract.EndContractBlock();
return (ulong)value;
}
@@ -2075,189 +2022,159 @@ namespace System
public static string ToString(bool value)
{
- Contract.Ensures(Contract.Result<string>() != null);
return value.ToString();
}
public static string ToString(bool value, IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<string>() != null);
return value.ToString();
}
public static string ToString(char value)
{
- Contract.Ensures(Contract.Result<string>() != null);
return Char.ToString(value);
}
public static string ToString(char value, IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<string>() != null);
return value.ToString();
}
[CLSCompliant(false)]
public static string ToString(sbyte value)
{
- Contract.Ensures(Contract.Result<string>() != null);
return value.ToString(CultureInfo.CurrentCulture);
}
[CLSCompliant(false)]
public static string ToString(sbyte value, IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<string>() != null);
return value.ToString(provider);
}
public static string ToString(byte value)
{
- Contract.Ensures(Contract.Result<string>() != null);
return value.ToString(CultureInfo.CurrentCulture);
}
public static string ToString(byte value, IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<string>() != null);
return value.ToString(provider);
}
public static string ToString(short value)
{
- Contract.Ensures(Contract.Result<string>() != null);
return value.ToString(CultureInfo.CurrentCulture);
}
public static string ToString(short value, IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<string>() != null);
return value.ToString(provider);
}
[CLSCompliant(false)]
public static string ToString(ushort value)
{
- Contract.Ensures(Contract.Result<string>() != null);
return value.ToString(CultureInfo.CurrentCulture);
}
[CLSCompliant(false)]
public static string ToString(ushort value, IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<string>() != null);
return value.ToString(provider);
}
public static string ToString(int value)
{
- Contract.Ensures(Contract.Result<string>() != null);
return value.ToString(CultureInfo.CurrentCulture);
}
public static string ToString(int value, IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<string>() != null);
return value.ToString(provider);
}
[CLSCompliant(false)]
public static string ToString(uint value)
{
- Contract.Ensures(Contract.Result<string>() != null);
return value.ToString(CultureInfo.CurrentCulture);
}
[CLSCompliant(false)]
public static string ToString(uint value, IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<string>() != null);
return value.ToString(provider);
}
public static string ToString(long value)
{
- Contract.Ensures(Contract.Result<string>() != null);
return value.ToString(CultureInfo.CurrentCulture);
}
public static string ToString(long value, IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<string>() != null);
return value.ToString(provider);
}
[CLSCompliant(false)]
public static string ToString(ulong value)
{
- Contract.Ensures(Contract.Result<string>() != null);
return value.ToString(CultureInfo.CurrentCulture);
}
[CLSCompliant(false)]
public static string ToString(ulong value, IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<string>() != null);
return value.ToString(provider);
}
public static string ToString(float value)
{
- Contract.Ensures(Contract.Result<string>() != null);
return value.ToString(CultureInfo.CurrentCulture);
}
public static string ToString(float value, IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<string>() != null);
return value.ToString(provider);
}
public static string ToString(double value)
{
- Contract.Ensures(Contract.Result<string>() != null);
return value.ToString(CultureInfo.CurrentCulture);
}
public static string ToString(double value, IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<string>() != null);
return value.ToString(provider);
}
public static string ToString(decimal value)
{
- Contract.Ensures(Contract.Result<string>() != null);
return value.ToString(CultureInfo.CurrentCulture);
}
public static string ToString(Decimal value, IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<string>() != null);
return value.ToString(provider);
}
public static string ToString(DateTime value)
{
- Contract.Ensures(Contract.Result<string>() != null);
return value.ToString();
}
public static string ToString(DateTime value, IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<string>() != null);
return value.ToString(provider);
}
public static String ToString(String value)
{
- Contract.Ensures(Contract.Result<string>() == value); // We were always skipping the null check here.
return value;
}
public static String ToString(String value, IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<string>() == value); // We were always skipping the null check here.
return value; // avoid the null check
}
@@ -2275,8 +2192,13 @@ namespace System
{
throw new ArgumentException(SR.Arg_InvalidBase);
}
- Contract.EndContractBlock();
- int r = ParseNumbers.StringToInt(value, fromBase, ParseNumbers.IsTight | ParseNumbers.TreatAsUnsigned);
+
+ if (value == null)
+ {
+ return 0;
+ }
+
+ int r = ParseNumbers.StringToInt(value.AsReadOnlySpan(), fromBase, ParseNumbers.IsTight | ParseNumbers.TreatAsUnsigned);
if (r < Byte.MinValue || r > Byte.MaxValue)
ThrowByteOverflowException();
return (byte)r;
@@ -2293,8 +2215,13 @@ namespace System
{
throw new ArgumentException(SR.Arg_InvalidBase);
}
- Contract.EndContractBlock();
- int r = ParseNumbers.StringToInt(value, fromBase, ParseNumbers.IsTight | ParseNumbers.TreatAsI1);
+
+ if (value == null)
+ {
+ return 0;
+ }
+
+ int r = ParseNumbers.StringToInt(value.AsReadOnlySpan(), fromBase, ParseNumbers.IsTight | ParseNumbers.TreatAsI1);
if (fromBase != 10 && r <= Byte.MaxValue)
return (sbyte)r;
@@ -2313,8 +2240,13 @@ namespace System
{
throw new ArgumentException(SR.Arg_InvalidBase);
}
- Contract.EndContractBlock();
- int r = ParseNumbers.StringToInt(value, fromBase, ParseNumbers.IsTight | ParseNumbers.TreatAsI2);
+
+ if (value == null)
+ {
+ return 0;
+ }
+
+ int r = ParseNumbers.StringToInt(value.AsReadOnlySpan(), fromBase, ParseNumbers.IsTight | ParseNumbers.TreatAsI2);
if (fromBase != 10 && r <= UInt16.MaxValue)
return (short)r;
@@ -2334,8 +2266,13 @@ namespace System
{
throw new ArgumentException(SR.Arg_InvalidBase);
}
- Contract.EndContractBlock();
- int r = ParseNumbers.StringToInt(value, fromBase, ParseNumbers.IsTight | ParseNumbers.TreatAsUnsigned);
+
+ if (value == null)
+ {
+ return 0;
+ }
+
+ int r = ParseNumbers.StringToInt(value.AsReadOnlySpan(), fromBase, ParseNumbers.IsTight | ParseNumbers.TreatAsUnsigned);
if (r < UInt16.MinValue || r > UInt16.MaxValue)
ThrowUInt16OverflowException();
return (ushort)r;
@@ -2351,8 +2288,9 @@ namespace System
{
throw new ArgumentException(SR.Arg_InvalidBase);
}
- Contract.EndContractBlock();
- return ParseNumbers.StringToInt(value, fromBase, ParseNumbers.IsTight);
+ return value != null ?
+ ParseNumbers.StringToInt(value.AsReadOnlySpan(), fromBase, ParseNumbers.IsTight) :
+ 0;
}
// Parses value in base fromBase. fromBase can only
@@ -2366,8 +2304,9 @@ namespace System
{
throw new ArgumentException(SR.Arg_InvalidBase);
}
- Contract.EndContractBlock();
- return (uint)ParseNumbers.StringToInt(value, fromBase, ParseNumbers.TreatAsUnsigned | ParseNumbers.IsTight);
+ return value != null ?
+ (uint)ParseNumbers.StringToInt(value.AsReadOnlySpan(), fromBase, ParseNumbers.TreatAsUnsigned | ParseNumbers.IsTight) :
+ 0;
}
// Parses value in base fromBase. fromBase can only
@@ -2380,8 +2319,9 @@ namespace System
{
throw new ArgumentException(SR.Arg_InvalidBase);
}
- Contract.EndContractBlock();
- return ParseNumbers.StringToLong(value, fromBase, ParseNumbers.IsTight);
+ return value != null ?
+ ParseNumbers.StringToLong(value.AsReadOnlySpan(), fromBase, ParseNumbers.IsTight) :
+ 0;
}
// Parses value in base fromBase. fromBase can only
@@ -2395,8 +2335,9 @@ namespace System
{
throw new ArgumentException(SR.Arg_InvalidBase);
}
- Contract.EndContractBlock();
- return (ulong)ParseNumbers.StringToLong(value, fromBase, ParseNumbers.TreatAsUnsigned | ParseNumbers.IsTight);
+ return value != null ?
+ (ulong)ParseNumbers.StringToLong(value.AsReadOnlySpan(), fromBase, ParseNumbers.TreatAsUnsigned | ParseNumbers.IsTight) :
+ 0;
}
// Convert the byte value to a string in base fromBase
@@ -2406,7 +2347,6 @@ namespace System
{
throw new ArgumentException(SR.Arg_InvalidBase);
}
- Contract.EndContractBlock();
return ParseNumbers.IntToString((int)value, toBase, -1, ' ', ParseNumbers.PrintAsI1);
}
@@ -2417,7 +2357,6 @@ namespace System
{
throw new ArgumentException(SR.Arg_InvalidBase);
}
- Contract.EndContractBlock();
return ParseNumbers.IntToString((int)value, toBase, -1, ' ', ParseNumbers.PrintAsI2);
}
@@ -2428,7 +2367,6 @@ namespace System
{
throw new ArgumentException(SR.Arg_InvalidBase);
}
- Contract.EndContractBlock();
return ParseNumbers.IntToString(value, toBase, -1, ' ', 0);
}
@@ -2439,7 +2377,6 @@ namespace System
{
throw new ArgumentException(SR.Arg_InvalidBase);
}
- Contract.EndContractBlock();
return ParseNumbers.LongToString(value, toBase, -1, ' ', 0);
}
@@ -2449,8 +2386,6 @@ namespace System
{
throw new ArgumentNullException(nameof(inArray));
}
- Contract.Ensures(Contract.Result<string>() != null);
- Contract.EndContractBlock();
return ToBase64String(inArray, 0, inArray.Length, Base64FormattingOptions.None);
}
@@ -2460,8 +2395,6 @@ namespace System
{
throw new ArgumentNullException(nameof(inArray));
}
- Contract.Ensures(Contract.Result<string>() != null);
- Contract.EndContractBlock();
return ToBase64String(inArray, 0, inArray.Length, options);
}
@@ -2481,8 +2414,6 @@ namespace System
throw new ArgumentOutOfRangeException(nameof(offset), SR.ArgumentOutOfRange_GenericPositive);
if (options < Base64FormattingOptions.None || options > Base64FormattingOptions.InsertLineBreaks)
throw new ArgumentException(string.Format(SR.Arg_EnumIllegalVal, (int)options));
- Contract.Ensures(Contract.Result<string>() != null);
- Contract.EndContractBlock();
int inArrayLength;
int stringLength;
@@ -2512,10 +2443,6 @@ namespace System
public static int ToBase64CharArray(byte[] inArray, int offsetIn, int length, char[] outArray, int offsetOut)
{
- Contract.Ensures(Contract.Result<int>() >= 0);
- Contract.Ensures(Contract.Result<int>() <= outArray.Length);
- Contract.EndContractBlock();
-
return ToBase64CharArray(inArray, offsetIn, length, outArray, offsetOut, Base64FormattingOptions.None);
}
@@ -2537,9 +2464,6 @@ namespace System
{
throw new ArgumentException(string.Format(SR.Arg_EnumIllegalVal, (int)options));
}
- Contract.Ensures(Contract.Result<int>() >= 0);
- Contract.Ensures(Contract.Result<int>() <= outArray.Length);
- Contract.EndContractBlock();
int retVal;
@@ -2678,7 +2602,6 @@ namespace System
if (s == null)
throw new ArgumentNullException(nameof(s));
- Contract.EndContractBlock();
unsafe
{
@@ -2711,7 +2634,6 @@ namespace System
if (offset > inArray.Length - length)
throw new ArgumentOutOfRangeException(nameof(offset), SR.ArgumentOutOfRange_OffsetLength);
- Contract.EndContractBlock();
if (inArray.Length == 0)
{
diff --git a/src/mscorlib/shared/System/CurrentSystemTimeZone.cs b/src/mscorlib/shared/System/CurrentSystemTimeZone.cs
index 3f17d6f371..bab6a92bf5 100644
--- a/src/mscorlib/shared/System/CurrentSystemTimeZone.cs
+++ b/src/mscorlib/shared/System/CurrentSystemTimeZone.cs
@@ -18,7 +18,6 @@
============================================================*/
using System;
-using System.Diagnostics.Contracts;
using System.Text;
using System.Collections;
using System.Globalization;
diff --git a/src/mscorlib/shared/System/DateTime.cs b/src/mscorlib/shared/System/DateTime.cs
index e72654a8d6..99a444d5e9 100644
--- a/src/mscorlib/shared/System/DateTime.cs
+++ b/src/mscorlib/shared/System/DateTime.cs
@@ -4,7 +4,6 @@
using System;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Threading;
using System.Globalization;
using System.Runtime;
@@ -18,7 +17,6 @@ using Calendar = System.Globalization.Calendar;
namespace System
{
-
// This value type represents a date and time. Every DateTime
// object has a private field (Ticks) of type Int64 that stores the
// date and time as the number of 100 nanosecond intervals since
@@ -147,7 +145,6 @@ namespace System
{
if (ticks < MinTicks || ticks > MaxTicks)
throw new ArgumentOutOfRangeException(nameof(ticks), SR.ArgumentOutOfRange_DateTimeBadTicks);
- Contract.EndContractBlock();
_dateData = (UInt64)ticks;
}
@@ -166,7 +163,6 @@ namespace System
{
throw new ArgumentException(SR.Argument_InvalidDateTimeKind, nameof(kind));
}
- Contract.EndContractBlock();
_dateData = ((UInt64)ticks | ((UInt64)kind << KindShift));
}
@@ -177,7 +173,6 @@ namespace System
throw new ArgumentOutOfRangeException(nameof(ticks), SR.ArgumentOutOfRange_DateTimeBadTicks);
}
Debug.Assert(kind == DateTimeKind.Local, "Internal Constructor is for local times only");
- Contract.EndContractBlock();
_dateData = ((UInt64)ticks | (isAmbiguousDst ? KindLocalAmbiguousDst : KindLocal));
}
@@ -212,7 +207,6 @@ namespace System
{
throw new ArgumentException(SR.Argument_InvalidDateTimeKind, nameof(kind));
}
- Contract.EndContractBlock();
Int64 ticks = DateToTicks(year, month, day) + TimeToTicks(hour, minute, second);
_dateData = ((UInt64)ticks | ((UInt64)kind << KindShift));
}
@@ -224,7 +218,6 @@ namespace System
{
if (calendar == null)
throw new ArgumentNullException(nameof(calendar));
- Contract.EndContractBlock();
_dateData = (UInt64)calendar.ToDateTime(year, month, day, hour, minute, second, 0).Ticks;
}
@@ -237,7 +230,6 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(millisecond), SR.Format(SR.ArgumentOutOfRange_Range, 0, MillisPerSecond - 1));
}
- Contract.EndContractBlock();
Int64 ticks = DateToTicks(year, month, day) + TimeToTicks(hour, minute, second);
ticks += millisecond * TicksPerMillisecond;
if (ticks < MinTicks || ticks > MaxTicks)
@@ -255,7 +247,6 @@ namespace System
{
throw new ArgumentException(SR.Argument_InvalidDateTimeKind, nameof(kind));
}
- Contract.EndContractBlock();
Int64 ticks = DateToTicks(year, month, day) + TimeToTicks(hour, minute, second);
ticks += millisecond * TicksPerMillisecond;
if (ticks < MinTicks || ticks > MaxTicks)
@@ -274,7 +265,6 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(millisecond), SR.Format(SR.ArgumentOutOfRange_Range, 0, MillisPerSecond - 1));
}
- Contract.EndContractBlock();
Int64 ticks = calendar.ToDateTime(year, month, day, hour, minute, second, 0).Ticks;
ticks += millisecond * TicksPerMillisecond;
if (ticks < MinTicks || ticks > MaxTicks)
@@ -294,7 +284,6 @@ namespace System
{
throw new ArgumentException(SR.Argument_InvalidDateTimeKind, nameof(kind));
}
- Contract.EndContractBlock();
Int64 ticks = calendar.ToDateTime(year, month, day, hour, minute, second, 0).Ticks;
ticks += millisecond * TicksPerMillisecond;
if (ticks < MinTicks || ticks > MaxTicks)
@@ -306,7 +295,6 @@ namespace System
{
if (info == null)
throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
Boolean foundTicks = false;
Boolean foundDateData = false;
@@ -452,7 +440,6 @@ namespace System
public DateTime AddMonths(int months)
{
if (months < -120000 || months > 120000) throw new ArgumentOutOfRangeException(nameof(months), SR.ArgumentOutOfRange_DateTimeBadMonths);
- Contract.EndContractBlock();
GetDatePart(out int y, out int m, out int d);
int i = m - 1 + months;
if (i >= 0)
@@ -515,7 +502,6 @@ namespace System
// parameter name out of the two for the exception.
throw new ArgumentOutOfRangeException("years", SR.ArgumentOutOfRange_DateTimeBadYears);
}
- Contract.EndContractBlock();
return AddMonths(value * 12);
}
@@ -589,7 +575,6 @@ namespace System
public static int DaysInMonth(int year, int month)
{
if (month < 1 || month > 12) throw new ArgumentOutOfRangeException(nameof(month), SR.ArgumentOutOfRange_Month);
- Contract.EndContractBlock();
// IsLeapYear checks the year argument
int[] days = IsLeapYear(year) ? s_daysToMonth366 : s_daysToMonth365;
return days[month] - days[month - 1];
@@ -725,7 +710,6 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(fileTime), SR.ArgumentOutOfRange_FileTimeInvalid);
}
- Contract.EndContractBlock();
// This is the ticks in Universal time for this fileTime.
long universalTicks = fileTime + FileTimeOffset;
@@ -745,7 +729,6 @@ namespace System
{
throw new ArgumentNullException(nameof(info));
}
- Contract.EndContractBlock();
// Serialize both the old and the new format
info.AddValue(TicksField, InternalTicks);
@@ -909,8 +892,6 @@ namespace System
{
get
{
- Contract.Ensures(Contract.Result<int>() >= 1);
- Contract.Ensures(Contract.Result<int>() <= 31);
return GetDatePart(DatePartDay);
}
}
@@ -924,8 +905,6 @@ namespace System
{
get
{
- Contract.Ensures(Contract.Result<DayOfWeek>() >= DayOfWeek.Sunday);
- Contract.Ensures(Contract.Result<DayOfWeek>() <= DayOfWeek.Saturday);
return (DayOfWeek)((InternalTicks / TicksPerDay + 1) % 7);
}
}
@@ -937,8 +916,6 @@ namespace System
{
get
{
- Contract.Ensures(Contract.Result<int>() >= 1);
- Contract.Ensures(Contract.Result<int>() <= 366); // leap year
return GetDatePart(DatePartDayOfYear);
}
}
@@ -958,8 +935,6 @@ namespace System
{
get
{
- Contract.Ensures(Contract.Result<int>() >= 0);
- Contract.Ensures(Contract.Result<int>() < 24);
return (int)((InternalTicks / TicksPerHour) % 24);
}
}
@@ -969,7 +944,6 @@ namespace System
return (InternalKind == KindLocalAmbiguousDst);
}
- [Pure]
public DateTimeKind Kind
{
get
@@ -993,8 +967,6 @@ namespace System
{
get
{
- Contract.Ensures(Contract.Result<int>() >= 0);
- Contract.Ensures(Contract.Result<int>() < 1000);
return (int)((InternalTicks / TicksPerMillisecond) % 1000);
}
}
@@ -1006,8 +978,6 @@ namespace System
{
get
{
- Contract.Ensures(Contract.Result<int>() >= 0);
- Contract.Ensures(Contract.Result<int>() < 60);
return (int)((InternalTicks / TicksPerMinute) % 60);
}
}
@@ -1019,7 +989,6 @@ namespace System
{
get
{
- Contract.Ensures(Contract.Result<int>() >= 1);
return GetDatePart(DatePartMonth);
}
}
@@ -1030,8 +999,6 @@ namespace System
{
get
{
- Contract.Ensures(Contract.Result<DateTime>().Kind == DateTimeKind.Local);
-
DateTime utc = UtcNow;
Boolean isAmbiguousLocalDst = false;
Int64 offset = TimeZoneInfo.GetDateTimeNowUtcOffsetFromUtc(utc, out isAmbiguousLocalDst).Ticks;
@@ -1055,8 +1022,6 @@ namespace System
{
get
{
- Contract.Ensures(Contract.Result<int>() >= 0);
- Contract.Ensures(Contract.Result<int>() < 60);
return (int)((InternalTicks / TicksPerSecond) % 60);
}
}
@@ -1103,7 +1068,6 @@ namespace System
{
get
{
- Contract.Ensures(Contract.Result<int>() >= 1 && Contract.Result<int>() <= 9999);
return GetDatePart(DatePartYear);
}
}
@@ -1117,7 +1081,6 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(year), SR.ArgumentOutOfRange_Year);
}
- Contract.EndContractBlock();
return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
}
@@ -1265,49 +1228,41 @@ namespace System
public String ToLongDateString()
{
- Contract.Ensures(Contract.Result<String>() != null);
return DateTimeFormat.Format(this, "D", DateTimeFormatInfo.CurrentInfo);
}
public String ToLongTimeString()
{
- Contract.Ensures(Contract.Result<String>() != null);
return DateTimeFormat.Format(this, "T", DateTimeFormatInfo.CurrentInfo);
}
public String ToShortDateString()
{
- Contract.Ensures(Contract.Result<String>() != null);
return DateTimeFormat.Format(this, "d", DateTimeFormatInfo.CurrentInfo);
}
public String ToShortTimeString()
{
- Contract.Ensures(Contract.Result<String>() != null);
return DateTimeFormat.Format(this, "t", DateTimeFormatInfo.CurrentInfo);
}
public override String ToString()
{
- Contract.Ensures(Contract.Result<String>() != null);
return DateTimeFormat.Format(this, null, DateTimeFormatInfo.CurrentInfo);
}
public String ToString(String format)
{
- Contract.Ensures(Contract.Result<String>() != null);
return DateTimeFormat.Format(this, format, DateTimeFormatInfo.CurrentInfo);
}
public String ToString(IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<String>() != null);
return DateTimeFormat.Format(this, null, DateTimeFormatInfo.GetInstance(provider));
}
public String ToString(String format, IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<String>() != null);
return DateTimeFormat.Format(this, format, DateTimeFormatInfo.GetInstance(provider));
}
@@ -1402,7 +1357,6 @@ namespace System
// time strings for the current instance of DateTime.
public String[] GetDateTimeFormats()
{
- Contract.Ensures(Contract.Result<String[]>() != null);
return (GetDateTimeFormats(CultureInfo.CurrentCulture));
}
@@ -1411,7 +1365,6 @@ namespace System
// time strings for the current instance of DateTime.
public String[] GetDateTimeFormats(IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<String[]>() != null);
return (DateTimeFormat.GetAllDateTimes(this, DateTimeFormatInfo.GetInstance(provider)));
}
@@ -1421,7 +1374,6 @@ namespace System
// time strings for the current instance of DateTime.
public String[] GetDateTimeFormats(char format)
{
- Contract.Ensures(Contract.Result<String[]>() != null);
return (GetDateTimeFormats(format, CultureInfo.CurrentCulture));
}
@@ -1430,7 +1382,6 @@ namespace System
// time strings for the current instance of DateTime.
public String[] GetDateTimeFormats(char format, IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<String[]>() != null);
return (DateTimeFormat.GetAllDateTimes(this, format, DateTimeFormatInfo.GetInstance(provider)));
}
diff --git a/src/mscorlib/shared/System/Diagnostics/Tracing/ActivityTracker.cs b/src/mscorlib/shared/System/Diagnostics/Tracing/ActivityTracker.cs
index bb52a9bb94..cb0526c1cc 100644
--- a/src/mscorlib/shared/System/Diagnostics/Tracing/ActivityTracker.cs
+++ b/src/mscorlib/shared/System/Diagnostics/Tracing/ActivityTracker.cs
@@ -5,12 +5,6 @@
using System;
using System.Diagnostics;
using System.Threading;
-#if !ES_BUILD_AGAINST_DOTNET_V35
-using Contract = System.Diagnostics.Contracts.Contract;
-#else
-using Contract = Microsoft.Diagnostics.Contracts.Internal.Contract;
-#endif
-
#if ES_BUILD_STANDALONE
namespace Microsoft.Diagnostics.Tracing
#else
@@ -43,7 +37,6 @@ namespace System.Diagnostics.Tracing
/// </summary>
internal class ActivityTracker
{
-
/// <summary>
/// Called on work item begins. The activity name = providerName + activityName without 'Start' suffix.
/// It updates CurrentActivityId to track.
diff --git a/src/mscorlib/shared/System/Diagnostics/Tracing/EventDescriptor.cs b/src/mscorlib/shared/System/Diagnostics/Tracing/EventDescriptor.cs
index 8fb471a99f..6dce32ce99 100644
--- a/src/mscorlib/shared/System/Diagnostics/Tracing/EventDescriptor.cs
+++ b/src/mscorlib/shared/System/Diagnostics/Tracing/EventDescriptor.cs
@@ -9,12 +9,6 @@ using System.Runtime.InteropServices;
using Environment = Microsoft.Diagnostics.Tracing.Internal.Environment;
#endif
-#if !ES_BUILD_AGAINST_DOTNET_V35
-using Contract = System.Diagnostics.Contracts.Contract;
-#else
-using Contract = Microsoft.Diagnostics.Contracts.Internal.Contract;
-#endif
-
#if ES_BUILD_STANDALONE
namespace Microsoft.Diagnostics.Tracing
#else
diff --git a/src/mscorlib/shared/System/Diagnostics/Tracing/EventProvider.cs b/src/mscorlib/shared/System/Diagnostics/Tracing/EventProvider.cs
index a74125a35a..d9f1747131 100644
--- a/src/mscorlib/shared/System/Diagnostics/Tracing/EventProvider.cs
+++ b/src/mscorlib/shared/System/Diagnostics/Tracing/EventProvider.cs
@@ -14,12 +14,6 @@ using System.Security.Permissions;
using System.Threading;
using System;
-#if !ES_BUILD_AGAINST_DOTNET_V35
-using Contract = System.Diagnostics.Contracts.Contract;
-#else
-using Contract = Microsoft.Diagnostics.Contracts.Internal.Contract;
-#endif
-
#if ES_BUILD_AGAINST_DOTNET_V35
using Microsoft.Internal; // for Tuple (can't define alias for open generic types so we "use" the whole namespace)
#endif
@@ -634,7 +628,6 @@ namespace System.Diagnostics.Tracing
if ((level <= m_level) ||
(m_level == 0))
{
-
//
// Check if Keyword is enabled
//
diff --git a/src/mscorlib/shared/System/Diagnostics/Tracing/EventSource.cs b/src/mscorlib/shared/System/Diagnostics/Tracing/EventSource.cs
index 4e436e7baf..fb15213984 100644
--- a/src/mscorlib/shared/System/Diagnostics/Tracing/EventSource.cs
+++ b/src/mscorlib/shared/System/Diagnostics/Tracing/EventSource.cs
@@ -197,12 +197,6 @@ using System.Threading.Tasks;
using Microsoft.Reflection;
-#if !ES_BUILD_AGAINST_DOTNET_V35
-using Contract = System.Diagnostics.Contracts.Contract;
-#else
-using Contract = Microsoft.Diagnostics.Contracts.Internal.Contract;
-#endif
-
#if CORECLR || ES_BUILD_PN
using Internal.Runtime.Augments;
#endif
@@ -250,7 +244,6 @@ namespace System.Diagnostics.Tracing
/// </remarks>
public partial class EventSource : IDisposable
{
-
#if FEATURE_EVENTSOURCE_XPLAT
private static readonly EventListener persistent_Xplat_Listener = XplatEventLogger.InitializePersistentListener();
#endif //FEATURE_EVENTSOURCE_XPLAT
@@ -405,7 +398,6 @@ namespace System.Diagnostics.Tracing
{
if (eventSourceType == null)
throw new ArgumentNullException(nameof(eventSourceType));
- Contract.EndContractBlock();
EventSourceAttribute attrib = (EventSourceAttribute)GetCustomAttributeHelper(eventSourceType, typeof(EventSourceAttribute));
string name = eventSourceType.Name;
@@ -473,7 +465,6 @@ namespace System.Diagnostics.Tracing
{
if (eventSourceType == null)
throw new ArgumentNullException(nameof(eventSourceType));
- Contract.EndContractBlock();
byte[] manifestBytes = EventSource.CreateManifestAndDescriptors(eventSourceType, assemblyPathToIncludeInManifest, null, flags);
return (manifestBytes == null) ? null : Encoding.UTF8.GetString(manifestBytes, 0, manifestBytes.Length);
@@ -1259,7 +1250,6 @@ namespace System.Diagnostics.Tracing
#if FEATURE_MANAGED_ETW
if (m_eventData[eventId].EnabledForETW)
{
-
#if FEATURE_ACTIVITYSAMPLING
// this code should be kept in sync with WriteEventVarargs().
SessionMask etwSessions = SessionMask.All;
@@ -1623,7 +1613,6 @@ namespace System.Diagnostics.Tracing
{
if (eventSourceType == null)
throw new ArgumentNullException(nameof(eventSourceType));
- Contract.EndContractBlock();
EventSourceAttribute attrib = (EventSourceAttribute)GetCustomAttributeHelper(eventSourceType, typeof(EventSourceAttribute), flags);
if (attrib != null && attrib.Name != null)
@@ -3599,7 +3588,6 @@ namespace System.Diagnostics.Tracing
string.Compare(startEventMetadata.Name, 0, taskName, 0, taskName.Length) == 0 &&
string.Compare(startEventMetadata.Name, taskName.Length, s_ActivityStartSuffix, 0, Math.Max(startEventMetadata.Name.Length - taskName.Length, s_ActivityStartSuffix.Length)) == 0)
{
-
// Make the stop event match the start event
eventAttribute.Task = (EventTask)startEventMetadata.Descriptor.Task;
noTask = false;
@@ -4455,7 +4443,6 @@ namespace System.Diagnostics.Tracing
{
throw new ArgumentNullException(nameof(eventSource));
}
- Contract.EndContractBlock();
eventSource.SendCommand(this, 0, 0, EventCommand.Update, true, level, matchAnyKeyword, arguments);
}
@@ -4470,7 +4457,6 @@ namespace System.Diagnostics.Tracing
{
throw new ArgumentNullException(nameof(eventSource));
}
- Contract.EndContractBlock();
eventSource.SendCommand(this, 0, 0, EventCommand.Update, false, EventLevel.LogAlways, EventKeywords.None, null);
}
@@ -4946,7 +4932,6 @@ namespace System.Diagnostics.Tracing
// do the lazy init if you know it is contract based (EventID >= 0)
if (EventId >= 0 && m_payloadNames == null)
{
-
var names = new List<string>();
foreach (var parameter in m_eventSource.m_eventData[EventId].Parameters)
{
@@ -6461,7 +6446,6 @@ namespace System.Diagnostics.Tracing
private string CreateManifestString()
{
-
#if FEATURE_MANAGED_ETW_CHANNELS
// Write out the channels
if (channelTab != null)
@@ -6529,7 +6513,6 @@ namespace System.Diagnostics.Tracing
// Write out the tasks
if (taskTab != null)
{
-
sb.Append(" <tasks>").AppendLine();
var sortedTasks = new List<int>(taskTab.Keys);
sortedTasks.Sort();
diff --git a/src/mscorlib/shared/System/Diagnostics/Tracing/StubEnvironment.cs b/src/mscorlib/shared/System/Diagnostics/Tracing/StubEnvironment.cs
index b365841d5f..5797d4d09c 100644
--- a/src/mscorlib/shared/System/Diagnostics/Tracing/StubEnvironment.cs
+++ b/src/mscorlib/shared/System/Diagnostics/Tracing/StubEnvironment.cs
@@ -52,29 +52,6 @@ namespace System.Diagnostics.Tracing.Internal
#if ES_BUILD_AGAINST_DOTNET_V35
-namespace Microsoft.Diagnostics.Contracts.Internal
-{
- internal class Contract
- {
- public static void Assert(bool invariant)
- {
- Assert(invariant, string.Empty);
- }
- public static void Assert(bool invariant, string message)
- {
- if (!invariant)
- {
- if (System.Diagnostics.Debugger.IsAttached)
- System.Diagnostics.Debugger.Break();
- throw new Exception("Assertion failed: " + message);
- }
- }
- public static void EndContractBlock()
- { }
- }
-}
-
-
namespace Microsoft.Internal
{
using System.Text;
diff --git a/src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/EventPayload.cs b/src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/EventPayload.cs
index 5967ad6ab5..abe9ece13c 100644
--- a/src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/EventPayload.cs
+++ b/src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/EventPayload.cs
@@ -6,12 +6,6 @@ using System.Collections.Generic;
using System.Collections;
using System.Diagnostics;
-#if !ES_BUILD_AGAINST_DOTNET_V35
-using Contract = System.Diagnostics.Contracts.Contract;
-#else
-using Contract = Microsoft.Diagnostics.Contracts.Internal.Contract;
-#endif
-
#if ES_BUILD_STANDALONE
namespace Microsoft.Diagnostics.Tracing
#else
diff --git a/src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/EventSourceActivity.cs b/src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/EventSourceActivity.cs
index acc3eeb233..ef2ec4715c 100644
--- a/src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/EventSourceActivity.cs
+++ b/src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/EventSourceActivity.cs
@@ -4,12 +4,6 @@
using System;
-#if !ES_BUILD_AGAINST_DOTNET_V35
-using Contract = System.Diagnostics.Contracts.Contract;
-#else
-using Contract = Microsoft.Diagnostics.Contracts.Internal.Contract;
-#endif
-
#if ES_BUILD_STANDALONE
namespace Microsoft.Diagnostics.Tracing
#else
@@ -36,7 +30,6 @@ namespace System.Diagnostics.Tracing
{
if (eventSource == null)
throw new ArgumentNullException(nameof(eventSource));
- Contract.EndContractBlock();
this.eventSource = eventSource;
}
diff --git a/src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/PropertyValue.cs b/src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/PropertyValue.cs
index aeee3ad9e3..d74494bc85 100644
--- a/src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/PropertyValue.cs
+++ b/src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/PropertyValue.cs
@@ -2,12 +2,6 @@
using System.Runtime.InteropServices;
using System.Diagnostics;
-#if !ES_BUILD_AGAINST_DOTNET_V35
-using Contract = System.Diagnostics.Contracts.Contract;
-#else
-using Contract = Microsoft.Diagnostics.Contracts.Internal.Contract;
-#endif
-
namespace System.Diagnostics.Tracing
{
/// <summary>
diff --git a/src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/SimpleTypeInfos.cs b/src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/SimpleTypeInfos.cs
index 901a0ed1a2..61cb92ffad 100644
--- a/src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/SimpleTypeInfos.cs
+++ b/src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/SimpleTypeInfos.cs
@@ -7,12 +7,6 @@ using System.Collections.Generic;
using System.Reflection;
using System.Diagnostics;
-#if !ES_BUILD_AGAINST_DOTNET_V35
-using Contract = System.Diagnostics.Contracts.Contract;
-#else
-using Contract = Microsoft.Diagnostics.Contracts.Internal.Contract;
-#endif
-
#if ES_BUILD_STANDALONE
namespace Microsoft.Diagnostics.Tracing
#else
diff --git a/src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventSource.cs b/src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventSource.cs
index a1218d1a7f..8d12b64a08 100644
--- a/src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventSource.cs
+++ b/src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventSource.cs
@@ -29,11 +29,9 @@ using System.Security;
using System.Collections.ObjectModel;
#if !ES_BUILD_AGAINST_DOTNET_V35
-using Contract = System.Diagnostics.Contracts.Contract;
using System.Collections.Generic;
using System.Text;
#else
-using Contract = Microsoft.Diagnostics.Contracts.Internal.Contract;
using System.Collections.Generic;
using System.Text;
#endif
@@ -102,7 +100,6 @@ namespace System.Diagnostics.Tracing
{
throw new ArgumentNullException(nameof(eventSourceName));
}
- Contract.EndContractBlock();
}
/// <summary>
@@ -117,7 +114,6 @@ namespace System.Diagnostics.Tracing
throw new ArgumentNullException(nameof(eventName));
}
- Contract.EndContractBlock();
if (!this.IsEnabled())
{
@@ -144,7 +140,6 @@ namespace System.Diagnostics.Tracing
throw new ArgumentNullException(nameof(eventName));
}
- Contract.EndContractBlock();
if (!this.IsEnabled())
{
diff --git a/src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventTypes.cs b/src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventTypes.cs
index c2239671bb..d024b218d8 100644
--- a/src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventTypes.cs
+++ b/src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventTypes.cs
@@ -6,12 +6,6 @@ using System;
using System.Collections.Generic;
using Interlocked = System.Threading.Interlocked;
-#if !ES_BUILD_AGAINST_DOTNET_V35
-using Contract = System.Diagnostics.Contracts.Contract;
-#else
-using Contract = Microsoft.Diagnostics.Contracts.Internal.Contract;
-#endif
-
#if ES_BUILD_STANDALONE
namespace Microsoft.Diagnostics.Tracing
#else
@@ -97,7 +91,6 @@ namespace System.Diagnostics.Tracing
throw new ArgumentNullException(nameof(name));
}
- Contract.EndContractBlock();
this.typeInfos = MakeArray(paramInfos);
this.name = name;
@@ -135,7 +128,6 @@ namespace System.Diagnostics.Tracing
throw new ArgumentNullException(nameof(defaultName));
}
- Contract.EndContractBlock();
this.typeInfos = typeInfos;
this.name = defaultName;
@@ -215,7 +207,6 @@ namespace System.Diagnostics.Tracing
throw new ArgumentNullException(nameof(paramInfos));
}
- Contract.EndContractBlock();
var recursionCheck = new List<Type>(paramInfos.Length);
var result = new TraceLoggingTypeInfo[paramInfos.Length];
@@ -234,7 +225,6 @@ namespace System.Diagnostics.Tracing
throw new ArgumentNullException(nameof(types));
}
- Contract.EndContractBlock();
var recursionCheck = new List<Type>(types.Length);
var result = new TraceLoggingTypeInfo[types.Length];
@@ -254,7 +244,6 @@ namespace System.Diagnostics.Tracing
throw new ArgumentNullException(nameof(typeInfos));
}
- Contract.EndContractBlock();
return (TraceLoggingTypeInfo[])typeInfos.Clone(); ;
}
diff --git a/src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/TraceLoggingTypeInfo.cs b/src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/TraceLoggingTypeInfo.cs
index d68e106b0b..81f80c63f7 100644
--- a/src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/TraceLoggingTypeInfo.cs
+++ b/src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/TraceLoggingTypeInfo.cs
@@ -5,12 +5,6 @@
using System;
using System.Collections.Generic;
-#if !ES_BUILD_AGAINST_DOTNET_V35
-using Contract = System.Diagnostics.Contracts.Contract;
-#else
-using Contract = Microsoft.Diagnostics.Contracts.Internal.Contract;
-#endif
-
#if ES_BUILD_STANDALONE
namespace Microsoft.Diagnostics.Tracing
#else
@@ -39,7 +33,6 @@ namespace System.Diagnostics.Tracing
throw new ArgumentNullException(nameof(dataType));
}
- Contract.EndContractBlock();
this.name = dataType.Name;
this.dataType = dataType;
@@ -64,7 +57,6 @@ namespace System.Diagnostics.Tracing
throw new ArgumentNullException(nameof(name));
}
- Contract.EndContractBlock();
Statics.CheckName(name);
diff --git a/src/mscorlib/shared/System/Double.cs b/src/mscorlib/shared/System/Double.cs
index 7ee52027f3..363c896fa8 100644
--- a/src/mscorlib/shared/System/Double.cs
+++ b/src/mscorlib/shared/System/Double.cs
@@ -12,7 +12,6 @@
**
===========================================================*/
-using System.Diagnostics.Contracts;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -44,7 +43,6 @@ namespace System
internal const double NegativeZero = -0.0;
/// <summary>Determines whether the specified value is finite (zero, subnormal, or normal).</summary>
- [Pure]
[NonVersionable]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe static bool IsFinite(double d)
@@ -54,7 +52,6 @@ namespace System
}
/// <summary>Determines whether the specified value is infinite.</summary>
- [Pure]
[NonVersionable]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe static bool IsInfinity(double d)
@@ -64,7 +61,6 @@ namespace System
}
/// <summary>Determines whether the specified value is NaN.</summary>
- [Pure]
[NonVersionable]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe static bool IsNaN(double d)
@@ -74,7 +70,6 @@ namespace System
}
/// <summary>Determines whether the specified value is negative.</summary>
- [Pure]
[NonVersionable]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe static bool IsNegative(double d)
@@ -84,7 +79,6 @@ namespace System
}
/// <summary>Determines whether the specified value is negative infinity.</summary>
- [Pure]
[NonVersionable]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsNegativeInfinity(double d)
@@ -93,7 +87,6 @@ namespace System
}
/// <summary>Determines whether the specified value is normal.</summary>
- [Pure]
[NonVersionable]
// This is probably not worth inlining, it has branches and should be rarely called
public unsafe static bool IsNormal(double d)
@@ -104,7 +97,6 @@ namespace System
}
/// <summary>Determines whether the specified value is positive infinity.</summary>
- [Pure]
[NonVersionable]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsPositiveInfinity(double d)
@@ -113,7 +105,6 @@ namespace System
}
/// <summary>Determines whether the specified value is subnormal.</summary>
- [Pure]
[NonVersionable]
// This is probably not worth inlining, it has branches and should be rarely called
public unsafe static bool IsSubnormal(double d)
@@ -244,25 +235,21 @@ namespace System
public override String ToString()
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatDouble(m_value, null, NumberFormatInfo.CurrentInfo);
}
public String ToString(String format)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatDouble(m_value, format, NumberFormatInfo.CurrentInfo);
}
public String ToString(IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatDouble(m_value, null, NumberFormatInfo.GetInstance(provider));
}
public String ToString(String format, IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatDouble(m_value, format, NumberFormatInfo.GetInstance(provider));
}
diff --git a/src/mscorlib/shared/System/Globalization/Calendar.cs b/src/mscorlib/shared/System/Globalization/Calendar.cs
index e6ab2477d6..49ad597ceb 100644
--- a/src/mscorlib/shared/System/Globalization/Calendar.cs
+++ b/src/mscorlib/shared/System/Globalization/Calendar.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.Serialization;
namespace System.Globalization
@@ -151,7 +150,6 @@ namespace System.Globalization
public static Calendar ReadOnly(Calendar calendar)
{
if (calendar == null) { throw new ArgumentNullException(nameof(calendar)); }
- Contract.EndContractBlock();
if (calendar.IsReadOnly) { return (calendar); }
Calendar clonedCalendar = (Calendar)(calendar.MemberwiseClone());
@@ -211,7 +209,6 @@ namespace System.Globalization
String.Format(CultureInfo.InvariantCulture, SR.Format(SR.Argument_ResultCalendarRange,
minValue, maxValue)));
}
- Contract.EndContractBlock();
}
internal DateTime Add(DateTime time, double value, int scale)
@@ -633,7 +630,6 @@ namespace System.Globalization
nameof(firstDayOfWeek), SR.Format(SR.ArgumentOutOfRange_Range,
DayOfWeek.Sunday, DayOfWeek.Saturday));
}
- Contract.EndContractBlock();
switch (rule)
{
case CalendarWeekRule.FirstDay:
@@ -803,7 +799,6 @@ namespace System.Globalization
throw new ArgumentOutOfRangeException(nameof(year),
SR.ArgumentOutOfRange_NeedNonNegNum);
}
- Contract.EndContractBlock();
if (year < 100)
{
return ((TwoDigitYearMax / 100 - (year > TwoDigitYearMax % 100 ? 1 : 0)) * 100 + year);
diff --git a/src/mscorlib/shared/System/Globalization/CalendarData.Unix.cs b/src/mscorlib/shared/System/Globalization/CalendarData.Unix.cs
index a2ceeb1e67..35ee82d3cb 100644
--- a/src/mscorlib/shared/System/Globalization/CalendarData.Unix.cs
+++ b/src/mscorlib/shared/System/Globalization/CalendarData.Unix.cs
@@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using System.Security;
using System.Text;
diff --git a/src/mscorlib/shared/System/Globalization/ChineseLunisolarCalendar.cs b/src/mscorlib/shared/System/Globalization/ChineseLunisolarCalendar.cs
index e09011a9d8..d2b52b97be 100644
--- a/src/mscorlib/shared/System/Globalization/ChineseLunisolarCalendar.cs
+++ b/src/mscorlib/shared/System/Globalization/ChineseLunisolarCalendar.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Diagnostics.Contracts;
namespace System.Globalization
{
@@ -320,7 +319,6 @@ namespace System.Globalization
CultureInfo.CurrentCulture,
SR.ArgumentOutOfRange_Range, MIN_LUNISOLAR_YEAR, MAX_LUNISOLAR_YEAR));
}
- Contract.EndContractBlock();
return s_yinfo[lunarYear - MIN_LUNISOLAR_YEAR, index];
}
@@ -345,7 +343,6 @@ namespace System.Globalization
CultureInfo.CurrentCulture,
SR.ArgumentOutOfRange_Range, MIN_LUNISOLAR_YEAR, MAX_LUNISOLAR_YEAR));
}
- Contract.EndContractBlock();
return year;
}
diff --git a/src/mscorlib/shared/System/Globalization/CultureData.Unix.cs b/src/mscorlib/shared/System/Globalization/CultureData.Unix.cs
index 4f685de580..c21d8c3f22 100644
--- a/src/mscorlib/shared/System/Globalization/CultureData.Unix.cs
+++ b/src/mscorlib/shared/System/Globalization/CultureData.Unix.cs
@@ -5,7 +5,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using System.Security;
using System.Text;
diff --git a/src/mscorlib/shared/System/Globalization/DateTimeFormat.cs b/src/mscorlib/shared/System/Globalization/DateTimeFormat.cs
index d6afc1b099..f129f73136 100644
--- a/src/mscorlib/shared/System/Globalization/DateTimeFormat.cs
+++ b/src/mscorlib/shared/System/Globalization/DateTimeFormat.cs
@@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Globalization;
using System.Text;
@@ -970,7 +969,7 @@ namespace System
internal static String Format(DateTime dateTime, String format, DateTimeFormatInfo dtfi, TimeSpan offset)
{
- Contract.Requires(dtfi != null);
+ Debug.Assert(dtfi != null);
if (format == null || format.Length == 0)
{
Boolean timeOnlySpecialCase = false;
@@ -1130,7 +1129,7 @@ namespace System
internal static String[] GetAllDateTimes(DateTime dateTime, char format, DateTimeFormatInfo dtfi)
{
- Contract.Requires(dtfi != null);
+ Debug.Assert(dtfi != null);
String[] allFormats = null;
String[] results = null;
diff --git a/src/mscorlib/shared/System/Globalization/DateTimeFormatInfo.cs b/src/mscorlib/shared/System/Globalization/DateTimeFormatInfo.cs
index 9f8c072c93..7c4200af7b 100644
--- a/src/mscorlib/shared/System/Globalization/DateTimeFormatInfo.cs
+++ b/src/mscorlib/shared/System/Globalization/DateTimeFormatInfo.cs
@@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.Serialization;
namespace System.Globalization
@@ -430,7 +429,6 @@ namespace System.Globalization
{
get
{
- Contract.Ensures(Contract.Result<DateTimeFormatInfo>() != null);
if (s_invariantInfo == null)
{
DateTimeFormatInfo info = new DateTimeFormatInfo();
@@ -449,7 +447,6 @@ namespace System.Globalization
{
get
{
- Contract.Ensures(Contract.Result<DateTimeFormatInfo>() != null);
System.Globalization.CultureInfo culture = System.Globalization.CultureInfo.CurrentCulture;
if (!culture._isInherited)
{
@@ -531,7 +528,6 @@ namespace System.Globalization
throw new ArgumentNullException(nameof(value),
SR.ArgumentNull_String);
}
- Contract.EndContractBlock();
ClearTokenHashTable();
amDesignator = value;
}
@@ -542,8 +538,6 @@ namespace System.Globalization
{
get
{
- Contract.Ensures(Contract.Result<Calendar>() != null);
-
Debug.Assert(this.calendar != null, "DateTimeFormatInfo.Calendar: calendar != null");
return (this.calendar);
}
@@ -556,7 +550,6 @@ namespace System.Globalization
{
throw new ArgumentNullException(nameof(value), SR.ArgumentNull_Obj);
}
- Contract.EndContractBlock();
if (value == calendar)
{
return;
@@ -664,7 +657,6 @@ namespace System.Globalization
throw new ArgumentNullException(nameof(eraName),
SR.ArgumentNull_String);
}
- Contract.EndContractBlock();
// The Era Name and Abbreviated Era Name
// for Taiwan Calendar on non-Taiwan SKU returns empty string (which
@@ -820,7 +812,6 @@ namespace System.Globalization
{
throw new ArgumentNullException(nameof(value), SR.ArgumentNull_String);
}
- Contract.EndContractBlock();
ClearTokenHashTable();
dateSeparator = value;
}
@@ -905,7 +896,6 @@ namespace System.Globalization
throw new ArgumentNullException(nameof(value),
SR.ArgumentNull_String);
}
- Contract.EndContractBlock();
fullDateTimePattern = value;
}
}
@@ -939,7 +929,6 @@ namespace System.Globalization
throw new ArgumentNullException(nameof(value),
SR.ArgumentNull_String);
}
- Contract.EndContractBlock();
// Remember the new string
this.longDatePattern = value;
@@ -980,7 +969,6 @@ namespace System.Globalization
throw new ArgumentNullException(nameof(value),
SR.ArgumentNull_String);
}
- Contract.EndContractBlock();
// Remember the new string
this.longTimePattern = value;
@@ -1019,7 +1007,6 @@ namespace System.Globalization
throw new ArgumentNullException(nameof(value),
SR.ArgumentNull_String);
}
- Contract.EndContractBlock();
this.monthDayPattern = value;
}
@@ -1047,7 +1034,6 @@ namespace System.Globalization
throw new ArgumentNullException(nameof(value),
SR.ArgumentNull_String);
}
- Contract.EndContractBlock();
ClearTokenHashTable();
pmDesignator = value;
@@ -1089,7 +1075,6 @@ namespace System.Globalization
if (value == null)
throw new ArgumentNullException(nameof(value),
SR.ArgumentNull_String);
- Contract.EndContractBlock();
// Remember the new string
this.shortDatePattern = value;
@@ -1132,7 +1117,6 @@ namespace System.Globalization
throw new ArgumentNullException(nameof(value),
SR.ArgumentNull_String);
}
- Contract.EndContractBlock();
// Remember the new string
this.shortTimePattern = value;
@@ -1289,7 +1273,6 @@ namespace System.Globalization
throw new ArgumentNullException(nameof(value), SR.ArgumentNull_String);
}
- Contract.EndContractBlock();
ClearTokenHashTable();
timeSeparator = value;
@@ -1331,7 +1314,6 @@ namespace System.Globalization
throw new ArgumentNullException(nameof(value),
SR.ArgumentNull_String);
}
- Contract.EndContractBlock();
// Remember the new string
this.yearMonthPattern = value;
@@ -1379,7 +1361,6 @@ namespace System.Globalization
{
throw new ArgumentException(SR.Format(SR.Argument_InvalidArrayLength, 7), nameof(value));
}
- Contract.EndContractBlock();
CheckNullValue(value, value.Length);
ClearTokenHashTable();
@@ -1408,7 +1389,6 @@ namespace System.Globalization
{
throw new ArgumentException(SR.Format(SR.Argument_InvalidArrayLength, 7), nameof(value));
}
- Contract.EndContractBlock();
CheckNullValue(value, value.Length);
this.m_superShortDayNames = value;
}
@@ -1435,7 +1415,6 @@ namespace System.Globalization
{
throw new ArgumentException(SR.Format(SR.Argument_InvalidArrayLength, 7), nameof(value));
}
- Contract.EndContractBlock();
CheckNullValue(value, value.Length);
ClearTokenHashTable();
@@ -1464,7 +1443,6 @@ namespace System.Globalization
{
throw new ArgumentException(SR.Format(SR.Argument_InvalidArrayLength, 13), nameof(value));
}
- Contract.EndContractBlock();
CheckNullValue(value, value.Length - 1);
ClearTokenHashTable();
abbreviatedMonthNames = value;
@@ -1492,7 +1470,6 @@ namespace System.Globalization
{
throw new ArgumentException(SR.Format(SR.Argument_InvalidArrayLength, 13), nameof(value));
}
- Contract.EndContractBlock();
CheckNullValue(value, value.Length - 1);
monthNames = value;
ClearTokenHashTable();
@@ -1620,7 +1597,6 @@ namespace System.Globalization
nameof(dayofweek), SR.Format(SR.ArgumentOutOfRange_Range,
DayOfWeek.Sunday, DayOfWeek.Saturday));
}
- Contract.EndContractBlock();
//
// Don't call the public property AbbreviatedDayNames here since a clone is needed in that
// property, so it will be slower. Instead, use GetAbbreviatedDayOfWeekNames() directly.
@@ -1637,7 +1613,6 @@ namespace System.Globalization
nameof(dayOfWeek), SR.Format(SR.ArgumentOutOfRange_Range,
DayOfWeek.Sunday, DayOfWeek.Saturday));
}
- Contract.EndContractBlock();
//
// Don't call the public property SuperShortDayNames here since a clone is needed in that
// property, so it will be slower. Instead, use internalGetSuperShortDayNames() directly.
@@ -1686,7 +1661,6 @@ namespace System.Globalization
public string[] GetAllDateTimePatterns(char format)
{
- Contract.Ensures(Contract.Result<String[]>() != null);
String[] result = null;
switch (format)
@@ -1753,7 +1727,6 @@ namespace System.Globalization
nameof(dayofweek), SR.Format(SR.ArgumentOutOfRange_Range,
DayOfWeek.Sunday, DayOfWeek.Saturday));
}
- Contract.EndContractBlock();
// Use the internal one so that we don't clone the array unnecessarily
return (internalGetDayOfWeekNames()[(int)dayofweek]);
@@ -1769,7 +1742,6 @@ namespace System.Globalization
nameof(month), SR.Format(SR.ArgumentOutOfRange_Range,
1, 13));
}
- Contract.EndContractBlock();
// Use the internal one so we don't clone the array unnecessarily
return (internalGetAbbreviatedMonthNames()[month - 1]);
}
@@ -1783,7 +1755,6 @@ namespace System.Globalization
nameof(month), SR.Format(SR.ArgumentOutOfRange_Range,
1, 13));
}
- Contract.EndContractBlock();
// Use the internal one so we don't clone the array unnecessarily
return (internalGetMonthNames()[month - 1]);
}
@@ -1988,7 +1959,6 @@ namespace System.Globalization
throw new ArgumentNullException(nameof(dtfi),
SR.ArgumentNull_Obj);
}
- Contract.EndContractBlock();
if (dtfi.IsReadOnly)
{
return (dtfi);
@@ -2055,7 +2025,6 @@ namespace System.Globalization
throw new ArgumentException(SR.Arg_ArrayZeroError, nameof(patterns));
}
- Contract.EndContractBlock();
for (int i = 0; i < patterns.Length; i++)
{
@@ -2122,7 +2091,6 @@ namespace System.Globalization
{
throw new ArgumentException(SR.Format(SR.Argument_InvalidArrayLength, 13), nameof(value));
}
- Contract.EndContractBlock();
CheckNullValue(value, value.Length - 1);
ClearTokenHashTable();
this.m_genitiveAbbreviatedMonthNames = value;
@@ -2149,7 +2117,6 @@ namespace System.Globalization
{
throw new ArgumentException(SR.Format(SR.Argument_InvalidArrayLength, 13), nameof(value));
}
- Contract.EndContractBlock();
CheckNullValue(value, value.Length - 1);
genitiveMonthNames = value;
ClearTokenHashTable();
@@ -2229,7 +2196,6 @@ namespace System.Globalization
{
throw new ArgumentException(SR.Argument_ConflictingDateTimeStyles, parameterName);
}
- Contract.EndContractBlock();
if (((style & DateTimeStyles.RoundtripKind) != 0)
&& ((style & (DateTimeStyles.AssumeLocal | DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal)) != 0))
{
diff --git a/src/mscorlib/shared/System/Globalization/DateTimeFormatInfoScanner.cs b/src/mscorlib/shared/System/Globalization/DateTimeFormatInfoScanner.cs
index 15af1b7d84..c38e7a26b8 100644
--- a/src/mscorlib/shared/System/Globalization/DateTimeFormatInfoScanner.cs
+++ b/src/mscorlib/shared/System/Globalization/DateTimeFormatInfoScanner.cs
@@ -24,7 +24,6 @@ using System.Text;
namespace System.Globalization
{
-
#if CORECLR
using StringStringDictionary = Dictionary<string, string>;
using StringList = List<string>;
diff --git a/src/mscorlib/shared/System/Globalization/DateTimeParse.cs b/src/mscorlib/shared/System/Globalization/DateTimeParse.cs
index f821a95412..2825f0107e 100644
--- a/src/mscorlib/shared/System/Globalization/DateTimeParse.cs
+++ b/src/mscorlib/shared/System/Globalization/DateTimeParse.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Globalization;
using System.Text;
@@ -4678,7 +4677,6 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR,
// COMPlus_LogToConsole=1
// COMPlus_LogLevel=9
// COMPlus_ManagedLogFacility=0x00001000
- [Pure]
[Conditional("_LOGGING")]
internal static void LexTraceExit(string message, DS dps)
{
@@ -4688,7 +4686,6 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR,
BCLDebug.Trace("DATETIME", "[DATETIME] Lex return {0}, DS.{1}", message, dps);
#endif // _LOGGING
}
- [Pure]
[Conditional("_LOGGING")]
internal static void PTSTraceExit(DS dps, bool passed)
{
@@ -4698,7 +4695,6 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR,
BCLDebug.Trace("DATETIME", "[DATETIME] ProcessTerminalState {0} @ DS.{1}", passed ? "passed" : "failed", dps);
#endif // _LOGGING
}
- [Pure]
[Conditional("_LOGGING")]
internal static void TPTraceExit(string message, DS dps)
{
@@ -4708,7 +4704,6 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR,
BCLDebug.Trace("DATETIME", "[DATETIME] TryParse return {0}, DS.{1}", message, dps);
#endif // _LOGGING
}
- [Pure]
[Conditional("_LOGGING")]
internal static void DTFITrace(DateTimeFormatInfo dtfi)
{
@@ -4733,7 +4728,6 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR,
#endif // _LOGGING
}
#if _LOGGING
- [Pure]
// return a string in the form: "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
internal static string Hex(string[] strs)
{
@@ -4787,7 +4781,6 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR,
buffer.Append(s);
return buffer.ToString();
}
- [Pure]
// return a string in the form: "Sun"
internal static string Hex(string str)
{
@@ -4803,7 +4796,6 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR,
buffer.Append("\"");
return buffer.ToString();
}
- [Pure]
// return an unicode escaped string form of char c
internal static String Hex(char c)
{
diff --git a/src/mscorlib/shared/System/Globalization/EastAsianLunisolarCalendar.cs b/src/mscorlib/shared/System/Globalization/EastAsianLunisolarCalendar.cs
index 383e0cd17c..358f4df182 100644
--- a/src/mscorlib/shared/System/Globalization/EastAsianLunisolarCalendar.cs
+++ b/src/mscorlib/shared/System/Globalization/EastAsianLunisolarCalendar.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Diagnostics.Contracts;
namespace System.Globalization
{
@@ -62,7 +61,6 @@ namespace System.Globalization
nameof(sexagenaryYear),
SR.Format(SR.ArgumentOutOfRange_Range, 1, 60));
}
- Contract.EndContractBlock();
return ((sexagenaryYear - 1) % 10) + 1;
}
@@ -79,7 +77,6 @@ namespace System.Globalization
nameof(sexagenaryYear),
SR.Format(SR.ArgumentOutOfRange_Range, 1, 60));
}
- Contract.EndContractBlock();
return ((sexagenaryYear - 1) % 12) + 1;
}
@@ -168,7 +165,6 @@ namespace System.Globalization
String.Format(CultureInfo.InvariantCulture, SR.ArgumentOutOfRange_CalendarRange,
MinSupportedDateTime, MaxSupportedDateTime));
}
- Contract.EndContractBlock();
}
internal void CheckEraRange(int era)
@@ -440,7 +436,6 @@ namespace System.Globalization
nameof(months),
SR.Format(SR.ArgumentOutOfRange_Range, -120000, 120000));
}
- Contract.EndContractBlock();
CheckTicksRange(time.Ticks);
@@ -699,7 +694,6 @@ namespace System.Globalization
throw new ArgumentOutOfRangeException(nameof(year),
SR.ArgumentOutOfRange_NeedNonNegNum);
}
- Contract.EndContractBlock();
year = base.ToFourDigitYear(year);
CheckYearRange(year, CurrentEra);
diff --git a/src/mscorlib/shared/System/Globalization/GregorianCalendar.cs b/src/mscorlib/shared/System/Globalization/GregorianCalendar.cs
index 65041af15f..81058ff664 100644
--- a/src/mscorlib/shared/System/Globalization/GregorianCalendar.cs
+++ b/src/mscorlib/shared/System/Globalization/GregorianCalendar.cs
@@ -4,7 +4,6 @@
using System;
using System.Globalization;
-using System.Diagnostics.Contracts;
using System.Threading;
namespace System.Globalization
@@ -99,7 +98,6 @@ namespace System.Globalization
SR.Format(SR.ArgumentOutOfRange_Range,
GregorianCalendarTypes.Localized, GregorianCalendarTypes.TransliteratedFrench));
}
- Contract.EndContractBlock();
this.m_type = type;
}
@@ -214,7 +212,6 @@ namespace System.Globalization
-120000,
120000));
}
- Contract.EndContractBlock();
time.GetDatePart(out int y, out int m, out int d);
int i = m - 1 + months;
if (i >= 0)
@@ -396,7 +393,6 @@ namespace System.Globalization
throw new ArgumentOutOfRangeException(nameof(month), SR.Format(SR.ArgumentOutOfRange_Range,
1, 12));
}
- Contract.EndContractBlock();
if (era != CurrentEra && era != ADEra)
{
@@ -443,7 +439,6 @@ namespace System.Globalization
CultureInfo.CurrentCulture,
SR.ArgumentOutOfRange_Range, 1, MaxYear));
}
- Contract.EndContractBlock();
return (0);
}
@@ -472,7 +467,6 @@ namespace System.Globalization
throw new ArgumentOutOfRangeException(nameof(month), SR.Format(SR.ArgumentOutOfRange_Range,
1, 12));
}
- Contract.EndContractBlock();
return (false);
}
@@ -573,7 +567,6 @@ namespace System.Globalization
throw new ArgumentOutOfRangeException(nameof(year),
SR.ArgumentOutOfRange_NeedNonNegNum);
}
- Contract.EndContractBlock();
if (year > MaxYear)
{
diff --git a/src/mscorlib/shared/System/Globalization/GregorianCalendarHelper.cs b/src/mscorlib/shared/System/Globalization/GregorianCalendarHelper.cs
index d694202ed1..2842bd3a16 100644
--- a/src/mscorlib/shared/System/Globalization/GregorianCalendarHelper.cs
+++ b/src/mscorlib/shared/System/Globalization/GregorianCalendarHelper.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System;
-using System.Diagnostics.Contracts;
using System.Threading;
namespace System.Globalization
@@ -141,7 +140,6 @@ namespace System.Globalization
throw new ArgumentOutOfRangeException(nameof(year),
SR.ArgumentOutOfRange_NeedNonNegNum);
}
- Contract.EndContractBlock();
if (era == Calendar.CurrentEra)
{
@@ -323,7 +321,6 @@ namespace System.Globalization
m_Cal.MinSupportedDateTime,
m_Cal.MaxSupportedDateTime));
}
- Contract.EndContractBlock();
}
// Returns the DateTime resulting from adding the given number of
@@ -355,7 +352,6 @@ namespace System.Globalization
-120000,
120000));
}
- Contract.EndContractBlock();
CheckTicksRange(time.Ticks);
int y = GetDatePart(time.Ticks, DatePartYear);
@@ -427,7 +423,6 @@ namespace System.Globalization
// Returns the number of days in the month given by the year and
// month arguments.
//
- [Pure]
public int GetDaysInMonth(int year, int month, int era)
{
//
@@ -555,7 +550,6 @@ namespace System.Globalization
1,
GetDaysInMonth(year, month, era)));
}
- Contract.EndContractBlock();
if (!IsLeapYear(year, era))
{
@@ -633,7 +627,6 @@ namespace System.Globalization
throw new ArgumentOutOfRangeException(nameof(year),
SR.ArgumentOutOfRange_NeedPosNum);
}
- Contract.EndContractBlock();
if (year < 100)
{
diff --git a/src/mscorlib/shared/System/Globalization/HebrewCalendar.cs b/src/mscorlib/shared/System/Globalization/HebrewCalendar.cs
index 92f4cab4be..533d3831bf 100644
--- a/src/mscorlib/shared/System/Globalization/HebrewCalendar.cs
+++ b/src/mscorlib/shared/System/Globalization/HebrewCalendar.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Globalization
{
@@ -1095,7 +1094,6 @@ namespace System.Globalization
throw new ArgumentOutOfRangeException(nameof(year),
SR.ArgumentOutOfRange_NeedNonNegNum);
}
- Contract.EndContractBlock();
if (year < 100)
{
diff --git a/src/mscorlib/shared/System/Globalization/HijriCalendar.cs b/src/mscorlib/shared/System/Globalization/HijriCalendar.cs
index 59b354f534..6755844620 100644
--- a/src/mscorlib/shared/System/Globalization/HijriCalendar.cs
+++ b/src/mscorlib/shared/System/Globalization/HijriCalendar.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Diagnostics.Contracts;
namespace System.Globalization
{
@@ -198,7 +197,6 @@ namespace System.Globalization
MinAdvancedHijri,
MaxAdvancedHijri));
}
- Contract.EndContractBlock();
VerifyWritable();
_hijriAdvance = value;
@@ -395,7 +393,6 @@ namespace System.Globalization
-120000,
120000));
}
- Contract.EndContractBlock();
// Get the date in Hijri calendar.
int y = GetDatePart(time.Ticks, DatePartYear);
int m = GetDatePart(time.Ticks, DatePartMonth);
@@ -467,7 +464,6 @@ namespace System.Globalization
// Returns the number of days in the month given by the year and
// month arguments.
//
- [Pure]
public override int GetDaysInMonth(int year, int month, int era)
{
CheckYearMonthRange(year, month, era);
@@ -653,7 +649,6 @@ namespace System.Globalization
throw new ArgumentOutOfRangeException(nameof(year),
SR.ArgumentOutOfRange_NeedNonNegNum);
}
- Contract.EndContractBlock();
if (year < 100)
{
diff --git a/src/mscorlib/shared/System/Globalization/JapaneseCalendar.cs b/src/mscorlib/shared/System/Globalization/JapaneseCalendar.cs
index 0db1e6517a..50195d7f1c 100644
--- a/src/mscorlib/shared/System/Globalization/JapaneseCalendar.cs
+++ b/src/mscorlib/shared/System/Globalization/JapaneseCalendar.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Diagnostics.CodeAnalysis;
-using System.Diagnostics.Contracts;
namespace System.Globalization
{
@@ -225,7 +224,6 @@ namespace System.Globalization
}
- [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
public override int GetWeekOfYear(DateTime time, CalendarWeekRule rule, DayOfWeek firstDayOfWeek)
{
return (helper.GetWeekOfYear(time, rule, firstDayOfWeek));
@@ -300,7 +298,6 @@ namespace System.Globalization
throw new ArgumentOutOfRangeException(nameof(year),
SR.ArgumentOutOfRange_NeedPosNum);
}
- Contract.EndContractBlock();
if (year > helper.MaxYear)
{
diff --git a/src/mscorlib/shared/System/Globalization/JapaneseLunisolarCalendar.cs b/src/mscorlib/shared/System/Globalization/JapaneseLunisolarCalendar.cs
index a90c4e8f21..e8a2dcd637 100644
--- a/src/mscorlib/shared/System/Globalization/JapaneseLunisolarCalendar.cs
+++ b/src/mscorlib/shared/System/Globalization/JapaneseLunisolarCalendar.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Diagnostics.Contracts;
namespace System.Globalization
{
@@ -211,7 +210,6 @@ namespace System.Globalization
MIN_LUNISOLAR_YEAR,
MAX_LUNISOLAR_YEAR));
}
- Contract.EndContractBlock();
return s_yinfo[lunarYear - MIN_LUNISOLAR_YEAR, index];
}
diff --git a/src/mscorlib/shared/System/Globalization/JulianCalendar.cs b/src/mscorlib/shared/System/Globalization/JulianCalendar.cs
index 8d94290547..82e4d589d3 100644
--- a/src/mscorlib/shared/System/Globalization/JulianCalendar.cs
+++ b/src/mscorlib/shared/System/Globalization/JulianCalendar.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Diagnostics.Contracts;
namespace System.Globalization
{
@@ -221,7 +220,6 @@ namespace System.Globalization
-120000,
120000));
}
- Contract.EndContractBlock();
int y = GetDatePart(time.Ticks, DatePartYear);
int m = GetDatePart(time.Ticks, DatePartMonth);
int d = GetDatePart(time.Ticks, DatePartDay);
@@ -424,7 +422,6 @@ namespace System.Globalization
throw new ArgumentOutOfRangeException(nameof(year),
SR.ArgumentOutOfRange_NeedNonNegNum);
}
- Contract.EndContractBlock();
if (year > MaxYear)
{
diff --git a/src/mscorlib/shared/System/Globalization/KoreanCalendar.cs b/src/mscorlib/shared/System/Globalization/KoreanCalendar.cs
index ef7495f07d..9168b664e0 100644
--- a/src/mscorlib/shared/System/Globalization/KoreanCalendar.cs
+++ b/src/mscorlib/shared/System/Globalization/KoreanCalendar.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Diagnostics.CodeAnalysis;
-using System.Diagnostics.Contracts;
namespace System.Globalization
{
@@ -153,7 +152,6 @@ namespace System.Globalization
}
- [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
public override int GetWeekOfYear(DateTime time, CalendarWeekRule rule, DayOfWeek firstDayOfWeek)
{
return (helper.GetWeekOfYear(time, rule, firstDayOfWeek));
@@ -257,7 +255,6 @@ namespace System.Globalization
throw new ArgumentOutOfRangeException(nameof(year),
SR.ArgumentOutOfRange_NeedNonNegNum);
}
- Contract.EndContractBlock();
return (helper.ToFourDigitYear(year, this.TwoDigitYearMax));
}
diff --git a/src/mscorlib/shared/System/Globalization/KoreanLunisolarCalendar.cs b/src/mscorlib/shared/System/Globalization/KoreanLunisolarCalendar.cs
index 8364532c9e..8cdade866c 100644
--- a/src/mscorlib/shared/System/Globalization/KoreanLunisolarCalendar.cs
+++ b/src/mscorlib/shared/System/Globalization/KoreanLunisolarCalendar.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Diagnostics.Contracts;
namespace System.Globalization
{
@@ -1256,7 +1255,6 @@ namespace System.Globalization
MIN_LUNISOLAR_YEAR,
MAX_LUNISOLAR_YEAR));
}
- Contract.EndContractBlock();
return s_yinfo[lunarYear - MIN_LUNISOLAR_YEAR, index];
}
@@ -1278,7 +1276,6 @@ namespace System.Globalization
CultureInfo.CurrentCulture,
SR.ArgumentOutOfRange_Range, MIN_LUNISOLAR_YEAR, MAX_LUNISOLAR_YEAR));
}
- Contract.EndContractBlock();
return year;
}
diff --git a/src/mscorlib/shared/System/Globalization/LocaleData.Unix.cs b/src/mscorlib/shared/System/Globalization/LocaleData.Unix.cs
index d4c58d8a3d..ccf1078ac6 100644
--- a/src/mscorlib/shared/System/Globalization/LocaleData.Unix.cs
+++ b/src/mscorlib/shared/System/Globalization/LocaleData.Unix.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
-using System.Diagnostics.Contracts;
// This file contains the handling of Windows OS specific culture features.
diff --git a/src/mscorlib/shared/System/Globalization/NumberFormatInfo.cs b/src/mscorlib/shared/System/Globalization/NumberFormatInfo.cs
index d7412bfcf3..787e36433e 100644
--- a/src/mscorlib/shared/System/Globalization/NumberFormatInfo.cs
+++ b/src/mscorlib/shared/System/Globalization/NumberFormatInfo.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System;
-using System.Diagnostics.Contracts;
using System.Runtime.Serialization;
using System.Text;
@@ -117,7 +116,6 @@ namespace System.Globalization
{
throw new ArgumentException(SR.Argument_EmptyDecString);
}
- Contract.EndContractBlock();
}
private static void VerifyGroupSeparator(String groupSep, String propertyName)
@@ -127,7 +125,6 @@ namespace System.Globalization
throw new ArgumentNullException(propertyName,
SR.ArgumentNull_String);
}
- Contract.EndContractBlock();
}
private static void VerifyNativeDigits(string[] nativeDig, string propertyName)
@@ -141,7 +138,6 @@ namespace System.Globalization
{
throw new ArgumentException(SR.Argument_InvalidNativeDigitCount, propertyName);
}
- Contract.EndContractBlock();
for (int i = 0; i < nativeDig.Length; i++)
{
@@ -205,14 +201,12 @@ namespace System.Globalization
}
}
- [Pure]
private void VerifyWritable()
{
if (isReadOnly)
{
throw new InvalidOperationException(SR.InvalidOperation_ReadOnly);
}
- Contract.EndContractBlock();
}
// Returns a default NumberFormatInfo that will be universally
@@ -290,7 +284,6 @@ namespace System.Globalization
0,
99));
}
- Contract.EndContractBlock();
VerifyWritable();
currencyDecimalDigits = value;
}
@@ -354,7 +347,6 @@ namespace System.Globalization
throw new ArgumentNullException(nameof(CurrencyGroupSizes),
SR.ArgumentNull_Obj);
}
- Contract.EndContractBlock();
VerifyWritable();
Int32[] inputSizes = (Int32[])value.Clone();
@@ -378,7 +370,6 @@ namespace System.Globalization
throw new ArgumentNullException(nameof(NumberGroupSizes),
SR.ArgumentNull_Obj);
}
- Contract.EndContractBlock();
VerifyWritable();
Int32[] inputSizes = (Int32[])value.Clone();
@@ -401,7 +392,6 @@ namespace System.Globalization
throw new ArgumentNullException(nameof(PercentGroupSizes),
SR.ArgumentNull_Obj);
}
- Contract.EndContractBlock();
VerifyWritable();
Int32[] inputSizes = (Int32[])value.Clone();
CheckGroupSize(nameof(PercentGroupSizes), inputSizes);
@@ -432,7 +422,6 @@ namespace System.Globalization
throw new ArgumentNullException(nameof(CurrencySymbol),
SR.ArgumentNull_String);
}
- Contract.EndContractBlock();
VerifyWritable();
currencySymbol = value;
}
@@ -472,7 +461,6 @@ namespace System.Globalization
throw new ArgumentNullException(nameof(NaNSymbol),
SR.ArgumentNull_String);
}
- Contract.EndContractBlock();
VerifyWritable();
nanSymbol = value;
}
@@ -495,7 +483,6 @@ namespace System.Globalization
0,
15));
}
- Contract.EndContractBlock();
VerifyWritable();
currencyNegativePattern = value;
}
@@ -520,7 +507,6 @@ namespace System.Globalization
0,
4));
}
- Contract.EndContractBlock();
VerifyWritable();
numberNegativePattern = value;
}
@@ -545,7 +531,6 @@ namespace System.Globalization
0,
3));
}
- Contract.EndContractBlock();
VerifyWritable();
percentPositivePattern = value;
}
@@ -570,7 +555,6 @@ namespace System.Globalization
0,
11));
}
- Contract.EndContractBlock();
VerifyWritable();
percentNegativePattern = value;
}
@@ -590,7 +574,6 @@ namespace System.Globalization
throw new ArgumentNullException(nameof(NegativeInfinitySymbol),
SR.ArgumentNull_String);
}
- Contract.EndContractBlock();
VerifyWritable();
negativeInfinitySymbol = value;
}
@@ -607,7 +590,6 @@ namespace System.Globalization
throw new ArgumentNullException(nameof(NegativeSign),
SR.ArgumentNull_String);
}
- Contract.EndContractBlock();
VerifyWritable();
negativeSign = value;
}
@@ -629,7 +611,6 @@ namespace System.Globalization
0,
99));
}
- Contract.EndContractBlock();
VerifyWritable();
numberDecimalDigits = value;
}
@@ -675,7 +656,6 @@ namespace System.Globalization
0,
3));
}
- Contract.EndContractBlock();
VerifyWritable();
currencyPositivePattern = value;
}
@@ -695,7 +675,6 @@ namespace System.Globalization
throw new ArgumentNullException(nameof(PositiveInfinitySymbol),
SR.ArgumentNull_String);
}
- Contract.EndContractBlock();
VerifyWritable();
positiveInfinitySymbol = value;
}
@@ -712,7 +691,6 @@ namespace System.Globalization
throw new ArgumentNullException(nameof(PositiveSign),
SR.ArgumentNull_String);
}
- Contract.EndContractBlock();
VerifyWritable();
positiveSign = value;
}
@@ -734,7 +712,6 @@ namespace System.Globalization
0,
99));
}
- Contract.EndContractBlock();
VerifyWritable();
percentDecimalDigits = value;
}
@@ -778,7 +755,6 @@ namespace System.Globalization
throw new ArgumentNullException(nameof(PercentSymbol),
SR.ArgumentNull_String);
}
- Contract.EndContractBlock();
VerifyWritable();
percentSymbol = value;
}
@@ -795,7 +771,6 @@ namespace System.Globalization
throw new ArgumentNullException(nameof(PerMilleSymbol),
SR.ArgumentNull_String);
}
- Contract.EndContractBlock();
VerifyWritable();
perMilleSymbol = value;
}
@@ -834,7 +809,6 @@ namespace System.Globalization
{
throw new ArgumentNullException(nameof(nfi));
}
- Contract.EndContractBlock();
if (nfi.IsReadOnly)
{
return (nfi);
@@ -858,7 +832,6 @@ namespace System.Globalization
{
throw new ArgumentException(SR.Argument_InvalidNumberStyles, nameof(style));
}
- Contract.EndContractBlock();
if ((style & NumberStyles.AllowHexSpecifier) != 0)
{ // Check for hex number
if ((style & ~NumberStyles.HexNumber) != 0)
@@ -875,7 +848,6 @@ namespace System.Globalization
{
throw new ArgumentException(SR.Argument_InvalidNumberStyles, nameof(style));
}
- Contract.EndContractBlock();
if ((style & NumberStyles.AllowHexSpecifier) != 0)
{ // Check for hex number
throw new ArgumentException(SR.Arg_HexStyleNotSupported);
diff --git a/src/mscorlib/shared/System/Globalization/PersianCalendar.cs b/src/mscorlib/shared/System/Globalization/PersianCalendar.cs
index 78a081e1b9..a80c6ece5b 100644
--- a/src/mscorlib/shared/System/Globalization/PersianCalendar.cs
+++ b/src/mscorlib/shared/System/Globalization/PersianCalendar.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Globalization
{
@@ -289,7 +288,6 @@ namespace System.Globalization
-120000,
120000));
}
- Contract.EndContractBlock();
// Get the date in Persian calendar.
int y = GetDatePart(time.Ticks, DatePartYear);
int m = GetDatePart(time.Ticks, DatePartMonth);
@@ -582,7 +580,6 @@ namespace System.Globalization
throw new ArgumentOutOfRangeException(nameof(year),
SR.ArgumentOutOfRange_NeedNonNegNum);
}
- Contract.EndContractBlock();
if (year < 100)
{
diff --git a/src/mscorlib/shared/System/Globalization/SortKey.cs b/src/mscorlib/shared/System/Globalization/SortKey.cs
index d65e097cb4..9b706fdad9 100644
--- a/src/mscorlib/shared/System/Globalization/SortKey.cs
+++ b/src/mscorlib/shared/System/Globalization/SortKey.cs
@@ -15,7 +15,6 @@ using System;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Globalization
{
@@ -114,7 +113,6 @@ namespace System.Globalization
{
throw new ArgumentNullException((sortkey1 == null ? nameof(sortkey1) : nameof(sortkey2)));
}
- Contract.EndContractBlock();
byte[] key1Data = sortkey1._keyData;
byte[] key2Data = sortkey2._keyData;
diff --git a/src/mscorlib/shared/System/Globalization/StringInfo.cs b/src/mscorlib/shared/System/Globalization/StringInfo.cs
index 87d1b9f684..c2fbe5a1d6 100644
--- a/src/mscorlib/shared/System/Globalization/StringInfo.cs
+++ b/src/mscorlib/shared/System/Globalization/StringInfo.cs
@@ -14,7 +14,6 @@
using System;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.Serialization;
namespace System.Globalization
@@ -95,7 +94,6 @@ namespace System.Globalization
throw new ArgumentNullException(nameof(String),
SR.ArgumentNull_String);
}
- Contract.EndContractBlock();
_str = value;
_indexes = null;
@@ -280,7 +278,6 @@ namespace System.Globalization
{
throw new ArgumentNullException(nameof(str));
}
- Contract.EndContractBlock();
int len = str.Length;
if (index < 0 || index >= len)
@@ -311,7 +308,6 @@ namespace System.Globalization
{
throw new ArgumentNullException(nameof(str));
}
- Contract.EndContractBlock();
int len = str.Length;
if (index < 0 || (index > len))
@@ -340,7 +336,6 @@ namespace System.Globalization
{
throw new ArgumentNullException(nameof(str));
}
- Contract.EndContractBlock();
int len = str.Length;
int[] result = new int[len];
diff --git a/src/mscorlib/shared/System/Globalization/TaiwanCalendar.cs b/src/mscorlib/shared/System/Globalization/TaiwanCalendar.cs
index ec4188161a..c5161138de 100644
--- a/src/mscorlib/shared/System/Globalization/TaiwanCalendar.cs
+++ b/src/mscorlib/shared/System/Globalization/TaiwanCalendar.cs
@@ -4,7 +4,6 @@
using System;
using System.Diagnostics.CodeAnalysis;
-using System.Diagnostics.Contracts;
namespace System.Globalization
{
@@ -160,7 +159,6 @@ namespace System.Globalization
}
- [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
public override int GetWeekOfYear(DateTime time, CalendarWeekRule rule, DayOfWeek firstDayOfWeek)
{
return (helper.GetWeekOfYear(time, rule, firstDayOfWeek));
@@ -265,7 +263,6 @@ namespace System.Globalization
throw new ArgumentOutOfRangeException(nameof(year),
SR.ArgumentOutOfRange_NeedPosNum);
}
- Contract.EndContractBlock();
if (year > helper.MaxYear)
{
diff --git a/src/mscorlib/shared/System/Globalization/TaiwanLunisolarCalendar.cs b/src/mscorlib/shared/System/Globalization/TaiwanLunisolarCalendar.cs
index 1e2ec62a71..60e84f7f33 100644
--- a/src/mscorlib/shared/System/Globalization/TaiwanLunisolarCalendar.cs
+++ b/src/mscorlib/shared/System/Globalization/TaiwanLunisolarCalendar.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System;
-using System.Diagnostics.Contracts;
namespace System.Globalization
{
@@ -270,7 +269,6 @@ namespace System.Globalization
MIN_LUNISOLAR_YEAR,
MAX_LUNISOLAR_YEAR));
}
- Contract.EndContractBlock();
return s_yinfo[lunarYear - MIN_LUNISOLAR_YEAR, index];
}
diff --git a/src/mscorlib/shared/System/Globalization/ThaiBuddhistCalendar.cs b/src/mscorlib/shared/System/Globalization/ThaiBuddhistCalendar.cs
index e1646bfa8e..4f8fd8f019 100644
--- a/src/mscorlib/shared/System/Globalization/ThaiBuddhistCalendar.cs
+++ b/src/mscorlib/shared/System/Globalization/ThaiBuddhistCalendar.cs
@@ -4,7 +4,6 @@
using System;
using System.Diagnostics.CodeAnalysis;
-using System.Diagnostics.Contracts;
namespace System.Globalization
{
@@ -122,7 +121,6 @@ namespace System.Globalization
}
- [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
public override int GetWeekOfYear(DateTime time, CalendarWeekRule rule, DayOfWeek firstDayOfWeek)
{
return (helper.GetWeekOfYear(time, rule, firstDayOfWeek));
@@ -226,7 +224,6 @@ namespace System.Globalization
throw new ArgumentOutOfRangeException(nameof(year),
SR.ArgumentOutOfRange_NeedNonNegNum);
}
- Contract.EndContractBlock();
return (helper.ToFourDigitYear(year, this.TwoDigitYearMax));
}
diff --git a/src/mscorlib/shared/System/Globalization/UmAlQuraCalendar.cs b/src/mscorlib/shared/System/Globalization/UmAlQuraCalendar.cs
index 99b99d67c0..21a938f8f1 100644
--- a/src/mscorlib/shared/System/Globalization/UmAlQuraCalendar.cs
+++ b/src/mscorlib/shared/System/Globalization/UmAlQuraCalendar.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Globalization
{
@@ -517,7 +516,6 @@ namespace System.Globalization
-120000,
120000));
}
- Contract.EndContractBlock();
// Get the date in UmAlQura calendar.
int y = GetDatePart(time, DatePartYear);
int m = GetDatePart(time, DatePartMonth);
@@ -822,7 +820,6 @@ namespace System.Globalization
MinCalendarYear,
MaxCalendarYear));
}
- Contract.EndContractBlock();
VerifyWritable();
// We allow year 99 to be set so that one can make ToFourDigitYearMax a no-op by setting TwoDigitYearMax to 99.
twoDigitYearMax = value;
@@ -838,7 +835,6 @@ namespace System.Globalization
throw new ArgumentOutOfRangeException(nameof(year),
SR.ArgumentOutOfRange_NeedNonNegNum);
}
- Contract.EndContractBlock();
if (year < 100)
{
diff --git a/src/mscorlib/shared/System/Guid.cs b/src/mscorlib/shared/System/Guid.cs
index b8b4dd5f0f..496bc35327 100644
--- a/src/mscorlib/shared/System/Guid.cs
+++ b/src/mscorlib/shared/System/Guid.cs
@@ -2,10 +2,9 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Runtime.InteropServices;
-using System.Runtime.CompilerServices;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
namespace System
{
@@ -87,7 +86,6 @@ namespace System
// Check that array is not too big
if (d.Length != 8)
throw new ArgumentException(SR.Format(SR.Arg_GuidArrayCtor, "8"), nameof(d));
- Contract.EndContractBlock();
_a = a;
_b = b;
@@ -225,7 +223,7 @@ namespace System
return _innerException;
default:
- Debug.Assert(false, "Unknown GuidParseFailure: " + _failure);
+ Debug.Fail("Unknown GuidParseFailure: " + _failure);
return new FormatException(SR.Format_GuidUnrecognized);
}
}
@@ -245,11 +243,10 @@ namespace System
{
throw new ArgumentNullException(nameof(g));
}
- Contract.EndContractBlock();
GuidResult result = new GuidResult();
result.Init(GuidParseThrowStyle.All);
- if (TryParseGuid(g, GuidStyles.Any, ref result))
+ if (TryParseGuid(g.AsReadOnlySpan(), GuidStyles.Any, ref result))
{
this = result._parsedGuid;
}
@@ -259,14 +256,11 @@ namespace System
}
}
- public static Guid Parse(string input)
- {
- if (input == null)
- {
- throw new ArgumentNullException(nameof(input));
- }
- Contract.EndContractBlock();
+ public static Guid Parse(string input) =>
+ Parse(input != null ? input.AsReadOnlySpan() : throw new ArgumentNullException(nameof(input)));
+ public static Guid Parse(ReadOnlySpan<char> input)
+ {
GuidResult result = new GuidResult();
result.Init(GuidParseThrowStyle.AllButOverflow);
if (TryParseGuid(input, GuidStyles.Any, ref result))
@@ -281,6 +275,17 @@ namespace System
public static bool TryParse(string input, out Guid result)
{
+ if (input == null)
+ {
+ result = default(Guid);
+ return false;
+ }
+
+ return TryParse(input.AsReadOnlySpan(), out result);
+ }
+
+ public static bool TryParse(ReadOnlySpan<char> input, out Guid result)
+ {
GuidResult parseResult = new GuidResult();
parseResult.Init(GuidParseThrowStyle.None);
if (TryParseGuid(input, GuidStyles.Any, ref parseResult))
@@ -290,19 +295,20 @@ namespace System
}
else
{
- result = Empty;
+ result = default(Guid);
return false;
}
}
- public static Guid ParseExact(string input, string format)
- {
- if (input == null)
- throw new ArgumentNullException(nameof(input));
+ public static Guid ParseExact(string input, string format) =>
+ ParseExact(input != null ? input.AsReadOnlySpan() : throw new ArgumentNullException(nameof(input)), format);
+ public static Guid ParseExact(ReadOnlySpan<char> input, string format)
+ {
if (format == null)
+ {
throw new ArgumentNullException(nameof(format));
-
+ }
if (format.Length != 1)
{
// all acceptable format strings are of length 1
@@ -310,30 +316,30 @@ namespace System
}
GuidStyles style;
- char formatCh = format[0];
- if (formatCh == 'D' || formatCh == 'd')
- {
- style = GuidStyles.DigitFormat;
- }
- else if (formatCh == 'N' || formatCh == 'n')
- {
- style = GuidStyles.NumberFormat;
- }
- else if (formatCh == 'B' || formatCh == 'b')
- {
- style = GuidStyles.BraceFormat;
- }
- else if (formatCh == 'P' || formatCh == 'p')
- {
- style = GuidStyles.ParenthesisFormat;
- }
- else if (formatCh == 'X' || formatCh == 'x')
- {
- style = GuidStyles.HexFormat;
- }
- else
+ switch (format[0])
{
- throw new FormatException(SR.Format_InvalidGuidFormatSpecification);
+ case 'D':
+ case 'd':
+ style = GuidStyles.DigitFormat;
+ break;
+ case 'N':
+ case 'n':
+ style = GuidStyles.NumberFormat;
+ break;
+ case 'B':
+ case 'b':
+ style = GuidStyles.BraceFormat;
+ break;
+ case 'P':
+ case 'p':
+ style = GuidStyles.ParenthesisFormat;
+ break;
+ case 'X':
+ case 'x':
+ style = GuidStyles.HexFormat;
+ break;
+ default:
+ throw new FormatException(SR.Format_InvalidGuidFormatSpecification);
}
GuidResult result = new GuidResult();
@@ -350,40 +356,50 @@ namespace System
public static bool TryParseExact(string input, string format, out Guid result)
{
- if (format == null || format.Length != 1)
+ if (input == null)
{
- result = Empty;
+ result = default(Guid);
return false;
}
- GuidStyles style;
- char formatCh = format[0];
+ return TryParseExact(input.AsReadOnlySpan(), format, out result);
+ }
- if (formatCh == 'D' || formatCh == 'd')
- {
- style = GuidStyles.DigitFormat;
- }
- else if (formatCh == 'N' || formatCh == 'n')
- {
- style = GuidStyles.NumberFormat;
- }
- else if (formatCh == 'B' || formatCh == 'b')
- {
- style = GuidStyles.BraceFormat;
- }
- else if (formatCh == 'P' || formatCh == 'p')
- {
- style = GuidStyles.ParenthesisFormat;
- }
- else if (formatCh == 'X' || formatCh == 'x')
+ public static bool TryParseExact(ReadOnlySpan<char> input, string format, out Guid result)
+ {
+ if (format == null || format.Length != 1)
{
- style = GuidStyles.HexFormat;
+ result = default(Guid);
+ return false;
}
- else
+
+ GuidStyles style;
+ switch (format[0])
{
- // invalid guid format specification
- result = Empty;
- return false;
+ case 'D':
+ case 'd':
+ style = GuidStyles.DigitFormat;
+ break;
+ case 'N':
+ case 'n':
+ style = GuidStyles.NumberFormat;
+ break;
+ case 'B':
+ case 'b':
+ style = GuidStyles.BraceFormat;
+ break;
+ case 'P':
+ case 'p':
+ style = GuidStyles.ParenthesisFormat;
+ break;
+ case 'X':
+ case 'x':
+ style = GuidStyles.HexFormat;
+ break;
+ default:
+ // invalid guid format specification
+ result = default(Guid);
+ return false;
}
GuidResult parseResult = new GuidResult();
@@ -395,19 +411,14 @@ namespace System
}
else
{
- result = Empty;
+ result = default(Guid);
return false;
}
}
- private static bool TryParseGuid(string g, GuidStyles flags, ref GuidResult result)
+ private static bool TryParseGuid(ReadOnlySpan<char> guidString, GuidStyles flags, ref GuidResult result)
{
- if (g == null)
- {
- result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidUnrecognized));
- return false;
- }
- string guidString = g.Trim(); //Remove Whitespace
+ guidString = guidString.Trim(); // Remove whitespace from beginning and end
if (guidString.Length == 0)
{
@@ -416,7 +427,7 @@ namespace System
}
// Check for dashes
- bool dashesExistInString = (guidString.IndexOf('-', 0) >= 0);
+ bool dashesExistInString = guidString.IndexOf('-') >= 0;
if (dashesExistInString)
{
@@ -513,7 +524,7 @@ namespace System
}
// Check if it's of the form {0xdddddddd,0xdddd,0xdddd,{0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd}}
- private static bool TryParseGuidWithHexPrefix(string guidString, ref GuidResult result)
+ private static bool TryParseGuidWithHexPrefix(ReadOnlySpan<char> guidString, ref GuidResult result)
{
int numStart = 0;
int numLen = 0;
@@ -522,7 +533,7 @@ namespace System
guidString = EatAllWhitespace(guidString);
// Check for leading '{'
- if (string.IsNullOrEmpty(guidString) || guidString[0] != '{')
+ if (guidString.Length == 0 || guidString[0] != '{')
{
result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidBrace));
return false;
@@ -544,7 +555,7 @@ namespace System
return false;
}
- if (!StringToInt(guidString.Substring(numStart, numLen) /*first DWORD*/, -1, ParseNumbers.IsTight, out result._parsedGuid._a, ref result))
+ if (!StringToInt(guidString.Slice(numStart, numLen) /*first DWORD*/, -1, ParseNumbers.IsTight, out result._parsedGuid._a, ref result))
return false;
// Check for '0x'
@@ -563,7 +574,7 @@ namespace System
}
// Read in the number
- if (!StringToShort(guidString.Substring(numStart, numLen) /*first DWORD*/, -1, ParseNumbers.IsTight, out result._parsedGuid._b, ref result))
+ if (!StringToShort(guidString.Slice(numStart, numLen) /*first DWORD*/, -1, ParseNumbers.IsTight, out result._parsedGuid._b, ref result))
return false;
// Check for '0x'
if (!IsHexPrefix(guidString, numStart + numLen + 1))
@@ -581,7 +592,7 @@ namespace System
}
// Read in the number
- if (!StringToShort(guidString.Substring(numStart, numLen) /*first DWORD*/, -1, ParseNumbers.IsTight, out result._parsedGuid._c, ref result))
+ if (!StringToShort(guidString.Slice(numStart, numLen) /*first DWORD*/, -1, ParseNumbers.IsTight, out result._parsedGuid._c, ref result))
return false;
// Check for '{'
@@ -593,9 +604,14 @@ namespace System
// Prepare for loop
numLen++;
- byte[] bytes = new byte[8];
+ Span<byte> bytes;
+ unsafe
+ {
+ byte* tmpBytes = stackalloc byte[8];
+ bytes = new Span<byte>(tmpBytes, 8);
+ }
- for (int i = 0; i < 8; i++)
+ for (int i = 0; i < bytes.Length; i++)
{
// Check for '0x'
if (!IsHexPrefix(guidString, numStart + numLen + 1))
@@ -629,7 +645,7 @@ namespace System
// Read in the number
int signedNumber;
- if (!StringToInt(guidString.Substring(numStart, numLen), -1, ParseNumbers.IsTight, out signedNumber, ref result))
+ if (!StringToInt(guidString.Slice(numStart, numLen), -1, ParseNumbers.IsTight, out signedNumber, ref result))
{
return false;
}
@@ -671,7 +687,7 @@ namespace System
}
// Check if it's of the form dddddddddddddddddddddddddddddddd
- private static bool TryParseGuidWithNoStyle(string guidString, ref GuidResult result)
+ private static bool TryParseGuidWithNoStyle(ReadOnlySpan<char> guidString, ref GuidResult result)
{
int startPos = 0;
int temp;
@@ -704,19 +720,19 @@ namespace System
return false;
}
- if (!StringToInt(guidString.Substring(startPos, 8) /*first DWORD*/, -1, ParseNumbers.IsTight, out result._parsedGuid._a, ref result))
+ if (!StringToInt(guidString.Slice(startPos, 8) /*first DWORD*/, -1, ParseNumbers.IsTight, out result._parsedGuid._a, ref result))
return false;
startPos += 8;
- if (!StringToShort(guidString.Substring(startPos, 4), -1, ParseNumbers.IsTight, out result._parsedGuid._b, ref result))
+ if (!StringToShort(guidString.Slice(startPos, 4), -1, ParseNumbers.IsTight, out result._parsedGuid._b, ref result))
return false;
startPos += 4;
- if (!StringToShort(guidString.Substring(startPos, 4), -1, ParseNumbers.IsTight, out result._parsedGuid._c, ref result))
+ if (!StringToShort(guidString.Slice(startPos, 4), -1, ParseNumbers.IsTight, out result._parsedGuid._c, ref result))
return false;
startPos += 4;
- if (!StringToInt(guidString.Substring(startPos, 4), -1, ParseNumbers.IsTight, out temp, ref result))
+ if (!StringToInt(guidString.Slice(startPos, 4), -1, ParseNumbers.IsTight, out temp, ref result))
return false;
startPos += 4;
@@ -746,7 +762,7 @@ namespace System
}
// Check if it's of the form [{|(]dddddddd-dddd-dddd-dddd-dddddddddddd[}|)]
- private static bool TryParseGuidWithDashes(string guidString, ref GuidResult result)
+ private static bool TryParseGuidWithDashes(ReadOnlySpan<char> guidString, ref GuidResult result)
{
int startPos = 0;
int temp;
@@ -830,13 +846,13 @@ namespace System
return true;
}
- private static bool StringToShort(string str, int requiredLength, int flags, out short result, ref GuidResult parseResult)
+ private static bool StringToShort(ReadOnlySpan<char> str, int requiredLength, int flags, out short result, ref GuidResult parseResult)
{
int parsePos = 0;
return StringToShort(str, ref parsePos, requiredLength, flags, out result, ref parseResult);
}
- private static bool StringToShort(string str, ref int parsePos, int requiredLength, int flags, out short result, ref GuidResult parseResult)
+ private static bool StringToShort(ReadOnlySpan<char> str, ref int parsePos, int requiredLength, int flags, out short result, ref GuidResult parseResult)
{
result = 0;
int x;
@@ -845,13 +861,13 @@ namespace System
return retValue;
}
- private static bool StringToInt(string str, int requiredLength, int flags, out int result, ref GuidResult parseResult)
+ private static bool StringToInt(ReadOnlySpan<char> str, int requiredLength, int flags, out int result, ref GuidResult parseResult)
{
int parsePos = 0;
return StringToInt(str, ref parsePos, requiredLength, flags, out result, ref parseResult);
}
- private static bool StringToInt(string str, ref int parsePos, int requiredLength, int flags, out int result, ref GuidResult parseResult)
+ private static bool StringToInt(ReadOnlySpan<char> str, ref int parsePos, int requiredLength, int flags, out int result, ref GuidResult parseResult)
{
result = 0;
@@ -898,7 +914,7 @@ namespace System
return true;
}
- private static unsafe bool StringToLong(string str, ref int parsePos, int flags, out long result, ref GuidResult parseResult)
+ private static unsafe bool StringToLong(ReadOnlySpan<char> str, ref int parsePos, int flags, out long result, ref GuidResult parseResult)
{
result = 0;
@@ -937,33 +953,43 @@ namespace System
return true;
}
- private static string EatAllWhitespace(string str)
+ private static ReadOnlySpan<char> EatAllWhitespace(ReadOnlySpan<char> str)
{
+ // Find the first whitespace character. If there is none, just return the input.
+ int i;
+ for (i = 0; i < str.Length && !char.IsWhiteSpace(str[i]); i++) ;
+ if (i == str.Length)
+ {
+ return str;
+ }
+
+ // There was at least one whitespace. Copy over everything prior to it to a new array.
+ var chArr = new char[str.Length];
int newLength = 0;
- char[] chArr = new char[str.Length];
- char curChar;
+ if (i > 0)
+ {
+ newLength = i;
+ str.Slice(0, i).CopyTo(chArr);
+ }
- // Now get each char from str and if it is not whitespace add it to chArr
- for (int i = 0; i < str.Length; i++)
+ // Loop through the remaining chars, copying over non-whitespace.
+ for (; i < str.Length; i++)
{
- curChar = str[i];
- if (!char.IsWhiteSpace(curChar))
+ char c = str[i];
+ if (!char.IsWhiteSpace(c))
{
- chArr[newLength++] = curChar;
+ chArr[newLength++] = c;
}
}
- // Return a new string based on chArr
- return new string(chArr, 0, newLength);
+ // Return the string with the whitespace removed.
+ return new ReadOnlySpan<char>(chArr, 0, newLength);
}
- private static bool IsHexPrefix(string str, int i)
- {
- if (str.Length > i + 1 && str[i] == '0' && (char.ToLowerInvariant(str[i + 1]) == 'x'))
- return true;
- else
- return false;
- }
+ private static bool IsHexPrefix(ReadOnlySpan<char> str, int i) =>
+ i + 1 < str.Length &&
+ str[i] == '0' &&
+ (str[i + 1] == 'x' || char.ToLowerInvariant(str[i + 1]) == 'x');
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void WriteByteHelper(Span<byte> destination)
diff --git a/src/mscorlib/shared/System/IFormattable.cs b/src/mscorlib/shared/System/IFormattable.cs
index 28a7d70571..1f2f7022cc 100644
--- a/src/mscorlib/shared/System/IFormattable.cs
+++ b/src/mscorlib/shared/System/IFormattable.cs
@@ -3,13 +3,11 @@
// See the LICENSE file in the project root for more information.
using System;
-using System.Diagnostics.Contracts;
namespace System
{
public interface IFormattable
{
- [Pure]
String ToString(String format, IFormatProvider formatProvider);
}
}
diff --git a/src/mscorlib/shared/System/IO/Error.cs b/src/mscorlib/shared/System/IO/Error.cs
index 2aef895181..1e319a0680 100644
--- a/src/mscorlib/shared/System/IO/Error.cs
+++ b/src/mscorlib/shared/System/IO/Error.cs
@@ -6,14 +6,12 @@ using System;
using System.Runtime.InteropServices;
using System.Text;
using System.Globalization;
-using System.Diagnostics.Contracts;
namespace System.IO
{
/// <summary>
/// Provides centralized methods for creating exceptions for System.IO.FileSystem.
/// </summary>
- [Pure]
internal static class Error
{
internal static Exception GetStreamIsClosed()
diff --git a/src/mscorlib/shared/System/IO/FileStream.Unix.cs b/src/mscorlib/shared/System/IO/FileStream.Unix.cs
index 8499595361..99a3377288 100644
--- a/src/mscorlib/shared/System/IO/FileStream.Unix.cs
+++ b/src/mscorlib/shared/System/IO/FileStream.Unix.cs
@@ -97,11 +97,17 @@ namespace System.IO
ignoreNotSupported: true); // just a hint.
}
- // Jump to the end of the file if opened as Append.
if (_mode == FileMode.Append)
{
+ // Jump to the end of the file if opened as Append.
_appendStart = SeekCore(_fileHandle, 0, SeekOrigin.End);
}
+ else if (mode == FileMode.Create || mode == FileMode.Truncate)
+ {
+ // Truncate the file now if the file mode requires it. This ensures that the file only will be truncated
+ // if opened successfully.
+ CheckFileCall(Interop.Sys.FTruncate(_fileHandle, 0));
+ }
}
/// <summary>Initializes a stream from an already open file handle (file descriptor).</summary>
@@ -128,24 +134,18 @@ namespace System.IO
{
default:
case FileMode.Open: // Open maps to the default behavior for open(...). No flags needed.
+ case FileMode.Truncate: // We truncate the file after getting the lock
break;
case FileMode.Append: // Append is the same as OpenOrCreate, except that we'll also separately jump to the end later
case FileMode.OpenOrCreate:
+ case FileMode.Create: // We truncate the file after getting the lock
flags |= Interop.Sys.OpenFlags.O_CREAT;
break;
- case FileMode.Create:
- flags |= (Interop.Sys.OpenFlags.O_CREAT | Interop.Sys.OpenFlags.O_TRUNC);
- break;
-
case FileMode.CreateNew:
flags |= (Interop.Sys.OpenFlags.O_CREAT | Interop.Sys.OpenFlags.O_EXCL);
break;
-
- case FileMode.Truncate:
- flags |= Interop.Sys.OpenFlags.O_TRUNC;
- break;
}
// Translate FileAccess. All possible values map cleanly to corresponding values for open.
diff --git a/src/mscorlib/shared/System/IO/Path.cs b/src/mscorlib/shared/System/IO/Path.cs
index 2676f0d2fe..c9b9ed0cd9 100644
--- a/src/mscorlib/shared/System/IO/Path.cs
+++ b/src/mscorlib/shared/System/IO/Path.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Text;
namespace System.IO
@@ -100,7 +99,6 @@ namespace System.IO
// period (".") character of the extension except when you have a terminal period when you get string.Empty, such as ".exe" or
// ".cpp". The returned value is null if the given path is
// null or if the given path does not include an extension.
- [Pure]
public static string GetExtension(string path)
{
if (path == null)
@@ -127,7 +125,6 @@ namespace System.IO
// Returns the name and extension parts of the given path. The resulting
// string contains the characters of path that follow the last
// separator in path. The resulting string is null if path is null.
- [Pure]
public static string GetFileName(string path)
{
if (path == null)
@@ -138,7 +135,6 @@ namespace System.IO
return path.Substring(offset, count);
}
- [Pure]
public static string GetFileNameWithoutExtension(string path)
{
if (path == null)
@@ -194,7 +190,6 @@ namespace System.IO
// true if the characters that follow the last directory
// separator ('\\' or '/') or volume separator (':') in the path include
// a period (".") other than a terminal period. The result is false otherwise.
- [Pure]
public static bool HasExtension(string path)
{
if (path != null)
@@ -218,7 +213,6 @@ namespace System.IO
{
if (path1 == null || path2 == null)
throw new ArgumentNullException((path1 == null) ? nameof(path1) : nameof(path2));
- Contract.EndContractBlock();
PathInternal.CheckInvalidPathChars(path1);
PathInternal.CheckInvalidPathChars(path2);
@@ -230,7 +224,6 @@ namespace System.IO
{
if (path1 == null || path2 == null || path3 == null)
throw new ArgumentNullException((path1 == null) ? nameof(path1) : (path2 == null) ? nameof(path2) : nameof(path3));
- Contract.EndContractBlock();
PathInternal.CheckInvalidPathChars(path1);
PathInternal.CheckInvalidPathChars(path2);
@@ -243,7 +236,6 @@ namespace System.IO
{
if (path1 == null || path2 == null || path3 == null || path4 == null)
throw new ArgumentNullException((path1 == null) ? nameof(path1) : (path2 == null) ? nameof(path2) : (path3 == null) ? nameof(path3) : nameof(path4));
- Contract.EndContractBlock();
PathInternal.CheckInvalidPathChars(path1);
PathInternal.CheckInvalidPathChars(path2);
@@ -259,7 +251,6 @@ namespace System.IO
{
throw new ArgumentNullException(nameof(paths));
}
- Contract.EndContractBlock();
int finalSize = 0;
int firstComponent = 0;
diff --git a/src/mscorlib/shared/System/IO/PinnedBufferMemoryStream.cs b/src/mscorlib/shared/System/IO/PinnedBufferMemoryStream.cs
index e8f74dd05c..2bd1ef6b95 100644
--- a/src/mscorlib/shared/System/IO/PinnedBufferMemoryStream.cs
+++ b/src/mscorlib/shared/System/IO/PinnedBufferMemoryStream.cs
@@ -17,7 +17,6 @@
using System;
using System.Runtime.InteropServices;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.IO
{
diff --git a/src/mscorlib/shared/System/IO/UnmanagedMemoryStream.cs b/src/mscorlib/shared/System/IO/UnmanagedMemoryStream.cs
index b899951ba7..dc6f67bae9 100644
--- a/src/mscorlib/shared/System/IO/UnmanagedMemoryStream.cs
+++ b/src/mscorlib/shared/System/IO/UnmanagedMemoryStream.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
@@ -111,7 +110,6 @@ namespace System.IO
{
throw new ArgumentOutOfRangeException(nameof(access));
}
- Contract.EndContractBlock();
if (_isOpen)
{
@@ -178,7 +176,6 @@ namespace System.IO
throw new ArgumentOutOfRangeException((length < 0) ? nameof(length) : nameof(capacity), SR.ArgumentOutOfRange_NeedNonNegNum);
if (length > capacity)
throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_LengthGreaterThanCapacity);
- Contract.EndContractBlock();
// Check for wraparound.
if (((byte*)((long)pointer + capacity)) < pointer)
throw new ArgumentOutOfRangeException(nameof(capacity), SR.ArgumentOutOfRange_UnmanagedMemStreamWrapAround);
@@ -200,7 +197,6 @@ namespace System.IO
/// </summary>
public override bool CanRead
{
- [Pure]
get { return _isOpen && (_access & FileAccess.Read) != 0; }
}
@@ -209,7 +205,6 @@ namespace System.IO
/// </summary>
public override bool CanSeek
{
- [Pure]
get { return _isOpen; }
}
@@ -218,7 +213,6 @@ namespace System.IO
/// </summary>
public override bool CanWrite
{
- [Pure]
get { return _isOpen && (_access & FileAccess.Write) != 0; }
}
@@ -298,14 +292,12 @@ namespace System.IO
get
{
if (!CanSeek) throw Error.GetStreamIsClosed();
- Contract.EndContractBlock();
return Interlocked.Read(ref _position);
}
set
{
if (value < 0) throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_NeedNonNegNum);
if (!CanSeek) throw Error.GetStreamIsClosed();
- Contract.EndContractBlock();
Interlocked.Exchange(ref _position, value);
}
@@ -452,7 +444,6 @@ namespace System.IO
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum);
if (buffer.Length - offset < count)
throw new ArgumentException(SR.Argument_InvalidOffLen);
- Contract.EndContractBlock(); // contract validation copied from Read(...)
if (cancellationToken.IsCancellationRequested)
return Task.FromCanceled<Int32>(cancellationToken);
@@ -484,7 +475,22 @@ namespace System.IO
try
{
- return new ValueTask<int>(Read(destination.Span));
+ // ReadAsync(Memory<byte>,...) needs to delegate to an existing virtual to do the work, in case an existing derived type
+ // has changed or augmented the logic associated with reads. If the Memory wraps an array, we could delegate to
+ // ReadAsync(byte[], ...), but that would defeat part of the purpose, as ReadAsync(byte[], ...) often needs to allocate
+ // a Task<int> for the return value, so we want to delegate to one of the synchronous methods. We could always
+ // delegate to the Read(Span<byte>) method, and that's the most efficient solution when dealing with a concrete
+ // UnmanagedMemoryStream, but if we're dealing with a type derived from UnmanagedMemoryStream, Read(Span<byte>) will end up delegating
+ // to Read(byte[], ...), which requires it to get a byte[] from ArrayPool and copy the data. So, we special-case the
+ // very common case of the Memory<byte> wrapping an array: if it does, we delegate to Read(byte[], ...) with it,
+ // as that will be efficient in both cases, and we fall back to Read(Span<byte>) if the Memory<byte> wrapped something
+ // else; if this is a concrete UnmanagedMemoryStream, that'll be efficient, and only in the case where the Memory<byte> wrapped
+ // something other than an array and this is an UnmanagedMemoryStream-derived type that doesn't override Read(Span<byte>) will
+ // it then fall back to doing the ArrayPool/copy behavior.
+ return new ValueTask<int>(
+ destination.TryGetArray(out ArraySegment<byte> destinationArray) ?
+ Read(destinationArray.Array, destinationArray.Offset, destinationArray.Count) :
+ Read(destination.Span));
}
catch (Exception ex)
{
@@ -585,7 +591,6 @@ namespace System.IO
{
if (value < 0)
throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
if (_buffer != null)
throw new NotSupportedException(SR.NotSupported_UmsSafeBuffer);
if (!_isOpen) throw Error.GetStreamIsClosed();
@@ -733,7 +738,6 @@ namespace System.IO
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum);
if (buffer.Length - offset < count)
throw new ArgumentException(SR.Argument_InvalidOffLen);
- Contract.EndContractBlock(); // contract validation copied from Write(..)
if (cancellationToken.IsCancellationRequested)
return Task.FromCanceled(cancellationToken);
@@ -764,7 +768,16 @@ namespace System.IO
try
{
- Write(source.Span);
+ // See corresponding comment in ReadAsync for why we don't just always use Write(ReadOnlySpan<byte>).
+ // Unlike ReadAsync, we could delegate to WriteAsync(byte[], ...) here, but we don't for consistency.
+ if (source.DangerousTryGetArray(out ArraySegment<byte> sourceArray))
+ {
+ Write(sourceArray.Array, sourceArray.Offset, sourceArray.Count);
+ }
+ else
+ {
+ Write(source.Span);
+ }
return Task.CompletedTask;
}
catch (Exception ex)
diff --git a/src/mscorlib/shared/System/IO/UnmanagedMemoryStreamWrapper.cs b/src/mscorlib/shared/System/IO/UnmanagedMemoryStreamWrapper.cs
index 2699912ea1..90bb21ac5b 100644
--- a/src/mscorlib/shared/System/IO/UnmanagedMemoryStreamWrapper.cs
+++ b/src/mscorlib/shared/System/IO/UnmanagedMemoryStreamWrapper.cs
@@ -14,7 +14,6 @@
using System;
using System.Runtime.InteropServices;
using System.Diagnostics.CodeAnalysis;
-using System.Diagnostics.Contracts;
using System.Threading;
using System.Threading.Tasks;
@@ -82,7 +81,6 @@ namespace System.IO
{
return (int)_unmanagedStream.Capacity;
}
- [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
set
{
throw new IOException(SR.IO_FixedCapacity);
@@ -156,7 +154,6 @@ namespace System.IO
{
if (stream == null)
throw new ArgumentNullException(nameof(stream), SR.ArgumentNull_Stream);
- Contract.EndContractBlock();
byte[] buffer = ToArray();
@@ -193,7 +190,6 @@ namespace System.IO
if (!destination.CanWrite)
throw new NotSupportedException(SR.NotSupported_UnwritableStream);
- Contract.EndContractBlock();
return _unmanagedStream.CopyToAsync(destination, bufferSize, cancellationToken);
}
diff --git a/src/mscorlib/shared/System/Int16.cs b/src/mscorlib/shared/System/Int16.cs
index 6aaf4280d3..87004861cb 100644
--- a/src/mscorlib/shared/System/Int16.cs
+++ b/src/mscorlib/shared/System/Int16.cs
@@ -12,7 +12,6 @@
**
===========================================================*/
-using System.Diagnostics.Contracts;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -80,32 +79,26 @@ namespace System
public override String ToString()
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatInt32(m_value, null, NumberFormatInfo.CurrentInfo);
}
public String ToString(IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatInt32(m_value, null, NumberFormatInfo.GetInstance(provider));
}
public String ToString(String format)
{
- Contract.Ensures(Contract.Result<String>() != null);
return ToString(format, NumberFormatInfo.CurrentInfo);
}
public String ToString(String format, IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<String>() != null);
return ToString(format, NumberFormatInfo.GetInstance(provider));
}
private String ToString(String format, NumberFormatInfo info)
{
- Contract.Ensures(Contract.Result<String>() != null);
-
if (m_value < 0 && format != null && format.Length > 0 && (format[0] == 'X' || format[0] == 'x'))
{
uint temp = (uint)(m_value & 0x0000FFFF);
diff --git a/src/mscorlib/shared/System/Int32.cs b/src/mscorlib/shared/System/Int32.cs
index f5e832a274..d674e7b6bf 100644
--- a/src/mscorlib/shared/System/Int32.cs
+++ b/src/mscorlib/shared/System/Int32.cs
@@ -12,7 +12,6 @@
**
===========================================================*/
-using System.Diagnostics.Contracts;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -87,42 +86,32 @@ namespace System
return m_value;
}
- [Pure]
public override String ToString()
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatInt32(m_value, null, NumberFormatInfo.CurrentInfo);
}
- [Pure]
public String ToString(String format)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatInt32(m_value, format, NumberFormatInfo.CurrentInfo);
}
- [Pure]
public String ToString(IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatInt32(m_value, null, NumberFormatInfo.GetInstance(provider));
}
- [Pure]
public String ToString(String format, IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatInt32(m_value, format, NumberFormatInfo.GetInstance(provider));
}
- [Pure]
public static int Parse(String s)
{
if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s);
return Number.ParseInt32(s.AsReadOnlySpan(), NumberStyles.Integer, NumberFormatInfo.CurrentInfo);
}
- [Pure]
public static int Parse(String s, NumberStyles style)
{
NumberFormatInfo.ValidateParseStyleInteger(style);
@@ -134,7 +123,6 @@ namespace System
// a NumberFormatInfo isn't specified, the current culture's
// NumberFormatInfo is assumed.
//
- [Pure]
public static int Parse(String s, IFormatProvider provider)
{
if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s);
@@ -145,7 +133,6 @@ namespace System
// a NumberFormatInfo isn't specified, the current culture's
// NumberFormatInfo is assumed.
//
- [Pure]
public static int Parse(String s, NumberStyles style, IFormatProvider provider)
{
NumberFormatInfo.ValidateParseStyleInteger(style);
@@ -162,7 +149,6 @@ namespace System
// Parses an integer from a String. Returns false rather
// than throwing exceptin if input is invalid
//
- [Pure]
public static bool TryParse(String s, out Int32 result)
{
if (s == null)
@@ -177,7 +163,6 @@ namespace System
// Parses an integer from a String in the given style. Returns false rather
// than throwing exceptin if input is invalid
//
- [Pure]
public static bool TryParse(String s, NumberStyles style, IFormatProvider provider, out Int32 result)
{
NumberFormatInfo.ValidateParseStyleInteger(style);
@@ -201,7 +186,6 @@ namespace System
// IConvertible implementation
//
- [Pure]
public TypeCode GetTypeCode()
{
return TypeCode.Int32;
diff --git a/src/mscorlib/shared/System/Int64.cs b/src/mscorlib/shared/System/Int64.cs
index 785fa39fa5..e17c3ea6ed 100644
--- a/src/mscorlib/shared/System/Int64.cs
+++ b/src/mscorlib/shared/System/Int64.cs
@@ -12,7 +12,6 @@
**
===========================================================*/
-using System.Diagnostics.Contracts;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -86,25 +85,21 @@ namespace System
public override String ToString()
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatInt64(m_value, null, NumberFormatInfo.CurrentInfo);
}
public String ToString(IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatInt64(m_value, null, NumberFormatInfo.GetInstance(provider));
}
public String ToString(String format)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatInt64(m_value, format, NumberFormatInfo.CurrentInfo);
}
public String ToString(String format, IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatInt64(m_value, format, NumberFormatInfo.GetInstance(provider));
}
diff --git a/src/mscorlib/shared/System/Lazy.cs b/src/mscorlib/shared/System/Lazy.cs
index 2ef3cd2e5f..e71a37dd9e 100644
--- a/src/mscorlib/shared/System/Lazy.cs
+++ b/src/mscorlib/shared/System/Lazy.cs
@@ -182,7 +182,7 @@ namespace System
/// using parameters to the type's constructors.
/// </para>
/// </remarks>
- [DebuggerTypeProxy(typeof(System_LazyDebugView<>))]
+ [DebuggerTypeProxy(typeof(LazyDebugView<>))]
[DebuggerDisplay("ThreadSafetyMode={Mode}, IsValueCreated={IsValueCreated}, IsValueFaulted={IsValueFaulted}, Value={ValueForDebugDisplay}")]
public class Lazy<T>
{
@@ -520,14 +520,14 @@ namespace System
/// <summary>A debugger view of the Lazy&lt;T&gt; to surface additional debugging properties and
/// to ensure that the Lazy&lt;T&gt; does not become initialized if it was not already.</summary>
- internal sealed class System_LazyDebugView<T>
+ internal sealed class LazyDebugView<T>
{
//The Lazy object being viewed.
private readonly Lazy<T> _lazy;
/// <summary>Constructs a new debugger view object for the provided Lazy object.</summary>
/// <param name="lazy">A Lazy object to browse in the debugger.</param>
- public System_LazyDebugView(Lazy<T> lazy)
+ public LazyDebugView(Lazy<T> lazy)
{
_lazy = lazy;
}
diff --git a/src/mscorlib/src/System/Math.cs b/src/mscorlib/shared/System/Math.cs
index 33d0f77013..5c69c84e45 100644
--- a/src/mscorlib/src/System/Math.cs
+++ b/src/mscorlib/shared/System/Math.cs
@@ -13,202 +13,352 @@
//This class contains only static members and doesn't require serialization.
-using System;
+using System.Diagnostics;
+using System.Diagnostics.Contracts;
using System.Runtime;
using System.Runtime.CompilerServices;
-using System.Runtime.ConstrainedExecution;
using System.Runtime.Versioning;
-using System.Diagnostics.Contracts;
namespace System
{
- public static class Math
+ public static partial class Math
{
- private static double doubleRoundLimit = 1e16d;
+ public const double E = 2.7182818284590452354;
+
+ public const double PI = 3.14159265358979323846;
private const int maxRoundingDigits = 15;
+ private static double doubleRoundLimit = 1e16d;
+
// This table is required for the Round function which can specify the number of digits to round to
private static double[] roundPower10Double = new double[] {
1E0, 1E1, 1E2, 1E3, 1E4, 1E5, 1E6, 1E7, 1E8,
1E9, 1E10, 1E11, 1E12, 1E13, 1E14, 1E15
- };
+ };
- public const double PI = 3.14159265358979323846;
- public const double E = 2.7182818284590452354;
+ public static short Abs(short value)
+ {
+ return (value >= 0) ? value : AbsHelper(value);
+ }
+
+ public static int Abs(int value)
+ {
+ return (value >= 0) ? value : AbsHelper(value);
+ }
+
+ public static long Abs(long value)
+ {
+ return (value >= 0) ? value : AbsHelper(value);
+ }
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern double Acos(double d);
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern double Asin(double d);
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern double Atan(double d);
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern double Atan2(double y, double x);
+ [CLSCompliant(false)]
+ public static sbyte Abs(sbyte value)
+ {
+ return (value >= 0) ? value : AbsHelper(value);
+ }
- public static Decimal Ceiling(Decimal d)
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static decimal Abs(decimal value)
{
- return Decimal.Ceiling(d);
+ return decimal.Abs(value);
}
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern double Ceiling(double a);
+ public static long BigMul(int a, int b)
+ {
+ return ((long)a) * b;
+ }
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern double Cos(double d);
+ public static int DivRem(int a, int b, out int result)
+ {
+ // TODO https://github.com/dotnet/coreclr/issues/3439:
+ // Restore to using % and / when the JIT is able to eliminate one of the idivs.
+ // In the meantime, a * and - is measurably faster than an extra /.
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern double Cosh(double value);
+ int div = a / b;
+ result = a - (div * b);
+ return div;
+ }
- public static Decimal Floor(Decimal d)
+ public static long DivRem(long a, long b, out long result)
{
- return Decimal.Floor(d);
+ // TODO https://github.com/dotnet/coreclr/issues/3439:
+ // Restore to using % and / when the JIT is able to eliminate one of the idivs.
+ // In the meantime, a * and - is measurably faster than an extra /.
+
+ long div = a / b;
+ result = a - (div * b);
+ return div;
}
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern double Floor(double d);
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static decimal Ceiling(decimal d)
+ {
+ return decimal.Ceiling(d);
+ }
- private static unsafe double InternalRound(double value, int digits, MidpointRounding mode)
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static byte Clamp(byte value, byte min, byte max)
{
- if (Abs(value) < doubleRoundLimit)
+ if (min > max)
{
- Double power10 = roundPower10Double[digits];
- value *= power10;
- if (mode == MidpointRounding.AwayFromZero)
- {
- double fraction = SplitFractionDouble(&value);
- if (Abs(fraction) >= 0.5d)
- {
- value += Sign(fraction);
- }
- }
- else
- {
- // On X86 this can be inlined to just a few instructions
- value = Round(value);
- }
- value /= power10;
+ ThrowMinMaxException(min, max);
+ }
+
+ if (value < min)
+ {
+ return min;
+ }
+ else if (value > max)
+ {
+ return max;
}
+
return value;
}
- private unsafe static double InternalTruncate(double d)
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static decimal Clamp(decimal value, decimal min, decimal max)
{
- SplitFractionDouble(&d);
- return d;
- }
+ if (min > max)
+ {
+ ThrowMinMaxException(min, max);
+ }
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern double Sin(double a);
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern double Tan(double a);
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern double Sinh(double value);
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern double Tanh(double value);
+ if (value < min)
+ {
+ return min;
+ }
+ else if (value > max)
+ {
+ return max;
+ }
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern double Round(double a);
+ return value;
+ }
- public static double Round(double value, int digits)
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static double Clamp(double value, double min, double max)
{
- if ((digits < 0) || (digits > maxRoundingDigits))
- throw new ArgumentOutOfRangeException(nameof(digits), SR.ArgumentOutOfRange_RoundingDigits);
- Contract.EndContractBlock();
- return InternalRound(value, digits, MidpointRounding.ToEven);
+ if (min > max)
+ {
+ ThrowMinMaxException(min, max);
+ }
+
+ if (value < min)
+ {
+ return min;
+ }
+ else if (value > max)
+ {
+ return max;
+ }
+
+ return value;
}
- public static double Round(double value, MidpointRounding mode)
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static short Clamp(short value, short min, short max)
{
- return Round(value, 0, mode);
+ if (min > max)
+ {
+ ThrowMinMaxException(min, max);
+ }
+
+ if (value < min)
+ {
+ return min;
+ }
+ else if (value > max)
+ {
+ return max;
+ }
+
+ return value;
}
- public static double Round(double value, int digits, MidpointRounding mode)
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static int Clamp(int value, int min, int max)
{
- if ((digits < 0) || (digits > maxRoundingDigits))
- throw new ArgumentOutOfRangeException(nameof(digits), SR.ArgumentOutOfRange_RoundingDigits);
- if (mode < MidpointRounding.ToEven || mode > MidpointRounding.AwayFromZero)
+ if (min > max)
{
- throw new ArgumentException(SR.Format(SR.Argument_InvalidEnumValue, mode, nameof(MidpointRounding)), nameof(mode));
+ ThrowMinMaxException(min, max);
+ }
+
+ if (value < min)
+ {
+ return min;
+ }
+ else if (value > max)
+ {
+ return max;
}
- Contract.EndContractBlock();
- return InternalRound(value, digits, mode);
+
+ return value;
}
- public static Decimal Round(Decimal d)
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static long Clamp(long value, long min, long max)
{
- return Decimal.Round(d, 0);
+ if (min > max)
+ {
+ ThrowMinMaxException(min, max);
+ }
+
+ if (value < min)
+ {
+ return min;
+ }
+ else if (value > max)
+ {
+ return max;
+ }
+
+ return value;
}
- public static Decimal Round(Decimal d, int decimals)
+ [CLSCompliant(false)]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static sbyte Clamp(sbyte value, sbyte min, sbyte max)
{
- return Decimal.Round(d, decimals);
+ if (min > max)
+ {
+ ThrowMinMaxException(min, max);
+ }
+
+ if (value < min)
+ {
+ return min;
+ }
+ else if (value > max)
+ {
+ return max;
+ }
+
+ return value;
}
- public static Decimal Round(Decimal d, MidpointRounding mode)
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static float Clamp(float value, float min, float max)
{
- return Decimal.Round(d, 0, mode);
+ if (min > max)
+ {
+ ThrowMinMaxException(min, max);
+ }
+
+ if (value < min)
+ {
+ return min;
+ }
+ else if (value > max)
+ {
+ return max;
+ }
+
+ return value;
}
- public static Decimal Round(Decimal d, int decimals, MidpointRounding mode)
+ [CLSCompliant(false)]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static ushort Clamp(ushort value, ushort min, ushort max)
{
- return Decimal.Round(d, decimals, mode);
- }
+ if (min > max)
+ {
+ ThrowMinMaxException(min, max);
+ }
+
+ if (value < min)
+ {
+ return min;
+ }
+ else if (value > max)
+ {
+ return max;
+ }
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static unsafe extern double SplitFractionDouble(double* value);
+ return value;
+ }
- public static Decimal Truncate(Decimal d)
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [CLSCompliant(false)]
+ public static uint Clamp(uint value, uint min, uint max)
{
- return Decimal.Truncate(d);
+ if (min > max)
+ {
+ ThrowMinMaxException(min, max);
+ }
+
+ if (value < min)
+ {
+ return min;
+ }
+ else if (value > max)
+ {
+ return max;
+ }
+
+ return value;
}
- public static double Truncate(double d)
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [CLSCompliant(false)]
+ public static ulong Clamp(ulong value, ulong min, ulong max)
{
- return InternalTruncate(d);
+ if (min > max)
+ {
+ ThrowMinMaxException(min, max);
+ }
+
+ if (value < min)
+ {
+ return min;
+ }
+ else if (value > max)
+ {
+ return max;
+ }
+
+ return value;
}
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern double Sqrt(double d);
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern double Log(double d);
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern double Log10(double d);
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern double Exp(double d);
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern double Pow(double x, double y);
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static decimal Floor(decimal d)
+ {
+ return decimal.Floor(d);
+ }
public static double IEEERemainder(double x, double y)
{
- if (Double.IsNaN(x))
+ if (double.IsNaN(x))
{
return x; // IEEE 754-2008: NaN payload must be preserved
}
- if (Double.IsNaN(y))
+
+ if (double.IsNaN(y))
{
return y; // IEEE 754-2008: NaN payload must be preserved
}
- double regularMod = x % y;
- if (Double.IsNaN(regularMod))
+ var regularMod = x % y;
+
+ if (double.IsNaN(regularMod))
{
- return Double.NaN;
+ return double.NaN;
}
- if (regularMod == 0)
+
+ if ((regularMod == 0) && double.IsNegative(x))
{
- if (Double.IsNegative(x))
- {
- return Double.NegativeZero;
- }
+ return double.NegativeZero;
}
- double alternativeResult;
- alternativeResult = regularMod - (Math.Abs(y) * Math.Sign(x));
- if (Math.Abs(alternativeResult) == Math.Abs(regularMod))
+
+ var alternativeResult = (regularMod - (Abs(y) * Sign(x)));
+
+ if (Abs(alternativeResult) == Abs(regularMod))
{
- double divisionResult = x / y;
- double roundedResult = Math.Round(divisionResult);
- if (Math.Abs(roundedResult) > Math.Abs(divisionResult))
+ var divisionResult = x / y;
+ var roundedResult = Round(divisionResult);
+
+ if (Abs(roundedResult) > Abs(divisionResult))
{
return alternativeResult;
}
@@ -217,7 +367,8 @@ namespace System
return regularMod;
}
}
- if (Math.Abs(alternativeResult) < Math.Abs(regularMod))
+
+ if (Abs(alternativeResult) < Abs(regularMod))
{
return alternativeResult;
}
@@ -227,238 +378,167 @@ namespace System
}
}
- /*================================Abs=========================================
- **Returns the absolute value of it's argument.
- ============================================================================*/
- [CLSCompliant(false)]
- public static sbyte Abs(sbyte value)
+ public static double Log(double a, double newBase)
{
- if (value >= 0)
- return value;
- else
- return AbsHelper(value);
- }
+ if (double.IsNaN(a))
+ {
+ return a; // IEEE 754-2008: NaN payload must be preserved
+ }
- private static sbyte AbsHelper(sbyte value)
- {
- Contract.Requires(value < 0, "AbsHelper should only be called for negative values! (workaround for JIT inlining)");
- if (value == SByte.MinValue)
- throw new OverflowException(SR.Overflow_NegateTwosCompNum);
- Contract.EndContractBlock();
- return ((sbyte)(-value));
- }
+ if (double.IsNaN(newBase))
+ {
+ return newBase; // IEEE 754-2008: NaN payload must be preserved
+ }
- public static short Abs(short value)
- {
- if (value >= 0)
- return value;
- else
- return AbsHelper(value);
- }
+ if (newBase == 1)
+ {
+ return double.NaN;
+ }
- private static short AbsHelper(short value)
- {
- Contract.Requires(value < 0, "AbsHelper should only be called for negative values! (workaround for JIT inlining)");
- if (value == Int16.MinValue)
- throw new OverflowException(SR.Overflow_NegateTwosCompNum);
- Contract.EndContractBlock();
- return (short)-value;
- }
+ if ((a != 1) && ((newBase == 0) || double.IsPositiveInfinity(newBase)))
+ {
+ return double.NaN;
+ }
- public static int Abs(int value)
- {
- if (value >= 0)
- return value;
- else
- return AbsHelper(value);
+ return (Log(a) / Log(newBase));
}
- private static int AbsHelper(int value)
+ [NonVersionable]
+ public static byte Max(byte val1, byte val2)
{
- Contract.Requires(value < 0, "AbsHelper should only be called for negative values! (workaround for JIT inlining)");
- if (value == Int32.MinValue)
- throw new OverflowException(SR.Overflow_NegateTwosCompNum);
- Contract.EndContractBlock();
- return -value;
+ return (val1 >= val2) ? val1 : val2;
}
- public static long Abs(long value)
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static decimal Max(decimal val1, decimal val2)
{
- if (value >= 0)
- return value;
- else
- return AbsHelper(value);
+ return decimal.Max(val1, val2);
}
- private static long AbsHelper(long value)
+ public static double Max(double val1, double val2)
{
- Contract.Requires(value < 0, "AbsHelper should only be called for negative values! (workaround for JIT inlining)");
- if (value == Int64.MinValue)
- throw new OverflowException(SR.Overflow_NegateTwosCompNum);
- Contract.EndContractBlock();
- return -value;
- }
+ if (val1 > val2)
+ {
+ return val1;
+ }
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- extern public static float Abs(float value);
- // This is special code to handle NaN (We need to make sure NaN's aren't
- // negated). In CSharp, the else clause here should always be taken if
- // value is NaN, since the normal case is taken if and only if value < 0.
- // To illustrate this completely, a compiler has translated this into:
- // "load value; load 0; bge; ret -value ; ret value".
- // The bge command branches for comparisons with the unordered NaN. So
- // it runs the else case, which returns +value instead of negating it.
- // return (value < 0) ? -value : value;
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- extern public static double Abs(double value);
- // This is special code to handle NaN (We need to make sure NaN's aren't
- // negated). In CSharp, the else clause here should always be taken if
- // value is NaN, since the normal case is taken if and only if value < 0.
- // To illustrate this completely, a compiler has translated this into:
- // "load value; load 0; bge; ret -value ; ret value".
- // The bge command branches for comparisons with the unordered NaN. So
- // it runs the else case, which returns +value instead of negating it.
- // return (value < 0) ? -value : value;
-
- public static Decimal Abs(Decimal value)
- {
- return Decimal.Abs(value);
- }
-
- /*================================MAX=========================================
- **Returns the larger of val1 and val2
- ============================================================================*/
- [CLSCompliant(false)]
- [System.Runtime.Versioning.NonVersionable]
- public static sbyte Max(sbyte val1, sbyte val2)
- {
- return (val1 >= val2) ? val1 : val2;
- }
+ if (double.IsNaN(val1))
+ {
+ return val1;
+ }
- [System.Runtime.Versioning.NonVersionable]
- public static byte Max(byte val1, byte val2)
- {
- return (val1 >= val2) ? val1 : val2;
+ return val2;
}
- [System.Runtime.Versioning.NonVersionable]
+ [NonVersionable]
public static short Max(short val1, short val2)
{
return (val1 >= val2) ? val1 : val2;
}
- [CLSCompliant(false)]
- [System.Runtime.Versioning.NonVersionable]
- public static ushort Max(ushort val1, ushort val2)
- {
- return (val1 >= val2) ? val1 : val2;
- }
-
- [System.Runtime.Versioning.NonVersionable]
+ [NonVersionable]
public static int Max(int val1, int val2)
{
return (val1 >= val2) ? val1 : val2;
}
- [CLSCompliant(false)]
- [System.Runtime.Versioning.NonVersionable]
- public static uint Max(uint val1, uint val2)
- {
- return (val1 >= val2) ? val1 : val2;
- }
-
- [System.Runtime.Versioning.NonVersionable]
+ [NonVersionable]
public static long Max(long val1, long val2)
{
return (val1 >= val2) ? val1 : val2;
}
[CLSCompliant(false)]
- [System.Runtime.Versioning.NonVersionable]
- public static ulong Max(ulong val1, ulong val2)
+ [NonVersionable]
+ public static sbyte Max(sbyte val1, sbyte val2)
{
return (val1 >= val2) ? val1 : val2;
}
-
+
public static float Max(float val1, float val2)
{
if (val1 > val2)
+ {
return val1;
+ }
- if (Single.IsNaN(val1))
+ if (float.IsNaN(val1))
+ {
return val1;
+ }
return val2;
}
- public static double Max(double val1, double val2)
+ [CLSCompliant(false)]
+ [NonVersionable]
+ public static ushort Max(ushort val1, ushort val2)
{
- if (val1 > val2)
- return val1;
-
- if (Double.IsNaN(val1))
- return val1;
-
- return val2;
+ return (val1 >= val2) ? val1 : val2;
}
- public static Decimal Max(Decimal val1, Decimal val2)
+ [CLSCompliant(false)]
+ [NonVersionable]
+ public static uint Max(uint val1, uint val2)
{
- return Decimal.Max(val1, val2);
+ return (val1 >= val2) ? val1 : val2;
}
- /*================================MIN=========================================
- **Returns the smaller of val1 and val2.
- ============================================================================*/
[CLSCompliant(false)]
- [System.Runtime.Versioning.NonVersionable]
- public static sbyte Min(sbyte val1, sbyte val2)
+ [NonVersionable]
+ public static ulong Max(ulong val1, ulong val2)
{
- return (val1 <= val2) ? val1 : val2;
+ return (val1 >= val2) ? val1 : val2;
}
- [System.Runtime.Versioning.NonVersionable]
+ [NonVersionable]
public static byte Min(byte val1, byte val2)
{
return (val1 <= val2) ? val1 : val2;
}
- [System.Runtime.Versioning.NonVersionable]
- public static short Min(short val1, short val2)
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static decimal Min(decimal val1, decimal val2)
{
- return (val1 <= val2) ? val1 : val2;
+ return decimal.Min(val1, val2);
}
- [CLSCompliant(false)]
- [System.Runtime.Versioning.NonVersionable]
- public static ushort Min(ushort val1, ushort val2)
+ public static double Min(double val1, double val2)
{
- return (val1 <= val2) ? val1 : val2;
+ if (val1 < val2)
+ {
+ return val1;
+ }
+
+ if (double.IsNaN(val1))
+ {
+ return val1;
+ }
+
+ return val2;
}
- [System.Runtime.Versioning.NonVersionable]
- public static int Min(int val1, int val2)
+ [NonVersionable]
+ public static short Min(short val1, short val2)
{
return (val1 <= val2) ? val1 : val2;
}
- [CLSCompliant(false)]
- [System.Runtime.Versioning.NonVersionable]
- public static uint Min(uint val1, uint val2)
+ [NonVersionable]
+ public static int Min(int val1, int val2)
{
return (val1 <= val2) ? val1 : val2;
}
- [System.Runtime.Versioning.NonVersionable]
+ [NonVersionable]
public static long Min(long val1, long val2)
{
return (val1 <= val2) ? val1 : val2;
}
[CLSCompliant(false)]
- [System.Runtime.Versioning.NonVersionable]
- public static ulong Min(ulong val1, ulong val2)
+ [NonVersionable]
+ public static sbyte Min(sbyte val1, sbyte val2)
{
return (val1 <= val2) ? val1 : val2;
}
@@ -466,259 +546,287 @@ namespace System
public static float Min(float val1, float val2)
{
if (val1 < val2)
+ {
return val1;
+ }
- if (Single.IsNaN(val1))
+ if (float.IsNaN(val1))
+ {
return val1;
+ }
return val2;
}
- public static double Min(double val1, double val2)
+ [CLSCompliant(false)]
+ [NonVersionable]
+ public static ushort Min(ushort val1, ushort val2)
{
- if (val1 < val2)
- return val1;
-
- if (Double.IsNaN(val1))
- return val1;
-
- return val2;
+ return (val1 <= val2) ? val1 : val2;
}
- public static Decimal Min(Decimal val1, Decimal val2)
+ [CLSCompliant(false)]
+ [NonVersionable]
+ public static uint Min(uint val1, uint val2)
{
- return Decimal.Min(val1, val2);
+ return (val1 <= val2) ? val1 : val2;
}
- /*=====================================Clamp====================================
- **
- ==============================================================================*/
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Byte Clamp(Byte value, Byte min, Byte max)
+ [CLSCompliant(false)]
+ [NonVersionable]
+ public static ulong Min(ulong val1, ulong val2)
{
- if (min > max)
- ThrowMinMaxException(min, max);
- if (value < min)
- return min;
- else if (value > max)
- return max;
- return value;
+ return (val1 <= val2) ? val1 : val2;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Decimal Clamp(Decimal value, Decimal min, Decimal max)
+ public static decimal Round(decimal d)
{
- if (min > max)
- ThrowMinMaxException(min, max);
- if (value < min)
- return min;
- else if (value > max)
- return max;
- return value;
+ return decimal.Round(d, 0);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Double Clamp(Double value, Double min, Double max)
+ public static decimal Round(decimal d, int decimals)
{
- if (min > max)
- ThrowMinMaxException(min, max);
- if (value < min)
- return min;
- else if (value > max)
- return max;
- return value;
+ return decimal.Round(d, decimals);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Int16 Clamp(Int16 value, Int16 min, Int16 max)
+ public static decimal Round(decimal d, MidpointRounding mode)
{
- if (min > max)
- ThrowMinMaxException(min, max);
- if (value < min)
- return min;
- else if (value > max)
- return max;
- return value;
+ return decimal.Round(d, 0, mode);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Int32 Clamp(Int32 value, Int32 min, Int32 max)
+ public static decimal Round(decimal d, int decimals, MidpointRounding mode)
{
- if (min > max)
- ThrowMinMaxException(min, max);
- if (value < min)
- return min;
- else if (value > max)
- return max;
- return value;
+ return decimal.Round(d, decimals, mode);
}
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Int64 Clamp(Int64 value, Int64 min, Int64 max)
+ [Intrinsic]
+ public static double Round(double a)
{
- if (min > max)
- ThrowMinMaxException(min, max);
- if (value < min)
- return min;
- else if (value > max)
- return max;
- return value;
- }
+ // ************************************************************************************
+ // IMPORTANT: Do not change this implementation without also updating Math.Round(double),
+ // FloatingPointUtils::round(double), and FloatingPointUtils::round(float)
+ // ************************************************************************************
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- [CLSCompliant(false)]
- public static SByte Clamp(SByte value, SByte min, SByte max)
- {
- if (min > max)
- ThrowMinMaxException(min, max);
- if (value < min)
- return min;
- else if (value > max)
- return max;
- return value;
- }
+ // If the number has no fractional part do nothing
+ // This shortcut is necessary to workaround precision loss in borderline cases on some platforms
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Single Clamp(Single value, Single min, Single max)
- {
- if (min > max)
- ThrowMinMaxException(min, max);
- if (value < min)
- return min;
- else if (value > max)
- return max;
- return value;
- }
+ if (a == (double)((long)a))
+ {
+ return a;
+ }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- [CLSCompliant(false)]
- public static UInt16 Clamp(UInt16 value, UInt16 min, UInt16 max)
- {
- if (min > max)
- ThrowMinMaxException(min, max);
- if (value < min)
- return min;
- else if (value > max)
- return max;
- return value;
- }
+ // We had a number that was equally close to 2 integers.
+ // We need to return the even one.
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- [CLSCompliant(false)]
- public static UInt32 Clamp(UInt32 value, UInt32 min, UInt32 max)
- {
- if (min > max)
- ThrowMinMaxException(min, max);
- if (value < min)
- return min;
- else if (value > max)
- return max;
- return value;
+ double flrTempVal = Floor(a + 0.5);
+
+ if ((a == (Floor(a) + 0.5)) && (FMod(flrTempVal, 2.0) != 0))
+ {
+ flrTempVal -= 1.0;
+ }
+
+ return copysign(flrTempVal, a);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- [CLSCompliant(false)]
- public static UInt64 Clamp(UInt64 value, UInt64 min, UInt64 max)
+ public static double Round(double value, int digits)
{
- if (min > max)
- ThrowMinMaxException(min, max);
- if (value < min)
- return min;
- else if (value > max)
- return max;
- return value;
+ return Round(value, digits, MidpointRounding.ToEven);
}
- private static void ThrowMinMaxException<T>(T min, T max)
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static double Round(double value, MidpointRounding mode)
{
- throw new ArgumentException(SR.Format(SR.Argument_MinMaxValue, min, max));
+ return Round(value, 0, mode);
}
- /*=====================================Log======================================
- **
- ==============================================================================*/
- public static double Log(double a, double newBase)
+ public static unsafe double Round(double value, int digits, MidpointRounding mode)
{
- if (Double.IsNaN(a))
+ if ((digits < 0) || (digits > maxRoundingDigits))
{
- return a; // IEEE 754-2008: NaN payload must be preserved
+ throw new ArgumentOutOfRangeException(nameof(digits), SR.ArgumentOutOfRange_RoundingDigits);
}
- if (Double.IsNaN(newBase))
+
+ if (mode < MidpointRounding.ToEven || mode > MidpointRounding.AwayFromZero)
{
- return newBase; // IEEE 754-2008: NaN payload must be preserved
+ throw new ArgumentException(SR.Format(SR.Argument_InvalidEnumValue, mode, nameof(MidpointRounding)), nameof(mode));
}
- if (newBase == 1)
- return Double.NaN;
- if (a != 1 && (newBase == 0 || Double.IsPositiveInfinity(newBase)))
- return Double.NaN;
+ if (Abs(value) < doubleRoundLimit)
+ {
+ var power10 = roundPower10Double[digits];
- return (Log(a) / Log(newBase));
- }
+ value *= power10;
+ if (mode == MidpointRounding.AwayFromZero)
+ {
+ var fraction = ModF(value, &value);
- // Sign function for VB. Returns -1, 0, or 1 if the sign of the number
- // is negative, 0, or positive. Throws for floating point NaN's.
- [CLSCompliant(false)]
- public static int Sign(sbyte value) => Sign((int)value);
+ if (Abs(fraction) >= 0.5)
+ {
+ value += Sign(fraction);
+ }
+ }
+ else
+ {
+ value = Round(value);
+ }
- // Sign function for VB. Returns -1, 0, or 1 if the sign of the number
- // is negative, 0, or positive. Throws for floating point NaN's.
- public static int Sign(short value) => Sign((int)value);
+ value /= power10;
+ }
- // Sign function for VB. Returns -1, 0, or 1 if the sign of the number
- // is negative, 0, or positive. Throws for floating point NaN's.
- public static int Sign(int value) => unchecked(value >> 31 | (int)((uint)-value >> 31));
+ return value;
+ }
- public static int Sign(long value) => unchecked((int)(value >> 63 | (long)((ulong)-value >> 63)));
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static int Sign(decimal value)
+ {
+ return decimal.Sign(ref value);
+ }
- public static int Sign(float value)
+ public static int Sign(double value)
{
if (value < 0)
+ {
return -1;
+ }
else if (value > 0)
+ {
return 1;
+ }
else if (value == 0)
+ {
return 0;
+ }
+
throw new ArithmeticException(SR.Arithmetic_NaN);
}
- public static int Sign(double value)
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static int Sign(short value)
+ {
+ return Sign((int)value);
+ }
+
+ public static int Sign(int value)
+ {
+ return unchecked(value >> 31 | (int)((uint)-value >> 31));
+ }
+
+ public static int Sign(long value)
+ {
+ return unchecked((int)(value >> 63 | (long)((ulong)-value >> 63)));
+ }
+
+ [CLSCompliant(false)]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static int Sign(sbyte value)
+ {
+ return Sign((int)value);
+ }
+
+ public static int Sign(float value)
{
if (value < 0)
+ {
return -1;
+ }
else if (value > 0)
+ {
return 1;
+ }
else if (value == 0)
+ {
return 0;
+ }
+
throw new ArithmeticException(SR.Arithmetic_NaN);
}
- public static int Sign(decimal value) => decimal.Sign(ref value);
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static decimal Truncate(decimal d)
+ {
+ return decimal.Truncate(d);
+ }
- public static long BigMul(int a, int b)
+ public static unsafe double Truncate(double d)
{
- return ((long)a) * b;
+ ModF(d, &d);
+ return d;
}
- public static int DivRem(int a, int b, out int result)
+ private static short AbsHelper(short value)
{
- // TODO https://github.com/dotnet/coreclr/issues/3439:
- // Restore to using % and / when the JIT is able to eliminate one of the idivs.
- // In the meantime, a * and - is measurably faster than an extra /.
- int div = a / b;
- result = a - (div * b);
- return div;
+ Debug.Assert(value < 0, "AbsHelper should only be called for negative values! (workaround for JIT inlining)");
+
+ if (value == short.MinValue)
+ {
+ throw new OverflowException(SR.Overflow_NegateTwosCompNum);
+ }
+
+ return ((short)(-value));
}
- public static long DivRem(long a, long b, out long result)
+ private static int AbsHelper(int value)
{
- // TODO https://github.com/dotnet/coreclr/issues/3439:
- // Restore to using % and / when the JIT is able to eliminate one of the idivs.
- // In the meantime, a * and - is measurably faster than an extra /.
- long div = a / b;
- result = a - (div * b);
- return div;
+ Debug.Assert(value < 0, "AbsHelper should only be called for negative values! (workaround for JIT inlining)");
+
+ if (value == int.MinValue)
+ {
+ throw new OverflowException(SR.Overflow_NegateTwosCompNum);
+ }
+
+ return -value;
+ }
+
+ private static long AbsHelper(long value)
+ {
+ Debug.Assert(value < 0, "AbsHelper should only be called for negative values! (workaround for JIT inlining)");
+
+ if (value == long.MinValue)
+ {
+ throw new OverflowException(SR.Overflow_NegateTwosCompNum);
+ }
+
+ return -value;
+ }
+
+ private static sbyte AbsHelper(sbyte value)
+ {
+ Debug.Assert(value < 0, "AbsHelper should only be called for negative values! (workaround for JIT inlining)");
+
+ if (value == sbyte.MinValue)
+ {
+ throw new OverflowException(SR.Overflow_NegateTwosCompNum);
+ }
+
+ return ((sbyte)(-value));
+ }
+
+ private static unsafe double copysign(double x, double y)
+ {
+ var xbits = BitConverter.DoubleToInt64Bits(x);
+ var ybits = BitConverter.DoubleToInt64Bits(y);
+
+ // If the sign bits of x and y are not the same,
+ // flip the sign bit of x and return the new value;
+ // otherwise, just return x
+
+ if (((xbits ^ ybits) >> 63) != 0)
+ {
+ return BitConverter.Int64BitsToDouble(xbits ^ long.MinValue);
+ }
+
+ return x;
+ }
+
+ private static void ThrowMinMaxException<T>(T min, T max)
+ {
+ throw new ArgumentException(SR.Format(SR.Argument_MinMaxValue, min, max));
}
}
}
diff --git a/src/mscorlib/src/System/MathF.cs b/src/mscorlib/shared/System/MathF.cs
index 60669a4561..5b7e48b062 100644
--- a/src/mscorlib/src/System/MathF.cs
+++ b/src/mscorlib/shared/System/MathF.cs
@@ -10,18 +10,16 @@
//This class contains only static members and doesn't require serialization.
-using System;
using System.Runtime;
using System.Runtime.CompilerServices;
-using System.Runtime.ConstrainedExecution;
-using System.Runtime.Versioning;
-using System.Diagnostics.Contracts;
namespace System
{
- public static class MathF
+ public static partial class MathF
{
- private static float singleRoundLimit = 1e8f;
+ public const float E = 2.71828183f;
+
+ public const float PI = 3.14159265f;
private const int maxRoundingDigits = 6;
@@ -30,38 +28,13 @@ namespace System
1e0f, 1e1f, 1e2f, 1e3f, 1e4f, 1e5f, 1e6f
};
- public const float PI = 3.14159265f;
-
- public const float E = 2.71828183f;
-
- public static float Abs(float x) => Math.Abs(x);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern float Acos(float x);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern float Asin(float x);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern float Atan(float x);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern float Atan2(float y, float x);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern float Ceiling(float x);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern float Cos(float x);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern float Cosh(float x);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern float Exp(float x);
+ private static float singleRoundLimit = 1e8f;
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern float Floor(float x);
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static float Abs(float x)
+ {
+ return Math.Abs(x);
+ }
public static float IEEERemainder(float x, float y)
{
@@ -114,9 +87,6 @@ namespace System
}
}
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern float Log(float x);
-
public static float Log(float x, float y)
{
if (float.IsNaN(x))
@@ -142,31 +112,60 @@ namespace System
return Log(x) / Log(y);
}
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern float Log10(float x);
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static float Max(float x, float y)
+ {
+ return Math.Max(x, y);
+ }
- public static float Max(float x, float y) => Math.Max(x, y);
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static float Min(float x, float y)
+ {
+ return Math.Min(x, y);
+ }
- public static float Min(float x, float y) => Math.Min(x, y);
+ [Intrinsic]
+ public static float Round(float x)
+ {
+ // ************************************************************************************
+ // IMPORTANT: Do not change this implementation without also updating Math.Round(double),
+ // FloatingPointUtils::round(double), and FloatingPointUtils::round(float)
+ // ************************************************************************************
+
+ // If the number has no fractional part do nothing
+ // This shortcut is necessary to workaround precision loss in borderline cases on some platforms
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern float Pow(float x, float y);
+ if (x == (float)((int)x))
+ {
+ return x;
+ }
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern float Round(float x);
+ // We had a number that was equally close to 2 integers.
+ // We need to return the even one.
- public static float Round(float x, int digits)
- {
- if ((digits < 0) || (digits > maxRoundingDigits))
+ float flrTempVal = Floor(x + 0.5f);
+
+ if ((x == (Floor(x) + 0.5f)) && (FMod(flrTempVal, 2.0f) != 0))
{
- throw new ArgumentOutOfRangeException(nameof(digits), SR.ArgumentOutOfRange_RoundingDigits);
+ flrTempVal -= 1.0f;
}
- Contract.EndContractBlock();
- return InternalRound(x, digits, MidpointRounding.ToEven);
+ return CopySign(flrTempVal, x);
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static float Round(float x, int digits)
+ {
+ return Round(x, digits, MidpointRounding.ToEven);
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static float Round(float x, MidpointRounding mode)
+ {
+ return Round(x, 0, mode);
}
- public static float Round(float x, int digits, MidpointRounding mode)
+ public static unsafe float Round(float x, int digits, MidpointRounding mode)
{
if ((digits < 0) || (digits > maxRoundingDigits))
{
@@ -177,43 +176,7 @@ namespace System
{
throw new ArgumentException(SR.Format(SR.Argument_InvalidEnum, mode, nameof(MidpointRounding)), nameof(mode));
}
- Contract.EndContractBlock();
-
- return InternalRound(x, digits, mode);
- }
-
- public static float Round(float x, MidpointRounding mode)
- {
- if (mode < MidpointRounding.ToEven || mode > MidpointRounding.AwayFromZero)
- {
- throw new ArgumentException(SR.Format(SR.Argument_InvalidEnum, mode, nameof(MidpointRounding)), nameof(mode));
- }
- Contract.EndContractBlock();
-
- return InternalRound(x, 0, mode);
- }
-
- public static int Sign(float x) => Math.Sign(x);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern float Sin(float x);
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern float Sinh(float x);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern float Sqrt(float x);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern float Tan(float x);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern float Tanh(float x);
-
- public static float Truncate(float x) => InternalTruncate(x);
-
- private static unsafe float InternalRound(float x, int digits, MidpointRounding mode)
- {
if (Abs(x) < singleRoundLimit)
{
var power10 = roundPower10Single[digits];
@@ -222,7 +185,7 @@ namespace System
if (mode == MidpointRounding.AwayFromZero)
{
- var fraction = SplitFractionSingle(&x);
+ var fraction = ModF(x, &x);
if (Abs(fraction) >= 0.5f)
{
@@ -240,13 +203,33 @@ namespace System
return x;
}
- private unsafe static float InternalTruncate(float x)
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static int Sign(float x)
+ {
+ return Math.Sign(x);
+ }
+
+ public static unsafe float Truncate(float x)
{
- SplitFractionSingle(&x);
+ ModF(x, &x);
return x;
}
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static unsafe extern float SplitFractionSingle(float* x);
+ private static unsafe float CopySign(float x, float y)
+ {
+ var xbits = BitConverter.SingleToInt32Bits(x);
+ var ybits = BitConverter.SingleToInt32Bits(y);
+
+ // If the sign bits of x and y are not the same,
+ // flip the sign bit of x and return the new value;
+ // otherwise, just return x
+
+ if (((xbits ^ ybits) >> 31) != 0)
+ {
+ return BitConverter.Int32BitsToSingle(xbits ^ int.MinValue);
+ }
+
+ return x;
+ }
}
}
diff --git a/src/mscorlib/shared/System/Memory.cs b/src/mscorlib/shared/System/Memory.cs
index 270f88e4bc..63d36a9641 100644
--- a/src/mscorlib/shared/System/Memory.cs
+++ b/src/mscorlib/shared/System/Memory.cs
@@ -12,6 +12,8 @@ using System.Runtime.InteropServices;
namespace System
{
+ [DebuggerDisplay("{DebuggerDisplay,nq}")]
+ [DebuggerTypeProxy(typeof(MemoryDebugView<>))]
public struct Memory<T>
{
// The highest order bit of _index is used to discern whether _arrayOrOwnedMemory is an array or an owned memory
@@ -106,6 +108,9 @@ namespace System
return new ReadOnlyMemory<T>((T[])memory._arrayOrOwnedMemory, memory._index, memory._length);
}
+ //Debugger Display = {T[length]}
+ private string DebuggerDisplay => string.Format("{{{0}[{1}]}}", typeof(T).Name, _length);
+
/// <summary>
/// Returns an empty <see cref="Memory{T}"/>
/// </summary>
@@ -167,7 +172,7 @@ namespace System
get
{
if (_index < 0)
- return ((OwnedMemory<T>)_arrayOrOwnedMemory).AsSpan().Slice(_index & RemoveOwnedFlagBitMask, _length);
+ return ((OwnedMemory<T>)_arrayOrOwnedMemory).Span.Slice(_index & RemoveOwnedFlagBitMask, _length);
return new Span<T>((T[])_arrayOrOwnedMemory, _index, _length);
}
}
@@ -180,6 +185,7 @@ namespace System
if (_index < 0)
{
memoryHandle = ((OwnedMemory<T>)_arrayOrOwnedMemory).Pin();
+ memoryHandle.AddOffset((_index & RemoveOwnedFlagBitMask) * Unsafe.SizeOf<T>());
}
else
{
@@ -281,4 +287,4 @@ namespace System
}
}
-} \ No newline at end of file
+}
diff --git a/src/mscorlib/shared/System/MemoryDebugView.cs b/src/mscorlib/shared/System/MemoryDebugView.cs
new file mode 100644
index 0000000000..761d558cc6
--- /dev/null
+++ b/src/mscorlib/shared/System/MemoryDebugView.cs
@@ -0,0 +1,40 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Diagnostics;
+
+namespace System
+{
+ internal sealed class MemoryDebugView<T>
+ {
+ private readonly ReadOnlyMemory<T> _memory;
+
+ public MemoryDebugView(Memory<T> memory)
+ {
+ _memory = memory;
+ }
+
+ public MemoryDebugView(ReadOnlyMemory<T> memory)
+ {
+ _memory = memory;
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
+ public T[] Items
+ {
+ // This is a work around since we cannot use _memory.ToArray() due to
+ // https://devdiv.visualstudio.com/DevDiv/_workitems?id=286592
+ get
+ {
+ if (_memory.DangerousTryGetArray(out ArraySegment<T> segment))
+ {
+ T[] array = new T[_memory.Length];
+ Array.Copy(segment.Array, segment.Offset, array, 0, array.Length);
+ return array;
+ }
+ return Array.Empty<T>();
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/src/mscorlib/shared/System/ParseNumbers.cs b/src/mscorlib/shared/System/ParseNumbers.cs
new file mode 100644
index 0000000000..3b02250b0e
--- /dev/null
+++ b/src/mscorlib/shared/System/ParseNumbers.cs
@@ -0,0 +1,674 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+
+namespace System
+{
+ /// <summary>Methods for parsing numbers and strings.</summary>
+ internal static class ParseNumbers
+ {
+ internal const int LeftAlign = 0x0001;
+ internal const int RightAlign = 0x0004;
+ internal const int PrefixSpace = 0x0008;
+ internal const int PrintSign = 0x0010;
+ internal const int PrintBase = 0x0020;
+ internal const int PrintAsI1 = 0x0040;
+ internal const int PrintAsI2 = 0x0080;
+ internal const int PrintAsI4 = 0x0100;
+ internal const int TreatAsUnsigned = 0x0200;
+ internal const int TreatAsI1 = 0x0400;
+ internal const int TreatAsI2 = 0x0800;
+ internal const int IsTight = 0x1000;
+ internal const int NoSpace = 0x2000;
+ internal const int PrintRadixBase = 0x4000;
+
+ private const int MinRadix = 2;
+ private const int MaxRadix = 36;
+
+ public static unsafe long StringToLong(ReadOnlySpan<char> s, int radix, int flags)
+ {
+ int pos = 0;
+ return StringToLong(s, radix, flags, ref pos);
+ }
+
+ public static long StringToLong(ReadOnlySpan<char> s, int radix, int flags, ref int currPos)
+ {
+ int i = currPos;
+
+ // Do some radix checking.
+ // A radix of -1 says to use whatever base is spec'd on the number.
+ // Parse in Base10 until we figure out what the base actually is.
+ int r = (-1 == radix) ? 10 : radix;
+
+ if (r != 2 && r != 10 && r != 8 && r != 16)
+ throw new ArgumentException(SR.Arg_InvalidBase, nameof(radix));
+
+ int length = s.Length;
+
+ if (i < 0 || i >= length)
+ throw new ArgumentOutOfRangeException(SR.ArgumentOutOfRange_Index);
+
+ // Get rid of the whitespace and then check that we've still got some digits to parse.
+ if (((flags & IsTight) == 0) && ((flags & NoSpace) == 0))
+ {
+ EatWhiteSpace(s, ref i);
+ if (i == length)
+ throw new FormatException(SR.Format_EmptyInputString);
+ }
+
+ // Check for a sign
+ int sign = 1;
+ if (s[i] == '-')
+ {
+ if (r != 10)
+ throw new ArgumentException(SR.Arg_CannotHaveNegativeValue);
+
+ if ((flags & TreatAsUnsigned) != 0)
+ throw new OverflowException(SR.Overflow_NegativeUnsigned);
+
+ sign = -1;
+ i++;
+ }
+ else if (s[i] == '+')
+ {
+ i++;
+ }
+
+ if ((radix == -1 || radix == 16) && (i + 1 < length) && s[i] == '0')
+ {
+ if (s[i + 1] == 'x' || s[i + 1] == 'X')
+ {
+ r = 16;
+ i += 2;
+ }
+ }
+
+ int grabNumbersStart = i;
+ long result = GrabLongs(r, s, ref i, (flags & TreatAsUnsigned) != 0);
+
+ // Check if they passed us a string with no parsable digits.
+ if (i == grabNumbersStart)
+ throw new FormatException(SR.Format_NoParsibleDigits);
+
+ if ((flags & IsTight) != 0)
+ {
+ //If we've got effluvia left at the end of the string, complain.
+ if (i < length)
+ throw new FormatException(SR.Format_ExtraJunkAtEnd);
+ }
+
+ // Put the current index back into the correct place.
+ currPos = i;
+
+ // Return the value properly signed.
+ if ((ulong)result == 0x8000000000000000 && sign == 1 && r == 10 && ((flags & TreatAsUnsigned) == 0))
+ throw new OverflowException(SR.Overflow_Int64);
+
+ if (r == 10)
+ {
+ result *= sign;
+ }
+
+ return result;
+ }
+
+ public static int StringToInt(ReadOnlySpan<char> s, int radix, int flags)
+ {
+ int pos = 0;
+ return StringToInt(s, radix, flags, ref pos);
+ }
+
+ public static int StringToInt(ReadOnlySpan<char> s, int radix, int flags, ref int currPos)
+ {
+ // They're requied to tell me where to start parsing.
+ int i = currPos;
+
+ // Do some radix checking.
+ // A radix of -1 says to use whatever base is spec'd on the number.
+ // Parse in Base10 until we figure out what the base actually is.
+ int r = (-1 == radix) ? 10 : radix;
+
+ if (r != 2 && r != 10 && r != 8 && r != 16)
+ throw new ArgumentException(SR.Arg_InvalidBase, nameof(radix));
+
+ int length = s.Length;
+
+ if (i < 0 || i >= length)
+ throw new ArgumentOutOfRangeException(SR.ArgumentOutOfRange_Index);
+
+ // Get rid of the whitespace and then check that we've still got some digits to parse.
+ if (((flags & IsTight) == 0) && ((flags & NoSpace) == 0))
+ {
+ EatWhiteSpace(s, ref i);
+ if (i == length)
+ throw new FormatException(SR.Format_EmptyInputString);
+ }
+
+ // Check for a sign
+ int sign = 1;
+ if (s[i] == '-')
+ {
+ if (r != 10)
+ throw new ArgumentException(SR.Arg_CannotHaveNegativeValue);
+
+ if ((flags & TreatAsUnsigned) != 0)
+ throw new OverflowException(SR.Overflow_NegativeUnsigned);
+
+ sign = -1;
+ i++;
+ }
+ else if (s[i] == '+')
+ {
+ i++;
+ }
+
+ // Consume the 0x if we're in an unknown base or in base-16.
+ if ((radix == -1 || radix == 16) && (i + 1 < length) && s[i] == '0')
+ {
+ if (s[i + 1] == 'x' || s[i + 1] == 'X')
+ {
+ r = 16;
+ i += 2;
+ }
+ }
+
+ int grabNumbersStart = i;
+ int result = GrabInts(r, s, ref i, ((flags & TreatAsUnsigned) != 0));
+
+ // Check if they passed us a string with no parsable digits.
+ if (i == grabNumbersStart)
+ throw new FormatException(SR.Format_NoParsibleDigits);
+
+ if ((flags & IsTight) != 0)
+ {
+ // If we've got effluvia left at the end of the string, complain.
+ if (i < length)
+ throw new FormatException(SR.Format_ExtraJunkAtEnd);
+ }
+
+ // Put the current index back into the correct place.
+ currPos = i;
+
+ // Return the value properly signed.
+ if ((flags & TreatAsI1) != 0)
+ {
+ if ((uint)result > 0xFF)
+ throw new OverflowException(SR.Overflow_SByte);
+ }
+ else if ((flags & TreatAsI2) != 0)
+ {
+ if ((uint)result > 0xFFFF)
+ throw new OverflowException(SR.Overflow_Int16);
+ }
+ else if ((uint)result == 0x80000000 && sign == 1 && r == 10 && ((flags & TreatAsUnsigned) == 0))
+ {
+ throw new OverflowException(SR.Overflow_Int32);
+ }
+
+ if (r == 10)
+ {
+ result *= sign;
+ }
+
+ return result;
+ }
+
+ public static string IntToString(int n, int radix, int width, char paddingChar, int flags)
+ {
+ Span<char> buffer;
+ unsafe
+ {
+ char* tmpBuffer = stackalloc char[66]; // Longest possible string length for an integer in binary notation with prefix
+ buffer = new Span<char>(tmpBuffer, 66);
+ }
+
+ if (radix < MinRadix || radix > MaxRadix)
+ throw new ArgumentException(SR.Arg_InvalidBase, nameof(radix));
+
+ // If the number is negative, make it positive and remember the sign.
+ // If the number is MIN_VALUE, this will still be negative, so we'll have to
+ // special case this later.
+ bool isNegative = false;
+ uint l;
+ if (n < 0)
+ {
+ isNegative = true;
+
+ // For base 10, write out -num, but other bases write out the
+ // 2's complement bit pattern
+ l = (10 == radix) ? (uint)-n : (uint)n;
+ }
+ else
+ {
+ l = (uint)n;
+ }
+
+ // The conversion to a uint will sign extend the number. In order to ensure
+ // that we only get as many bits as we expect, we chop the number.
+ if ((flags & PrintAsI1) != 0)
+ {
+ l &= 0xFF;
+ }
+ else if ((flags & PrintAsI2) != 0)
+ {
+ l &= 0xFFFF;
+ }
+
+ // Special case the 0.
+ int index;
+ if (0 == l)
+ {
+ buffer[0] = '0';
+ index = 1;
+ }
+ else
+ {
+ index = 0;
+ for (int i = 0; i < buffer.Length; i++) // for(...;i<buffer.Length;...) loop instead of do{...}while(l!=0) to help JIT eliminate span bounds checks
+ {
+ uint div = l / (uint)radix; // TODO https://github.com/dotnet/coreclr/issues/3439
+ uint charVal = l - (div * (uint)radix);
+ l = div;
+
+ buffer[i] = (charVal < 10) ?
+ (char)(charVal + '0') :
+ (char)(charVal + 'a' - 10);
+
+ if (l == 0)
+ {
+ index = i + 1;
+ break;
+ }
+ }
+
+ Debug.Assert(l == 0, $"Expected {l} == 0");
+ }
+
+ // If they want the base, append that to the string (in reverse order)
+ if (radix != 10 && ((flags & PrintBase) != 0))
+ {
+ if (16 == radix)
+ {
+ buffer[index++] = 'x';
+ buffer[index++] = '0';
+ }
+ else if (8 == radix)
+ {
+ buffer[index++] = '0';
+ }
+ }
+
+ if (10 == radix)
+ {
+ // If it was negative, append the sign, else if they requested, add the '+'.
+ // If they requested a leading space, put it on.
+ if (isNegative)
+ {
+ buffer[index++] = '-';
+ }
+ else if ((flags & PrintSign) != 0)
+ {
+ buffer[index++] = '+';
+ }
+ else if ((flags & PrefixSpace) != 0)
+ {
+ buffer[index++] = ' ';
+ }
+ }
+
+ // Figure out the size of and allocate the resulting string
+ string result = string.FastAllocateString(Math.Max(width, index));
+ unsafe
+ {
+ // Put the characters into the string in reverse order.
+ // Fill the remaining space, if there is any, with the correct padding character.
+ fixed (char* resultPtr = result)
+ {
+ char* p = resultPtr;
+ int padding = result.Length - index;
+
+ if ((flags & LeftAlign) != 0)
+ {
+ for (int i = 0; i < padding; i++)
+ {
+ *p++ = paddingChar;
+ }
+
+ for (int i = 0; i < index; i++)
+ {
+ *p++ = buffer[index - i - 1];
+ }
+ }
+ else
+ {
+ for (int i = 0; i < index; i++)
+ {
+ *p++ = buffer[index - i - 1];
+ }
+
+ for (int i = 0; i < padding; i++)
+ {
+ *p++ = paddingChar;
+ }
+ }
+
+ Debug.Assert((p - resultPtr) == result.Length, $"Expected {p - resultPtr} == {result.Length}");
+ }
+ }
+ return result;
+ }
+
+ public static string LongToString(long n, int radix, int width, char paddingChar, int flags)
+ {
+ Span<char> buffer;
+ unsafe
+ {
+ char* tmpBuffer = stackalloc char[67]; // Longest possible string length for an integer in binary notation with prefix
+ buffer = new Span<char>(tmpBuffer, 67);
+ }
+
+ if (radix < MinRadix || radix > MaxRadix)
+ throw new ArgumentException(SR.Arg_InvalidBase, nameof(radix));
+
+ //If the number is negative, make it positive and remember the sign.
+ ulong ul;
+ bool isNegative = false;
+ if (n < 0)
+ {
+ isNegative = true;
+
+ // For base 10, write out -num, but other bases write out the
+ // 2's complement bit pattern
+ ul = (10 == radix) ? (ulong)(-n) : (ulong)n;
+ }
+ else
+ {
+ ul = (ulong)n;
+ }
+
+ if ((flags & PrintAsI1) != 0)
+ {
+ ul = ul & 0xFF;
+ }
+ else if ((flags & PrintAsI2) != 0)
+ {
+ ul = ul & 0xFFFF;
+ }
+ else if ((flags & PrintAsI4) != 0)
+ {
+ ul = ul & 0xFFFFFFFF;
+ }
+
+ //Special case the 0.
+ int index;
+ if (0 == ul)
+ {
+ buffer[0] = '0';
+ index = 1;
+ }
+ else
+ {
+ index = 0;
+ for (int i = 0; i < buffer.Length; i++) // for loop instead of do{...}while(l!=0) to help JIT eliminate span bounds checks
+ {
+ ulong div = ul / (ulong)radix; // TODO https://github.com/dotnet/coreclr/issues/3439
+ int charVal = (int)(ul - (div * (ulong)radix));
+ ul = div;
+
+ buffer[i] = (charVal < 10) ?
+ (char)(charVal + '0') :
+ (char)(charVal + 'a' - 10);
+
+ if (ul == 0)
+ {
+ index = i + 1;
+ break;
+ }
+ }
+ Debug.Assert(ul == 0, $"Expected {ul} == 0");
+ }
+
+ //If they want the base, append that to the string (in reverse order)
+ if (radix != 10 && ((flags & PrintBase) != 0))
+ {
+ if (16 == radix)
+ {
+ buffer[index++] = 'x';
+ buffer[index++] = '0';
+ }
+ else if (8 == radix)
+ {
+ buffer[index++] = '0';
+ }
+ else if ((flags & PrintRadixBase) != 0)
+ {
+ buffer[index++] = '#';
+ buffer[index++] = (char)((radix % 10) + '0');
+ buffer[index++] = (char)((radix / 10) + '0');
+ }
+ }
+
+ if (10 == radix)
+ {
+ //If it was negative, append the sign.
+ if (isNegative)
+ {
+ buffer[index++] = '-';
+ }
+
+ //else if they requested, add the '+';
+ else if ((flags & PrintSign) != 0)
+ {
+ buffer[index++] = '+';
+ }
+
+ //If they requested a leading space, put it on.
+ else if ((flags & PrefixSpace) != 0)
+ {
+ buffer[index++] = ' ';
+ }
+ }
+
+ // Figure out the size of and allocate the resulting string
+ string result = string.FastAllocateString(Math.Max(width, index));
+ unsafe
+ {
+ // Put the characters into the string in reverse order.
+ // Fill the remaining space, if there is any, with the correct padding character.
+ fixed (char* resultPtr = result)
+ {
+ char* p = resultPtr;
+ int padding = result.Length - index;
+
+ if ((flags & LeftAlign) != 0)
+ {
+ for (int i = 0; i < padding; i++)
+ {
+ *p++ = paddingChar;
+ }
+
+ for (int i = 0; i < index; i++)
+ {
+ *p++ = buffer[index - i - 1];
+ }
+ }
+ else
+ {
+ for (int i = 0; i < index; i++)
+ {
+ *p++ = buffer[index - i - 1];
+ }
+
+ for (int i = 0; i < padding; i++)
+ {
+ *p++ = paddingChar;
+ }
+ }
+
+ Debug.Assert((p - resultPtr) == result.Length, $"Expected {p - resultPtr} == {result.Length}");
+ }
+ }
+ return result;
+ }
+
+ private static void EatWhiteSpace(ReadOnlySpan<char> s, ref int i)
+ {
+ int localIndex = i;
+ for (; localIndex < s.Length && char.IsWhiteSpace(s[localIndex]); localIndex++);
+ i = localIndex;
+ }
+
+ private static long GrabLongs(int radix, ReadOnlySpan<char> s, ref int i, bool isUnsigned)
+ {
+ ulong result = 0;
+ ulong maxVal;
+
+ // Allow all non-decimal numbers to set the sign bit.
+ if (radix == 10 && !isUnsigned)
+ {
+ maxVal = 0x7FFFFFFFFFFFFFFF / 10;
+
+ // Read all of the digits and convert to a number
+ while (i < s.Length && IsDigit(s[i], radix, out int value))
+ {
+ // Check for overflows - this is sufficient & correct.
+ if (result > maxVal || ((long)result) < 0)
+ {
+ ThrowOverflowInt64Exception();
+ }
+
+ result = result * (ulong)radix + (ulong)value;
+ i++;
+ }
+
+ if ((long)result < 0 && result != 0x8000000000000000)
+ {
+ ThrowOverflowInt64Exception();
+ }
+ }
+ else
+ {
+ Debug.Assert(radix == 2 || radix == 8 || radix == 10 || radix == 16);
+ maxVal =
+ radix == 10 ? 0xffffffffffffffff / 10 :
+ radix == 16 ? 0xffffffffffffffff / 16 :
+ radix == 8 ? 0xffffffffffffffff / 8 :
+ 0xffffffffffffffff / 2;
+
+ // Read all of the digits and convert to a number
+ while (i < s.Length && IsDigit(s[i], radix, out int value))
+ {
+ // Check for overflows - this is sufficient & correct.
+ if (result > maxVal)
+ {
+ ThrowOverflowUInt64Exception();
+ }
+
+ ulong temp = result * (ulong)radix + (ulong)value;
+
+ if (temp < result) // this means overflow as well
+ {
+ ThrowOverflowUInt64Exception();
+ }
+
+ result = temp;
+ i++;
+ }
+ }
+
+ return (long)result;
+ }
+
+ private static int GrabInts(int radix, ReadOnlySpan<char> s, ref int i, bool isUnsigned)
+ {
+ uint result = 0;
+ uint maxVal;
+
+ // Allow all non-decimal numbers to set the sign bit.
+ if (radix == 10 && !isUnsigned)
+ {
+ maxVal = (0x7FFFFFFF / 10);
+
+ // Read all of the digits and convert to a number
+ while (i < s.Length && IsDigit(s[i], radix, out int value))
+ {
+ // Check for overflows - this is sufficient & correct.
+ if (result > maxVal || (int)result < 0)
+ {
+ ThrowOverflowInt32Exception();
+ }
+ result = result * (uint)radix + (uint)value;
+ i++;
+ }
+ if ((int)result < 0 && result != 0x80000000)
+ {
+ ThrowOverflowInt32Exception();
+ }
+ }
+ else
+ {
+ Debug.Assert(radix == 2 || radix == 8 || radix == 10 || radix == 16);
+ maxVal =
+ radix == 10 ? 0xffffffff / 10 :
+ radix == 16 ? 0xffffffff / 16 :
+ radix == 8 ? 0xffffffff / 8 :
+ 0xffffffff / 2;
+
+ // Read all of the digits and convert to a number
+ while (i < s.Length && IsDigit(s[i], radix, out int value))
+ {
+ // Check for overflows - this is sufficient & correct.
+ if (result > maxVal)
+ {
+ throw new OverflowException(SR.Overflow_UInt32);
+ }
+
+ uint temp = result * (uint)radix + (uint)value;
+
+ if (temp < result) // this means overflow as well
+ {
+ ThrowOverflowUInt32Exception();
+ }
+
+ result = temp;
+ i++;
+ }
+ }
+
+ return (int)result;
+ }
+
+ private static void ThrowOverflowInt32Exception() => throw new OverflowException(SR.Overflow_Int32);
+ private static void ThrowOverflowInt64Exception() => throw new OverflowException(SR.Overflow_Int64);
+ private static void ThrowOverflowUInt32Exception() => throw new OverflowException(SR.Overflow_UInt32);
+ private static void ThrowOverflowUInt64Exception() => throw new OverflowException(SR.Overflow_UInt64);
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ private static bool IsDigit(char c, int radix, out int result)
+ {
+ int tmp;
+ if ((uint)(c - '0') <= 9)
+ {
+ result = tmp = c - '0';
+ }
+ else if ((uint)(c - 'A') <= 'Z' - 'A')
+ {
+ result = tmp = c - 'A' + 10;
+ }
+ else if ((uint)(c - 'a') <= 'z' - 'a')
+ {
+ result = tmp = c - 'a' + 10;
+ }
+ else
+ {
+ result = -1;
+ return false;
+ }
+
+ return tmp < radix;
+ }
+ }
+}
diff --git a/src/mscorlib/shared/System/ReadOnlyMemory.cs b/src/mscorlib/shared/System/ReadOnlyMemory.cs
index 8153d02fa3..ddbfbdde89 100644
--- a/src/mscorlib/shared/System/ReadOnlyMemory.cs
+++ b/src/mscorlib/shared/System/ReadOnlyMemory.cs
@@ -12,6 +12,8 @@ using System.Runtime.InteropServices;
namespace System
{
+ [DebuggerDisplay("{DebuggerDisplay,nq}")]
+ [DebuggerTypeProxy(typeof(MemoryDebugView<>))]
public struct ReadOnlyMemory<T>
{
// The highest order bit of _index is used to discern whether _arrayOrOwnedMemory is an array or an owned memory
@@ -81,6 +83,9 @@ namespace System
_length = length;
}
+ //Debugger Display = {T[length]}
+ private string DebuggerDisplay => string.Format("{{{0}[{1}]}}", typeof(T).Name, _length);
+
/// <summary>
/// Defines an implicit conversion of an array to a <see cref="Memory{T}"/>
/// </summary>
@@ -152,7 +157,7 @@ namespace System
get
{
if (_index < 0)
- return ((OwnedMemory<T>)_arrayOrOwnedMemory).AsSpan().Slice(_index & RemoveOwnedFlagBitMask, _length);
+ return ((OwnedMemory<T>)_arrayOrOwnedMemory).Span.Slice(_index & RemoveOwnedFlagBitMask, _length);
return new ReadOnlySpan<T>((T[])_arrayOrOwnedMemory, _index, _length);
}
}
@@ -165,6 +170,7 @@ namespace System
if (_index < 0)
{
memoryHandle = ((OwnedMemory<T>)_arrayOrOwnedMemory).Pin();
+ memoryHandle.AddOffset((_index & RemoveOwnedFlagBitMask) * Unsafe.SizeOf<T>());
}
else
{
diff --git a/src/mscorlib/shared/System/ReadOnlySpan.cs b/src/mscorlib/shared/System/ReadOnlySpan.cs
index bcf1697e88..4e1910df60 100644
--- a/src/mscorlib/shared/System/ReadOnlySpan.cs
+++ b/src/mscorlib/shared/System/ReadOnlySpan.cs
@@ -15,6 +15,7 @@ namespace System
/// ReadOnlySpan represents a contiguous region of arbitrary memory. Unlike arrays, it can point to either managed
/// or native memory, or to memory allocated on the stack. It is type- and memory-safe.
/// </summary>
+ [DebuggerDisplay("{DebuggerDisplay,nq}")]
[IsReadOnly]
[IsByRefLike]
[NonVersionable]
@@ -118,6 +119,9 @@ namespace System
_length = length;
}
+ //Debugger Display = {T[length]}
+ private string DebuggerDisplay => string.Format("{{{0}[{1}]}}", typeof(T).Name, _length);
+
/// <summary>
/// Returns a reference to the 0th element of the Span. If the Span is empty, returns a reference to the location where the 0th element
/// would have been stored. Such a reference can be used for pinning but must never be dereferenced.
diff --git a/src/mscorlib/shared/System/Resources/RuntimeResourceSet.cs b/src/mscorlib/shared/System/Resources/RuntimeResourceSet.cs
index 41d7541c24..eadc92c7f8 100644
--- a/src/mscorlib/shared/System/Resources/RuntimeResourceSet.cs
+++ b/src/mscorlib/shared/System/Resources/RuntimeResourceSet.cs
@@ -21,7 +21,6 @@ using System.Globalization;
using System.Reflection;
using System.Runtime.Versioning;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Resources
{
@@ -285,7 +284,6 @@ namespace System.Resources
throw new ArgumentNullException(nameof(key));
if (Reader == null || _resCache == null)
throw new ObjectDisposedException(null, SR.ObjectDisposed_ResourceSet);
- Contract.EndContractBlock();
Object value = null;
ResourceLocator resLocation;
diff --git a/src/mscorlib/shared/System/Runtime/CompilerServices/ConfiguredValueTaskAwaitable.cs b/src/mscorlib/shared/System/Runtime/CompilerServices/ConfiguredValueTaskAwaitable.cs
index 4ec931c4af..0784e6135c 100644
--- a/src/mscorlib/shared/System/Runtime/CompilerServices/ConfiguredValueTaskAwaitable.cs
+++ b/src/mscorlib/shared/System/Runtime/CompilerServices/ConfiguredValueTaskAwaitable.cs
@@ -39,7 +39,7 @@ namespace System.Runtime.CompilerServices
/// <summary>The value being awaited.</summary>
private ValueTask<TResult> _value; // Methods are called on this; avoid making it readonly so as to avoid unnecessary copies
/// <summary>The value to pass to ConfigureAwait.</summary>
- private readonly bool _continueOnCapturedContext;
+ internal readonly bool _continueOnCapturedContext;
/// <summary>Initializes the awaiter.</summary>
/// <param name="value">The value to be awaited.</param>
@@ -66,6 +66,9 @@ namespace System.Runtime.CompilerServices
/// <summary>Schedules the continuation action for the <see cref="ConfiguredValueTaskAwaitable{TResult}"/>.</summary>
public void UnsafeOnCompleted(Action continuation) =>
_value.AsTask().ConfigureAwait(_continueOnCapturedContext).GetAwaiter().UnsafeOnCompleted(continuation);
+
+ /// <summary>Gets the task underlying <see cref="_value"/>.</summary>
+ internal Task<TResult> AsTask() => _value.AsTask();
}
}
}
diff --git a/src/mscorlib/shared/System/Runtime/CompilerServices/ValueTaskAwaiter.cs b/src/mscorlib/shared/System/Runtime/CompilerServices/ValueTaskAwaiter.cs
index c419482521..30e688e077 100644
--- a/src/mscorlib/shared/System/Runtime/CompilerServices/ValueTaskAwaiter.cs
+++ b/src/mscorlib/shared/System/Runtime/CompilerServices/ValueTaskAwaiter.cs
@@ -33,5 +33,8 @@ namespace System.Runtime.CompilerServices
/// <summary>Schedules the continuation action for this ValueTask.</summary>
public void UnsafeOnCompleted(Action continuation) =>
_value.AsTask().ConfigureAwait(continueOnCapturedContext: true).GetAwaiter().UnsafeOnCompleted(continuation);
+
+ /// <summary>Gets the task underlying <see cref="_value"/>.</summary>
+ internal Task<TResult> AsTask() => _value.AsTask();
}
}
diff --git a/src/mscorlib/shared/System/Runtime/Versioning/TargetFrameworkAttribute.cs b/src/mscorlib/shared/System/Runtime/Versioning/TargetFrameworkAttribute.cs
index 54ccdf2c81..a819066382 100644
--- a/src/mscorlib/shared/System/Runtime/Versioning/TargetFrameworkAttribute.cs
+++ b/src/mscorlib/shared/System/Runtime/Versioning/TargetFrameworkAttribute.cs
@@ -13,7 +13,6 @@
===========================================================*/
using System;
-using System.Diagnostics.Contracts;
namespace System.Runtime.Versioning
{
@@ -28,7 +27,6 @@ namespace System.Runtime.Versioning
{
if (frameworkName == null)
throw new ArgumentNullException(nameof(frameworkName));
- Contract.EndContractBlock();
_frameworkName = frameworkName;
}
diff --git a/src/mscorlib/shared/System/SByte.cs b/src/mscorlib/shared/System/SByte.cs
index c984767336..5b5c031d5f 100644
--- a/src/mscorlib/shared/System/SByte.cs
+++ b/src/mscorlib/shared/System/SByte.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Diagnostics.Contracts;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -74,32 +73,26 @@ namespace System
// Provides a string representation of a byte.
public override String ToString()
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatInt32(m_value, null, NumberFormatInfo.CurrentInfo);
}
public String ToString(IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatInt32(m_value, null, NumberFormatInfo.GetInstance(provider));
}
public String ToString(String format)
{
- Contract.Ensures(Contract.Result<String>() != null);
return ToString(format, NumberFormatInfo.CurrentInfo);
}
public String ToString(String format, IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<String>() != null);
return ToString(format, NumberFormatInfo.GetInstance(provider));
}
private String ToString(String format, NumberFormatInfo info)
{
- Contract.Ensures(Contract.Result<String>() != null);
-
if (m_value < 0 && format != null && format.Length > 0 && (format[0] == 'X' || format[0] == 'x'))
{
uint temp = (uint)(m_value & 0x000000FF);
diff --git a/src/mscorlib/shared/System/Single.cs b/src/mscorlib/shared/System/Single.cs
index 0be8cfbc37..14f0ca49ff 100644
--- a/src/mscorlib/shared/System/Single.cs
+++ b/src/mscorlib/shared/System/Single.cs
@@ -11,7 +11,6 @@
**
===========================================================*/
-using System.Diagnostics.Contracts;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -40,7 +39,6 @@ namespace System
internal const float NegativeZero = (float)-0.0;
/// <summary>Determines whether the specified value is finite (zero, subnormal, or normal).</summary>
- [Pure]
[NonVersionable]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsFinite(float f)
@@ -50,7 +48,6 @@ namespace System
}
/// <summary>Determines whether the specified value is infinite.</summary>
- [Pure]
[NonVersionable]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe static bool IsInfinity(float f)
@@ -60,7 +57,6 @@ namespace System
}
/// <summary>Determines whether the specified value is NaN.</summary>
- [Pure]
[NonVersionable]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe static bool IsNaN(float f)
@@ -70,7 +66,6 @@ namespace System
}
/// <summary>Determines whether the specified value is negative.</summary>
- [Pure]
[NonVersionable]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe static bool IsNegative(float f)
@@ -80,7 +75,6 @@ namespace System
}
/// <summary>Determines whether the specified value is negative infinity.</summary>
- [Pure]
[NonVersionable]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe static bool IsNegativeInfinity(float f)
@@ -89,7 +83,6 @@ namespace System
}
/// <summary>Determines whether the specified value is normal.</summary>
- [Pure]
[NonVersionable]
// This is probably not worth inlining, it has branches and should be rarely called
public unsafe static bool IsNormal(float f)
@@ -100,7 +93,6 @@ namespace System
}
/// <summary>Determines whether the specified value is positive infinity.</summary>
- [Pure]
[NonVersionable]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe static bool IsPositiveInfinity(float f)
@@ -109,7 +101,6 @@ namespace System
}
/// <summary>Determines whether the specified value is subnormal.</summary>
- [Pure]
[NonVersionable]
// This is probably not worth inlining, it has branches and should be rarely called
public unsafe static bool IsSubnormal(float f)
@@ -236,25 +227,21 @@ namespace System
public override String ToString()
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatSingle(m_value, null, NumberFormatInfo.CurrentInfo);
}
public String ToString(IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatSingle(m_value, null, NumberFormatInfo.GetInstance(provider));
}
public String ToString(String format)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatSingle(m_value, format, NumberFormatInfo.CurrentInfo);
}
public String ToString(String format, IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatSingle(m_value, format, NumberFormatInfo.GetInstance(provider));
}
diff --git a/src/mscorlib/shared/System/Span.cs b/src/mscorlib/shared/System/Span.cs
index de6787d09d..f4f4e571de 100644
--- a/src/mscorlib/shared/System/Span.cs
+++ b/src/mscorlib/shared/System/Span.cs
@@ -21,6 +21,7 @@ namespace System
/// Span represents a contiguous region of arbitrary memory. Unlike arrays, it can point to either managed
/// or native memory, or to memory allocated on the stack. It is type- and memory-safe.
/// </summary>
+ [DebuggerDisplay("{DebuggerDisplay,nq}")]
[IsReadOnly]
[IsByRefLike]
[NonVersionable]
@@ -130,6 +131,9 @@ namespace System
_length = length;
}
+ //Debugger Display = {T[length]}
+ private string DebuggerDisplay => string.Format("{{{0}[{1}]}}", typeof(T).Name, _length);
+
/// <summary>
/// Returns a reference to the 0th element of the Span. If the Span is empty, returns a reference to the location where the 0th element
/// would have been stored. Such a reference can be used for pinning but must never be dereferenced.
diff --git a/src/mscorlib/shared/System/StringComparer.cs b/src/mscorlib/shared/System/StringComparer.cs
index ad667ae29b..73c013599d 100644
--- a/src/mscorlib/shared/System/StringComparer.cs
+++ b/src/mscorlib/shared/System/StringComparer.cs
@@ -5,7 +5,6 @@
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
-using System.Diagnostics.Contracts;
using System.Runtime.Serialization;
namespace System
@@ -23,7 +22,6 @@ namespace System
{
get
{
- Contract.Ensures(Contract.Result<StringComparer>() != null);
return s_invariantCulture;
}
}
@@ -32,7 +30,6 @@ namespace System
{
get
{
- Contract.Ensures(Contract.Result<StringComparer>() != null);
return s_invariantCultureIgnoreCase;
}
}
@@ -41,7 +38,6 @@ namespace System
{
get
{
- Contract.Ensures(Contract.Result<StringComparer>() != null);
return new CultureAwareComparer(CultureInfo.CurrentCulture, false);
}
}
@@ -50,7 +46,6 @@ namespace System
{
get
{
- Contract.Ensures(Contract.Result<StringComparer>() != null);
return new CultureAwareComparer(CultureInfo.CurrentCulture, true);
}
}
@@ -59,7 +54,6 @@ namespace System
{
get
{
- Contract.Ensures(Contract.Result<StringComparer>() != null);
return s_ordinal;
}
}
@@ -68,7 +62,6 @@ namespace System
{
get
{
- Contract.Ensures(Contract.Result<StringComparer>() != null);
return s_ordinalIgnoreCase;
}
}
@@ -101,8 +94,6 @@ namespace System
{
throw new ArgumentNullException(nameof(culture));
}
- Contract.Ensures(Contract.Result<StringComparer>() != null);
- Contract.EndContractBlock();
return new CultureAwareComparer(culture, ignoreCase);
}
@@ -156,7 +147,6 @@ namespace System
{
throw new ArgumentNullException(nameof(obj));
}
- Contract.EndContractBlock();
string s = obj as string;
if (s != null)
@@ -279,7 +269,6 @@ namespace System
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.obj);
}
- Contract.EndContractBlock();
if (_ignoreCase)
{
diff --git a/src/mscorlib/shared/System/Text/ASCIIEncoding.cs b/src/mscorlib/shared/System/Text/ASCIIEncoding.cs
index f614fb768b..2d2bf205ae 100644
--- a/src/mscorlib/shared/System/Text/ASCIIEncoding.cs
+++ b/src/mscorlib/shared/System/Text/ASCIIEncoding.cs
@@ -4,7 +4,6 @@
using System;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Text
{
@@ -66,7 +65,6 @@ namespace System.Text
if (chars.Length - index < count)
throw new ArgumentOutOfRangeException("chars", SR.ArgumentOutOfRange_IndexCountBuffer);
- Contract.EndContractBlock();
// If no input, return 0, avoid fixed empty array problem
if (count == 0)
@@ -87,7 +85,6 @@ namespace System.Text
// Validate input
if (chars==null)
throw new ArgumentNullException("chars");
- Contract.EndContractBlock();
fixed (char* pChars = chars)
return GetByteCount(pChars, chars.Length, null);
@@ -106,7 +103,6 @@ namespace System.Text
if (count < 0)
throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// Call it with empty encoder
return GetByteCount(chars, count, null);
@@ -131,7 +127,6 @@ namespace System.Text
if (byteIndex < 0 || byteIndex > bytes.Length)
throw new ArgumentOutOfRangeException("byteIndex", SR.ArgumentOutOfRange_Index);
- Contract.EndContractBlock();
int byteCount = bytes.Length - byteIndex;
@@ -172,7 +167,6 @@ namespace System.Text
if (byteIndex < 0 || byteIndex > bytes.Length)
throw new ArgumentOutOfRangeException("byteIndex", SR.ArgumentOutOfRange_Index);
- Contract.EndContractBlock();
// If nothing to encode return 0, avoid fixed problem
if (charCount == 0)
@@ -203,7 +197,6 @@ namespace System.Text
if (charCount < 0 || byteCount < 0)
throw new ArgumentOutOfRangeException((charCount < 0 ? "charCount" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
return GetBytes(chars, charCount, bytes, byteCount, null);
}
@@ -227,7 +220,6 @@ namespace System.Text
if (bytes.Length - index < count)
throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer);
- Contract.EndContractBlock();
// If no input just return 0, fixed doesn't like 0 length arrays
if (count == 0)
@@ -251,7 +243,6 @@ namespace System.Text
if (count < 0)
throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
return GetCharCount(bytes, count, null);
}
@@ -276,7 +267,6 @@ namespace System.Text
if (charIndex < 0 || charIndex > chars.Length)
throw new ArgumentOutOfRangeException("charIndex", SR.ArgumentOutOfRange_Index);
- Contract.EndContractBlock();
// If no input, return 0 & avoid fixed problem
if (byteCount == 0)
@@ -307,7 +297,6 @@ namespace System.Text
if (charCount < 0 || byteCount < 0)
throw new ArgumentOutOfRangeException((charCount < 0 ? "charCount" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
return GetChars(bytes, byteCount, chars, charCount, null);
}
@@ -332,7 +321,6 @@ namespace System.Text
if (bytes.Length - byteIndex < byteCount)
throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer);
- Contract.EndContractBlock();
// Avoid problems with empty input buffer
if (byteCount == 0) return String.Empty;
@@ -910,7 +898,6 @@ namespace System.Text
if (charCount < 0)
throw new ArgumentOutOfRangeException(nameof(charCount),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// Characters would be # of characters + 1 in case high surrogate is ? * max fallback
long byteCount = (long)charCount + 1;
@@ -931,7 +918,6 @@ namespace System.Text
if (byteCount < 0)
throw new ArgumentOutOfRangeException(nameof(byteCount),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// Just return length, SBCS stay the same length because they don't map to surrogate
long charCount = (long)byteCount;
diff --git a/src/mscorlib/shared/System/Text/Decoder.cs b/src/mscorlib/shared/System/Text/Decoder.cs
index 82d33d518c..8dccaacd98 100644
--- a/src/mscorlib/shared/System/Text/Decoder.cs
+++ b/src/mscorlib/shared/System/Text/Decoder.cs
@@ -5,7 +5,6 @@
using System.Text;
using System;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Text
{
@@ -42,7 +41,6 @@ namespace System.Text
{
if (value == null)
throw new ArgumentNullException(nameof(value));
- Contract.EndContractBlock();
// Can't change fallback if buffer is wrong
if (_fallbackBuffer != null && _fallbackBuffer.Remaining > 0)
@@ -123,7 +121,6 @@ namespace System.Text
if (count < 0)
throw new ArgumentOutOfRangeException(nameof(count),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
byte[] arrbyte = new byte[count];
int index;
@@ -195,7 +192,6 @@ namespace System.Text
if (byteCount < 0 || charCount < 0)
throw new ArgumentOutOfRangeException((byteCount < 0 ? nameof(byteCount) : nameof(charCount)),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// Get the byte array to convert
byte[] arrByte = new byte[byteCount];
@@ -274,7 +270,6 @@ namespace System.Text
if (chars.Length - charIndex < charCount)
throw new ArgumentOutOfRangeException(nameof(chars),
SR.ArgumentOutOfRange_IndexCountBuffer);
- Contract.EndContractBlock();
bytesUsed = byteCount;
@@ -319,7 +314,6 @@ namespace System.Text
if (byteCount < 0 || charCount < 0)
throw new ArgumentOutOfRangeException((byteCount < 0 ? nameof(byteCount) : nameof(charCount)),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// Get ready to do it
bytesUsed = byteCount;
diff --git a/src/mscorlib/shared/System/Text/DecoderNLS.cs b/src/mscorlib/shared/System/Text/DecoderNLS.cs
index ef85200d55..098730eed4 100644
--- a/src/mscorlib/shared/System/Text/DecoderNLS.cs
+++ b/src/mscorlib/shared/System/Text/DecoderNLS.cs
@@ -5,7 +5,6 @@
using System.Runtime.Serialization;
using System.Text;
using System;
-using System.Diagnostics.Contracts;
namespace System.Text
{
@@ -67,7 +66,6 @@ namespace System.Text
throw new ArgumentOutOfRangeException(nameof(bytes),
SR.ArgumentOutOfRange_IndexCountBuffer);
- Contract.EndContractBlock();
// Avoid null fixed problem
if (bytes.Length == 0)
@@ -88,7 +86,6 @@ namespace System.Text
if (count < 0)
throw new ArgumentOutOfRangeException(nameof(count),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// Remember the flush
_mustFlush = flush;
@@ -124,7 +121,6 @@ namespace System.Text
throw new ArgumentOutOfRangeException(nameof(charIndex),
SR.ArgumentOutOfRange_Index);
- Contract.EndContractBlock();
// Avoid empty input fixed problem
if (bytes.Length == 0)
@@ -153,7 +149,6 @@ namespace System.Text
if (byteCount < 0 || charCount < 0)
throw new ArgumentOutOfRangeException((byteCount < 0 ? nameof(byteCount) : nameof(charCount)),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// Remember our flush
_mustFlush = flush;
@@ -190,7 +185,6 @@ namespace System.Text
throw new ArgumentOutOfRangeException(nameof(chars),
SR.ArgumentOutOfRange_IndexCountBuffer);
- Contract.EndContractBlock();
// Avoid empty input problem
if (bytes.Length == 0)
@@ -223,7 +217,6 @@ namespace System.Text
if (byteCount < 0 || charCount < 0)
throw new ArgumentOutOfRangeException((byteCount < 0 ? nameof(byteCount) : nameof(charCount)),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// We don't want to throw
_mustFlush = flush;
diff --git a/src/mscorlib/shared/System/Text/DecoderReplacementFallback.cs b/src/mscorlib/shared/System/Text/DecoderReplacementFallback.cs
index 8a8d550c84..422b80bb2f 100644
--- a/src/mscorlib/shared/System/Text/DecoderReplacementFallback.cs
+++ b/src/mscorlib/shared/System/Text/DecoderReplacementFallback.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Text
{
@@ -21,7 +20,6 @@ namespace System.Text
{
if (replacement == null)
throw new ArgumentNullException(nameof(replacement));
- Contract.EndContractBlock();
// Make sure it doesn't have bad surrogate pairs
bool bFoundHigh = false;
diff --git a/src/mscorlib/shared/System/Text/Encoder.cs b/src/mscorlib/shared/System/Text/Encoder.cs
index 79a633f1ff..1670608599 100644
--- a/src/mscorlib/shared/System/Text/Encoder.cs
+++ b/src/mscorlib/shared/System/Text/Encoder.cs
@@ -5,7 +5,6 @@
using System.Text;
using System;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Text
{
@@ -42,7 +41,6 @@ namespace System.Text
{
if (value == null)
throw new ArgumentNullException(nameof(value));
- Contract.EndContractBlock();
// Can't change fallback if buffer is wrong
if (_fallbackBuffer != null && _fallbackBuffer.Remaining > 0)
@@ -121,7 +119,6 @@ namespace System.Text
if (count < 0)
throw new ArgumentOutOfRangeException(nameof(count),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
char[] arrChar = new char[count];
int index;
@@ -190,7 +187,6 @@ namespace System.Text
if (charCount < 0 || byteCount < 0)
throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount) : nameof(byteCount)),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// Get the char array to convert
char[] arrChar = new char[charCount];
@@ -268,7 +264,6 @@ namespace System.Text
if (bytes.Length - byteIndex < byteCount)
throw new ArgumentOutOfRangeException(nameof(bytes),
SR.ArgumentOutOfRange_IndexCountBuffer);
- Contract.EndContractBlock();
charsUsed = charCount;
@@ -313,7 +308,6 @@ namespace System.Text
if (charCount < 0 || byteCount < 0)
throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount) : nameof(byteCount)),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// Get ready to do it
charsUsed = charCount;
diff --git a/src/mscorlib/shared/System/Text/EncoderBestFitFallback.cs b/src/mscorlib/shared/System/Text/EncoderBestFitFallback.cs
index a8c288b633..7f3be2a7a6 100644
--- a/src/mscorlib/shared/System/Text/EncoderBestFitFallback.cs
+++ b/src/mscorlib/shared/System/Text/EncoderBestFitFallback.cs
@@ -7,7 +7,6 @@
//
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Globalization;
using System.Threading;
@@ -123,7 +122,6 @@ namespace System.Text
throw new ArgumentOutOfRangeException(nameof(charUnknownLow),
SR.Format(SR.ArgumentOutOfRange_Range,
0xDC00, 0xDFFF));
- Contract.EndContractBlock();
// If we had a buffer already we're being recursive, throw, it's probably at the suspect
// character in our array. 0 is processing last character, < 0 is not falling back
diff --git a/src/mscorlib/shared/System/Text/EncoderExceptionFallback.cs b/src/mscorlib/shared/System/Text/EncoderExceptionFallback.cs
index 71426e5f31..4c71916901 100644
--- a/src/mscorlib/shared/System/Text/EncoderExceptionFallback.cs
+++ b/src/mscorlib/shared/System/Text/EncoderExceptionFallback.cs
@@ -4,7 +4,6 @@
using System;
using System.Runtime.Serialization;
-using System.Diagnostics.Contracts;
namespace System.Text
{
@@ -68,7 +67,6 @@ namespace System.Text
throw new ArgumentOutOfRangeException(nameof(charUnknownLow),
SR.Format(SR.ArgumentOutOfRange_Range, 0xDC00, 0xDFFF));
}
- Contract.EndContractBlock();
int iTemp = Char.ConvertToUtf32(charUnknownHigh, charUnknownLow);
@@ -143,7 +141,6 @@ namespace System.Text
throw new ArgumentOutOfRangeException(nameof(CharUnknownLow),
SR.Format(SR.ArgumentOutOfRange_Range, 0xDC00, 0xDFFF));
}
- Contract.EndContractBlock();
_charUnknownHigh = charUnknownHigh;
_charUnknownLow = charUnknownLow;
diff --git a/src/mscorlib/shared/System/Text/EncoderNLS.cs b/src/mscorlib/shared/System/Text/EncoderNLS.cs
index 28a1b8b9b3..f8ff86d985 100644
--- a/src/mscorlib/shared/System/Text/EncoderNLS.cs
+++ b/src/mscorlib/shared/System/Text/EncoderNLS.cs
@@ -4,7 +4,6 @@
using System.Text;
using System;
-using System.Diagnostics.Contracts;
namespace System.Text
{
@@ -63,7 +62,6 @@ namespace System.Text
if (chars.Length - index < count)
throw new ArgumentOutOfRangeException(nameof(chars),
SR.ArgumentOutOfRange_IndexCountBuffer);
- Contract.EndContractBlock();
// Avoid empty input problem
if (chars.Length == 0)
@@ -88,7 +86,6 @@ namespace System.Text
if (count < 0)
throw new ArgumentOutOfRangeException(nameof(count),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
_mustFlush = flush;
_throwOnOverflow = true;
@@ -114,7 +111,6 @@ namespace System.Text
if (byteIndex < 0 || byteIndex > bytes.Length)
throw new ArgumentOutOfRangeException(nameof(byteIndex),
SR.ArgumentOutOfRange_Index);
- Contract.EndContractBlock();
if (chars.Length == 0)
chars = new char[1];
@@ -142,7 +138,6 @@ namespace System.Text
if (byteCount < 0 || charCount < 0)
throw new ArgumentOutOfRangeException((byteCount < 0 ? nameof(byteCount) : nameof(charCount)),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
_mustFlush = flush;
_throwOnOverflow = true;
@@ -176,7 +171,6 @@ namespace System.Text
throw new ArgumentOutOfRangeException(nameof(bytes),
SR.ArgumentOutOfRange_IndexCountBuffer);
- Contract.EndContractBlock();
// Avoid empty input problem
if (chars.Length == 0)
@@ -208,7 +202,6 @@ namespace System.Text
if (charCount < 0 || byteCount < 0)
throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount) : nameof(byteCount)),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// We don't want to throw
_mustFlush = flush;
diff --git a/src/mscorlib/shared/System/Text/EncoderReplacementFallback.cs b/src/mscorlib/shared/System/Text/EncoderReplacementFallback.cs
index 22d094ce5c..a1d0bbcd95 100644
--- a/src/mscorlib/shared/System/Text/EncoderReplacementFallback.cs
+++ b/src/mscorlib/shared/System/Text/EncoderReplacementFallback.cs
@@ -5,7 +5,6 @@
using System;
using System.Runtime;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Text
{
@@ -24,7 +23,6 @@ namespace System.Text
// Must not be null
if (replacement == null)
throw new ArgumentNullException(nameof(replacement));
- Contract.EndContractBlock();
// Make sure it doesn't have bad surrogate pairs
bool bFoundHigh = false;
@@ -153,7 +151,6 @@ namespace System.Text
if (!Char.IsLowSurrogate(charUnknownLow))
throw new ArgumentOutOfRangeException(nameof(charUnknownLow),
SR.Format(SR.ArgumentOutOfRange_Range, 0xDC00, 0xDFFF));
- Contract.EndContractBlock();
// If we had a buffer already we're being recursive, throw, it's probably at the suspect
// character in our array.
diff --git a/src/mscorlib/shared/System/Text/Encoding.cs b/src/mscorlib/shared/System/Text/Encoding.cs
index bf8cb03db2..8e4d29d24c 100644
--- a/src/mscorlib/shared/System/Text/Encoding.cs
+++ b/src/mscorlib/shared/System/Text/Encoding.cs
@@ -4,7 +4,6 @@
using System.Diagnostics;
using System.Globalization;
-using System.Diagnostics.Contracts;
using System.Threading;
using System.Runtime.Serialization;
using System.Diagnostics.CodeAnalysis;
@@ -178,7 +177,6 @@ namespace System.Text
{
throw new ArgumentOutOfRangeException(nameof(codePage));
}
- Contract.EndContractBlock();
// Remember code page
_codePage = codePage;
@@ -197,7 +195,6 @@ namespace System.Text
{
throw new ArgumentOutOfRangeException(nameof(codePage));
}
- Contract.EndContractBlock();
// Remember code page
_codePage = codePage;
@@ -220,13 +217,11 @@ namespace System.Text
// dstEncoding, and the returned value is a new byte array
// containing the result of the conversion.
//
- [Pure]
public static byte[] Convert(Encoding srcEncoding, Encoding dstEncoding,
byte[] bytes)
{
if (bytes == null)
throw new ArgumentNullException(nameof(bytes));
- Contract.Ensures(Contract.Result<byte[]>() != null);
return Convert(srcEncoding, dstEncoding, bytes, 0, bytes.Length);
}
@@ -236,7 +231,6 @@ namespace System.Text
// index index from srcEncoding to dstEncoding, and
// returns a new byte array containing the result of the conversion.
//
- [Pure]
public static byte[] Convert(Encoding srcEncoding, Encoding dstEncoding,
byte[] bytes, int index, int count)
{
@@ -250,7 +244,6 @@ namespace System.Text
throw new ArgumentNullException(nameof(bytes),
SR.ArgumentNull_Array);
}
- Contract.Ensures(Contract.Result<byte[]>() != null);
return dstEncoding.GetBytes(srcEncoding.GetChars(bytes, index, count));
}
@@ -261,7 +254,6 @@ namespace System.Text
EncodingProvider.AddProvider(provider);
}
- [Pure]
public static Encoding GetEncoding(int codepage)
{
Encoding result = EncodingProvider.GetEncodingFromProvider(codepage);
@@ -280,7 +272,6 @@ namespace System.Text
nameof(codepage), SR.Format(SR.ArgumentOutOfRange_Range, 0, 65535));
}
- Contract.EndContractBlock();
switch (codepage)
{
@@ -312,7 +303,6 @@ namespace System.Text
return UTF8;
}
- [Pure]
public static Encoding GetEncoding(int codepage,
EncoderFallback encoderFallback, DecoderFallback decoderFallback)
{
@@ -334,7 +324,6 @@ namespace System.Text
// Returns an Encoding object for a given name or a given code page value.
//
- [Pure]
public static Encoding GetEncoding(String name)
{
Encoding baseEncoding = EncodingProvider.GetEncodingFromProvider(name);
@@ -352,7 +341,6 @@ namespace System.Text
// Returns an Encoding object for a given name or a given code page value.
//
- [Pure]
public static Encoding GetEncoding(String name,
EncoderFallback encoderFallback, DecoderFallback decoderFallback)
{
@@ -370,13 +358,11 @@ namespace System.Text
}
// Return a list of all EncodingInfo objects describing all of our encodings
- [Pure]
public static EncodingInfo[] GetEncodings()
{
return EncodingTable.GetEncodings();
}
- [Pure]
public virtual byte[] GetPreamble()
{
return Array.Empty<byte>();
@@ -590,7 +576,6 @@ namespace System.Text
if (value == null)
throw new ArgumentNullException(nameof(value));
- Contract.EndContractBlock();
encoderFallback = value;
}
@@ -611,7 +596,6 @@ namespace System.Text
if (value == null)
throw new ArgumentNullException(nameof(value));
- Contract.EndContractBlock();
decoderFallback = value;
}
@@ -650,7 +634,6 @@ namespace System.Text
// Returns the number of bytes required to encode the given character
// array.
//
- [Pure]
public virtual int GetByteCount(char[] chars)
{
if (chars == null)
@@ -658,17 +641,14 @@ namespace System.Text
throw new ArgumentNullException(nameof(chars),
SR.ArgumentNull_Array);
}
- Contract.EndContractBlock();
return GetByteCount(chars, 0, chars.Length);
}
- [Pure]
public virtual int GetByteCount(String s)
{
if (s == null)
throw new ArgumentNullException(nameof(s));
- Contract.EndContractBlock();
char[] chars = s.ToCharArray();
return GetByteCount(chars, 0, chars.Length);
@@ -677,12 +657,10 @@ namespace System.Text
// Returns the number of bytes required to encode a range of characters in
// a character array.
//
- [Pure]
public abstract int GetByteCount(char[] chars, int index, int count);
// Returns the number of bytes required to encode a string range.
//
- [Pure]
public int GetByteCount(string s, int index, int count)
{
if (s == null)
@@ -697,7 +675,6 @@ namespace System.Text
if (index > s.Length - count)
throw new ArgumentOutOfRangeException(nameof(index),
SR.ArgumentOutOfRange_IndexCount);
- Contract.EndContractBlock();
unsafe
{
@@ -712,7 +689,6 @@ namespace System.Text
// unfortunately for existing overrides, it has to call the [] version,
// which is really slow, so this method should be avoided if you're calling
// a 3rd party encoding.
- [Pure]
[CLSCompliant(false)]
public virtual unsafe int GetByteCount(char* chars, int count)
{
@@ -724,7 +700,6 @@ namespace System.Text
if (count < 0)
throw new ArgumentOutOfRangeException(nameof(count),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
char[] arrChar = new char[count];
int index;
@@ -756,7 +731,6 @@ namespace System.Text
// Returns a byte array containing the encoded representation of the given
// character array.
//
- [Pure]
public virtual byte[] GetBytes(char[] chars)
{
if (chars == null)
@@ -764,14 +738,12 @@ namespace System.Text
throw new ArgumentNullException(nameof(chars),
SR.ArgumentNull_Array);
}
- Contract.EndContractBlock();
return GetBytes(chars, 0, chars.Length);
}
// Returns a byte array containing the encoded representation of a range
// of characters in a character array.
//
- [Pure]
public virtual byte[] GetBytes(char[] chars, int index, int count)
{
byte[] result = new byte[GetByteCount(chars, index, count)];
@@ -794,13 +766,11 @@ namespace System.Text
// Returns a byte array containing the encoded representation of the given
// string.
//
- [Pure]
public virtual byte[] GetBytes(String s)
{
if (s == null)
throw new ArgumentNullException(nameof(s),
SR.ArgumentNull_String);
- Contract.EndContractBlock();
int byteCount = GetByteCount(s);
byte[] bytes = new byte[byteCount];
@@ -812,7 +782,6 @@ namespace System.Text
// Returns a byte array containing the encoded representation of the given
// string range.
//
- [Pure]
public byte[] GetBytes(string s, int index, int count)
{
if (s == null)
@@ -827,7 +796,6 @@ namespace System.Text
if (index > s.Length - count)
throw new ArgumentOutOfRangeException(nameof(index),
SR.ArgumentOutOfRange_IndexCount);
- Contract.EndContractBlock();
unsafe
{
@@ -853,7 +821,6 @@ namespace System.Text
{
if (s == null)
throw new ArgumentNullException(nameof(s));
- Contract.EndContractBlock();
return GetBytes(s.ToCharArray(), charIndex, charCount, bytes, byteIndex);
}
@@ -894,7 +861,6 @@ namespace System.Text
if (charCount < 0 || byteCount < 0)
throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount) : nameof(byteCount)),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// Get the char array to convert
char[] arrChar = new char[charCount];
@@ -938,7 +904,6 @@ namespace System.Text
// Returns the number of characters produced by decoding the given byte
// array.
//
- [Pure]
public virtual int GetCharCount(byte[] bytes)
{
if (bytes == null)
@@ -946,19 +911,16 @@ namespace System.Text
throw new ArgumentNullException(nameof(bytes),
SR.ArgumentNull_Array);
}
- Contract.EndContractBlock();
return GetCharCount(bytes, 0, bytes.Length);
}
// Returns the number of characters produced by decoding a range of bytes
// in a byte array.
//
- [Pure]
public abstract int GetCharCount(byte[] bytes, int index, int count);
// We expect this to be the workhorse for NLS Encodings, but for existing
// ones we need a working (if slow) default implementation)
- [Pure]
[CLSCompliant(false)]
public virtual unsafe int GetCharCount(byte* bytes, int count)
{
@@ -970,7 +932,6 @@ namespace System.Text
if (count < 0)
throw new ArgumentOutOfRangeException(nameof(count),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
byte[] arrbyte = new byte[count];
int index;
@@ -999,7 +960,6 @@ namespace System.Text
// Returns a character array containing the decoded representation of a
// given byte array.
//
- [Pure]
public virtual char[] GetChars(byte[] bytes)
{
if (bytes == null)
@@ -1007,14 +967,12 @@ namespace System.Text
throw new ArgumentNullException(nameof(bytes),
SR.ArgumentNull_Array);
}
- Contract.EndContractBlock();
return GetChars(bytes, 0, bytes.Length);
}
// Returns a character array containing the decoded representation of a
// range of bytes in a byte array.
//
- [Pure]
public virtual char[] GetChars(byte[] bytes, int index, int count)
{
char[] result = new char[GetCharCount(bytes, index, count)];
@@ -1065,7 +1023,6 @@ namespace System.Text
if (byteCount < 0 || charCount < 0)
throw new ArgumentOutOfRangeException((byteCount < 0 ? nameof(byteCount) : nameof(charCount)),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// Get the byte array to convert
byte[] arrByte = new byte[byteCount];
@@ -1123,7 +1080,6 @@ namespace System.Text
if (byteCount < 0)
throw new ArgumentOutOfRangeException(nameof(byteCount), SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
return String.CreateStringFromEncoding(bytes, byteCount, this);
}
@@ -1152,13 +1108,11 @@ namespace System.Text
// IsAlwaysNormalized
// Returns true if the encoding is always normalized for the specified encoding form
- [Pure]
public bool IsAlwaysNormalized()
{
return this.IsAlwaysNormalized(NormalizationForm.FormC);
}
- [Pure]
public virtual bool IsAlwaysNormalized(NormalizationForm form)
{
// Assume false unless the encoding knows otherwise
@@ -1214,7 +1168,6 @@ namespace System.Text
// WARNING: If you're using something besides the default replacement encoder fallback,
// then you could have more bytes than this returned from an actual call to GetBytes().
//
- [Pure]
public abstract int GetMaxByteCount(int charCount);
// Returns the maximum number of characters produced by decoding a given
@@ -1225,19 +1178,16 @@ namespace System.Text
// exceptions will occur if buffers are sized according to the results of
// this method.
//
- [Pure]
public abstract int GetMaxCharCount(int byteCount);
// Returns a string containing the decoded representation of a given byte
// array.
//
- [Pure]
public virtual String GetString(byte[] bytes)
{
if (bytes == null)
throw new ArgumentNullException(nameof(bytes),
SR.ArgumentNull_Array);
- Contract.EndContractBlock();
return GetString(bytes, 0, bytes.Length);
}
@@ -1247,7 +1197,6 @@ namespace System.Text
//
// Internally we override this for performance
//
- [Pure]
public virtual String GetString(byte[] bytes, int index, int count)
{
return new String(GetChars(bytes, index, count));
@@ -1393,7 +1342,6 @@ namespace System.Text
return _encoding.GetByteCount(chars, index, count);
}
- [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
public unsafe override int GetByteCount(char* chars, int count, bool flush)
{
return _encoding.GetByteCount(chars, count);
@@ -1425,7 +1373,6 @@ namespace System.Text
return _encoding.GetBytes(chars, charIndex, charCount, bytes, byteIndex);
}
- [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
public unsafe override int GetBytes(char* chars, int charCount,
byte* bytes, int byteCount, bool flush)
{
@@ -1464,7 +1411,6 @@ namespace System.Text
return _encoding.GetCharCount(bytes, index, count);
}
- [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
public unsafe override int GetCharCount(byte* bytes, int count, bool flush)
{
// By default just call the encoding version, no flush by default
@@ -1500,7 +1446,6 @@ namespace System.Text
return _encoding.GetChars(bytes, byteIndex, byteCount, chars, charIndex);
}
- [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
public unsafe override int GetChars(byte* bytes, int byteCount,
char* chars, int charCount, bool flush)
{
diff --git a/src/mscorlib/shared/System/Text/EncodingNLS.cs b/src/mscorlib/shared/System/Text/EncodingNLS.cs
index 835bf8fb37..5059407ab9 100644
--- a/src/mscorlib/shared/System/Text/EncodingNLS.cs
+++ b/src/mscorlib/shared/System/Text/EncodingNLS.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System;
-using System.Diagnostics.Contracts;
using System.Collections;
using System.Globalization;
using System.Threading;
@@ -47,7 +46,6 @@ namespace System.Text
if (chars.Length - index < count)
throw new ArgumentOutOfRangeException("chars", SR.ArgumentOutOfRange_IndexCountBuffer);
- Contract.EndContractBlock();
// If no input, return 0, avoid fixed empty array problem
if (count == 0)
@@ -67,7 +65,6 @@ namespace System.Text
// Validate input
if (s==null)
throw new ArgumentNullException("s");
- Contract.EndContractBlock();
fixed (char* pChars = s)
return GetByteCount(pChars, s.Length, null);
@@ -84,7 +81,6 @@ namespace System.Text
if (count < 0)
throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// Call it with empty encoder
return GetByteCount(chars, count, null);
@@ -108,7 +104,6 @@ namespace System.Text
if (byteIndex < 0 || byteIndex > bytes.Length)
throw new ArgumentOutOfRangeException("byteIndex", SR.ArgumentOutOfRange_Index);
- Contract.EndContractBlock();
int byteCount = bytes.Length - byteIndex;
@@ -148,7 +143,6 @@ namespace System.Text
if (byteIndex < 0 || byteIndex > bytes.Length)
throw new ArgumentOutOfRangeException("byteIndex", SR.ArgumentOutOfRange_Index);
- Contract.EndContractBlock();
// If nothing to encode return 0, avoid fixed problem
if (charCount == 0)
@@ -177,7 +171,6 @@ namespace System.Text
if (charCount < 0 || byteCount < 0)
throw new ArgumentOutOfRangeException((charCount < 0 ? "charCount" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
return GetBytes(chars, charCount, bytes, byteCount, null);
}
@@ -200,7 +193,6 @@ namespace System.Text
if (bytes.Length - index < count)
throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer);
- Contract.EndContractBlock();
// If no input just return 0, fixed doesn't like 0 length arrays
if (count == 0)
@@ -222,7 +214,6 @@ namespace System.Text
if (count < 0)
throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
return GetCharCount(bytes, count, null);
}
@@ -246,7 +237,6 @@ namespace System.Text
if (charIndex < 0 || charIndex > chars.Length)
throw new ArgumentOutOfRangeException("charIndex", SR.ArgumentOutOfRange_Index);
- Contract.EndContractBlock();
// If no input, return 0 & avoid fixed problem
if (byteCount == 0)
@@ -275,7 +265,6 @@ namespace System.Text
if (charCount < 0 || byteCount < 0)
throw new ArgumentOutOfRangeException((charCount < 0 ? "charCount" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
return GetChars(bytes, byteCount, chars, charCount, null);
}
@@ -298,7 +287,6 @@ namespace System.Text
if (bytes.Length - index < count)
throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer);
- Contract.EndContractBlock();
// Avoid problems with empty input buffer
if (count == 0) return String.Empty;
diff --git a/src/mscorlib/shared/System/Text/Latin1Encoding.cs b/src/mscorlib/shared/System/Text/Latin1Encoding.cs
index 679698d926..335eb76e3c 100644
--- a/src/mscorlib/shared/System/Text/Latin1Encoding.cs
+++ b/src/mscorlib/shared/System/Text/Latin1Encoding.cs
@@ -4,7 +4,6 @@
using System;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Text
{
@@ -420,7 +419,6 @@ namespace System.Text
if (charCount < 0)
throw new ArgumentOutOfRangeException(nameof(charCount),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// Characters would be # of characters + 1 in case high surrogate is ? * max fallback
long byteCount = (long)charCount + 1;
@@ -440,7 +438,6 @@ namespace System.Text
if (byteCount < 0)
throw new ArgumentOutOfRangeException(nameof(byteCount),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// Just return length, SBCS stay the same length because they don't map to surrogate
long charCount = (long)byteCount;
diff --git a/src/mscorlib/shared/System/Text/StringBuilder.cs b/src/mscorlib/shared/System/Text/StringBuilder.cs
index a73e6757d4..f5003d8124 100644
--- a/src/mscorlib/shared/System/Text/StringBuilder.cs
+++ b/src/mscorlib/shared/System/Text/StringBuilder.cs
@@ -12,7 +12,6 @@ using System.Security;
using System.Threading;
using System.Globalization;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Collections.Generic;
namespace System.Text
@@ -134,7 +133,6 @@ namespace System.Text
{
throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_StartIndex);
}
- Contract.EndContractBlock();
if (value == null)
{
@@ -183,7 +181,6 @@ namespace System.Text
{
throw new ArgumentOutOfRangeException(nameof(capacity), SR.Format(SR.ArgumentOutOfRange_MustBePositive, nameof(capacity)));
}
- Contract.EndContractBlock();
if (capacity == 0)
{
@@ -200,7 +197,6 @@ namespace System.Text
{
throw new ArgumentNullException(nameof(info));
}
- Contract.EndContractBlock();
int persistedCapacity = 0;
string persistedString = null;
@@ -265,7 +261,6 @@ namespace System.Text
{
throw new ArgumentNullException(nameof(info));
}
- Contract.EndContractBlock();
AssertInvariants();
info.AddValue(MaxCapacityField, m_MaxCapacity);
@@ -321,7 +316,6 @@ namespace System.Text
{
throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_SmallCapacity);
}
- Contract.EndContractBlock();
if (Capacity != value)
{
@@ -352,7 +346,6 @@ namespace System.Text
{
throw new ArgumentOutOfRangeException(nameof(capacity), SR.ArgumentOutOfRange_NegativeCapacity);
}
- Contract.EndContractBlock();
if (Capacity < capacity)
Capacity = capacity;
@@ -410,8 +403,6 @@ namespace System.Text
/// <param name="length">The number of characters to read in this builder.</param>
public string ToString(int startIndex, int length)
{
- Contract.Ensures(Contract.Result<String>() != null);
-
int currentLength = this.Length;
if (startIndex < 0)
{
@@ -496,7 +487,6 @@ namespace System.Text
{
get
{
- Contract.Ensures(Contract.Result<int>() >= 0);
return m_ChunkOffset + m_ChunkLength;
}
set
@@ -511,7 +501,6 @@ namespace System.Text
{
throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_SmallCapacity);
}
- Contract.EndContractBlock();
int originalCapacity = Capacity;
@@ -612,8 +601,6 @@ namespace System.Text
{
throw new ArgumentOutOfRangeException(nameof(repeatCount), SR.ArgumentOutOfRange_NegativeCount);
}
- Contract.Ensures(Contract.Result<StringBuilder>() != null);
- Contract.EndContractBlock();
if (repeatCount == 0)
{
@@ -666,8 +653,6 @@ namespace System.Text
{
throw new ArgumentOutOfRangeException(nameof(charCount), SR.ArgumentOutOfRange_GenericPositive);
}
- Contract.Ensures(Contract.Result<StringBuilder>() != null);
- Contract.EndContractBlock();
if (value == null)
{
@@ -705,8 +690,6 @@ namespace System.Text
/// <param name="value">The string to append.</param>
public StringBuilder Append(String value)
{
- Contract.Ensures(Contract.Result<StringBuilder>() != null);
-
if (value != null)
{
// We could have just called AppendHelper here; this is a hand-specialization of that code.
@@ -776,7 +759,6 @@ namespace System.Text
{
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_GenericPositive);
}
- Contract.Ensures(Contract.Result<StringBuilder>() != null);
if (value == null)
{
@@ -831,7 +813,6 @@ namespace System.Text
{
throw new ArgumentException(SR.ArgumentOutOfRange_OffsetOut);
}
- Contract.EndContractBlock();
CopyTo(sourceIndex, new Span<char>(destination).Slice(destinationIndex), count);
}
@@ -852,7 +833,6 @@ namespace System.Text
{
throw new ArgumentException(SR.Arg_LongerThanSrcString);
}
- Contract.EndContractBlock();
AssertInvariants();
@@ -896,8 +876,6 @@ namespace System.Text
{
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum);
}
- Contract.Ensures(Contract.Result<StringBuilder>() != null);
- Contract.EndContractBlock();
int currentLength = Length;
if ((uint)index > (uint)currentLength)
@@ -959,8 +937,6 @@ namespace System.Text
{
throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_Index);
}
- Contract.Ensures(Contract.Result<StringBuilder>() != null);
- Contract.EndContractBlock();
if (Length == length && startIndex == 0)
{
@@ -987,8 +963,6 @@ namespace System.Text
public StringBuilder Append(char value)
{
- Contract.Ensures(Contract.Result<StringBuilder>() != null);
-
if (m_ChunkLength < m_ChunkChars.Length)
{
m_ChunkChars[m_ChunkLength++] = value;
@@ -1170,8 +1144,6 @@ namespace System.Text
{
throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index);
}
- Contract.Ensures(Contract.Result<StringBuilder>() != null);
- Contract.EndContractBlock();
if (value != null)
{
@@ -1195,8 +1167,6 @@ namespace System.Text
public StringBuilder Insert(int index, char value)
{
- Contract.Ensures(Contract.Result<StringBuilder>() != null);
-
unsafe
{
Insert(index, &value, 1);
@@ -1210,8 +1180,6 @@ namespace System.Text
{
throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index);
}
- Contract.Ensures(Contract.Result<StringBuilder>() != null);
- Contract.EndContractBlock();
if (value != null)
Insert(index, value, 0, value.Length);
@@ -1220,8 +1188,6 @@ namespace System.Text
public StringBuilder Insert(int index, char[] value, int startIndex, int charCount)
{
- Contract.Ensures(Contract.Result<StringBuilder>() != null);
-
int currentLength = Length;
if ((uint)index > (uint)currentLength)
{
@@ -1286,9 +1252,6 @@ namespace System.Text
public StringBuilder Insert(int index, ReadOnlySpan<char> value)
{
- Contract.Ensures(Contract.Result<StringBuilder>() != null);
- Contract.EndContractBlock();
-
if ((uint)index > (uint)Length)
{
throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index);
@@ -1320,8 +1283,6 @@ namespace System.Text
string paramName = (format == null) ? nameof(format) : nameof(args);
throw new ArgumentNullException(paramName);
}
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.EndContractBlock();
return AppendFormatHelper(null, format, new ParamsArray(args));
}
@@ -1341,8 +1302,6 @@ namespace System.Text
string paramName = (format == null) ? nameof(format) : nameof(args);
throw new ArgumentNullException(paramName);
}
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.EndContractBlock();
return AppendFormatHelper(provider, format, new ParamsArray(args));
}
@@ -1362,8 +1321,6 @@ namespace System.Text
{
throw new ArgumentNullException(nameof(format));
}
- Contract.Ensures(Contract.Result<StringBuilder>() != null);
- Contract.EndContractBlock();
int pos = 0;
int len = format.Length;
@@ -1665,8 +1622,6 @@ namespace System.Text
/// </remarks>
public StringBuilder Replace(String oldValue, String newValue, int startIndex, int count)
{
- Contract.Ensures(Contract.Result<StringBuilder>() != null);
-
int currentLength = Length;
if ((uint)startIndex > (uint)currentLength)
{
@@ -1762,8 +1717,6 @@ namespace System.Text
/// <param name="count">The number of characters to read in this builder.</param>
public StringBuilder Replace(char oldChar, char newChar, int startIndex, int count)
{
- Contract.Ensures(Contract.Result<StringBuilder>() != null);
-
int currentLength = Length;
if ((uint)startIndex > (uint)currentLength)
{
@@ -2125,8 +2078,8 @@ namespace System.Text
/// </remarks>
private void ExpandByABlock(int minBlockCharCount)
{
- Contract.Requires(Capacity == Length, $"{nameof(ExpandByABlock)} should only be called when there is no space left.");
- Contract.Requires(minBlockCharCount > 0);
+ Debug.Assert(Capacity == Length, nameof(ExpandByABlock) + " should only be called when there is no space left.");
+ Debug.Assert(minBlockCharCount > 0);
AssertInvariants();
diff --git a/src/mscorlib/shared/System/Text/UTF32Encoding.cs b/src/mscorlib/shared/System/Text/UTF32Encoding.cs
index 260518e21c..a666c25627 100644
--- a/src/mscorlib/shared/System/Text/UTF32Encoding.cs
+++ b/src/mscorlib/shared/System/Text/UTF32Encoding.cs
@@ -8,7 +8,6 @@
using System;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Globalization;
namespace System.Text
@@ -110,7 +109,6 @@ namespace System.Text
if (chars.Length - index < count)
throw new ArgumentOutOfRangeException("chars", SR.ArgumentOutOfRange_IndexCountBuffer);
- Contract.EndContractBlock();
// If no input, return 0, avoid fixed empty array problem
if (count == 0)
@@ -131,7 +129,6 @@ namespace System.Text
// Validate input
if (s==null)
throw new ArgumentNullException("s");
- Contract.EndContractBlock();
fixed (char* pChars = s)
return GetByteCount(pChars, s.Length, null);
@@ -150,7 +147,6 @@ namespace System.Text
if (count < 0)
throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// Call it with empty encoder
return GetByteCount(chars, count, null);
@@ -175,7 +171,6 @@ namespace System.Text
if (byteIndex < 0 || byteIndex > bytes.Length)
throw new ArgumentOutOfRangeException("byteIndex", SR.ArgumentOutOfRange_Index);
- Contract.EndContractBlock();
int byteCount = bytes.Length - byteIndex;
@@ -216,7 +211,6 @@ namespace System.Text
if (byteIndex < 0 || byteIndex > bytes.Length)
throw new ArgumentOutOfRangeException("byteIndex", SR.ArgumentOutOfRange_Index);
- Contract.EndContractBlock();
// If nothing to encode return 0, avoid fixed problem
if (charCount == 0)
@@ -247,7 +241,6 @@ namespace System.Text
if (charCount < 0 || byteCount < 0)
throw new ArgumentOutOfRangeException((charCount < 0 ? "charCount" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
return GetBytes(chars, charCount, bytes, byteCount, null);
}
@@ -271,7 +264,6 @@ namespace System.Text
if (bytes.Length - index < count)
throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer);
- Contract.EndContractBlock();
// If no input just return 0, fixed doesn't like 0 length arrays.
if (count == 0)
@@ -295,7 +287,6 @@ namespace System.Text
if (count < 0)
throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
return GetCharCount(bytes, count, null);
}
@@ -320,7 +311,6 @@ namespace System.Text
if (charIndex < 0 || charIndex > chars.Length)
throw new ArgumentOutOfRangeException("charIndex", SR.ArgumentOutOfRange_Index);
- Contract.EndContractBlock();
// If no input, return 0 & avoid fixed problem
if (byteCount == 0)
@@ -351,7 +341,6 @@ namespace System.Text
if (charCount < 0 || byteCount < 0)
throw new ArgumentOutOfRangeException((charCount < 0 ? "charCount" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
return GetChars(bytes, byteCount, chars, charCount, null);
}
@@ -375,7 +364,6 @@ namespace System.Text
if (bytes.Length - index < count)
throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer);
- Contract.EndContractBlock();
// Avoid problems with empty input buffer
if (count == 0) return String.Empty;
@@ -960,7 +948,6 @@ namespace System.Text
if (!fallbackResult)
{
-
// Couldn't fallback, throw or wait til next time
// We either read enough bytes for bytes-=4 to work, or we're
// going to throw in ThrowCharsOverflow because chars == charStart
@@ -1114,7 +1101,6 @@ namespace System.Text
if (charCount < 0)
throw new ArgumentOutOfRangeException(nameof(charCount),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// Characters would be # of characters + 1 in case left over high surrogate is ? * max fallback
long byteCount = (long)charCount + 1;
@@ -1137,7 +1123,6 @@ namespace System.Text
if (byteCount < 0)
throw new ArgumentOutOfRangeException(nameof(byteCount),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// A supplementary character becomes 2 surrogate characters, so 4 input bytes becomes 2 chars,
// plus we may have 1 surrogate char left over if the decoder has 3 bytes in it already for a non-bmp char.
diff --git a/src/mscorlib/shared/System/Text/UTF7Encoding.cs b/src/mscorlib/shared/System/Text/UTF7Encoding.cs
index b9065477e9..78813649b6 100644
--- a/src/mscorlib/shared/System/Text/UTF7Encoding.cs
+++ b/src/mscorlib/shared/System/Text/UTF7Encoding.cs
@@ -8,7 +8,6 @@
using System;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Text
{
@@ -140,7 +139,6 @@ namespace System.Text
if (chars.Length - index < count)
throw new ArgumentOutOfRangeException("chars", SR.ArgumentOutOfRange_IndexCountBuffer);
- Contract.EndContractBlock();
// If no input, return 0, avoid fixed empty array problem
if (count == 0)
@@ -161,7 +159,6 @@ namespace System.Text
// Validate input
if (s==null)
throw new ArgumentNullException("s");
- Contract.EndContractBlock();
fixed (char* pChars = s)
return GetByteCount(pChars, s.Length, null);
@@ -180,7 +177,6 @@ namespace System.Text
if (count < 0)
throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// Call it with empty encoder
return GetByteCount(chars, count, null);
@@ -205,7 +201,6 @@ namespace System.Text
if (byteIndex < 0 || byteIndex > bytes.Length)
throw new ArgumentOutOfRangeException("byteIndex", SR.ArgumentOutOfRange_Index);
- Contract.EndContractBlock();
int byteCount = bytes.Length - byteIndex;
@@ -246,7 +241,6 @@ namespace System.Text
if (byteIndex < 0 || byteIndex > bytes.Length)
throw new ArgumentOutOfRangeException("byteIndex", SR.ArgumentOutOfRange_Index);
- Contract.EndContractBlock();
// If nothing to encode return 0, avoid fixed problem
if (charCount == 0)
@@ -277,7 +271,6 @@ namespace System.Text
if (charCount < 0 || byteCount < 0)
throw new ArgumentOutOfRangeException((charCount < 0 ? "charCount" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
return GetBytes(chars, charCount, bytes, byteCount, null);
}
@@ -301,7 +294,6 @@ namespace System.Text
if (bytes.Length - index < count)
throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer);
- Contract.EndContractBlock();
// If no input just return 0, fixed doesn't like 0 length arrays.
if (count == 0)
@@ -325,7 +317,6 @@ namespace System.Text
if (count < 0)
throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
return GetCharCount(bytes, count, null);
}
@@ -350,7 +341,6 @@ namespace System.Text
if (charIndex < 0 || charIndex > chars.Length)
throw new ArgumentOutOfRangeException("charIndex", SR.ArgumentOutOfRange_Index);
- Contract.EndContractBlock();
// If no input, return 0 & avoid fixed problem
if (byteCount == 0)
@@ -381,7 +371,6 @@ namespace System.Text
if (charCount < 0 || byteCount < 0)
throw new ArgumentOutOfRangeException((charCount < 0 ? "charCount" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
return GetChars(bytes, byteCount, chars, charCount, null);
}
@@ -405,7 +394,6 @@ namespace System.Text
if (bytes.Length - index < count)
throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer);
- Contract.EndContractBlock();
// Avoid problems with empty input buffer
if (count == 0) return String.Empty;
@@ -762,7 +750,6 @@ namespace System.Text
if (charCount < 0)
throw new ArgumentOutOfRangeException(nameof(charCount),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// Suppose that every char can not be direct-encoded, we know that
// a byte can encode 6 bits of the Unicode character. And we will
@@ -795,7 +782,6 @@ namespace System.Text
if (byteCount < 0)
throw new ArgumentOutOfRangeException(nameof(byteCount),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// Worst case is 1 char per byte. Minimum 1 for left over bits in case decoder is being flushed
// Also note that we ignore extra bits (per spec), so UTF7 doesn't have unknown in this direction.
diff --git a/src/mscorlib/shared/System/Text/UTF8Encoding.cs b/src/mscorlib/shared/System/Text/UTF8Encoding.cs
index 974bf75650..e5544c5194 100644
--- a/src/mscorlib/shared/System/Text/UTF8Encoding.cs
+++ b/src/mscorlib/shared/System/Text/UTF8Encoding.cs
@@ -16,7 +16,6 @@
using System;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Globalization;
namespace System.Text
@@ -137,7 +136,6 @@ namespace System.Text
if (chars.Length - index < count)
throw new ArgumentOutOfRangeException("chars", SR.ArgumentOutOfRange_IndexCountBuffer);
- Contract.EndContractBlock();
// If no input, return 0, avoid fixed empty array problem
if (count == 0)
@@ -158,7 +156,6 @@ namespace System.Text
// Validate input
if (chars==null)
throw new ArgumentNullException("s");
- Contract.EndContractBlock();
fixed (char* pChars = chars)
return GetByteCount(pChars, chars.Length, null);
@@ -177,7 +174,6 @@ namespace System.Text
if (count < 0)
throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// Call it with empty encoder
return GetByteCount(chars, count, null);
@@ -202,7 +198,6 @@ namespace System.Text
if (byteIndex < 0 || byteIndex > bytes.Length)
throw new ArgumentOutOfRangeException("byteIndex", SR.ArgumentOutOfRange_Index);
- Contract.EndContractBlock();
int byteCount = bytes.Length - byteIndex;
@@ -243,7 +238,6 @@ namespace System.Text
if (byteIndex < 0 || byteIndex > bytes.Length)
throw new ArgumentOutOfRangeException("byteIndex", SR.ArgumentOutOfRange_Index);
- Contract.EndContractBlock();
// If nothing to encode return 0, avoid fixed problem
if (charCount == 0)
@@ -274,7 +268,6 @@ namespace System.Text
if (charCount < 0 || byteCount < 0)
throw new ArgumentOutOfRangeException((charCount < 0 ? "charCount" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
return GetBytes(chars, charCount, bytes, byteCount, null);
}
@@ -298,7 +291,6 @@ namespace System.Text
if (bytes.Length - index < count)
throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer);
- Contract.EndContractBlock();
// If no input just return 0, fixed doesn't like 0 length arrays.
if (count == 0)
@@ -322,7 +314,6 @@ namespace System.Text
if (count < 0)
throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
return GetCharCount(bytes, count, null);
}
@@ -347,7 +338,6 @@ namespace System.Text
if (charIndex < 0 || charIndex > chars.Length)
throw new ArgumentOutOfRangeException("charIndex", SR.ArgumentOutOfRange_Index);
- Contract.EndContractBlock();
// If no input, return 0 & avoid fixed problem
if (byteCount == 0)
@@ -378,7 +368,6 @@ namespace System.Text
if (charCount < 0 || byteCount < 0)
throw new ArgumentOutOfRangeException((charCount < 0 ? "charCount" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
return GetChars(bytes, byteCount, chars, charCount, null);
}
@@ -402,7 +391,6 @@ namespace System.Text
if (bytes.Length - index < count)
throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer);
- Contract.EndContractBlock();
// Avoid problems with empty input buffer
if (count == 0) return String.Empty;
@@ -2448,7 +2436,6 @@ namespace System.Text
if (charCount < 0)
throw new ArgumentOutOfRangeException(nameof(charCount),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// Characters would be # of characters + 1 in case left over high surrogate is ? * max fallback
long byteCount = (long)charCount + 1;
@@ -2471,7 +2458,6 @@ namespace System.Text
if (byteCount < 0)
throw new ArgumentOutOfRangeException(nameof(byteCount),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// Figure out our length, 1 char per input byte + 1 char if 1st byte is last byte of 4 byte surrogate pair
long charCount = ((long)byteCount + 1);
diff --git a/src/mscorlib/shared/System/Text/UnicodeEncoding.cs b/src/mscorlib/shared/System/Text/UnicodeEncoding.cs
index 78355299c1..a5b89a6666 100644
--- a/src/mscorlib/shared/System/Text/UnicodeEncoding.cs
+++ b/src/mscorlib/shared/System/Text/UnicodeEncoding.cs
@@ -9,7 +9,6 @@
using System;
using System.Globalization;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Text
{
@@ -96,7 +95,6 @@ namespace System.Text
if (chars.Length - index < count)
throw new ArgumentOutOfRangeException("chars", SR.ArgumentOutOfRange_IndexCountBuffer);
- Contract.EndContractBlock();
// If no input, return 0, avoid fixed empty array problem
if (count == 0)
@@ -117,7 +115,6 @@ namespace System.Text
// Validate input
if (s==null)
throw new ArgumentNullException("s");
- Contract.EndContractBlock();
fixed (char* pChars = s)
return GetByteCount(pChars, s.Length, null);
@@ -136,7 +133,6 @@ namespace System.Text
if (count < 0)
throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// Call it with empty encoder
return GetByteCount(chars, count, null);
@@ -161,7 +157,6 @@ namespace System.Text
if (byteIndex < 0 || byteIndex > bytes.Length)
throw new ArgumentOutOfRangeException("byteIndex", SR.ArgumentOutOfRange_Index);
- Contract.EndContractBlock();
int byteCount = bytes.Length - byteIndex;
@@ -202,7 +197,6 @@ namespace System.Text
if (byteIndex < 0 || byteIndex > bytes.Length)
throw new ArgumentOutOfRangeException("byteIndex", SR.ArgumentOutOfRange_Index);
- Contract.EndContractBlock();
// If nothing to encode return 0, avoid fixed problem
if (charCount == 0)
@@ -233,7 +227,6 @@ namespace System.Text
if (charCount < 0 || byteCount < 0)
throw new ArgumentOutOfRangeException((charCount < 0 ? "charCount" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
return GetBytes(chars, charCount, bytes, byteCount, null);
}
@@ -257,7 +250,6 @@ namespace System.Text
if (bytes.Length - index < count)
throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer);
- Contract.EndContractBlock();
// If no input just return 0, fixed doesn't like 0 length arrays
if (count == 0)
@@ -281,7 +273,6 @@ namespace System.Text
if (count < 0)
throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
return GetCharCount(bytes, count, null);
}
@@ -306,7 +297,6 @@ namespace System.Text
if (charIndex < 0 || charIndex > chars.Length)
throw new ArgumentOutOfRangeException("charIndex", SR.ArgumentOutOfRange_Index);
- Contract.EndContractBlock();
// If no input, return 0 & avoid fixed problem
if (byteCount == 0)
@@ -337,7 +327,6 @@ namespace System.Text
if (charCount < 0 || byteCount < 0)
throw new ArgumentOutOfRangeException((charCount < 0 ? "charCount" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
return GetChars(bytes, byteCount, chars, charCount, null);
}
@@ -361,7 +350,6 @@ namespace System.Text
if (bytes.Length - index < count)
throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer);
- Contract.EndContractBlock();
// Avoid problems with empty input buffer
if (count == 0) return String.Empty;
@@ -1911,7 +1899,6 @@ namespace System.Text
if (charCount < 0)
throw new ArgumentOutOfRangeException(nameof(charCount),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// Characters would be # of characters + 1 in case left over high surrogate is ? * max fallback
long byteCount = (long)charCount + 1;
@@ -1934,7 +1921,6 @@ namespace System.Text
if (byteCount < 0)
throw new ArgumentOutOfRangeException(nameof(byteCount),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// long because byteCount could be biggest int.
// 1 char per 2 bytes. Round up in case 1 left over in decoder.
diff --git a/src/mscorlib/shared/System/Threading/ExecutionContext.cs b/src/mscorlib/shared/System/Threading/ExecutionContext.cs
index a573af3383..2d5f5be190 100644
--- a/src/mscorlib/shared/System/Threading/ExecutionContext.cs
+++ b/src/mscorlib/shared/System/Threading/ExecutionContext.cs
@@ -12,7 +12,6 @@
===========================================================*/
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.ExceptionServices;
using System.Runtime.Serialization;
@@ -103,7 +102,6 @@ namespace System.Threading
{
throw new InvalidOperationException(SR.InvalidOperation_CannotSupressFlowMultipleTimes);
}
- Contract.EndContractBlock();
executionContext = executionContext.ShallowClone(isFlowSuppressed: true);
var asyncFlowControl = new AsyncFlowControl();
@@ -120,7 +118,6 @@ namespace System.Threading
{
throw new InvalidOperationException(SR.InvalidOperation_CannotRestoreUnsupressedFlow);
}
- Contract.EndContractBlock();
currentThread.ExecutionContext = executionContext.ShallowClone(isFlowSuppressed: false);
}
@@ -322,7 +319,6 @@ namespace System.Threading
{
throw new InvalidOperationException(SR.InvalidOperation_AsyncFlowCtrlCtxMismatch);
}
- Contract.EndContractBlock();
_thread = null;
ExecutionContext.RestoreFlow();
diff --git a/src/mscorlib/shared/System/TimeSpan.cs b/src/mscorlib/shared/System/TimeSpan.cs
index 263a0a5824..639d24b248 100644
--- a/src/mscorlib/shared/System/TimeSpan.cs
+++ b/src/mscorlib/shared/System/TimeSpan.cs
@@ -6,7 +6,6 @@ using System.Text;
using System;
using System.Runtime;
using System.Runtime.CompilerServices;
-using System.Diagnostics.Contracts;
using System.Globalization;
namespace System
@@ -207,7 +206,6 @@ namespace System
{
if (Ticks == TimeSpan.MinValue.Ticks)
throw new OverflowException(SR.Overflow_Duration);
- Contract.EndContractBlock();
return new TimeSpan(_ticks >= 0 ? _ticks : -_ticks);
}
@@ -244,7 +242,6 @@ namespace System
{
if (Double.IsNaN(value))
throw new ArgumentException(SR.Arg_CannotBeNaN);
- Contract.EndContractBlock();
double tmp = value * scale;
double millis = tmp + (value >= 0 ? 0.5 : -0.5);
if ((millis > Int64.MaxValue / TicksPerMillisecond) || (millis < Int64.MinValue / TicksPerMillisecond))
@@ -266,7 +263,6 @@ namespace System
{
if (Ticks == TimeSpan.MinValue.Ticks)
throw new OverflowException(SR.Overflow_NegateTwosCompNum);
- Contract.EndContractBlock();
return new TimeSpan(-_ticks);
}
diff --git a/src/mscorlib/shared/System/UInt16.cs b/src/mscorlib/shared/System/UInt16.cs
index 4cd290bc45..be61313e30 100644
--- a/src/mscorlib/shared/System/UInt16.cs
+++ b/src/mscorlib/shared/System/UInt16.cs
@@ -11,7 +11,6 @@
**
===========================================================*/
-using System.Diagnostics.Contracts;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -79,26 +78,22 @@ namespace System
// Converts the current value to a String in base-10 with no extra padding.
public override String ToString()
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatUInt32(m_value, null, NumberFormatInfo.CurrentInfo);
}
public String ToString(IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatUInt32(m_value, null, NumberFormatInfo.GetInstance(provider));
}
public String ToString(String format)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatUInt32(m_value, format, NumberFormatInfo.CurrentInfo);
}
public String ToString(String format, IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatUInt32(m_value, format, NumberFormatInfo.GetInstance(provider));
}
diff --git a/src/mscorlib/shared/System/UInt32.cs b/src/mscorlib/shared/System/UInt32.cs
index 49835613b2..3cd016cba1 100644
--- a/src/mscorlib/shared/System/UInt32.cs
+++ b/src/mscorlib/shared/System/UInt32.cs
@@ -12,7 +12,6 @@
**
===========================================================*/
-using System.Diagnostics.Contracts;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -89,25 +88,21 @@ namespace System
// The base 10 representation of the number with no extra padding.
public override String ToString()
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatUInt32(m_value, null, NumberFormatInfo.CurrentInfo);
}
public String ToString(IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatUInt32(m_value, null, NumberFormatInfo.GetInstance(provider));
}
public String ToString(String format)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatUInt32(m_value, format, NumberFormatInfo.CurrentInfo);
}
public String ToString(String format, IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatUInt32(m_value, format, NumberFormatInfo.GetInstance(provider));
}
diff --git a/src/mscorlib/shared/System/UInt64.cs b/src/mscorlib/shared/System/UInt64.cs
index 424d48b8b1..175d763308 100644
--- a/src/mscorlib/shared/System/UInt64.cs
+++ b/src/mscorlib/shared/System/UInt64.cs
@@ -11,7 +11,6 @@
**
===========================================================*/
-using System.Diagnostics.Contracts;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -86,25 +85,21 @@ namespace System
public override String ToString()
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatUInt64(m_value, null, NumberFormatInfo.CurrentInfo);
}
public String ToString(IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatUInt64(m_value, null, NumberFormatInfo.GetInstance(provider));
}
public String ToString(String format)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatUInt64(m_value, format, NumberFormatInfo.CurrentInfo);
}
public String ToString(String format, IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatUInt64(m_value, format, NumberFormatInfo.GetInstance(provider));
}
diff --git a/src/mscorlib/shared/System/ValueTuple.cs b/src/mscorlib/shared/System/ValueTuple.cs
index 3464f2781c..d3ae20f416 100644
--- a/src/mscorlib/shared/System/ValueTuple.cs
+++ b/src/mscorlib/shared/System/ValueTuple.cs
@@ -4,7 +4,7 @@
using System.Collections;
using System.Collections.Generic;
-using System.Diagnostics.Contracts;
+using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using HashHelpers = System.Numerics.Hashing.HashHelpers;
@@ -2186,7 +2186,7 @@ namespace System
rest.GetHashCode());
}
- Contract.Assert(false, "Missed all cases for computing ValueTuple hash code");
+ Debug.Fail("Missed all cases for computing ValueTuple hash code");
return -1;
}
@@ -2237,7 +2237,7 @@ namespace System
comparer.GetHashCode(Item7), rest.GetHashCode(comparer));
}
- Contract.Assert(false, "Missed all cases for computing ValueTuple hash code");
+ Debug.Fail("Missed all cases for computing ValueTuple hash code");
return -1;
}
diff --git a/src/mscorlib/shared/System/Version.cs b/src/mscorlib/shared/System/Version.cs
index 9c66d9b904..a084f9f5a4 100644
--- a/src/mscorlib/shared/System/Version.cs
+++ b/src/mscorlib/shared/System/Version.cs
@@ -4,7 +4,6 @@
using System.Globalization;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Text;
namespace System
@@ -39,7 +38,6 @@ namespace System
if (revision < 0)
throw new ArgumentOutOfRangeException(nameof(revision), SR.ArgumentOutOfRange_Version);
- Contract.EndContractBlock();
_Major = major;
_Minor = minor;
@@ -58,7 +56,6 @@ namespace System
if (build < 0)
throw new ArgumentOutOfRangeException(nameof(build), SR.ArgumentOutOfRange_Version);
- Contract.EndContractBlock();
_Major = major;
_Minor = minor;
@@ -72,7 +69,6 @@ namespace System
if (minor < 0)
throw new ArgumentOutOfRangeException(nameof(minor), SR.ArgumentOutOfRange_Version);
- Contract.EndContractBlock();
_Major = major;
_Minor = minor;
@@ -441,7 +437,6 @@ namespace System
{
if ((Object)v1 == null)
throw new ArgumentNullException(nameof(v1));
- Contract.EndContractBlock();
return (v1.CompareTo(v2) < 0);
}
@@ -449,7 +444,6 @@ namespace System
{
if ((Object)v1 == null)
throw new ArgumentNullException(nameof(v1));
- Contract.EndContractBlock();
return (v1.CompareTo(v2) <= 0);
}
diff --git a/src/mscorlib/src/Internal/Padding.cs b/src/mscorlib/src/Internal/Padding.cs
index d25acdc9c7..14bf998bab 100644
--- a/src/mscorlib/src/Internal/Padding.cs
+++ b/src/mscorlib/src/Internal/Padding.cs
@@ -6,7 +6,6 @@ using System.Runtime.InteropServices;
namespace Internal
{
-
/// <summary>A class for common padding constants and eventually routines.</summary>
internal static class PaddingHelpers
{
diff --git a/src/mscorlib/src/Internal/Runtime/Augments/RuntimeThread.cs b/src/mscorlib/src/Internal/Runtime/Augments/RuntimeThread.cs
index 4c67ea3fd6..1b2b69519f 100644
--- a/src/mscorlib/src/Internal/Runtime/Augments/RuntimeThread.cs
+++ b/src/mscorlib/src/Internal/Runtime/Augments/RuntimeThread.cs
@@ -4,7 +4,6 @@
using System;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
@@ -207,8 +206,8 @@ namespace Internal.Runtime.Augments
}
// This is done lazily because the first call to the function below in the process triggers a measurement that
- // takes a nontrivial amount of time. See Thread::InitializeYieldProcessorNormalized(), which describes and
- // calculates this value.
+ // takes a nontrivial amount of time if the measurement has not already been done in the backgorund.
+ // See Thread::InitializeYieldProcessorNormalized(), which describes and calculates this value.
s_optimalMaxSpinWaitsPerSpinIteration = GetOptimalMaxSpinWaitsPerSpinIterationInternal();
Debug.Assert(s_optimalMaxSpinWaitsPerSpinIteration > 0);
return s_optimalMaxSpinWaitsPerSpinIteration;
diff --git a/src/mscorlib/src/Microsoft/Win32/OAVariantLib.cs b/src/mscorlib/src/Microsoft/Win32/OAVariantLib.cs
index 93138e6e16..52224637b0 100644
--- a/src/mscorlib/src/Microsoft/Win32/OAVariantLib.cs
+++ b/src/mscorlib/src/Microsoft/Win32/OAVariantLib.cs
@@ -16,7 +16,7 @@
namespace Microsoft.Win32
{
using System;
- using System.Diagnostics.Contracts;
+ using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
@@ -99,7 +99,7 @@ namespace Microsoft.Win32
private static int GetCVTypeFromClass(Type ctype)
{
- Contract.Requires(ctype != null);
+ Debug.Assert(ctype != null);
#if _DEBUG
BCLDebug.Assert(ClassTypes[CV_OBJECT] == typeof(Object), "OAVariantLib::ClassTypes[CV_OBJECT] == Object.class");
#endif
diff --git a/src/mscorlib/src/Microsoft/Win32/RegistryKey.cs b/src/mscorlib/src/Microsoft/Win32/RegistryKey.cs
index 0a2057ca53..e314c48167 100644
--- a/src/mscorlib/src/Microsoft/Win32/RegistryKey.cs
+++ b/src/mscorlib/src/Microsoft/Win32/RegistryKey.cs
@@ -52,7 +52,7 @@ using Microsoft.Win32.SafeHandles;
using System;
using System.Buffers;
using System.Collections.Generic;
-using System.Diagnostics.Contracts;
+using System.Diagnostics;
using System.IO;
using System.Text;
@@ -1011,7 +1011,7 @@ namespace Microsoft.Win32
private static void FixupPath(StringBuilder path)
{
- Contract.Requires(path != null);
+ Debug.Assert(path != null);
int length = path.Length;
bool fixup = false;
char markerChar = (char)0xFFFF;
@@ -1107,7 +1107,6 @@ namespace Microsoft.Win32
static private void ValidateKeyName(string name)
{
- Contract.Ensures(name != null);
if (name == null)
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.name);
diff --git a/src/mscorlib/src/System/Activator.cs b/src/mscorlib/src/System/Activator.cs
index be938aa43d..3fa92c5874 100644
--- a/src/mscorlib/src/System/Activator.cs
+++ b/src/mscorlib/src/System/Activator.cs
@@ -23,7 +23,6 @@ namespace System
using System.Runtime.CompilerServices;
using AssemblyHashAlgorithm = System.Configuration.Assemblies.AssemblyHashAlgorithm;
using System.Runtime.Versioning;
- using System.Diagnostics.Contracts;
// Only statics, does not need to be marked with the serializable attribute
public sealed class Activator
@@ -60,7 +59,6 @@ namespace System
{
if ((object)type == null)
throw new ArgumentNullException(nameof(type));
- Contract.EndContractBlock();
if (type is System.Reflection.Emit.TypeBuilder)
throw new NotSupportedException(SR.NotSupported_CreateInstanceWithTypeBuilder);
@@ -118,7 +116,6 @@ namespace System
{
if ((object)type == null)
throw new ArgumentNullException(nameof(type));
- Contract.EndContractBlock();
RuntimeType rt = type.UnderlyingSystemType as RuntimeType;
diff --git a/src/mscorlib/src/System/AppDomain.cs b/src/mscorlib/src/System/AppDomain.cs
index 1c009ed605..5f7c7205b6 100644
--- a/src/mscorlib/src/System/AppDomain.cs
+++ b/src/mscorlib/src/System/AppDomain.cs
@@ -321,7 +321,6 @@ namespace System
{
get
{
- Contract.Ensures(Contract.Result<AppDomain>() != null);
return Thread.GetDomain();
}
}
@@ -372,7 +371,6 @@ namespace System
{
if (name == null)
throw new ArgumentNullException(nameof(name));
- Contract.EndContractBlock();
lock (((ICollection)LocalStore).SyncRoot)
{
@@ -385,7 +383,6 @@ namespace System
{
if (name == null)
throw new ArgumentNullException(nameof(name));
- Contract.EndContractBlock();
object data;
lock (((ICollection)LocalStore).SyncRoot)
@@ -403,7 +400,7 @@ namespace System
private AppDomain()
{
- throw new NotSupportedException(SR.GetResourceString(ResId.NotSupported_Constructor));
+ throw new NotSupportedException(SR.NotSupported_Constructor);
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
@@ -632,7 +629,7 @@ namespace System
private void SetupFusionStore(AppDomainSetup info, AppDomainSetup oldInfo)
{
- Contract.Requires(info != null);
+ Debug.Assert(info != null);
if (info.ApplicationBase == null)
{
@@ -694,9 +691,6 @@ namespace System
private static Object Setup(Object arg)
{
- Contract.Requires(arg != null && arg is Object[]);
- Contract.Requires(((Object[])arg).Length >= 8);
-
Object[] args = (Object[])arg;
String friendlyName = (String)args[0];
AppDomainSetup setup = (AppDomainSetup)args[1];
diff --git a/src/mscorlib/src/System/AppDomainSetup.cs b/src/mscorlib/src/System/AppDomainSetup.cs
index d0fdf4e725..f3b3d8c823 100644
--- a/src/mscorlib/src/System/AppDomainSetup.cs
+++ b/src/mscorlib/src/System/AppDomainSetup.cs
@@ -17,7 +17,6 @@ namespace System
using System.Security;
using Path = System.IO.Path;
using System.Diagnostics;
- using System.Diagnostics.Contracts;
using System.Collections.Generic;
internal sealed class AppDomainSetup
@@ -128,7 +127,6 @@ namespace System
public String ApplicationBase
{
- [Pure]
get
{
return Value[(int)LoaderInformation.ApplicationBaseValue];
diff --git a/src/mscorlib/src/System/ArgIterator.cs b/src/mscorlib/src/System/ArgIterator.cs
index 584f85fbd3..51e416c7b0 100644
--- a/src/mscorlib/src/System/ArgIterator.cs
+++ b/src/mscorlib/src/System/ArgIterator.cs
@@ -8,7 +8,6 @@ namespace System
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
- using System.Diagnostics.Contracts;
// This class will not be marked serializable
// Note: This type must have the same layout as the CLR's VARARGS type in CLRVarArgs.h.
diff --git a/src/mscorlib/src/System/Array.cs b/src/mscorlib/src/System/Array.cs
index 75e7679954..0841d7ac63 100644
--- a/src/mscorlib/src/System/Array.cs
+++ b/src/mscorlib/src/System/Array.cs
@@ -13,13 +13,12 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
using System.Runtime.Versioning;
using System.Security;
-using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System
{
@@ -39,7 +38,6 @@ namespace System
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
}
- Contract.Ensures(Contract.Result<ReadOnlyCollection<T>>() != null);
// T[] implements IList<T>.
return new ReadOnlyCollection<T>(array);
@@ -49,9 +47,6 @@ namespace System
{
if (newSize < 0)
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.newSize, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
- Contract.Ensures(Contract.ValueAtReturn(out array) != null);
- Contract.Ensures(Contract.ValueAtReturn(out array).Length == newSize);
- Contract.EndContractBlock();
T[] larray = array;
if (larray == null)
@@ -75,10 +70,6 @@ namespace System
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.elementType);
if (length < 0)
ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum();
- Contract.Ensures(Contract.Result<Array>() != null);
- Contract.Ensures(Contract.Result<Array>().Length == length);
- Contract.Ensures(Contract.Result<Array>().Rank == 1);
- Contract.EndContractBlock();
RuntimeType t = elementType.UnderlyingSystemType as RuntimeType;
if (t == null)
@@ -94,10 +85,6 @@ namespace System
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length1, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
if (length2 < 0)
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length2, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
- Contract.Ensures(Contract.Result<Array>() != null);
- Contract.Ensures(Contract.Result<Array>().Rank == 2);
- Contract.Ensures(Contract.Result<Array>().GetLength(0) == length1);
- Contract.Ensures(Contract.Result<Array>().GetLength(1) == length2);
RuntimeType t = elementType.UnderlyingSystemType as RuntimeType;
if (t == null)
@@ -118,11 +105,6 @@ namespace System
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length2, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
if (length3 < 0)
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length3, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
- Contract.Ensures(Contract.Result<Array>() != null);
- Contract.Ensures(Contract.Result<Array>().Rank == 3);
- Contract.Ensures(Contract.Result<Array>().GetLength(0) == length1);
- Contract.Ensures(Contract.Result<Array>().GetLength(1) == length2);
- Contract.Ensures(Contract.Result<Array>().GetLength(2) == length3);
RuntimeType t = elementType.UnderlyingSystemType as RuntimeType;
if (t == null)
@@ -142,9 +124,6 @@ namespace System
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.lengths);
if (lengths.Length == 0)
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_NeedAtLeast1Rank);
- Contract.Ensures(Contract.Result<Array>() != null);
- Contract.Ensures(Contract.Result<Array>().Rank == lengths.Length);
- Contract.EndContractBlock();
RuntimeType t = elementType.UnderlyingSystemType as RuntimeType;
if (t == null)
@@ -170,9 +149,6 @@ namespace System
}
if (lengths.Length == 0)
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_NeedAtLeast1Rank);
- Contract.Ensures(Contract.Result<Array>() != null);
- Contract.Ensures(Contract.Result<Array>().Rank == lengths.Length);
- Contract.EndContractBlock();
int[] intLengths = new int[lengths.Length];
@@ -200,9 +176,6 @@ namespace System
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RanksAndBounds);
if (lengths.Length == 0)
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_NeedAtLeast1Rank);
- Contract.Ensures(Contract.Result<Array>() != null);
- Contract.Ensures(Contract.Result<Array>().Rank == lengths.Length);
- Contract.EndContractBlock();
RuntimeType t = elementType.UnderlyingSystemType as RuntimeType;
if (t == null)
@@ -238,13 +211,6 @@ namespace System
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.sourceArray);
if (destinationArray == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.destinationArray);
- /*
- Contract.Requires(sourceArray.Rank == destinationArray.Rank);
- Contract.Requires(length >= 0);
- Contract.Requires(length <= sourceArray.GetLowerBound(0) + sourceArray.Length);
- Contract.Requires(length <= destinationArray.GetLowerBound(0) + destinationArray.Length);
- */
- Contract.EndContractBlock();
Copy(sourceArray, sourceArray.GetLowerBound(0), destinationArray, destinationArray.GetLowerBound(0), length, false);
}
@@ -308,7 +274,6 @@ namespace System
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.indices);
if (Rank != indices.Length)
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankIndices);
- Contract.EndContractBlock();
TypedReference elemref = new TypedReference();
fixed (int* pIndices = &indices[0])
@@ -320,7 +285,6 @@ namespace System
{
if (Rank != 1)
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_Need1DArray);
- Contract.EndContractBlock();
TypedReference elemref = new TypedReference();
InternalGetReference(&elemref, 1, &index);
@@ -331,7 +295,6 @@ namespace System
{
if (Rank != 2)
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_Need2DArray);
- Contract.EndContractBlock();
int* pIndices = stackalloc int[2];
pIndices[0] = index1;
@@ -346,7 +309,6 @@ namespace System
{
if (Rank != 3)
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_Need3DArray);
- Contract.EndContractBlock();
int* pIndices = stackalloc int[3];
pIndices[0] = index1;
@@ -362,7 +324,6 @@ namespace System
{
if (index > Int32.MaxValue || index < Int32.MinValue)
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
- Contract.EndContractBlock();
return this.GetValue((int)index);
}
@@ -373,7 +334,6 @@ namespace System
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index1, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
if (index2 > Int32.MaxValue || index2 < Int32.MinValue)
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index2, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
- Contract.EndContractBlock();
return this.GetValue((int)index1, (int)index2);
}
@@ -386,7 +346,6 @@ namespace System
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index2, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
if (index3 > Int32.MaxValue || index3 < Int32.MinValue)
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index3, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
- Contract.EndContractBlock();
return this.GetValue((int)index1, (int)index2, (int)index3);
}
@@ -397,7 +356,6 @@ namespace System
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.indices);
if (Rank != indices.Length)
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankIndices);
- Contract.EndContractBlock();
int[] intIndices = new int[indices.Length];
@@ -417,7 +375,6 @@ namespace System
{
if (Rank != 1)
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_Need1DArray);
- Contract.EndContractBlock();
TypedReference elemref = new TypedReference();
InternalGetReference(&elemref, 1, &index);
@@ -428,7 +385,6 @@ namespace System
{
if (Rank != 2)
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_Need2DArray);
- Contract.EndContractBlock();
int* pIndices = stackalloc int[2];
pIndices[0] = index1;
@@ -443,7 +399,6 @@ namespace System
{
if (Rank != 3)
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_Need3DArray);
- Contract.EndContractBlock();
int* pIndices = stackalloc int[3];
pIndices[0] = index1;
@@ -461,7 +416,6 @@ namespace System
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.indices);
if (Rank != indices.Length)
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankIndices);
- Contract.EndContractBlock();
TypedReference elemref = new TypedReference();
fixed (int* pIndices = &indices[0])
@@ -473,7 +427,6 @@ namespace System
{
if (index > Int32.MaxValue || index < Int32.MinValue)
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
- Contract.EndContractBlock();
this.SetValue(value, (int)index);
}
@@ -484,7 +437,6 @@ namespace System
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index1, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
if (index2 > Int32.MaxValue || index2 < Int32.MinValue)
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index2, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
- Contract.EndContractBlock();
this.SetValue(value, (int)index1, (int)index2);
}
@@ -497,7 +449,6 @@ namespace System
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index2, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
if (index3 > Int32.MaxValue || index3 < Int32.MinValue)
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index3, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
- Contract.EndContractBlock();
this.SetValue(value, (int)index1, (int)index2, (int)index3);
}
@@ -508,7 +459,6 @@ namespace System
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.indices);
if (Rank != indices.Length)
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankIndices);
- Contract.EndContractBlock();
int[] intIndices = new int[indices.Length];
@@ -534,7 +484,6 @@ namespace System
public extern int Length
{
- [Pure]
[MethodImpl(MethodImplOptions.InternalCall)]
get;
}
@@ -542,7 +491,7 @@ namespace System
private static int GetMedian(int low, int hi)
{
// Note both may be negative, if we are dealing with arrays w/ negative lower bounds.
- Contract.Requires(low <= hi);
+ Debug.Assert(low <= hi);
Debug.Assert(hi - low >= 0, "Length overflow!");
return low + ((hi - low) >> 1);
}
@@ -557,16 +506,13 @@ namespace System
public extern long LongLength
{
- [Pure]
[MethodImpl(MethodImplOptions.InternalCall)]
get;
}
- [Pure]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern int GetLength(int dimension);
- [Pure]
public long GetLongLength(int dimension)
{
//This method should throw an IndexOufOfRangeException for compat if dimension < 0 or >= Rank
@@ -575,16 +521,13 @@ namespace System
public extern int Rank
{
- [Pure]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
get;
}
- [Pure]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern int GetUpperBound(int dimension);
- [Pure]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern int GetLowerBound(int dimension);
@@ -741,7 +684,6 @@ namespace System
{
if (comparer == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.comparer);
- Contract.EndContractBlock();
int ret = 0;
@@ -766,13 +708,10 @@ namespace System
// negative result to produce the index of the first element (if any) that
// is larger than the given search value.
//
- [Pure]
public static int BinarySearch(Array array, Object value)
{
if (array == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
- Contract.Ensures((Contract.Result<int>() >= array.GetLowerBound(0) && Contract.Result<int>() <= array.GetUpperBound(0)) || (Contract.Result<int>() < array.GetLowerBound(0) && ~Contract.Result<int>() <= array.GetUpperBound(0) + 1));
- Contract.EndContractBlock();
int lb = array.GetLowerBound(0);
return BinarySearch(array, lb, array.Length, value, null);
}
@@ -790,7 +729,6 @@ namespace System
// negative result to produce the index of the first element (if any) that
// is larger than the given search value.
//
- [Pure]
public static int BinarySearch(Array array, int index, int length, Object value)
{
return BinarySearch(array, index, length, value, null);
@@ -810,12 +748,10 @@ namespace System
// negative result to produce the index of the first element (if any) that
// is larger than the given search value.
//
- [Pure]
public static int BinarySearch(Array array, Object value, IComparer comparer)
{
if (array == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
- Contract.EndContractBlock();
int lb = array.GetLowerBound(0);
return BinarySearch(array, lb, array.Length, value, comparer);
}
@@ -835,12 +771,10 @@ namespace System
// negative result to produce the index of the first element (if any) that
// is larger than the given search value.
//
- [Pure]
public static int BinarySearch(Array array, int index, int length, Object value, IComparer comparer)
{
if (array == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
- Contract.EndContractBlock();
int lb = array.GetLowerBound(0);
if (index < lb)
ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException();
@@ -922,31 +856,25 @@ namespace System
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern bool TrySZBinarySearch(Array sourceArray, int sourceIndex, int count, Object value, out int retVal);
- [Pure]
public static int BinarySearch<T>(T[] array, T value)
{
if (array == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
- Contract.EndContractBlock();
return BinarySearch<T>(array, 0, array.Length, value, null);
}
- [Pure]
public static int BinarySearch<T>(T[] array, T value, System.Collections.Generic.IComparer<T> comparer)
{
if (array == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
- Contract.EndContractBlock();
return BinarySearch<T>(array, 0, array.Length, value, comparer);
}
- [Pure]
public static int BinarySearch<T>(T[] array, int index, int length, T value)
{
return BinarySearch<T>(array, index, length, value, null);
}
- [Pure]
public static int BinarySearch<T>(T[] array, int index, int length, T value, System.Collections.Generic.IComparer<T> comparer)
{
if (array == null)
@@ -958,7 +886,6 @@ namespace System
if (array.Length - index < length)
ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen);
- Contract.EndContractBlock();
return ArraySortHelper<T>.Default.BinarySearch(array, index, length, value, comparer);
}
@@ -974,9 +901,6 @@ namespace System
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.converter);
}
- Contract.Ensures(Contract.Result<TOutput[]>() != null);
- Contract.Ensures(Contract.Result<TOutput[]>().Length == array.Length);
- Contract.EndContractBlock();
TOutput[] newArray = new TOutput[array.Length];
for (int i = 0; i < array.Length; i++)
@@ -993,22 +917,18 @@ namespace System
// Array.Copy internally. If you aren't using ICollection explicitly,
// call Array.Copy to avoid an extra indirection.
//
- [Pure]
public void CopyTo(Array array, int index)
{
if (array != null && array.Rank != 1)
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankMultiDimNotSupported);
- Contract.EndContractBlock();
// Note: Array.Copy throws a RankException and we want a consistent ArgumentException for all the IList CopyTo methods.
Array.Copy(this, GetLowerBound(0), array, index, Length);
}
- [Pure]
public void CopyTo(Array array, long index)
{
if (index > Int32.MaxValue || index < Int32.MinValue)
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
- Contract.EndContractBlock();
this.CopyTo(array, (int)index);
}
@@ -1018,13 +938,8 @@ namespace System
internal static readonly T[] Value = new T[0];
}
- [Pure]
public static T[] Empty<T>()
{
- Contract.Ensures(Contract.Result<T[]>() != null);
- Contract.Ensures(Contract.Result<T[]>().Length == 0);
- Contract.EndContractBlock();
-
return EmptyArray<T>.Value;
}
@@ -1080,7 +995,6 @@ namespace System
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match);
}
- Contract.EndContractBlock();
for (int i = 0; i < array.Length; i++)
{
@@ -1103,7 +1017,6 @@ namespace System
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match);
}
- Contract.EndContractBlock();
List<T> list = new List<T>();
for (int i = 0; i < array.Length; i++)
@@ -1122,8 +1035,6 @@ namespace System
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
}
- Contract.Ensures(Contract.Result<int>() < array.Length);
- Contract.EndContractBlock();
return FindIndex(array, 0, array.Length, match);
}
@@ -1134,8 +1045,6 @@ namespace System
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
}
- Contract.Ensures(Contract.Result<int>() < array.Length);
- Contract.EndContractBlock();
return FindIndex(array, startIndex, array.Length - startIndex, match);
}
@@ -1161,8 +1070,6 @@ namespace System
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match);
}
- Contract.Ensures(Contract.Result<int>() < array.Length);
- Contract.EndContractBlock();
int endIndex = startIndex + count;
for (int i = startIndex; i < endIndex; i++)
@@ -1183,7 +1090,6 @@ namespace System
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match);
}
- Contract.EndContractBlock();
for (int i = array.Length - 1; i >= 0; i--)
{
@@ -1201,7 +1107,6 @@ namespace System
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
}
- Contract.EndContractBlock();
return FindLastIndex(array, array.Length - 1, array.Length, match);
}
@@ -1212,7 +1117,6 @@ namespace System
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
}
- Contract.EndContractBlock();
return FindLastIndex(array, startIndex, startIndex + 1, match);
}
@@ -1228,7 +1132,6 @@ namespace System
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match);
}
- Contract.EndContractBlock();
if (array.Length == 0)
{
@@ -1275,7 +1178,6 @@ namespace System
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.action);
}
- Contract.EndContractBlock();
for (int i = 0; i < array.Length; i++)
{
@@ -1304,8 +1206,6 @@ namespace System
{
if (array == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
- Contract.Ensures(Contract.Result<int>() < array.GetLowerBound(0) + array.Length);
- Contract.EndContractBlock();
int lb = array.GetLowerBound(0);
return IndexOf(array, value, lb, array.Length);
}
@@ -1320,8 +1220,6 @@ namespace System
{
if (array == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
- Contract.Ensures(Contract.Result<int>() < array.GetLowerBound(0) + array.Length);
- Contract.EndContractBlock();
int lb = array.GetLowerBound(0);
return IndexOf(array, value, startIndex, array.Length - startIndex + lb);
}
@@ -1338,8 +1236,6 @@ namespace System
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
if (array.Rank != 1)
ThrowHelper.ThrowRankException(ExceptionResource.Rank_MultiDimNotSupported);
- Contract.Ensures(Contract.Result<int>() < array.GetLowerBound(0) + array.Length);
- Contract.EndContractBlock();
int lb = array.GetLowerBound(0);
if (startIndex < lb || startIndex > array.Length + lb)
@@ -1395,16 +1291,12 @@ namespace System
return lb - 1;
}
- [Pure]
public static int IndexOf<T>(T[] array, T value)
{
if (array == null)
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
}
- Contract.Ensures((Contract.Result<int>() < 0) ||
- (Contract.Result<int>() >= 0 && Contract.Result<int>() < array.Length && EqualityComparer<T>.Default.Equals(value, array[Contract.Result<int>()])));
- Contract.EndContractBlock();
return IndexOf(array, value, 0, array.Length);
}
@@ -1415,8 +1307,6 @@ namespace System
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
}
- Contract.Ensures(Contract.Result<int>() < array.Length);
- Contract.EndContractBlock();
return IndexOf(array, value, startIndex, array.Length - startIndex);
}
@@ -1437,8 +1327,6 @@ namespace System
{
ThrowHelper.ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count();
}
- Contract.Ensures(Contract.Result<int>() < array.Length);
- Contract.EndContractBlock();
return EqualityComparer<T>.Default.IndexOf(array, value, startIndex, count);
}
@@ -1455,8 +1343,6 @@ namespace System
{
if (array == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
- Contract.Ensures(Contract.Result<int>() < array.GetLowerBound(0) + array.Length);
- Contract.EndContractBlock();
int lb = array.GetLowerBound(0);
return LastIndexOf(array, value, array.Length - 1 + lb, array.Length);
}
@@ -1470,8 +1356,6 @@ namespace System
{
if (array == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
- Contract.Ensures(Contract.Result<int>() < array.GetLowerBound(0) + array.Length);
- Contract.EndContractBlock();
int lb = array.GetLowerBound(0);
return LastIndexOf(array, value, startIndex, startIndex + 1 - lb);
}
@@ -1486,8 +1370,6 @@ namespace System
{
if (array == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
- Contract.Ensures(Contract.Result<int>() < array.GetLowerBound(0) + array.Length);
- Contract.EndContractBlock();
int lb = array.GetLowerBound(0);
if (array.Length == 0)
{
@@ -1553,8 +1435,6 @@ namespace System
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
}
- Contract.Ensures(Contract.Result<int>() < array.Length);
- Contract.EndContractBlock();
return LastIndexOf(array, value, array.Length - 1, array.Length);
}
@@ -1565,8 +1445,6 @@ namespace System
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
}
- Contract.Ensures(Contract.Result<int>() < array.Length);
- Contract.EndContractBlock();
// if array is empty and startIndex is 0, we need to pass 0 as count
return LastIndexOf(array, value, startIndex, (array.Length == 0) ? 0 : (startIndex + 1));
}
@@ -1577,8 +1455,6 @@ namespace System
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
}
- Contract.Ensures(Contract.Result<int>() < array.Length);
- Contract.EndContractBlock();
if (array.Length == 0)
{
@@ -1627,7 +1503,6 @@ namespace System
{
if (array == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
- Contract.EndContractBlock();
Reverse(array, array.GetLowerBound(0), array.Length);
}
@@ -1651,7 +1526,6 @@ namespace System
ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen);
if (array.Rank != 1)
ThrowHelper.ThrowRankException(ExceptionResource.Rank_MultiDimNotSupported);
- Contract.EndContractBlock();
bool r = TrySZReverse(array, index, length);
if (r)
@@ -1684,7 +1558,6 @@ namespace System
{
if (array == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
- Contract.EndContractBlock();
Reverse(array, 0, array.Length);
}
@@ -1698,7 +1571,6 @@ namespace System
ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum();
if (array.Length - index < length)
ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen);
- Contract.EndContractBlock();
ref T p = ref Unsafe.As<byte, T>(ref array.GetRawSzArrayData());
int i = index;
@@ -1721,7 +1593,6 @@ namespace System
{
if (array == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
- Contract.EndContractBlock();
Sort(array, null, array.GetLowerBound(0), array.Length, null);
}
@@ -1735,7 +1606,6 @@ namespace System
{
if (keys == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.keys);
- Contract.EndContractBlock();
Sort(keys, items, keys.GetLowerBound(0), keys.Length, null);
}
@@ -1769,7 +1639,6 @@ namespace System
{
if (array == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
- Contract.EndContractBlock();
Sort(array, null, array.GetLowerBound(0), array.Length, comparer);
}
@@ -1785,7 +1654,6 @@ namespace System
{
if (keys == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.keys);
- Contract.EndContractBlock();
Sort(keys, items, keys.GetLowerBound(0), keys.Length, comparer);
}
@@ -1825,7 +1693,6 @@ namespace System
if (keys.Length - (index - keysLowerBound) < length || (items != null && (index - keysLowerBound) > items.Length - length))
ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen);
- Contract.EndContractBlock();
if (length > 1)
{
@@ -1860,7 +1727,6 @@ namespace System
{
if (array == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
- Contract.EndContractBlock();
Sort<T>(array, 0, array.Length, null);
}
@@ -1868,7 +1734,6 @@ namespace System
{
if (keys == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.keys);
- Contract.EndContractBlock();
Sort<TKey, TValue>(keys, items, 0, keys.Length, null);
}
@@ -1886,7 +1751,6 @@ namespace System
{
if (array == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
- Contract.EndContractBlock();
Sort<T>(array, 0, array.Length, comparer);
}
@@ -1894,7 +1758,6 @@ namespace System
{
if (keys == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.keys);
- Contract.EndContractBlock();
Sort<TKey, TValue>(keys, items, 0, keys.Length, comparer);
}
@@ -1908,7 +1771,6 @@ namespace System
ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum();
if (array.Length - index < length)
ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen);
- Contract.EndContractBlock();
if (length > 1)
{
@@ -1934,7 +1796,6 @@ namespace System
ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum();
if (keys.Length - index < length || (items != null && index > items.Length - length))
ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen);
- Contract.EndContractBlock();
if (length > 1)
{
@@ -1967,7 +1828,6 @@ namespace System
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.comparison);
}
- Contract.EndContractBlock();
ArraySortHelper<T>.Sort(array, 0, array.Length, comparison);
}
@@ -1983,7 +1843,6 @@ namespace System
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match);
}
- Contract.EndContractBlock();
for (int i = 0; i < array.Length; i++)
{
diff --git a/src/mscorlib/src/System/ArraySegment.cs b/src/mscorlib/src/System/ArraySegment.cs
index 7546c5bd56..a96db8f9f7 100644
--- a/src/mscorlib/src/System/ArraySegment.cs
+++ b/src/mscorlib/src/System/ArraySegment.cs
@@ -16,7 +16,6 @@
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System
{
@@ -41,7 +40,6 @@ namespace System
{
if (array == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
- Contract.EndContractBlock();
_array = array;
_offset = 0;
@@ -55,7 +53,6 @@ namespace System
// Failure should be rare and location determination and message is delegated to failure functions
if (array == null || (uint)offset > (uint)array.Length || (uint)count > (uint)(array.Length - offset))
ThrowHelper.ThrowArraySegmentCtorValidationFailedExceptions(array, offset, count);
- Contract.EndContractBlock();
_array = array;
_offset = offset;
@@ -205,7 +202,6 @@ namespace System
ThrowInvalidOperationIfDefault();
if (index < 0 || index >= _count)
ThrowHelper.ThrowArgumentOutOfRange_IndexException();
- Contract.EndContractBlock();
return _array[_offset + index];
}
@@ -215,7 +211,6 @@ namespace System
ThrowInvalidOperationIfDefault();
if (index < 0 || index >= _count)
ThrowHelper.ThrowArgumentOutOfRange_IndexException();
- Contract.EndContractBlock();
_array[_offset + index] = value;
}
@@ -252,7 +247,6 @@ namespace System
ThrowInvalidOperationIfDefault();
if (index < 0 || index >= _count)
ThrowHelper.ThrowArgumentOutOfRange_IndexException();
- Contract.EndContractBlock();
return _array[_offset + index];
}
@@ -326,10 +320,10 @@ namespace System
internal Enumerator(ArraySegment<T> arraySegment)
{
- Contract.Requires(arraySegment.Array != null);
- Contract.Requires(arraySegment.Offset >= 0);
- Contract.Requires(arraySegment.Count >= 0);
- Contract.Requires(arraySegment.Offset + arraySegment.Count <= arraySegment.Array.Length);
+ Debug.Assert(arraySegment.Array != null);
+ Debug.Assert(arraySegment.Offset >= 0);
+ Debug.Assert(arraySegment.Count >= 0);
+ Debug.Assert(arraySegment.Offset + arraySegment.Count <= arraySegment.Array.Length);
_array = arraySegment.Array;
_start = arraySegment.Offset;
diff --git a/src/mscorlib/src/System/Attribute.cs b/src/mscorlib/src/System/Attribute.cs
index 23fd9aaaaf..37445cc23b 100644
--- a/src/mscorlib/src/System/Attribute.cs
+++ b/src/mscorlib/src/System/Attribute.cs
@@ -10,7 +10,6 @@ using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Globalization;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Security;
namespace System
@@ -25,9 +24,9 @@ namespace System
#region PropertyInfo
private static Attribute[] InternalGetCustomAttributes(PropertyInfo element, Type type, bool inherit)
{
- Contract.Requires(element != null);
- Contract.Requires(type != null);
- Contract.Requires(type.IsSubclassOf(typeof(Attribute)) || type == typeof(Attribute));
+ Debug.Assert(element != null);
+ Debug.Assert(type != null);
+ Debug.Assert(type.IsSubclassOf(typeof(Attribute)) || type == typeof(Attribute));
// walk up the hierarchy chain
Attribute[] attributes = (Attribute[])element.GetCustomAttributes(type, inherit);
@@ -90,7 +89,7 @@ namespace System
private static PropertyInfo GetParentDefinition(PropertyInfo property, Type[] propertyParameters)
{
- Contract.Requires(property != null);
+ Debug.Assert(property != null);
// for the current property get the base class of the getter and the setter, they might be different
// note that this only works for RuntimeMethodInfo
@@ -127,9 +126,9 @@ namespace System
#region EventInfo
private static Attribute[] InternalGetCustomAttributes(EventInfo element, Type type, bool inherit)
{
- Contract.Requires(element != null);
- Contract.Requires(type != null);
- Contract.Requires(type.IsSubclassOf(typeof(Attribute)) || type == typeof(Attribute));
+ Debug.Assert(element != null);
+ Debug.Assert(type != null);
+ Debug.Assert(type.IsSubclassOf(typeof(Attribute)) || type == typeof(Attribute));
// walk up the hierarchy chain
Attribute[] attributes = (Attribute[])element.GetCustomAttributes(type, inherit);
@@ -158,7 +157,7 @@ namespace System
private static EventInfo GetParentDefinition(EventInfo ev)
{
- Contract.Requires(ev != null);
+ Debug.Assert(ev != null);
// note that this only works for RuntimeMethodInfo
MethodInfo add = ev.GetAddMethod(true);
@@ -176,7 +175,7 @@ namespace System
private static bool InternalIsDefined(EventInfo element, Type attributeType, bool inherit)
{
- Contract.Requires(element != null);
+ Debug.Assert(element != null);
// walk up the hierarchy chain
if (element.IsDefined(attributeType, inherit))
@@ -207,7 +206,7 @@ namespace System
#region ParameterInfo
private static ParameterInfo GetParentDefinition(ParameterInfo param)
{
- Contract.Requires(param != null);
+ Debug.Assert(param != null);
// note that this only works for RuntimeMethodInfo
RuntimeMethodInfo rtMethod = param.Member as RuntimeMethodInfo;
@@ -236,7 +235,7 @@ namespace System
private static Attribute[] InternalParamGetCustomAttributes(ParameterInfo param, Type type, bool inherit)
{
- Contract.Requires(param != null);
+ Debug.Assert(param != null);
// For ParameterInfo's we need to make sure that we chain through all the MethodInfo's in the inheritance chain that
// have this ParameterInfo defined. .We pick up all the CustomAttributes for the starting ParameterInfo. We need to pick up only attributes
@@ -326,8 +325,8 @@ namespace System
private static bool InternalParamIsDefined(ParameterInfo param, Type type, bool inherit)
{
- Contract.Requires(param != null);
- Contract.Requires(type != null);
+ Debug.Assert(param != null);
+ Debug.Assert(type != null);
// For ParameterInfo's we need to make sure that we chain through all the MethodInfo's in the inheritance chain.
// We pick up all the CustomAttributes for the starting ParameterInfo. We need to pick up only attributes
@@ -461,7 +460,6 @@ namespace System
if (!type.IsSubclassOf(typeof(Attribute)) && type != typeof(Attribute))
throw new ArgumentException(SR.Argument_MustHaveAttributeBaseClass);
- Contract.EndContractBlock();
switch (element.MemberType)
{
@@ -485,7 +483,6 @@ namespace System
{
if (element == null)
throw new ArgumentNullException(nameof(element));
- Contract.EndContractBlock();
switch (element.MemberType)
{
@@ -516,7 +513,6 @@ namespace System
if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute))
throw new ArgumentException(SR.Argument_MustHaveAttributeBaseClass);
- Contract.EndContractBlock();
switch (element.MemberType)
{
@@ -576,7 +572,6 @@ namespace System
if (element.Member == null)
throw new ArgumentException(SR.Argument_InvalidParameterInfo, nameof(element));
- Contract.EndContractBlock();
MemberInfo member = element.Member;
if (member.MemberType == MemberTypes.Method && inherit)
@@ -593,7 +588,6 @@ namespace System
if (element.Member == null)
throw new ArgumentException(SR.Argument_InvalidParameterInfo, nameof(element));
- Contract.EndContractBlock();
MemberInfo member = element.Member;
if (member.MemberType == MemberTypes.Method && inherit)
@@ -618,7 +612,6 @@ namespace System
if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute))
throw new ArgumentException(SR.Argument_MustHaveAttributeBaseClass);
- Contract.EndContractBlock();
MemberInfo member = element.Member;
@@ -679,7 +672,6 @@ namespace System
{
if (element == null)
throw new ArgumentNullException(nameof(element));
- Contract.EndContractBlock();
return (Attribute[])element.GetCustomAttributes(typeof(Attribute), inherit);
}
@@ -694,7 +686,6 @@ namespace System
if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute))
throw new ArgumentException(SR.Argument_MustHaveAttributeBaseClass);
- Contract.EndContractBlock();
return (Attribute[])element.GetCustomAttributes(attributeType, inherit);
}
@@ -715,7 +706,6 @@ namespace System
if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute))
throw new ArgumentException(SR.Argument_MustHaveAttributeBaseClass);
- Contract.EndContractBlock();
return element.IsDefined(attributeType, false);
}
@@ -758,7 +748,6 @@ namespace System
if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute))
throw new ArgumentException(SR.Argument_MustHaveAttributeBaseClass);
- Contract.EndContractBlock();
return (Attribute[])element.GetCustomAttributes(attributeType, inherit);
}
@@ -772,7 +761,6 @@ namespace System
{
if (element == null)
throw new ArgumentNullException(nameof(element));
- Contract.EndContractBlock();
return (Attribute[])element.GetCustomAttributes(typeof(Attribute), inherit);
}
@@ -793,7 +781,6 @@ namespace System
if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute))
throw new ArgumentException(SR.Argument_MustHaveAttributeBaseClass);
- Contract.EndContractBlock();
return element.IsDefined(attributeType, false);
}
diff --git a/src/mscorlib/src/System/BCLDebug.cs b/src/mscorlib/src/System/BCLDebug.cs
index 4a5f6d1891..9170a55c38 100644
--- a/src/mscorlib/src/System/BCLDebug.cs
+++ b/src/mscorlib/src/System/BCLDebug.cs
@@ -20,7 +20,6 @@ namespace System
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
- using System.Diagnostics.Contracts;
internal enum LogLevel
{
@@ -121,7 +120,6 @@ namespace System
#endif
}
- [Pure]
[Conditional("_LOGGING")]
static public void Log(String message)
{
@@ -135,7 +133,6 @@ namespace System
System.Diagnostics.Log.Trace(Environment.NewLine);
}
- [Pure]
[Conditional("_LOGGING")]
static public void Log(String switchName, String message)
{
@@ -254,7 +251,6 @@ namespace System
return ((int)logSwitch.MinimumLevel <= (int)level);
}
- [Pure]
[Conditional("_LOGGING")]
public static void Log(String switchName, LogLevel level, params Object[] messages)
{
@@ -298,7 +294,6 @@ namespace System
System.Diagnostics.Log.LogMessage((LoggingLevels)((int)level), logSwitch, StringBuilderCache.GetStringAndRelease(sb));
}
- [Pure]
[Conditional("_LOGGING")]
public static void Trace(String switchName, String format, params Object[] messages)
{
diff --git a/src/mscorlib/src/System/Buffer.cs b/src/mscorlib/src/System/Buffer.cs
index 71859ec587..1a5a4b6ad9 100644
--- a/src/mscorlib/src/System/Buffer.cs
+++ b/src/mscorlib/src/System/Buffer.cs
@@ -16,7 +16,6 @@ namespace System
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Diagnostics;
- using System.Diagnostics.Contracts;
using System.Security;
using System.Runtime;
diff --git a/src/mscorlib/src/System/Collections/Comparer.cs b/src/mscorlib/src/System/Collections/Comparer.cs
index 00259e6bdb..28baf90cae 100644
--- a/src/mscorlib/src/System/Collections/Comparer.cs
+++ b/src/mscorlib/src/System/Collections/Comparer.cs
@@ -14,7 +14,6 @@
===========================================================*/
using System.Globalization;
-using System.Diagnostics.Contracts;
namespace System.Collections
{
@@ -35,7 +34,6 @@ namespace System.Collections
{
throw new ArgumentNullException(nameof(culture));
}
- Contract.EndContractBlock();
m_compareInfo = culture.CompareInfo;
}
diff --git a/src/mscorlib/src/System/Collections/CompatibleComparer.cs b/src/mscorlib/src/System/Collections/CompatibleComparer.cs
index 7dcaa4e103..eb74123036 100644
--- a/src/mscorlib/src/System/Collections/CompatibleComparer.cs
+++ b/src/mscorlib/src/System/Collections/CompatibleComparer.cs
@@ -4,7 +4,6 @@
//
-using System.Diagnostics.Contracts;
namespace System.Collections
{
@@ -46,7 +45,6 @@ namespace System.Collections
{
throw new ArgumentNullException(nameof(obj));
}
- Contract.EndContractBlock();
if (_hcp != null)
return _hcp.GetHashCode(obj);
diff --git a/src/mscorlib/src/System/Collections/Concurrent/ConcurrentDictionary.cs b/src/mscorlib/src/System/Collections/Concurrent/ConcurrentDictionary.cs
index 4111c5964e..e1593e35aa 100644
--- a/src/mscorlib/src/System/Collections/Concurrent/ConcurrentDictionary.cs
+++ b/src/mscorlib/src/System/Collections/Concurrent/ConcurrentDictionary.cs
@@ -31,7 +31,7 @@ namespace System.Collections.Concurrent
/// All public and protected members of <see cref="ConcurrentDictionary{TKey,TValue}"/> are thread-safe and may be used
/// concurrently from multiple threads.
/// </remarks>
- [DebuggerTypeProxy(typeof(Mscorlib_DictionaryDebugView<,>))]
+ [DebuggerTypeProxy(typeof(IDictionaryDebugView<,>))]
[DebuggerDisplay("Count = {Count}")]
internal class ConcurrentDictionary<TKey, TValue> : IDictionary<TKey, TValue>, IDictionary, IReadOnlyDictionary<TKey, TValue>
{
diff --git a/src/mscorlib/src/System/Collections/EmptyReadOnlyDictionaryInternal.cs b/src/mscorlib/src/System/Collections/EmptyReadOnlyDictionaryInternal.cs
index 9841bdb4bb..a6a04b4964 100644
--- a/src/mscorlib/src/System/Collections/EmptyReadOnlyDictionaryInternal.cs
+++ b/src/mscorlib/src/System/Collections/EmptyReadOnlyDictionaryInternal.cs
@@ -13,7 +13,6 @@
**
===========================================================*/
-using System.Diagnostics.Contracts;
namespace System.Collections
{
@@ -49,7 +48,6 @@ namespace System.Collections
if (array.Length - index < this.Count)
throw new ArgumentException(SR.ArgumentOutOfRange_Index, nameof(index));
- Contract.EndContractBlock();
// the actual copy is a NOP
}
@@ -88,7 +86,6 @@ namespace System.Collections
{
throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key);
}
- Contract.EndContractBlock();
return null;
}
set
@@ -103,7 +100,6 @@ namespace System.Collections
if ((value != null) && (!value.GetType().IsSerializable))
throw new ArgumentException(SR.Argument_NotSerializable, nameof(value));
- Contract.EndContractBlock();
throw new InvalidOperationException(SR.InvalidOperation_ReadOnly);
}
@@ -142,7 +138,6 @@ namespace System.Collections
if ((value != null) && (!value.GetType().IsSerializable))
throw new ArgumentException(SR.Argument_NotSerializable, nameof(value));
- Contract.EndContractBlock();
throw new InvalidOperationException(SR.InvalidOperation_ReadOnly);
}
diff --git a/src/mscorlib/src/System/Collections/Generic/ArraySortHelper.cs b/src/mscorlib/src/System/Collections/Generic/ArraySortHelper.cs
index e4a4acf74e..be9ffb0566 100644
--- a/src/mscorlib/src/System/Collections/Generic/ArraySortHelper.cs
+++ b/src/mscorlib/src/System/Collections/Generic/ArraySortHelper.cs
@@ -17,7 +17,6 @@ using System;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.Versioning;
namespace System.Collections.Generic
@@ -155,8 +154,8 @@ namespace System.Collections.Generic
internal static int InternalBinarySearch(T[] array, int index, int length, T value, IComparer<T> comparer)
{
- Contract.Requires(array != null, "Check the arguments in the caller!");
- Contract.Requires(index >= 0 && length >= 0 && (array.Length - index >= length), "Check the arguments in the caller!");
+ Debug.Assert(array != null, "Check the arguments in the caller!");
+ Debug.Assert(index >= 0 && length >= 0 && (array.Length - index >= length), "Check the arguments in the caller!");
int lo = index;
int hi = index + length - 1;
@@ -204,12 +203,12 @@ namespace System.Collections.Generic
internal static void IntrospectiveSort(T[] keys, int left, int length, Comparison<T> comparer)
{
- Contract.Requires(keys != null);
- Contract.Requires(comparer != null);
- Contract.Requires(left >= 0);
- Contract.Requires(length >= 0);
- Contract.Requires(length <= keys.Length);
- Contract.Requires(length + left <= keys.Length);
+ Debug.Assert(keys != null);
+ Debug.Assert(comparer != null);
+ Debug.Assert(left >= 0);
+ Debug.Assert(length >= 0);
+ Debug.Assert(length <= keys.Length);
+ Debug.Assert(length + left <= keys.Length);
if (length < 2)
return;
@@ -219,10 +218,10 @@ namespace System.Collections.Generic
private static void IntroSort(T[] keys, int lo, int hi, int depthLimit, Comparison<T> comparer)
{
- Contract.Requires(keys != null);
- Contract.Requires(comparer != null);
- Contract.Requires(lo >= 0);
- Contract.Requires(hi < keys.Length);
+ Debug.Assert(keys != null);
+ Debug.Assert(comparer != null);
+ Debug.Assert(lo >= 0);
+ Debug.Assert(hi < keys.Length);
while (hi > lo)
{
@@ -266,12 +265,11 @@ namespace System.Collections.Generic
private static int PickPivotAndPartition(T[] keys, int lo, int hi, Comparison<T> comparer)
{
- Contract.Requires(keys != null);
- Contract.Requires(comparer != null);
- Contract.Requires(lo >= 0);
- Contract.Requires(hi > lo);
- Contract.Requires(hi < keys.Length);
- Contract.Ensures(Contract.Result<int>() >= lo && Contract.Result<int>() <= hi);
+ Debug.Assert(keys != null);
+ Debug.Assert(comparer != null);
+ Debug.Assert(lo >= 0);
+ Debug.Assert(hi > lo);
+ Debug.Assert(hi < keys.Length);
// Compute median-of-three. But also partition them, since we've done the comparison.
int middle = lo + ((hi - lo) / 2);
@@ -303,11 +301,11 @@ namespace System.Collections.Generic
private static void Heapsort(T[] keys, int lo, int hi, Comparison<T> comparer)
{
- Contract.Requires(keys != null);
- Contract.Requires(comparer != null);
- Contract.Requires(lo >= 0);
- Contract.Requires(hi > lo);
- Contract.Requires(hi < keys.Length);
+ Debug.Assert(keys != null);
+ Debug.Assert(comparer != null);
+ Debug.Assert(lo >= 0);
+ Debug.Assert(hi > lo);
+ Debug.Assert(hi < keys.Length);
int n = hi - lo + 1;
for (int i = n / 2; i >= 1; i = i - 1)
@@ -323,10 +321,10 @@ namespace System.Collections.Generic
private static void DownHeap(T[] keys, int i, int n, int lo, Comparison<T> comparer)
{
- Contract.Requires(keys != null);
- Contract.Requires(comparer != null);
- Contract.Requires(lo >= 0);
- Contract.Requires(lo < keys.Length);
+ Debug.Assert(keys != null);
+ Debug.Assert(comparer != null);
+ Debug.Assert(lo >= 0);
+ Debug.Assert(lo < keys.Length);
T d = keys[lo + i - 1];
int child;
@@ -347,10 +345,10 @@ namespace System.Collections.Generic
private static void InsertionSort(T[] keys, int lo, int hi, Comparison<T> comparer)
{
- Contract.Requires(keys != null);
- Contract.Requires(lo >= 0);
- Contract.Requires(hi >= lo);
- Contract.Requires(hi <= keys.Length);
+ Debug.Assert(keys != null);
+ Debug.Assert(lo >= 0);
+ Debug.Assert(hi >= lo);
+ Debug.Assert(hi <= keys.Length);
int i, j;
T t;
@@ -466,9 +464,9 @@ namespace System.Collections.Generic
private static void SwapIfGreaterWithItems(T[] keys, int a, int b)
{
- Contract.Requires(keys != null);
- Contract.Requires(0 <= a && a < keys.Length);
- Contract.Requires(0 <= b && b < keys.Length);
+ Debug.Assert(keys != null);
+ Debug.Assert(0 <= a && a < keys.Length);
+ Debug.Assert(0 <= b && b < keys.Length);
if (a != b)
{
@@ -493,11 +491,11 @@ namespace System.Collections.Generic
internal static void IntrospectiveSort(T[] keys, int left, int length)
{
- Contract.Requires(keys != null);
- Contract.Requires(left >= 0);
- Contract.Requires(length >= 0);
- Contract.Requires(length <= keys.Length);
- Contract.Requires(length + left <= keys.Length);
+ Debug.Assert(keys != null);
+ Debug.Assert(left >= 0);
+ Debug.Assert(length >= 0);
+ Debug.Assert(length <= keys.Length);
+ Debug.Assert(length + left <= keys.Length);
if (length < 2)
return;
@@ -507,9 +505,9 @@ namespace System.Collections.Generic
private static void IntroSort(T[] keys, int lo, int hi, int depthLimit)
{
- Contract.Requires(keys != null);
- Contract.Requires(lo >= 0);
- Contract.Requires(hi < keys.Length);
+ Debug.Assert(keys != null);
+ Debug.Assert(lo >= 0);
+ Debug.Assert(hi < keys.Length);
while (hi > lo)
{
@@ -553,11 +551,10 @@ namespace System.Collections.Generic
private static int PickPivotAndPartition(T[] keys, int lo, int hi)
{
- Contract.Requires(keys != null);
- Contract.Requires(lo >= 0);
- Contract.Requires(hi > lo);
- Contract.Requires(hi < keys.Length);
- Contract.Ensures(Contract.Result<int>() >= lo && Contract.Result<int>() <= hi);
+ Debug.Assert(keys != null);
+ Debug.Assert(lo >= 0);
+ Debug.Assert(hi > lo);
+ Debug.Assert(hi < keys.Length);
// Compute median-of-three. But also partition them, since we've done the comparison.
int middle = lo + ((hi - lo) / 2);
@@ -597,10 +594,10 @@ namespace System.Collections.Generic
private static void Heapsort(T[] keys, int lo, int hi)
{
- Contract.Requires(keys != null);
- Contract.Requires(lo >= 0);
- Contract.Requires(hi > lo);
- Contract.Requires(hi < keys.Length);
+ Debug.Assert(keys != null);
+ Debug.Assert(lo >= 0);
+ Debug.Assert(hi > lo);
+ Debug.Assert(hi < keys.Length);
int n = hi - lo + 1;
for (int i = n / 2; i >= 1; i = i - 1)
@@ -616,9 +613,9 @@ namespace System.Collections.Generic
private static void DownHeap(T[] keys, int i, int n, int lo)
{
- Contract.Requires(keys != null);
- Contract.Requires(lo >= 0);
- Contract.Requires(lo < keys.Length);
+ Debug.Assert(keys != null);
+ Debug.Assert(lo >= 0);
+ Debug.Assert(lo < keys.Length);
T d = keys[lo + i - 1];
int child;
@@ -639,10 +636,10 @@ namespace System.Collections.Generic
private static void InsertionSort(T[] keys, int lo, int hi)
{
- Contract.Requires(keys != null);
- Contract.Requires(lo >= 0);
- Contract.Requires(hi >= lo);
- Contract.Requires(hi <= keys.Length);
+ Debug.Assert(keys != null);
+ Debug.Assert(lo >= 0);
+ Debug.Assert(hi >= lo);
+ Debug.Assert(hi <= keys.Length);
int i, j;
T t;
@@ -728,11 +725,11 @@ namespace System.Collections.Generic
private static void SwapIfGreaterWithItems(TKey[] keys, TValue[] values, IComparer<TKey> comparer, int a, int b)
{
- Contract.Requires(keys != null);
- Contract.Requires(values == null || values.Length >= keys.Length);
- Contract.Requires(comparer != null);
- Contract.Requires(0 <= a && a < keys.Length);
- Contract.Requires(0 <= b && b < keys.Length);
+ Debug.Assert(keys != null);
+ Debug.Assert(values == null || values.Length >= keys.Length);
+ Debug.Assert(comparer != null);
+ Debug.Assert(0 <= a && a < keys.Length);
+ Debug.Assert(0 <= b && b < keys.Length);
if (a != b)
{
@@ -769,14 +766,14 @@ namespace System.Collections.Generic
internal static void IntrospectiveSort(TKey[] keys, TValue[] values, int left, int length, IComparer<TKey> comparer)
{
- Contract.Requires(keys != null);
- Contract.Requires(values != null);
- Contract.Requires(comparer != null);
- Contract.Requires(left >= 0);
- Contract.Requires(length >= 0);
- Contract.Requires(length <= keys.Length);
- Contract.Requires(length + left <= keys.Length);
- Contract.Requires(length + left <= values.Length);
+ Debug.Assert(keys != null);
+ Debug.Assert(values != null);
+ Debug.Assert(comparer != null);
+ Debug.Assert(left >= 0);
+ Debug.Assert(length >= 0);
+ Debug.Assert(length <= keys.Length);
+ Debug.Assert(length + left <= keys.Length);
+ Debug.Assert(length + left <= values.Length);
if (length < 2)
return;
@@ -786,11 +783,11 @@ namespace System.Collections.Generic
private static void IntroSort(TKey[] keys, TValue[] values, int lo, int hi, int depthLimit, IComparer<TKey> comparer)
{
- Contract.Requires(keys != null);
- Contract.Requires(values != null);
- Contract.Requires(comparer != null);
- Contract.Requires(lo >= 0);
- Contract.Requires(hi < keys.Length);
+ Debug.Assert(keys != null);
+ Debug.Assert(values != null);
+ Debug.Assert(comparer != null);
+ Debug.Assert(lo >= 0);
+ Debug.Assert(hi < keys.Length);
while (hi > lo)
{
@@ -834,13 +831,12 @@ namespace System.Collections.Generic
private static int PickPivotAndPartition(TKey[] keys, TValue[] values, int lo, int hi, IComparer<TKey> comparer)
{
- Contract.Requires(keys != null);
- Contract.Requires(values != null);
- Contract.Requires(comparer != null);
- Contract.Requires(lo >= 0);
- Contract.Requires(hi > lo);
- Contract.Requires(hi < keys.Length);
- Contract.Ensures(Contract.Result<int>() >= lo && Contract.Result<int>() <= hi);
+ Debug.Assert(keys != null);
+ Debug.Assert(values != null);
+ Debug.Assert(comparer != null);
+ Debug.Assert(lo >= 0);
+ Debug.Assert(hi > lo);
+ Debug.Assert(hi < keys.Length);
// Compute median-of-three. But also partition them, since we've done the comparison.
int middle = lo + ((hi - lo) / 2);
@@ -872,12 +868,12 @@ namespace System.Collections.Generic
private static void Heapsort(TKey[] keys, TValue[] values, int lo, int hi, IComparer<TKey> comparer)
{
- Contract.Requires(keys != null);
- Contract.Requires(values != null);
- Contract.Requires(comparer != null);
- Contract.Requires(lo >= 0);
- Contract.Requires(hi > lo);
- Contract.Requires(hi < keys.Length);
+ Debug.Assert(keys != null);
+ Debug.Assert(values != null);
+ Debug.Assert(comparer != null);
+ Debug.Assert(lo >= 0);
+ Debug.Assert(hi > lo);
+ Debug.Assert(hi < keys.Length);
int n = hi - lo + 1;
for (int i = n / 2; i >= 1; i = i - 1)
@@ -893,10 +889,10 @@ namespace System.Collections.Generic
private static void DownHeap(TKey[] keys, TValue[] values, int i, int n, int lo, IComparer<TKey> comparer)
{
- Contract.Requires(keys != null);
- Contract.Requires(comparer != null);
- Contract.Requires(lo >= 0);
- Contract.Requires(lo < keys.Length);
+ Debug.Assert(keys != null);
+ Debug.Assert(comparer != null);
+ Debug.Assert(lo >= 0);
+ Debug.Assert(lo < keys.Length);
TKey d = keys[lo + i - 1];
TValue dValue = (values != null) ? values[lo + i - 1] : default(TValue);
@@ -922,12 +918,12 @@ namespace System.Collections.Generic
private static void InsertionSort(TKey[] keys, TValue[] values, int lo, int hi, IComparer<TKey> comparer)
{
- Contract.Requires(keys != null);
- Contract.Requires(values != null);
- Contract.Requires(comparer != null);
- Contract.Requires(lo >= 0);
- Contract.Requires(hi >= lo);
- Contract.Requires(hi <= keys.Length);
+ Debug.Assert(keys != null);
+ Debug.Assert(values != null);
+ Debug.Assert(comparer != null);
+ Debug.Assert(lo >= 0);
+ Debug.Assert(hi >= lo);
+ Debug.Assert(hi <= keys.Length);
int i, j;
TKey t;
@@ -1020,13 +1016,13 @@ namespace System.Collections.Generic
internal static void IntrospectiveSort(TKey[] keys, TValue[] values, int left, int length)
{
- Contract.Requires(keys != null);
- Contract.Requires(values != null);
- Contract.Requires(left >= 0);
- Contract.Requires(length >= 0);
- Contract.Requires(length <= keys.Length);
- Contract.Requires(length + left <= keys.Length);
- Contract.Requires(length + left <= values.Length);
+ Debug.Assert(keys != null);
+ Debug.Assert(values != null);
+ Debug.Assert(left >= 0);
+ Debug.Assert(length >= 0);
+ Debug.Assert(length <= keys.Length);
+ Debug.Assert(length + left <= keys.Length);
+ Debug.Assert(length + left <= values.Length);
if (length < 2)
return;
@@ -1036,10 +1032,10 @@ namespace System.Collections.Generic
private static void IntroSort(TKey[] keys, TValue[] values, int lo, int hi, int depthLimit)
{
- Contract.Requires(keys != null);
- Contract.Requires(values != null);
- Contract.Requires(lo >= 0);
- Contract.Requires(hi < keys.Length);
+ Debug.Assert(keys != null);
+ Debug.Assert(values != null);
+ Debug.Assert(lo >= 0);
+ Debug.Assert(hi < keys.Length);
while (hi > lo)
{
@@ -1083,12 +1079,11 @@ namespace System.Collections.Generic
private static int PickPivotAndPartition(TKey[] keys, TValue[] values, int lo, int hi)
{
- Contract.Requires(keys != null);
- Contract.Requires(values != null);
- Contract.Requires(lo >= 0);
- Contract.Requires(hi > lo);
- Contract.Requires(hi < keys.Length);
- Contract.Ensures(Contract.Result<int>() >= lo && Contract.Result<int>() <= hi);
+ Debug.Assert(keys != null);
+ Debug.Assert(values != null);
+ Debug.Assert(lo >= 0);
+ Debug.Assert(hi > lo);
+ Debug.Assert(hi < keys.Length);
// Compute median-of-three. But also partition them, since we've done the comparison.
int middle = lo + ((hi - lo) / 2);
@@ -1128,11 +1123,11 @@ namespace System.Collections.Generic
private static void Heapsort(TKey[] keys, TValue[] values, int lo, int hi)
{
- Contract.Requires(keys != null);
- Contract.Requires(values != null);
- Contract.Requires(lo >= 0);
- Contract.Requires(hi > lo);
- Contract.Requires(hi < keys.Length);
+ Debug.Assert(keys != null);
+ Debug.Assert(values != null);
+ Debug.Assert(lo >= 0);
+ Debug.Assert(hi > lo);
+ Debug.Assert(hi < keys.Length);
int n = hi - lo + 1;
for (int i = n / 2; i >= 1; i = i - 1)
@@ -1148,9 +1143,9 @@ namespace System.Collections.Generic
private static void DownHeap(TKey[] keys, TValue[] values, int i, int n, int lo)
{
- Contract.Requires(keys != null);
- Contract.Requires(lo >= 0);
- Contract.Requires(lo < keys.Length);
+ Debug.Assert(keys != null);
+ Debug.Assert(lo >= 0);
+ Debug.Assert(lo < keys.Length);
TKey d = keys[lo + i - 1];
TValue dValue = (values != null) ? values[lo + i - 1] : default(TValue);
@@ -1176,11 +1171,11 @@ namespace System.Collections.Generic
private static void InsertionSort(TKey[] keys, TValue[] values, int lo, int hi)
{
- Contract.Requires(keys != null);
- Contract.Requires(values != null);
- Contract.Requires(lo >= 0);
- Contract.Requires(hi >= lo);
- Contract.Requires(hi <= keys.Length);
+ Debug.Assert(keys != null);
+ Debug.Assert(values != null);
+ Debug.Assert(lo >= 0);
+ Debug.Assert(hi >= lo);
+ Debug.Assert(hi <= keys.Length);
int i, j;
TKey t;
diff --git a/src/mscorlib/src/System/Collections/Generic/Comparer.cs b/src/mscorlib/src/System/Collections/Generic/Comparer.cs
index 47c241500d..bb9e07d491 100644
--- a/src/mscorlib/src/System/Collections/Generic/Comparer.cs
+++ b/src/mscorlib/src/System/Collections/Generic/Comparer.cs
@@ -8,7 +8,6 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
//using System.Globalization;
using System.Runtime.CompilerServices;
using System.Security;
@@ -27,8 +26,6 @@ namespace System.Collections.Generic
public static Comparer<T> Create(Comparison<T> comparison)
{
- Contract.Ensures(Contract.Result<Comparer<T>>() != null);
-
if (comparison == null)
throw new ArgumentNullException(nameof(comparison));
diff --git a/src/mscorlib/src/System/Collections/Generic/ComparerHelpers.cs b/src/mscorlib/src/System/Collections/Generic/ComparerHelpers.cs
index 3e428413d4..1c4b9bbc09 100644
--- a/src/mscorlib/src/System/Collections/Generic/ComparerHelpers.cs
+++ b/src/mscorlib/src/System/Collections/Generic/ComparerHelpers.cs
@@ -23,7 +23,8 @@ namespace System.Collections.Generic
/// </summary>
/// <param name="type">The type to create the default comparer for.</param>
/// <remarks>
- /// The logic in this method is replicated in vm/compile.cpp to ensure that NGen saves the right instantiations.
+ /// The logic in this method is replicated in vm/compile.cpp to ensure that NGen saves the right instantiations,
+ /// and in vm/jitinterface.cpp so the jit can model the behavior of this method.
/// </remarks>
internal static object CreateDefaultComparer(Type type)
{
diff --git a/src/mscorlib/src/System/Collections/Generic/DebugView.cs b/src/mscorlib/src/System/Collections/Generic/DebugView.cs
deleted file mode 100644
index dc487c1411..0000000000
--- a/src/mscorlib/src/System/Collections/Generic/DebugView.cs
+++ /dev/null
@@ -1,124 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*=============================================================================
-**
-**
-**
-** Purpose: DebugView class for generic collections
-**
-**
-**
-**
-=============================================================================*/
-
-using System;
-using System.Collections.ObjectModel;
-using System.Diagnostics;
-using System.Diagnostics.Contracts;
-
-namespace System.Collections.Generic
-{
- //
- // VS IDE can't differentiate between types with the same name from different
- // assembly. So we need to use different names for collection debug view for
- // collections in mscorlib.dll and system.dll.
- //
- internal sealed class Mscorlib_CollectionDebugView<T>
- {
- private ICollection<T> collection;
-
- public Mscorlib_CollectionDebugView(ICollection<T> collection)
- {
- if (collection == null)
- ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection);
-
- this.collection = collection;
- }
-
- [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
- public T[] Items
- {
- get
- {
- T[] items = new T[collection.Count];
- collection.CopyTo(items, 0);
- return items;
- }
- }
- }
-
- internal sealed class Mscorlib_DictionaryKeyCollectionDebugView<TKey, TValue>
- {
- private ICollection<TKey> collection;
-
- public Mscorlib_DictionaryKeyCollectionDebugView(ICollection<TKey> collection)
- {
- if (collection == null)
- ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection);
-
- this.collection = collection;
- }
-
- [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
- public TKey[] Items
- {
- get
- {
- TKey[] items = new TKey[collection.Count];
- collection.CopyTo(items, 0);
- return items;
- }
- }
- }
-
- internal sealed class Mscorlib_DictionaryValueCollectionDebugView<TKey, TValue>
- {
- private ICollection<TValue> collection;
-
- public Mscorlib_DictionaryValueCollectionDebugView(ICollection<TValue> collection)
- {
- if (collection == null)
- ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection);
-
- this.collection = collection;
- }
-
- [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
- public TValue[] Items
- {
- get
- {
- TValue[] items = new TValue[collection.Count];
- collection.CopyTo(items, 0);
- return items;
- }
- }
- }
-
- internal sealed class Mscorlib_DictionaryDebugView<K, V>
- {
- private IDictionary<K, V> dict;
-
- public Mscorlib_DictionaryDebugView(IDictionary<K, V> dictionary)
- {
- if (dictionary == null)
- ThrowHelper.ThrowArgumentNullException(ExceptionArgument.dictionary);
-
- dict = dictionary;
- }
-
- [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
- public KeyValuePair<K, V>[] Items
- {
- get
- {
- KeyValuePair<K, V>[] items = new KeyValuePair<K, V>[dict.Count];
- dict.CopyTo(items, 0);
- return items;
- }
- }
- }
-
-}
diff --git a/src/mscorlib/src/System/Collections/Generic/Dictionary.cs b/src/mscorlib/src/System/Collections/Generic/Dictionary.cs
index 0a83734eb0..761f775905 100644
--- a/src/mscorlib/src/System/Collections/Generic/Dictionary.cs
+++ b/src/mscorlib/src/System/Collections/Generic/Dictionary.cs
@@ -24,7 +24,6 @@ namespace System.Collections.Generic
using System;
using System.Collections;
using System.Diagnostics;
- using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
@@ -49,7 +48,7 @@ namespace System.Collections.Generic
ThrowOnExisting = 2
}
- [DebuggerTypeProxy(typeof(Mscorlib_DictionaryDebugView<,>))]
+ [DebuggerTypeProxy(typeof(IDictionaryDebugView<,>))]
[DebuggerDisplay("Count = {Count}")]
[Serializable]
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
@@ -176,7 +175,6 @@ namespace System.Collections.Generic
{
get
{
- Contract.Ensures(Contract.Result<KeyCollection>() != null);
if (keys == null) keys = new KeyCollection(this);
return keys;
}
@@ -204,7 +202,6 @@ namespace System.Collections.Generic
{
get
{
- Contract.Ensures(Contract.Result<ValueCollection>() != null);
if (values == null) values = new ValueCollection(this);
return values;
}
@@ -1026,7 +1023,7 @@ namespace System.Collections.Generic
}
}
- [DebuggerTypeProxy(typeof(Mscorlib_DictionaryKeyCollectionDebugView<,>))]
+ [DebuggerTypeProxy(typeof(DictionaryKeyCollectionDebugView<,>))]
[DebuggerDisplay("Count = {Count}")]
public sealed class KeyCollection : ICollection<TKey>, ICollection, IReadOnlyCollection<TKey>
{
@@ -1254,7 +1251,7 @@ namespace System.Collections.Generic
}
}
- [DebuggerTypeProxy(typeof(Mscorlib_DictionaryValueCollectionDebugView<,>))]
+ [DebuggerTypeProxy(typeof(DictionaryValueCollectionDebugView<,>))]
[DebuggerDisplay("Count = {Count}")]
public sealed class ValueCollection : ICollection<TValue>, ICollection, IReadOnlyCollection<TValue>
{
diff --git a/src/mscorlib/src/System/Collections/Generic/EqualityComparer.cs b/src/mscorlib/src/System/Collections/Generic/EqualityComparer.cs
index 4427682d38..06af626526 100644
--- a/src/mscorlib/src/System/Collections/Generic/EqualityComparer.cs
+++ b/src/mscorlib/src/System/Collections/Generic/EqualityComparer.cs
@@ -11,7 +11,6 @@ using System.Globalization;
using System.Runtime;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
-using System.Diagnostics.Contracts;
namespace System.Collections.Generic
{
@@ -22,11 +21,9 @@ namespace System.Collections.Generic
{
// To minimize generic instantiation overhead of creating the comparer per type, we keep the generic portion of the code as small
// as possible and define most of the creation logic in a non-generic class.
- public static EqualityComparer<T> Default { get; } = (EqualityComparer<T>)ComparerHelpers.CreateDefaultEqualityComparer(typeof(T));
+ public static EqualityComparer<T> Default { [Intrinsic] get; } = (EqualityComparer<T>)ComparerHelpers.CreateDefaultEqualityComparer(typeof(T));
- [Pure]
public abstract bool Equals(T x, T y);
- [Pure]
public abstract int GetHashCode(T obj);
internal virtual int IndexOf(T[] array, T value, int startIndex, int count)
@@ -73,7 +70,7 @@ namespace System.Collections.Generic
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
internal class GenericEqualityComparer<T> : EqualityComparer<T> where T : IEquatable<T>
{
- [Pure]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(T x, T y)
{
if (x != null)
@@ -85,7 +82,7 @@ namespace System.Collections.Generic
return true;
}
- [Pure]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public override int GetHashCode(T obj) => obj?.GetHashCode() ?? 0;
internal override int IndexOf(T[] array, T value, int startIndex, int count)
@@ -142,7 +139,7 @@ namespace System.Collections.Generic
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
internal sealed class NullableEqualityComparer<T> : EqualityComparer<T?> where T : struct, IEquatable<T>
{
- [Pure]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(T? x, T? y)
{
if (x.HasValue)
@@ -154,7 +151,7 @@ namespace System.Collections.Generic
return true;
}
- [Pure]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public override int GetHashCode(T? obj) => obj.GetHashCode();
internal override int IndexOf(T?[] array, T? value, int startIndex, int count)
@@ -209,7 +206,7 @@ namespace System.Collections.Generic
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
internal sealed class ObjectEqualityComparer<T> : EqualityComparer<T>
{
- [Pure]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(T x, T y)
{
if (x != null)
@@ -221,7 +218,7 @@ namespace System.Collections.Generic
return true;
}
- [Pure]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public override int GetHashCode(T obj) => obj?.GetHashCode() ?? 0;
internal override int IndexOf(T[] array, T value, int startIndex, int count)
@@ -293,7 +290,6 @@ namespace System.Collections.Generic
}
}
- [Pure]
public override int GetHashCode(string obj)
{
if (obj == null) return 0;
@@ -307,13 +303,13 @@ namespace System.Collections.Generic
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
internal sealed class ByteEqualityComparer : EqualityComparer<byte>
{
- [Pure]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(byte x, byte y)
{
return x == y;
}
- [Pure]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public override int GetHashCode(byte b)
{
return b.GetHashCode();
@@ -329,7 +325,6 @@ namespace System.Collections.Generic
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_Count);
if (count > array.Length - startIndex)
throw new ArgumentException(SR.Argument_InvalidOffLen);
- Contract.EndContractBlock();
if (count == 0) return -1;
fixed (byte* pbytes = array)
{
@@ -359,7 +354,7 @@ namespace System.Collections.Generic
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
internal class EnumEqualityComparer<T> : EqualityComparer<T>, ISerializable where T : struct
{
- [Pure]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(T x, T y)
{
int x_final = System.Runtime.CompilerServices.JitHelpers.UnsafeEnumCast(x);
@@ -367,7 +362,7 @@ namespace System.Collections.Generic
return x_final == y_final;
}
- [Pure]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public override int GetHashCode(T obj)
{
int x_final = System.Runtime.CompilerServices.JitHelpers.UnsafeEnumCast(obj);
@@ -428,7 +423,7 @@ namespace System.Collections.Generic
// This is used by the serialization engine.
public SByteEnumEqualityComparer(SerializationInfo information, StreamingContext context) { }
- [Pure]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public override int GetHashCode(T obj)
{
int x_final = System.Runtime.CompilerServices.JitHelpers.UnsafeEnumCast(obj);
@@ -445,7 +440,7 @@ namespace System.Collections.Generic
// This is used by the serialization engine.
public ShortEnumEqualityComparer(SerializationInfo information, StreamingContext context) { }
- [Pure]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public override int GetHashCode(T obj)
{
int x_final = System.Runtime.CompilerServices.JitHelpers.UnsafeEnumCast(obj);
@@ -457,7 +452,7 @@ namespace System.Collections.Generic
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
internal sealed class LongEnumEqualityComparer<T> : EqualityComparer<T>, ISerializable where T : struct
{
- [Pure]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(T x, T y)
{
long x_final = System.Runtime.CompilerServices.JitHelpers.UnsafeEnumCastLong(x);
@@ -465,7 +460,7 @@ namespace System.Collections.Generic
return x_final == y_final;
}
- [Pure]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public override int GetHashCode(T obj)
{
long x_final = System.Runtime.CompilerServices.JitHelpers.UnsafeEnumCastLong(obj);
diff --git a/src/mscorlib/src/System/Collections/Hashtable.cs b/src/mscorlib/src/System/Collections/Hashtable.cs
index fcfcc3bbd6..0550030e7c 100644
--- a/src/mscorlib/src/System/Collections/Hashtable.cs
+++ b/src/mscorlib/src/System/Collections/Hashtable.cs
@@ -205,7 +205,6 @@ namespace System.Collections
throw new ArgumentOutOfRangeException(nameof(capacity), SR.ArgumentOutOfRange_NeedNonNegNum);
if (!(loadFactor >= 0.1f && loadFactor <= 1.0f))
throw new ArgumentOutOfRangeException(nameof(loadFactor), SR.Format(SR.ArgumentOutOfRange_HashtableLoadFactor, .1, 1.0));
- Contract.EndContractBlock();
// Based on perf work, .72 is the optimal load factor for this table.
this.loadFactor = 0.72f * loadFactor;
@@ -344,7 +343,6 @@ namespace System.Collections
{
throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key);
}
- Contract.EndContractBlock();
uint seed;
uint incr;
@@ -375,8 +373,8 @@ namespace System.Collections
// the KeyCollection class.
private void CopyKeys(Array array, int arrayIndex)
{
- Contract.Requires(array != null);
- Contract.Requires(array.Rank == 1);
+ Debug.Assert(array != null);
+ Debug.Assert(array.Rank == 1);
bucket[] lbuckets = buckets;
for (int i = lbuckets.Length; --i >= 0;)
@@ -394,8 +392,8 @@ namespace System.Collections
// the KeyCollection class.
private void CopyEntries(Array array, int arrayIndex)
{
- Contract.Requires(array != null);
- Contract.Requires(array.Rank == 1);
+ Debug.Assert(array != null);
+ Debug.Assert(array.Rank == 1);
bucket[] lbuckets = buckets;
for (int i = lbuckets.Length; --i >= 0;)
@@ -421,7 +419,6 @@ namespace System.Collections
throw new ArgumentOutOfRangeException(nameof(arrayIndex), SR.ArgumentOutOfRange_NeedNonNegNum);
if (array.Length - arrayIndex < Count)
throw new ArgumentException(SR.Arg_ArrayPlusOffTooSmall);
- Contract.EndContractBlock();
CopyEntries(array, arrayIndex);
}
@@ -431,8 +428,8 @@ namespace System.Collections
// the ValueCollection class.
private void CopyValues(Array array, int arrayIndex)
{
- Contract.Requires(array != null);
- Contract.Requires(array.Rank == 1);
+ Debug.Assert(array != null);
+ Debug.Assert(array.Rank == 1);
bucket[] lbuckets = buckets;
for (int i = lbuckets.Length; --i >= 0;)
@@ -456,7 +453,6 @@ namespace System.Collections
{
throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key);
}
- Contract.EndContractBlock();
uint seed;
uint incr;
@@ -699,7 +695,6 @@ namespace System.Collections
{
throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key);
}
- Contract.EndContractBlock();
if (count >= loadsize)
{
expand();
@@ -842,7 +837,6 @@ namespace System.Collections
{
throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key);
}
- Contract.EndContractBlock();
Debug.Assert(!isWriterInProgress, "Race condition detected in usages of Hashtable - multiple threads appear to be writing to a Hashtable instance simultaneously! Don't do that - use Hashtable.Synchronized.");
uint seed;
@@ -908,7 +902,6 @@ namespace System.Collections
{
if (table == null)
throw new ArgumentNullException(nameof(table));
- Contract.EndContractBlock();
return new SyncHashtable(table);
}
@@ -1038,7 +1031,6 @@ namespace System.Collections
throw new ArgumentException(SR.Arg_RankMultiDimNotSupported);
if (arrayIndex < 0)
throw new ArgumentOutOfRangeException(nameof(arrayIndex), SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
if (array.Length - arrayIndex < _hashtable.count)
throw new ArgumentException(SR.Arg_ArrayPlusOffTooSmall);
_hashtable.CopyKeys(array, arrayIndex);
@@ -1084,7 +1076,6 @@ namespace System.Collections
throw new ArgumentException(SR.Arg_RankMultiDimNotSupported);
if (arrayIndex < 0)
throw new ArgumentOutOfRangeException(nameof(arrayIndex), SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
if (array.Length - arrayIndex < _hashtable.count)
throw new ArgumentException(SR.Arg_ArrayPlusOffTooSmall);
_hashtable.CopyValues(array, arrayIndex);
@@ -1204,7 +1195,6 @@ namespace System.Collections
{
throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key);
}
- Contract.EndContractBlock();
return _table.ContainsKey(key);
}
@@ -1314,14 +1304,14 @@ namespace System.Collections
{
get
{
- if (current == false) throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumNotStarted));
+ if (current == false) throw new InvalidOperationException(SR.InvalidOperation_EnumNotStarted);
return currentKey;
}
}
public virtual bool MoveNext()
{
- if (version != hashtable.version) throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumFailedVersion));
+ if (version != hashtable.version) throw new InvalidOperationException(SR.InvalidOperation_EnumFailedVersion);
while (bucket > 0)
{
bucket--;
@@ -1342,7 +1332,7 @@ namespace System.Collections
{
get
{
- if (current == false) throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumOpCantHappen));
+ if (current == false) throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen);
return new DictionaryEntry(currentKey, currentValue);
}
}
@@ -1352,7 +1342,7 @@ namespace System.Collections
{
get
{
- if (current == false) throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumOpCantHappen));
+ if (current == false) throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen);
if (getObjectRetType == Keys)
return currentKey;
@@ -1367,14 +1357,14 @@ namespace System.Collections
{
get
{
- if (current == false) throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumOpCantHappen));
+ if (current == false) throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen);
return currentValue;
}
}
public virtual void Reset()
{
- if (version != hashtable.version) throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumFailedVersion));
+ if (version != hashtable.version) throw new InvalidOperationException(SR.InvalidOperation_EnumFailedVersion);
current = false;
bucket = hashtable.buckets.Length;
currentKey = null;
@@ -1449,7 +1439,6 @@ namespace System.Collections
{
if (min < 0)
throw new ArgumentException(SR.Arg_HTCapacityOverflow);
- Contract.EndContractBlock();
for (int i = 0; i < primes.Length; i++)
{
diff --git a/src/mscorlib/src/System/Collections/ObjectModel/ReadOnlyDictionary.cs b/src/mscorlib/src/System/Collections/ObjectModel/ReadOnlyDictionary.cs
index 3fd0cf8c6c..2337439dda 100644
--- a/src/mscorlib/src/System/Collections/ObjectModel/ReadOnlyDictionary.cs
+++ b/src/mscorlib/src/System/Collections/ObjectModel/ReadOnlyDictionary.cs
@@ -15,11 +15,10 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Collections.ObjectModel
{
- [DebuggerTypeProxy(typeof(Mscorlib_DictionaryDebugView<,>))]
+ [DebuggerTypeProxy(typeof(IDictionaryDebugView<,>))]
[DebuggerDisplay("Count = {Count}")]
internal class ReadOnlyDictionary<TKey, TValue> : IDictionary<TKey, TValue>, IDictionary, IReadOnlyDictionary<TKey, TValue>
{
@@ -37,7 +36,6 @@ namespace System.Collections.ObjectModel
{
throw new ArgumentNullException(nameof(dictionary));
}
- Contract.EndContractBlock();
m_dictionary = dictionary;
}
@@ -50,7 +48,6 @@ namespace System.Collections.ObjectModel
{
get
{
- Contract.Ensures(Contract.Result<KeyCollection>() != null);
if (m_keys == null)
{
m_keys = new KeyCollection(m_dictionary.Keys);
@@ -63,7 +60,6 @@ namespace System.Collections.ObjectModel
{
get
{
- Contract.Ensures(Contract.Result<ValueCollection>() != null);
if (m_values == null)
{
m_values = new ValueCollection(m_dictionary.Values);
@@ -428,7 +424,7 @@ namespace System.Collections.ObjectModel
#endregion IReadOnlyDictionary members
- [DebuggerTypeProxy(typeof(Mscorlib_CollectionDebugView<>))]
+ [DebuggerTypeProxy(typeof(ICollectionDebugView<>))]
[DebuggerDisplay("Count = {Count}")]
public sealed class KeyCollection : ICollection<TKey>, ICollection, IReadOnlyCollection<TKey>
{
@@ -538,7 +534,7 @@ namespace System.Collections.ObjectModel
#endregion
}
- [DebuggerTypeProxy(typeof(Mscorlib_CollectionDebugView<>))]
+ [DebuggerTypeProxy(typeof(ICollectionDebugView<>))]
[DebuggerDisplay("Count = {Count}")]
public sealed class ValueCollection : ICollection<TValue>, ICollection, IReadOnlyCollection<TValue>
{
diff --git a/src/mscorlib/src/System/DateTime.CoreCLR.cs b/src/mscorlib/src/System/DateTime.CoreCLR.cs
index 69c595663b..4d36b9970a 100644
--- a/src/mscorlib/src/System/DateTime.CoreCLR.cs
+++ b/src/mscorlib/src/System/DateTime.CoreCLR.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
namespace System
@@ -13,7 +12,6 @@ namespace System
{
get
{
- Contract.Ensures(Contract.Result<DateTime>().Kind == DateTimeKind.Utc);
// following code is tuned for speed. Don't change it without running benchmark.
long ticks = 0;
ticks = GetSystemTimeAsFileTime();
diff --git a/src/mscorlib/src/System/Decimal.cs b/src/mscorlib/src/System/Decimal.cs
index 5bb0446784..e93971d1c0 100644
--- a/src/mscorlib/src/System/Decimal.cs
+++ b/src/mscorlib/src/System/Decimal.cs
@@ -10,7 +10,7 @@ using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
using System.Runtime.Versioning;
using System.Runtime.Serialization;
-using System.Diagnostics.Contracts;
+using System.Diagnostics;
namespace System
{
@@ -275,7 +275,6 @@ namespace System
{
if (bits == null)
throw new ArgumentNullException(nameof(bits));
- Contract.EndContractBlock();
if (bits.Length == 4)
{
int f = bits[3];
@@ -297,7 +296,6 @@ namespace System
{
if (scale > 28)
throw new ArgumentOutOfRangeException(nameof(scale), SR.ArgumentOutOfRange_DecimalScale);
- Contract.EndContractBlock();
this.lo = lo;
this.mid = mid;
this.hi = hi;
@@ -478,25 +476,21 @@ namespace System
//
public override String ToString()
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatDecimal(this, null, NumberFormatInfo.CurrentInfo);
}
public String ToString(String format)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatDecimal(this, format, NumberFormatInfo.CurrentInfo);
}
public String ToString(IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatDecimal(this, null, NumberFormatInfo.GetInstance(provider));
}
public String ToString(String format, IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatDecimal(this, format, NumberFormatInfo.GetInstance(provider));
}
@@ -587,7 +581,7 @@ namespace System
internal static void GetBytes(Decimal d, byte[] buffer)
{
- Contract.Requires((buffer != null && buffer.Length >= 16), "[GetBytes]buffer != null && buffer.Length >= 16");
+ Debug.Assert((buffer != null && buffer.Length >= 16), "[GetBytes]buffer != null && buffer.Length >= 16");
buffer[0] = (byte)d.lo;
buffer[1] = (byte)(d.lo >> 8);
buffer[2] = (byte)(d.lo >> 16);
@@ -611,7 +605,7 @@ namespace System
internal static decimal ToDecimal(byte[] buffer)
{
- Contract.Requires((buffer != null && buffer.Length >= 16), "[ToDecimal]buffer != null && buffer.Length >= 16");
+ Debug.Assert((buffer != null && buffer.Length >= 16), "[ToDecimal]buffer != null && buffer.Length >= 16");
int lo = ((int)buffer[0]) | ((int)buffer[1] << 8) | ((int)buffer[2] << 16) | ((int)buffer[3] << 24);
int mid = ((int)buffer[4]) | ((int)buffer[5] << 8) | ((int)buffer[6] << 16) | ((int)buffer[7] << 24);
int hi = ((int)buffer[8]) | ((int)buffer[9] << 8) | ((int)buffer[10] << 16) | ((int)buffer[11] << 24);
@@ -818,7 +812,6 @@ namespace System
{
throw new ArgumentException(SR.Format(SR.Argument_InvalidEnumValue, mode, nameof(MidpointRounding)), nameof(mode));
}
- Contract.EndContractBlock();
if (mode == MidpointRounding.ToEven)
{
diff --git a/src/mscorlib/src/System/Delegate.cs b/src/mscorlib/src/System/Delegate.cs
index 8a9763694b..188657aa7a 100644
--- a/src/mscorlib/src/System/Delegate.cs
+++ b/src/mscorlib/src/System/Delegate.cs
@@ -13,7 +13,6 @@ namespace System
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Diagnostics;
- using System.Diagnostics.Contracts;
[ClassInterface(ClassInterfaceType.AutoDual)]
[System.Runtime.InteropServices.ComVisible(true)]
@@ -45,7 +44,6 @@ namespace System
if (method == null)
throw new ArgumentNullException(nameof(method));
- Contract.EndContractBlock();
// This API existed in v1/v1.1 and only expected to create closed
// instance delegates. Constrain the call to BindToMethodName to
@@ -72,7 +70,6 @@ namespace System
if (method == null)
throw new ArgumentNullException(nameof(method));
- Contract.EndContractBlock();
RuntimeType rtTarget = target as RuntimeType;
if (rtTarget == null)
@@ -349,7 +346,6 @@ namespace System
throw new ArgumentNullException(nameof(target));
if (method == null)
throw new ArgumentNullException(nameof(method));
- Contract.EndContractBlock();
RuntimeType rtType = type as RuntimeType;
if (rtType == null)
@@ -402,7 +398,6 @@ namespace System
throw new ArgumentException(SR.Arg_UnboundGenParam, nameof(target));
if (method == null)
throw new ArgumentNullException(nameof(method));
- Contract.EndContractBlock();
RuntimeType rtType = type as RuntimeType;
RuntimeType rtTarget = target as RuntimeType;
@@ -440,7 +435,6 @@ namespace System
throw new ArgumentNullException(nameof(type));
if (method == null)
throw new ArgumentNullException(nameof(method));
- Contract.EndContractBlock();
RuntimeType rtType = type as RuntimeType;
if (rtType == null)
@@ -490,7 +484,6 @@ namespace System
throw new ArgumentNullException(nameof(type));
if (method == null)
throw new ArgumentNullException(nameof(method));
- Contract.EndContractBlock();
RuntimeType rtType = type as RuntimeType;
if (rtType == null)
@@ -558,7 +551,6 @@ namespace System
// Validate the parameters.
if (type == null)
throw new ArgumentNullException(nameof(type));
- Contract.EndContractBlock();
if (method.IsNullHandle())
throw new ArgumentNullException(nameof(method));
@@ -594,7 +586,6 @@ namespace System
if (method == null)
throw new ArgumentNullException(nameof(method));
- Contract.EndContractBlock();
RuntimeMethodInfo rtMethod = method as RuntimeMethodInfo;
if (rtMethod == null)
diff --git a/src/mscorlib/src/System/Diagnostics/Assert.cs b/src/mscorlib/src/System/Diagnostics/Assert.cs
index 67e6914aa4..3fbbdc9830 100644
--- a/src/mscorlib/src/System/Diagnostics/Assert.cs
+++ b/src/mscorlib/src/System/Diagnostics/Assert.cs
@@ -7,7 +7,6 @@ using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
-using System.Diagnostics.Contracts;
using System.Diagnostics.CodeAnalysis;
namespace System.Diagnostics
diff --git a/src/mscorlib/src/System/Diagnostics/Contracts/Contracts.cs b/src/mscorlib/src/System/Diagnostics/Contracts/Contracts.cs
index 32a417036f..5b74f601b1 100644
--- a/src/mscorlib/src/System/Diagnostics/Contracts/Contracts.cs
+++ b/src/mscorlib/src/System/Diagnostics/Contracts/Contracts.cs
@@ -646,7 +646,6 @@ namespace System.Diagnostics.Contracts
#endif
if (predicate == null)
throw new ArgumentNullException(nameof(predicate));
- Contract.EndContractBlock();
for (int i = fromInclusive; i < toExclusive; i++)
if (!predicate(i)) return false;
@@ -672,7 +671,6 @@ namespace System.Diagnostics.Contracts
throw new ArgumentNullException(nameof(collection));
if (predicate == null)
throw new ArgumentNullException(nameof(predicate));
- Contract.EndContractBlock();
foreach (T t in collection)
if (!predicate(t)) return false;
@@ -706,7 +704,6 @@ namespace System.Diagnostics.Contracts
#endif
if (predicate == null)
throw new ArgumentNullException(nameof(predicate));
- Contract.EndContractBlock();
for (int i = fromInclusive; i < toExclusive; i++)
if (predicate(i)) return true;
@@ -731,7 +728,6 @@ namespace System.Diagnostics.Contracts
throw new ArgumentNullException(nameof(collection));
if (predicate == null)
throw new ArgumentNullException(nameof(predicate));
- Contract.EndContractBlock();
foreach (T t in collection)
if (predicate(t)) return true;
diff --git a/src/mscorlib/src/System/Diagnostics/Contracts/ContractsBCL.cs b/src/mscorlib/src/System/Diagnostics/Contracts/ContractsBCL.cs
index db6a40c54a..e4bbe1d71e 100644
--- a/src/mscorlib/src/System/Diagnostics/Contracts/ContractsBCL.cs
+++ b/src/mscorlib/src/System/Diagnostics/Contracts/ContractsBCL.cs
@@ -96,7 +96,6 @@ namespace System.Diagnostics.Contracts
{
if (failureKind < ContractFailureKind.Precondition || failureKind > ContractFailureKind.Assume)
throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, failureKind), nameof(failureKind));
- Contract.EndContractBlock();
// displayMessage == null means: yes we handled it. Otherwise it is the localized failure message
var displayMessage = System.Runtime.CompilerServices.ContractHelper.RaiseContractFailedEvent(failureKind, userMessage, conditionText, innerException);
@@ -148,7 +147,7 @@ namespace System.Diagnostics.Contracts
#endif
public ContractFailedEventArgs(ContractFailureKind failureKind, String message, String condition, Exception originalException)
{
- Contract.Requires(originalException == null || failureKind == ContractFailureKind.PostconditionOnException);
+ Debug.Assert(originalException == null || failureKind == ContractFailureKind.PostconditionOnException);
_failureKind = failureKind;
_message = message;
_condition = condition;
@@ -296,7 +295,6 @@ namespace System.Runtime.CompilerServices
{
if (failureKind < ContractFailureKind.Precondition || failureKind > ContractFailureKind.Assume)
throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, failureKind), nameof(failureKind));
- Contract.EndContractBlock();
string returnValue;
String displayMessage = "contract failed."; // Incomplete, but in case of OOM during resource lookup...
@@ -405,7 +403,7 @@ namespace System.Runtime.CompilerServices
break;
default:
- Contract.Assume(false, "Unreachable code");
+ Debug.Fail("Unreachable code");
resourceName = "AssumptionFailed";
break;
}
diff --git a/src/mscorlib/src/System/Diagnostics/DebuggerAttributes.cs b/src/mscorlib/src/System/Diagnostics/DebuggerAttributes.cs
index 34e65bcb3e..035f809b21 100644
--- a/src/mscorlib/src/System/Diagnostics/DebuggerAttributes.cs
+++ b/src/mscorlib/src/System/Diagnostics/DebuggerAttributes.cs
@@ -14,7 +14,6 @@
using System;
using System.Runtime.InteropServices;
-using System.Diagnostics.Contracts;
namespace System.Diagnostics
{
@@ -126,7 +125,6 @@ namespace System.Diagnostics
{
if (state < DebuggerBrowsableState.Never || state > DebuggerBrowsableState.RootHidden)
throw new ArgumentOutOfRangeException(nameof(state));
- Contract.EndContractBlock();
this.state = state;
}
@@ -151,7 +149,6 @@ namespace System.Diagnostics
{
throw new ArgumentNullException(nameof(type));
}
- Contract.EndContractBlock();
typeName = type.AssemblyQualifiedName;
}
@@ -173,7 +170,6 @@ namespace System.Diagnostics
{
throw new ArgumentNullException(nameof(value));
}
- Contract.EndContractBlock();
targetName = value.AssemblyQualifiedName;
target = value;
@@ -246,7 +242,6 @@ namespace System.Diagnostics
{
throw new ArgumentNullException(nameof(value));
}
- Contract.EndContractBlock();
targetName = value.AssemblyQualifiedName;
target = value;
diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/XplatEventLogger.cs b/src/mscorlib/src/System/Diagnostics/Eventing/XplatEventLogger.cs
index 00155d72a0..d8057f36de 100644
--- a/src/mscorlib/src/System/Diagnostics/Eventing/XplatEventLogger.cs
+++ b/src/mscorlib/src/System/Diagnostics/Eventing/XplatEventLogger.cs
@@ -7,13 +7,10 @@ using System.Text;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
-using Contract = System.Diagnostics.Contracts.Contract;
-
#if FEATURE_EVENTSOURCE_XPLAT
namespace System.Diagnostics.Tracing
{
-
internal class XplatEventLogger : EventListener
{
private static Lazy<string> eventSourceNameFilter = new Lazy<string>(() => CompatibilitySwitch.GetValueInternal("EventSourceFilter"));
@@ -26,7 +23,6 @@ namespace System.Diagnostics.Tracing
public static EventListener InitializePersistentListener()
{
try{
-
if (!initializedPersistentListener && XplatEventLogger.IsEventSourceLoggingEnabled())
{
initializedPersistentListener = true;
diff --git a/src/mscorlib/src/System/Diagnostics/LogSwitch.cs b/src/mscorlib/src/System/Diagnostics/LogSwitch.cs
index d3994d48b8..5382c37547 100644
--- a/src/mscorlib/src/System/Diagnostics/LogSwitch.cs
+++ b/src/mscorlib/src/System/Diagnostics/LogSwitch.cs
@@ -6,7 +6,6 @@ using System;
using System.IO;
using System.Collections;
using System.Runtime.Versioning;
-using System.Diagnostics.Contracts;
using System.Diagnostics.CodeAnalysis;
namespace System.Diagnostics
@@ -37,7 +36,6 @@ namespace System.Diagnostics
{
if (name != null && name.Length == 0)
throw new ArgumentOutOfRangeException(nameof(Name), SR.Argument_StringZeroLength);
- Contract.EndContractBlock();
if ((name != null) && (parent != null))
{
diff --git a/src/mscorlib/src/System/Diagnostics/Stackframe.cs b/src/mscorlib/src/System/Diagnostics/Stackframe.cs
index a6a7067af3..f45de5cab9 100644
--- a/src/mscorlib/src/System/Diagnostics/Stackframe.cs
+++ b/src/mscorlib/src/System/Diagnostics/Stackframe.cs
@@ -7,7 +7,6 @@ using System.Text;
using System;
using System.IO;
using System.Reflection;
-using System.Diagnostics.Contracts;
namespace System.Diagnostics
{
@@ -149,8 +148,6 @@ namespace System.Diagnostics
//
public virtual MethodBase GetMethod()
{
- Contract.Ensures(Contract.Result<MethodBase>() != null);
-
return method;
}
diff --git a/src/mscorlib/src/System/Diagnostics/Stacktrace.cs b/src/mscorlib/src/System/Diagnostics/Stacktrace.cs
index 097ed44f85..022c72ce01 100644
--- a/src/mscorlib/src/System/Diagnostics/Stacktrace.cs
+++ b/src/mscorlib/src/System/Diagnostics/Stacktrace.cs
@@ -14,7 +14,6 @@ using System.Runtime.CompilerServices;
using System.Globalization;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
-using System.Diagnostics.Contracts;
namespace System.Diagnostics
{
@@ -279,7 +278,6 @@ namespace System.Diagnostics
if (skipFrames < 0)
throw new ArgumentOutOfRangeException(nameof(skipFrames),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
m_iNumOfFrames = 0;
m_iMethodsToSkip = 0;
@@ -295,7 +293,6 @@ namespace System.Diagnostics
if (skipFrames < 0)
throw new ArgumentOutOfRangeException(nameof(skipFrames),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
m_iNumOfFrames = 0;
m_iMethodsToSkip = 0;
@@ -309,7 +306,6 @@ namespace System.Diagnostics
{
if (e == null)
throw new ArgumentNullException(nameof(e));
- Contract.EndContractBlock();
m_iNumOfFrames = 0;
m_iMethodsToSkip = 0;
@@ -322,7 +318,6 @@ namespace System.Diagnostics
{
if (e == null)
throw new ArgumentNullException(nameof(e));
- Contract.EndContractBlock();
m_iNumOfFrames = 0;
m_iMethodsToSkip = 0;
@@ -340,7 +335,6 @@ namespace System.Diagnostics
if (skipFrames < 0)
throw new ArgumentOutOfRangeException(nameof(skipFrames),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
m_iNumOfFrames = 0;
m_iMethodsToSkip = 0;
@@ -359,7 +353,6 @@ namespace System.Diagnostics
if (skipFrames < 0)
throw new ArgumentOutOfRangeException(nameof(skipFrames),
SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
m_iNumOfFrames = 0;
m_iMethodsToSkip = 0;
diff --git a/src/mscorlib/src/System/Diagnostics/log.cs b/src/mscorlib/src/System/Diagnostics/log.cs
index 5ed3a3e502..f38eaccabc 100644
--- a/src/mscorlib/src/System/Diagnostics/log.cs
+++ b/src/mscorlib/src/System/Diagnostics/log.cs
@@ -10,7 +10,6 @@ namespace System.Diagnostics
using System.Runtime.CompilerServices;
using Encoding = System.Text.Encoding;
using System.Runtime.Versioning;
- using System.Diagnostics.Contracts;
using System.Diagnostics.CodeAnalysis;
using Console = Internal.Console;
@@ -87,7 +86,6 @@ namespace System.Diagnostics
if (level < 0)
throw new ArgumentOutOfRangeException(nameof(level), SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
// Is logging for this level for this switch enabled?
if (logswitch.CheckLevel(level) == true)
diff --git a/src/mscorlib/src/System/Empty.cs b/src/mscorlib/src/System/Empty.cs
index 2b585b3141..ac01fa6f5c 100644
--- a/src/mscorlib/src/System/Empty.cs
+++ b/src/mscorlib/src/System/Empty.cs
@@ -6,7 +6,6 @@
// This class represents an empty variant
////////////////////////////////////////////////////////////////////////////////
-using System.Diagnostics.Contracts;
using System;
using System.Runtime.Serialization;
diff --git a/src/mscorlib/src/System/Enum.cs b/src/mscorlib/src/System/Enum.cs
index b5d00fe60e..96bf31c889 100644
--- a/src/mscorlib/src/System/Enum.cs
+++ b/src/mscorlib/src/System/Enum.cs
@@ -10,7 +10,6 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
// The code below includes partial support for float/double and
// pointer sized enums.
@@ -122,7 +121,7 @@ namespace System
internal static String GetEnumName(RuntimeType eT, ulong ulValue)
{
- Contract.Requires(eT != null);
+ Debug.Assert(eT != null);
ulong[] ulValues = Enum.InternalGetValues(eT);
int index = Array.BinarySearch(ulValues, ulValue);
@@ -137,7 +136,7 @@ namespace System
private static String InternalFormat(RuntimeType eT, ulong value)
{
- Contract.Requires(eT != null);
+ Debug.Assert(eT != null);
// These values are sorted by value. Don't change this
TypeValuesAndNames entry = GetCachedValuesAndNames(eT, true);
@@ -162,7 +161,7 @@ namespace System
private static String InternalFlagsFormat(RuntimeType eT, TypeValuesAndNames entry, ulong result)
{
- Contract.Requires(eT != null);
+ Debug.Assert(eT != null);
String[] names = entry.Names;
ulong[] values = entry.Values;
@@ -411,7 +410,6 @@ namespace System
{
if (enumType == null)
throw new ArgumentNullException(nameof(enumType));
- Contract.EndContractBlock();
RuntimeType rtType = enumType as RuntimeType;
if (rtType == null)
@@ -547,8 +545,6 @@ namespace System
{
if (enumType == null)
throw new ArgumentNullException(nameof(enumType));
- Contract.Ensures(Contract.Result<Type>() != null);
- Contract.EndContractBlock();
return enumType.GetEnumUnderlyingType();
}
@@ -557,8 +553,6 @@ namespace System
{
if (enumType == null)
throw new ArgumentNullException(nameof(enumType));
- Contract.Ensures(Contract.Result<Array>() != null);
- Contract.EndContractBlock();
return enumType.GetEnumValues();
}
@@ -573,7 +567,6 @@ namespace System
{
if (enumType == null)
throw new ArgumentNullException(nameof(enumType));
- Contract.EndContractBlock();
return enumType.GetEnumName(value);
}
@@ -582,8 +575,6 @@ namespace System
{
if (enumType == null)
throw new ArgumentNullException(nameof(enumType));
- Contract.Ensures(Contract.Result<String[]>() != null);
- Contract.EndContractBlock();
return enumType.GetEnumNames();
}
@@ -598,7 +589,6 @@ namespace System
{
if (value == null)
throw new ArgumentNullException(nameof(value));
- Contract.EndContractBlock();
// Delegate rest of error checking to the other functions
TypeCode typeCode = Convert.GetTypeCode(value);
@@ -641,12 +631,10 @@ namespace System
}
}
- [Pure]
public static bool IsDefined(Type enumType, Object value)
{
if (enumType == null)
throw new ArgumentNullException(nameof(enumType));
- Contract.EndContractBlock();
return enumType.IsEnumDefined(value);
}
@@ -664,7 +652,6 @@ namespace System
if (format == null)
throw new ArgumentNullException(nameof(format));
- Contract.EndContractBlock();
RuntimeType rtType = enumType as RuntimeType;
if (rtType == null)
@@ -915,7 +902,6 @@ namespace System
if (this == null)
throw new NullReferenceException();
- Contract.EndContractBlock();
int ret = InternalCompareTo(this, target);
@@ -978,7 +964,6 @@ namespace System
{
if (flag == null)
throw new ArgumentNullException(nameof(flag));
- Contract.EndContractBlock();
if (!this.GetType().IsEquivalentTo(flag.GetType()))
{
@@ -1104,7 +1089,6 @@ namespace System
throw new ArgumentNullException(nameof(enumType));
if (!enumType.IsEnum)
throw new ArgumentException(SR.Arg_MustBeEnum, nameof(enumType));
- Contract.EndContractBlock();
RuntimeType rtType = enumType as RuntimeType;
if (rtType == null)
throw new ArgumentException(SR.Arg_MustBeType, nameof(enumType));
@@ -1117,7 +1101,6 @@ namespace System
throw new ArgumentNullException(nameof(enumType));
if (!enumType.IsEnum)
throw new ArgumentException(SR.Arg_MustBeEnum, nameof(enumType));
- Contract.EndContractBlock();
RuntimeType rtType = enumType as RuntimeType;
if (rtType == null)
throw new ArgumentException(SR.Arg_MustBeType, nameof(enumType));
@@ -1130,7 +1113,6 @@ namespace System
throw new ArgumentNullException(nameof(enumType));
if (!enumType.IsEnum)
throw new ArgumentException(SR.Arg_MustBeEnum, nameof(enumType));
- Contract.EndContractBlock();
RuntimeType rtType = enumType as RuntimeType;
if (rtType == null)
throw new ArgumentException(SR.Arg_MustBeType, nameof(enumType));
@@ -1143,7 +1125,6 @@ namespace System
throw new ArgumentNullException(nameof(enumType));
if (!enumType.IsEnum)
throw new ArgumentException(SR.Arg_MustBeEnum, nameof(enumType));
- Contract.EndContractBlock();
RuntimeType rtType = enumType as RuntimeType;
if (rtType == null)
throw new ArgumentException(SR.Arg_MustBeType, nameof(enumType));
@@ -1157,7 +1138,6 @@ namespace System
throw new ArgumentNullException(nameof(enumType));
if (!enumType.IsEnum)
throw new ArgumentException(SR.Arg_MustBeEnum, nameof(enumType));
- Contract.EndContractBlock();
RuntimeType rtType = enumType as RuntimeType;
if (rtType == null)
throw new ArgumentException(SR.Arg_MustBeType, nameof(enumType));
@@ -1171,7 +1151,6 @@ namespace System
throw new ArgumentNullException(nameof(enumType));
if (!enumType.IsEnum)
throw new ArgumentException(SR.Arg_MustBeEnum, nameof(enumType));
- Contract.EndContractBlock();
RuntimeType rtType = enumType as RuntimeType;
if (rtType == null)
throw new ArgumentException(SR.Arg_MustBeType, nameof(enumType));
@@ -1184,7 +1163,6 @@ namespace System
throw new ArgumentNullException(nameof(enumType));
if (!enumType.IsEnum)
throw new ArgumentException(SR.Arg_MustBeEnum, nameof(enumType));
- Contract.EndContractBlock();
RuntimeType rtType = enumType as RuntimeType;
if (rtType == null)
throw new ArgumentException(SR.Arg_MustBeType, nameof(enumType));
@@ -1198,7 +1176,6 @@ namespace System
throw new ArgumentNullException(nameof(enumType));
if (!enumType.IsEnum)
throw new ArgumentException(SR.Arg_MustBeEnum, nameof(enumType));
- Contract.EndContractBlock();
RuntimeType rtType = enumType as RuntimeType;
if (rtType == null)
throw new ArgumentException(SR.Arg_MustBeType, nameof(enumType));
@@ -1211,7 +1188,6 @@ namespace System
throw new ArgumentNullException(nameof(enumType));
if (!enumType.IsEnum)
throw new ArgumentException(SR.Arg_MustBeEnum, nameof(enumType));
- Contract.EndContractBlock();
RuntimeType rtType = enumType as RuntimeType;
if (rtType == null)
throw new ArgumentException(SR.Arg_MustBeType, nameof(enumType));
@@ -1224,7 +1200,6 @@ namespace System
throw new ArgumentNullException(nameof(enumType));
if (!enumType.IsEnum)
throw new ArgumentException(SR.Arg_MustBeEnum, nameof(enumType));
- Contract.EndContractBlock();
RuntimeType rtType = enumType as RuntimeType;
if (rtType == null)
throw new ArgumentException(SR.Arg_MustBeType, nameof(enumType));
diff --git a/src/mscorlib/src/System/Environment.cs b/src/mscorlib/src/System/Environment.cs
index ea99a1e3f2..4ea73e4d9c 100644
--- a/src/mscorlib/src/System/Environment.cs
+++ b/src/mscorlib/src/System/Environment.cs
@@ -30,7 +30,6 @@ namespace System
using System.Threading;
using System.Runtime.ConstrainedExecution;
using System.Runtime.Versioning;
- using System.Diagnostics.Contracts;
public enum EnvironmentVariableTarget
{
@@ -135,7 +134,6 @@ namespace System
{
if (name == null)
throw new ArgumentNullException(nameof(name));
- Contract.EndContractBlock();
if (name.Length == 0)
{
@@ -289,7 +287,6 @@ namespace System
{
get
{
- Contract.Ensures(Contract.Result<String>() != null);
#if PLATFORM_WINDOWS
return "\r\n";
#else
@@ -362,7 +359,6 @@ namespace System
[MethodImpl(MethodImplOptions.NoInlining)] // Prevent inlining from affecting where the stacktrace starts
get
{
- Contract.Ensures(Contract.Result<String>() != null);
return Internal.Runtime.Augments.EnvironmentAugments.StackTrace;
}
}
diff --git a/src/mscorlib/src/System/Exception.cs b/src/mscorlib/src/System/Exception.cs
index 785637d1ba..79a581271d 100644
--- a/src/mscorlib/src/System/Exception.cs
+++ b/src/mscorlib/src/System/Exception.cs
@@ -25,7 +25,6 @@ namespace System
using System.Reflection;
using System.Collections;
using System.Globalization;
- using System.Diagnostics.Contracts;
[Serializable]
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
@@ -74,7 +73,6 @@ namespace System
{
if (info == null)
throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
_className = info.GetString("ClassName"); // Do not rename (binary serialization)
_message = info.GetString("Message"); // Do not rename (binary serialization)
@@ -439,7 +437,6 @@ namespace System
{
throw new ArgumentNullException(nameof(info));
}
- Contract.EndContractBlock();
String tempStackTraceString = _stackTraceString;
diff --git a/src/mscorlib/src/System/GC.cs b/src/mscorlib/src/System/GC.cs
index 11ae8bf32e..46333bce89 100644
--- a/src/mscorlib/src/System/GC.cs
+++ b/src/mscorlib/src/System/GC.cs
@@ -24,7 +24,7 @@ using System.Runtime.ConstrainedExecution;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
-using System.Diagnostics.Contracts;
+using System.Diagnostics;
namespace System
{
@@ -119,7 +119,6 @@ namespace System
throw new ArgumentOutOfRangeException("pressure",
SR.ArgumentOutOfRange_MustBeNonNegInt32);
}
- Contract.EndContractBlock();
_AddMemoryPressure((ulong)bytesAllocated);
}
@@ -137,7 +136,6 @@ namespace System
throw new ArgumentOutOfRangeException(nameof(bytesAllocated),
SR.ArgumentOutOfRange_MustBeNonNegInt32);
}
- Contract.EndContractBlock();
_RemoveMemoryPressure((ulong)bytesAllocated);
}
@@ -186,7 +184,6 @@ namespace System
throw new ArgumentOutOfRangeException(nameof(mode), SR.ArgumentOutOfRange_Enum);
}
- Contract.EndContractBlock();
int iInternalModes = 0;
@@ -216,7 +213,6 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(generation), SR.ArgumentOutOfRange_GenericPositive);
}
- Contract.EndContractBlock();
return _CollectionCount(generation, 0);
}
@@ -295,7 +291,6 @@ namespace System
{
if (obj == null)
throw new ArgumentNullException(nameof(obj));
- Contract.EndContractBlock();
_SuppressFinalize(obj);
}
@@ -310,7 +305,6 @@ namespace System
{
if (obj == null)
throw new ArgumentNullException(nameof(obj));
- Contract.EndContractBlock();
_ReRegisterForFinalize(obj);
}
@@ -441,14 +435,37 @@ namespace System
private static bool StartNoGCRegionWorker(long totalSize, bool hasLohSize, long lohSize, bool disallowFullBlockingGC)
{
+ if (totalSize <= 0)
+ {
+ throw new ArgumentOutOfRangeException(nameof(totalSize), "totalSize can't be zero or negative");
+ }
+
+ if (hasLohSize)
+ {
+ if (lohSize <= 0)
+ {
+ throw new ArgumentOutOfRangeException(nameof(lohSize), "lohSize can't be zero or negative");
+ }
+
+ if (lohSize > totalSize)
+ {
+ throw new ArgumentOutOfRangeException(nameof(lohSize), "lohSize can't be greater than totalSize");
+ }
+ }
+
StartNoGCRegionStatus status = (StartNoGCRegionStatus)_StartNoGCRegion(totalSize, hasLohSize, lohSize, disallowFullBlockingGC);
- if (status == StartNoGCRegionStatus.AmountTooLarge)
- throw new ArgumentOutOfRangeException(nameof(totalSize),
- "totalSize is too large. For more information about setting the maximum size, see \"Latency Modes\" in http://go.microsoft.com/fwlink/?LinkId=522706");
- else if (status == StartNoGCRegionStatus.AlreadyInProgress)
- throw new InvalidOperationException("The NoGCRegion mode was already in progress");
- else if (status == StartNoGCRegionStatus.NotEnoughMemory)
- return false;
+ switch (status)
+ {
+ case StartNoGCRegionStatus.NotEnoughMemory:
+ return false;
+ case StartNoGCRegionStatus.AlreadyInProgress:
+ throw new InvalidOperationException("The NoGCRegion mode was already in progress");
+ case StartNoGCRegionStatus.AmountTooLarge:
+ throw new ArgumentOutOfRangeException(nameof(totalSize),
+ "totalSize is too large. For more information about setting the maximum size, see \"Latency Modes\" in http://go.microsoft.com/fwlink/?LinkId=522706");
+ }
+
+ Debug.Assert(status == StartNoGCRegionStatus.Succeeded);
return true;
}
diff --git a/src/mscorlib/src/System/Globalization/CalendarData.Windows.cs b/src/mscorlib/src/System/Globalization/CalendarData.Windows.cs
index 89de24d9d7..952f63f80b 100644
--- a/src/mscorlib/src/System/Globalization/CalendarData.Windows.cs
+++ b/src/mscorlib/src/System/Globalization/CalendarData.Windows.cs
@@ -6,7 +6,6 @@ using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
-using System.Diagnostics.Contracts;
using System.Collections.Generic;
namespace System.Globalization
diff --git a/src/mscorlib/src/System/Globalization/CharUnicodeInfo.cs b/src/mscorlib/src/System/Globalization/CharUnicodeInfo.cs
index 8e3bb47424..3881272287 100644
--- a/src/mscorlib/src/System/Globalization/CharUnicodeInfo.cs
+++ b/src/mscorlib/src/System/Globalization/CharUnicodeInfo.cs
@@ -13,7 +13,6 @@
////////////////////////////////////////////////////////////////////////////
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Globalization
{
@@ -232,7 +231,6 @@ namespace System.Globalization
{
throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index);
}
- Contract.EndContractBlock();
return (InternalGetNumericValue(InternalConvertToUtf32(s, index)));
}
@@ -252,7 +250,6 @@ namespace System.Globalization
{
throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index);
}
- Contract.EndContractBlock();
return (sbyte)(InternalGetDigitValues(InternalConvertToUtf32(s, index)) >> 8);
}
@@ -274,7 +271,6 @@ namespace System.Globalization
throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index);
}
- Contract.EndContractBlock();
return (sbyte)(InternalGetDigitValues(InternalConvertToUtf32(s, index)) & 0x00FF);
}
@@ -291,7 +287,6 @@ namespace System.Globalization
{
throw new ArgumentOutOfRangeException(nameof(index));
}
- Contract.EndContractBlock();
return InternalGetUnicodeCategory(s, index);
}
diff --git a/src/mscorlib/src/System/Globalization/CompareInfo.Invariant.cs b/src/mscorlib/src/System/Globalization/CompareInfo.Invariant.cs
index 2a20de76bb..13725bcc51 100644
--- a/src/mscorlib/src/System/Globalization/CompareInfo.Invariant.cs
+++ b/src/mscorlib/src/System/Globalization/CompareInfo.Invariant.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Globalization
{
@@ -199,7 +198,6 @@ namespace System.Globalization
private unsafe SortKey InvariantCreateSortKey(string source, CompareOptions options)
{
if (source == null) { throw new ArgumentNullException(nameof(source)); }
- Contract.EndContractBlock();
if ((options & ValidSortkeyCtorMaskOffFlags) != 0)
{
diff --git a/src/mscorlib/src/System/Globalization/CompareInfo.Unix.cs b/src/mscorlib/src/System/Globalization/CompareInfo.Unix.cs
index 92fd691c8b..612c99e98e 100644
--- a/src/mscorlib/src/System/Globalization/CompareInfo.Unix.cs
+++ b/src/mscorlib/src/System/Globalization/CompareInfo.Unix.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
@@ -280,7 +279,6 @@ namespace System.Globalization
Debug.Assert(!_invariantMode);
if (source==null) { throw new ArgumentNullException(nameof(source)); }
- Contract.EndContractBlock();
if ((options & ValidSortkeyCtorMaskOffFlags) != 0)
{
diff --git a/src/mscorlib/src/System/Globalization/CompareInfo.Windows.cs b/src/mscorlib/src/System/Globalization/CompareInfo.Windows.cs
index 2bfe15b835..6fdb8b20e6 100644
--- a/src/mscorlib/src/System/Globalization/CompareInfo.Windows.cs
+++ b/src/mscorlib/src/System/Globalization/CompareInfo.Windows.cs
@@ -4,7 +4,6 @@
using System.Security;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
@@ -377,7 +376,6 @@ namespace System.Globalization
Debug.Assert(!_invariantMode);
if (source == null) { throw new ArgumentNullException(nameof(source)); }
- Contract.EndContractBlock();
if ((options & ValidSortkeyCtorMaskOffFlags) != 0)
{
diff --git a/src/mscorlib/src/System/Globalization/CompareInfo.cs b/src/mscorlib/src/System/Globalization/CompareInfo.cs
index bfdbdc546b..1b794eceea 100644
--- a/src/mscorlib/src/System/Globalization/CompareInfo.cs
+++ b/src/mscorlib/src/System/Globalization/CompareInfo.cs
@@ -14,7 +14,6 @@
using System.Reflection;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.Serialization;
namespace System.Globalization
@@ -107,7 +106,6 @@ namespace System.Globalization
{
throw new ArgumentException(SR.Argument_OnlyMscorlib);
}
- Contract.EndContractBlock();
return GetCompareInfo(culture);
}
@@ -130,7 +128,6 @@ namespace System.Globalization
{
throw new ArgumentNullException(name == null ? nameof(name) : nameof(assembly));
}
- Contract.EndContractBlock();
if (assembly != typeof(Object).Module.Assembly)
{
@@ -176,7 +173,6 @@ namespace System.Globalization
{
throw new ArgumentNullException(nameof(name));
}
- Contract.EndContractBlock();
return CultureInfo.GetCultureInfo(name).CompareInfo;
}
@@ -254,7 +250,7 @@ namespace System.Globalization
{
// This is merely for serialization compatibility with Whidbey/Orcas, it can go away when we don't want that compat any more.
culture = CultureInfo.GetCultureInfo(this.Name).LCID; // This is the lcid of the constructing culture (still have to dereference to get target sort)
- Contract.Assert(m_name != null, "CompareInfo.OnSerializing - expected m_name to be set already");
+ Debug.Assert(m_name != null, "CompareInfo.OnSerializing - expected m_name to be set already");
}
///////////////////////////----- Name -----/////////////////////////////////
@@ -540,7 +536,6 @@ namespace System.Globalization
throw new ArgumentNullException((source == null ? nameof(source) : nameof(prefix)),
SR.ArgumentNull_String);
}
- Contract.EndContractBlock();
if (prefix.Length == 0)
{
@@ -595,7 +590,6 @@ namespace System.Globalization
throw new ArgumentNullException((source == null ? nameof(source) : nameof(suffix)),
SR.ArgumentNull_String);
}
- Contract.EndContractBlock();
if (suffix.Length == 0)
{
@@ -654,7 +648,6 @@ namespace System.Globalization
{
if (source == null)
throw new ArgumentNullException(nameof(source));
- Contract.EndContractBlock();
return IndexOf(source, value, 0, source.Length, CompareOptions.None);
}
@@ -664,7 +657,6 @@ namespace System.Globalization
{
if (source == null)
throw new ArgumentNullException(nameof(source));
- Contract.EndContractBlock();
return IndexOf(source, value, 0, source.Length, CompareOptions.None);
}
@@ -674,7 +666,6 @@ namespace System.Globalization
{
if (source == null)
throw new ArgumentNullException(nameof(source));
- Contract.EndContractBlock();
return IndexOf(source, value, 0, source.Length, options);
}
@@ -684,7 +675,6 @@ namespace System.Globalization
{
if (source == null)
throw new ArgumentNullException(nameof(source));
- Contract.EndContractBlock();
return IndexOf(source, value, 0, source.Length, options);
}
@@ -693,7 +683,6 @@ namespace System.Globalization
{
if (source == null)
throw new ArgumentNullException(nameof(source));
- Contract.EndContractBlock();
return IndexOf(source, value, startIndex, source.Length - startIndex, CompareOptions.None);
}
@@ -702,7 +691,6 @@ namespace System.Globalization
{
if (source == null)
throw new ArgumentNullException(nameof(source));
- Contract.EndContractBlock();
return IndexOf(source, value, startIndex, source.Length - startIndex, CompareOptions.None);
}
@@ -711,7 +699,6 @@ namespace System.Globalization
{
if (source == null)
throw new ArgumentNullException(nameof(source));
- Contract.EndContractBlock();
return IndexOf(source, value, startIndex, source.Length - startIndex, options);
}
@@ -721,7 +708,6 @@ namespace System.Globalization
{
if (source == null)
throw new ArgumentNullException(nameof(source));
- Contract.EndContractBlock();
return IndexOf(source, value, startIndex, source.Length - startIndex, options);
}
@@ -749,7 +735,6 @@ namespace System.Globalization
if (count < 0 || startIndex > source.Length - count)
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_Count);
- Contract.EndContractBlock();
if (options == CompareOptions.OrdinalIgnoreCase)
{
@@ -779,7 +764,6 @@ namespace System.Globalization
{
throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_Index);
}
- Contract.EndContractBlock();
// In Everett we used to return -1 for empty string even if startIndex is negative number so we keeping same behavior here.
// We return 0 if both source and value are empty strings for Everett compatibility too.
@@ -891,7 +875,6 @@ namespace System.Globalization
{
if (source == null)
throw new ArgumentNullException(nameof(source));
- Contract.EndContractBlock();
// Can't start at negative index, so make sure we check for the length == 0 case.
return LastIndexOf(source, value, source.Length - 1, source.Length, CompareOptions.None);
@@ -902,7 +885,6 @@ namespace System.Globalization
{
if (source == null)
throw new ArgumentNullException(nameof(source));
- Contract.EndContractBlock();
// Can't start at negative index, so make sure we check for the length == 0 case.
return LastIndexOf(source, value, source.Length - 1,
@@ -914,7 +896,6 @@ namespace System.Globalization
{
if (source == null)
throw new ArgumentNullException(nameof(source));
- Contract.EndContractBlock();
// Can't start at negative index, so make sure we check for the length == 0 case.
return LastIndexOf(source, value, source.Length - 1,
@@ -925,7 +906,6 @@ namespace System.Globalization
{
if (source == null)
throw new ArgumentNullException(nameof(source));
- Contract.EndContractBlock();
// Can't start at negative index, so make sure we check for the length == 0 case.
return LastIndexOf(source, value, source.Length - 1, source.Length, options);
@@ -971,7 +951,6 @@ namespace System.Globalization
// Verify Arguments
if (source == null)
throw new ArgumentNullException(nameof(source));
- Contract.EndContractBlock();
// Validate CompareOptions
// Ordinal can't be selected with other flags
@@ -1019,7 +998,6 @@ namespace System.Globalization
throw new ArgumentNullException(nameof(source));
if (value == null)
throw new ArgumentNullException(nameof(value));
- Contract.EndContractBlock();
// Validate CompareOptions
// Ordinal can't be selected with other flags
@@ -1176,7 +1154,6 @@ namespace System.Globalization
{
throw new ArgumentException(SR.Argument_InvalidFlag, nameof(options));
}
- Contract.EndContractBlock();
return GetHashCodeOfStringCore(source, options);
}
diff --git a/src/mscorlib/src/System/Globalization/CultureInfo.cs b/src/mscorlib/src/System/Globalization/CultureInfo.cs
index fd879c709d..fb7176abe0 100644
--- a/src/mscorlib/src/System/Globalization/CultureInfo.cs
+++ b/src/mscorlib/src/System/Globalization/CultureInfo.cs
@@ -28,7 +28,6 @@
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.Serialization;
using System.Threading;
@@ -236,7 +235,6 @@ namespace System.Globalization
{
throw new ArgumentOutOfRangeException(nameof(culture), SR.ArgumentOutOfRange_NeedPosNum);
}
- Contract.EndContractBlock();
InitializeFromCultureId(culture, useUserOverride);
}
@@ -289,7 +287,6 @@ namespace System.Globalization
{
throw new ArgumentNullException(nameof(cultureName),SR.ArgumentNull_String);
}
- Contract.EndContractBlock();
_cultureData = CultureData.GetCultureData(cultureName, false);
if (_cultureData == null)
@@ -337,8 +334,6 @@ namespace System.Globalization
//
public static CultureInfo CreateSpecificCulture(String name)
{
- Contract.Ensures(Contract.Result<CultureInfo>() != null);
-
CultureInfo culture;
try
@@ -481,7 +476,6 @@ namespace System.Globalization
{
get
{
- Contract.Ensures(Contract.Result<CultureInfo>() != null);
if (s_userDefaultCulture == null)
{
Init();
@@ -600,7 +594,6 @@ namespace System.Globalization
public static CultureInfo[] GetCultures(CultureTypes types)
{
- Contract.Ensures(Contract.Result<CultureInfo[]>() != null);
// internally we treat UserCustomCultures as Supplementals but v2
// treats as Supplementals and Replacements
if ((types & CultureTypes.UserCustomCulture) == CultureTypes.UserCustomCulture)
@@ -653,8 +646,6 @@ namespace System.Globalization
{
get
{
- Contract.Ensures(Contract.Result<string>() != null);
-
// special case the compatibility cultures
switch (this.Name)
{
@@ -681,7 +672,6 @@ namespace System.Globalization
{
get
{
- Contract.Ensures(Contract.Result<String>() != null);
Debug.Assert(_name != null, "[CultureInfo.DisplayName] Always expect _name to be set");
return _cultureData.SLOCALIZEDDISPLAYNAME;
@@ -701,7 +691,6 @@ namespace System.Globalization
{
get
{
- Contract.Ensures(Contract.Result<String>() != null);
return (_cultureData.SNATIVEDISPLAYNAME);
}
}
@@ -719,7 +708,6 @@ namespace System.Globalization
{
get
{
- Contract.Ensures(Contract.Result<String>() != null);
return (_cultureData.SENGDISPLAYNAME);
}
}
@@ -729,7 +717,6 @@ namespace System.Globalization
{
get
{
- Contract.Ensures(Contract.Result<String>() != null);
return (_cultureData.SISO639LANGNAME);
}
}
@@ -739,7 +726,6 @@ namespace System.Globalization
{
get
{
- Contract.Ensures(Contract.Result<String>() != null);
return _cultureData.SISO639LANGNAME2;
}
}
@@ -756,7 +742,6 @@ namespace System.Globalization
{
get
{
- Contract.Ensures(Contract.Result<String>() != null);
return _cultureData.SABBREVLANGNAME;
}
}
@@ -1094,8 +1079,6 @@ namespace System.Globalization
{
get
{
- Contract.Ensures(Contract.Result<Calendar[]>() != null);
-
//
// This property always returns a new copy of the calendar array.
//
@@ -1119,8 +1102,6 @@ namespace System.Globalization
public CultureInfo GetConsoleFallbackUICulture()
{
- Contract.Ensures(Contract.Result<CultureInfo>() != null);
-
CultureInfo temp = _consoleFallbackCulture;
if (temp == null)
{
@@ -1174,8 +1155,6 @@ namespace System.Globalization
{
throw new ArgumentNullException(nameof(ci));
}
- Contract.Ensures(Contract.Result<CultureInfo>() != null);
- Contract.EndContractBlock();
if (ci.IsReadOnly)
{
@@ -1398,8 +1377,6 @@ namespace System.Globalization
{
throw new ArgumentOutOfRangeException(nameof(culture), SR.ArgumentOutOfRange_NeedPosNum);
}
- Contract.Ensures(Contract.Result<CultureInfo>() != null);
- Contract.EndContractBlock();
CultureInfo retval = GetCultureInfoHelper(culture, null, null);
if (null == retval)
{
@@ -1442,8 +1419,6 @@ namespace System.Globalization
throw new ArgumentNullException(nameof(altName));
}
- Contract.Ensures(Contract.Result<CultureInfo>() != null);
- Contract.EndContractBlock();
CultureInfo retval = GetCultureInfoHelper(-1, name, altName);
if (retval == null)
@@ -1457,8 +1432,6 @@ namespace System.Globalization
// This function is deprecated, we don't like it
public static CultureInfo GetCultureInfoByIetfLanguageTag(string name)
{
- Contract.Ensures(Contract.Result<CultureInfo>() != null);
-
// Disallow old zh-CHT/zh-CHS names
if (name == "zh-CHT" || name == "zh-CHS")
{
diff --git a/src/mscorlib/src/System/Globalization/EncodingTable.Unix.cs b/src/mscorlib/src/System/Globalization/EncodingTable.Unix.cs
index dc61c9f0d9..f9671cc684 100644
--- a/src/mscorlib/src/System/Globalization/EncodingTable.Unix.cs
+++ b/src/mscorlib/src/System/Globalization/EncodingTable.Unix.cs
@@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Text;
namespace System.Globalization
@@ -33,7 +32,6 @@ namespace System.Globalization
{
throw new ArgumentNullException(nameof(name));
}
- Contract.EndContractBlock();
ushort codePage;
if (s_encodingDataTable.TryGetValue(name, out codePage))
diff --git a/src/mscorlib/src/System/Globalization/EncodingTable.cs b/src/mscorlib/src/System/Globalization/EncodingTable.cs
index 6d9cc3127f..75ab073116 100644
--- a/src/mscorlib/src/System/Globalization/EncodingTable.cs
+++ b/src/mscorlib/src/System/Globalization/EncodingTable.cs
@@ -11,7 +11,6 @@ using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Threading;
-using System.Diagnostics.Contracts;
namespace System.Globalization
{
@@ -139,7 +138,6 @@ namespace System.Globalization
{
throw new ArgumentNullException(nameof(name));
}
- Contract.EndContractBlock();
Object codePageObj;
diff --git a/src/mscorlib/src/System/Globalization/IdnMapping.cs b/src/mscorlib/src/System/Globalization/IdnMapping.cs
index 4320e3abf5..176e5feed5 100644
--- a/src/mscorlib/src/System/Globalization/IdnMapping.cs
+++ b/src/mscorlib/src/System/Globalization/IdnMapping.cs
@@ -25,7 +25,6 @@
// RFC 3492 - Punycode: A Bootstring encoding of Unicode for Internationalized Domain Names in Applications (IDNA)
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Text;
namespace System.Globalization
@@ -62,7 +61,6 @@ namespace System.Globalization
{
if (unicode == null)
throw new ArgumentNullException(nameof(unicode));
- Contract.EndContractBlock();
return GetAscii(unicode, index, unicode.Length - index);
}
@@ -76,7 +74,6 @@ namespace System.Globalization
throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index);
if (index > unicode.Length - count)
throw new ArgumentOutOfRangeException(nameof(unicode), SR.ArgumentOutOfRange_IndexCountBuffer);
- Contract.EndContractBlock();
if (count == 0)
{
@@ -111,7 +108,6 @@ namespace System.Globalization
{
if (ascii == null)
throw new ArgumentNullException(nameof(ascii));
- Contract.EndContractBlock();
return GetUnicode(ascii, index, ascii.Length - index);
}
@@ -131,7 +127,6 @@ namespace System.Globalization
// The Win32 APIs fail on an embedded null, but not on a terminating null.
if (count > 0 && ascii[index + count - 1] == (char)0)
throw new ArgumentException(SR.Argument_IdnBadPunycode, nameof(ascii));
- Contract.EndContractBlock();
if (GlobalizationMode.Invariant)
{
@@ -328,7 +323,7 @@ namespace System.Globalization
{
// Find end of this segment
iNextDot = unicode.IndexOfAny(c_Dots, iAfterLastDot);
- Contract.Assert(iNextDot <= unicode.Length, "[IdnMapping.punycode_encode]IndexOfAny is broken");
+ Debug.Assert(iNextDot <= unicode.Length, "[IdnMapping.punycode_encode]IndexOfAny is broken");
if (iNextDot < 0)
iNextDot = unicode.Length;
@@ -469,7 +464,7 @@ namespace System.Globalization
if (test < n)
{
delta++;
- Contract.Assert(delta > 0, "[IdnMapping.cs]2 punycode_encode - delta overflowed int");
+ Debug.Assert(delta > 0, "[IdnMapping.cs]2 punycode_encode - delta overflowed int");
}
if (test == n)
diff --git a/src/mscorlib/src/System/Globalization/RegionInfo.cs b/src/mscorlib/src/System/Globalization/RegionInfo.cs
index ab52002fdc..3acfa160b9 100644
--- a/src/mscorlib/src/System/Globalization/RegionInfo.cs
+++ b/src/mscorlib/src/System/Globalization/RegionInfo.cs
@@ -15,7 +15,6 @@
////////////////////////////////////////////////////////////////////////////
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.Serialization;
namespace System.Globalization
@@ -66,7 +65,6 @@ namespace System.Globalization
throw new ArgumentException(SR.Argument_NoRegionInvariantCulture, nameof(name));
}
- Contract.EndContractBlock();
//
// For CoreCLR we only want the region names that are full culture names
diff --git a/src/mscorlib/src/System/Globalization/TextInfo.Unix.cs b/src/mscorlib/src/System/Globalization/TextInfo.Unix.cs
index 9f80d73891..27b35da284 100644
--- a/src/mscorlib/src/System/Globalization/TextInfo.Unix.cs
+++ b/src/mscorlib/src/System/Globalization/TextInfo.Unix.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Security;
using System.Text;
diff --git a/src/mscorlib/src/System/Globalization/TextInfo.cs b/src/mscorlib/src/System/Globalization/TextInfo.cs
index c5acbd4579..70475af59e 100644
--- a/src/mscorlib/src/System/Globalization/TextInfo.cs
+++ b/src/mscorlib/src/System/Globalization/TextInfo.cs
@@ -13,7 +13,6 @@
////////////////////////////////////////////////////////////////////////////
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.Serialization;
using System.Text;
@@ -221,7 +220,6 @@ namespace System.Globalization
public static TextInfo ReadOnly(TextInfo textInfo)
{
if (textInfo == null) { throw new ArgumentNullException(nameof(textInfo)); }
- Contract.EndContractBlock();
if (textInfo.IsReadOnly) { return (textInfo); }
TextInfo clonedTextInfo = (TextInfo)(textInfo.MemberwiseClone());
@@ -541,7 +539,6 @@ namespace System.Globalization
{
throw new ArgumentNullException(nameof(str));
}
- Contract.EndContractBlock();
if (str.Length == 0)
{
return (str);
diff --git a/src/mscorlib/src/System/Guid.CoreCLR.cs b/src/mscorlib/src/System/Guid.CoreCLR.cs
index f71d71b145..e3722b8092 100644
--- a/src/mscorlib/src/System/Guid.CoreCLR.cs
+++ b/src/mscorlib/src/System/Guid.CoreCLR.cs
@@ -4,21 +4,13 @@
using Microsoft.Win32;
using System.Runtime.InteropServices;
-using System.Diagnostics.Contracts;
namespace System
{
partial struct Guid
{
- // This will create a new guid. Since we've now decided that constructors should 0-init,
- // we need a method that allows users to create a guid.
public static Guid NewGuid()
{
- // CoCreateGuid should never return Guid.Empty, since it attempts to maintain some
- // uniqueness guarantees. It should also never return a known GUID, but it's unclear
- // how extensively it checks for known values.
- Contract.Ensures(Contract.Result<Guid>() != Guid.Empty);
-
Guid guid;
Marshal.ThrowExceptionForHR(Win32Native.CoCreateGuid(out guid), new IntPtr(-1));
return guid;
diff --git a/src/mscorlib/src/System/IO/BinaryReader.cs b/src/mscorlib/src/System/IO/BinaryReader.cs
index 83fc2806bf..33ff5fa503 100644
--- a/src/mscorlib/src/System/IO/BinaryReader.cs
+++ b/src/mscorlib/src/System/IO/BinaryReader.cs
@@ -19,7 +19,6 @@ using System.Runtime;
using System.Text;
using System.Globalization;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Security;
namespace System.IO
@@ -61,7 +60,6 @@ namespace System.IO
}
if (!input.CanRead)
throw new ArgumentException(SR.Argument_StreamNotReadable);
- Contract.EndContractBlock();
_stream = input;
_decoder = encoding.GetDecoder();
_maxCharsSize = encoding.GetMaxCharCount(MaxCharBytesSize);
@@ -119,8 +117,6 @@ namespace System.IO
public virtual int PeekChar()
{
- Contract.Ensures(Contract.Result<int>() >= -1);
-
if (_stream == null) __Error.FileNotOpen();
if (!_stream.CanSeek)
@@ -133,8 +129,6 @@ namespace System.IO
public virtual int Read()
{
- Contract.Ensures(Contract.Result<int>() >= -1);
-
if (_stream == null)
{
__Error.FileNotOpen();
@@ -270,8 +264,6 @@ namespace System.IO
public virtual String ReadString()
{
- Contract.Ensures(Contract.Result<String>() != null);
-
if (_stream == null)
__Error.FileNotOpen();
@@ -346,9 +338,6 @@ namespace System.IO
{
throw new ArgumentException(SR.Argument_InvalidOffLen);
}
- Contract.Ensures(Contract.Result<int>() >= 0);
- Contract.Ensures(Contract.Result<int>() <= count);
- Contract.EndContractBlock();
if (_stream == null)
__Error.FileNotOpen();
@@ -359,10 +348,6 @@ namespace System.IO
public virtual int Read(Span<char> destination)
{
- Contract.Ensures(Contract.Result<int>() >= 0);
- Contract.Ensures(Contract.Result<int>() <= destination.Length);
- Contract.EndContractBlock();
-
if (_stream == null)
__Error.FileNotOpen();
@@ -537,9 +522,6 @@ namespace System.IO
{
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum);
}
- Contract.Ensures(Contract.Result<char[]>() != null);
- Contract.Ensures(Contract.Result<char[]>().Length <= count);
- Contract.EndContractBlock();
if (_stream == null)
{
__Error.FileNotOpen();
@@ -573,9 +555,6 @@ namespace System.IO
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum);
if (buffer.Length - index < count)
throw new ArgumentException(SR.Argument_InvalidOffLen);
- Contract.Ensures(Contract.Result<int>() >= 0);
- Contract.Ensures(Contract.Result<int>() <= count);
- Contract.EndContractBlock();
if (_stream == null) __Error.FileNotOpen();
return _stream.Read(buffer, index, count);
@@ -583,10 +562,6 @@ namespace System.IO
public virtual int Read(Span<byte> destination)
{
- Contract.Ensures(Contract.Result<int>() >= 0);
- Contract.Ensures(Contract.Result<int>() <= destination.Length);
- Contract.EndContractBlock();
-
if (_stream == null)
__Error.FileNotOpen();
@@ -596,9 +571,6 @@ namespace System.IO
public virtual byte[] ReadBytes(int count)
{
if (count < 0) throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.Ensures(Contract.Result<byte[]>() != null);
- Contract.Ensures(Contract.Result<byte[]>().Length <= Contract.OldValue(count));
- Contract.EndContractBlock();
if (_stream == null) __Error.FileNotOpen();
if (count == 0)
diff --git a/src/mscorlib/src/System/IO/Directory.cs b/src/mscorlib/src/System/IO/Directory.cs
index fcc43f73c4..bb05022878 100644
--- a/src/mscorlib/src/System/IO/Directory.cs
+++ b/src/mscorlib/src/System/IO/Directory.cs
@@ -21,7 +21,6 @@ using Microsoft.Win32;
using Microsoft.Win32.SafeHandles;
using System.Runtime.InteropServices;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.IO
{
@@ -33,9 +32,9 @@ namespace System.IO
{
public SearchData(String fullPath, String userPath, SearchOption searchOption)
{
- Contract.Requires(fullPath != null && fullPath.Length > 0);
- Contract.Requires(userPath != null && userPath.Length > 0);
- Contract.Requires(searchOption == SearchOption.AllDirectories || searchOption == SearchOption.TopDirectoryOnly);
+ Debug.Assert(fullPath != null && fullPath.Length > 0);
+ Debug.Assert(userPath != null && userPath.Length > 0);
+ Debug.Assert(searchOption == SearchOption.AllDirectories || searchOption == SearchOption.TopDirectoryOnly);
this.fullPath = fullPath;
this.userPath = userPath;
@@ -56,18 +55,15 @@ namespace System.IO
throw new ArgumentNullException(nameof(searchPattern));
if ((searchOption != SearchOption.TopDirectoryOnly) && (searchOption != SearchOption.AllDirectories))
throw new ArgumentOutOfRangeException(nameof(searchOption), SR.ArgumentOutOfRange_Enum);
- Contract.Ensures(Contract.Result<IEnumerable<String>>() != null);
- Contract.EndContractBlock();
return InternalEnumerateFiles(path, searchPattern, searchOption);
}
private static IEnumerable<String> InternalEnumerateFiles(String path, String searchPattern, SearchOption searchOption)
{
- Contract.Requires(path != null);
- Contract.Requires(searchPattern != null);
- Contract.Requires(searchOption == SearchOption.AllDirectories || searchOption == SearchOption.TopDirectoryOnly);
- Contract.Ensures(Contract.Result<IEnumerable<String>>() != null);
+ Debug.Assert(path != null);
+ Debug.Assert(searchPattern != null);
+ Debug.Assert(searchOption == SearchOption.AllDirectories || searchOption == SearchOption.TopDirectoryOnly);
return EnumerateFileSystemNames(path, searchPattern, searchOption, true, false);
}
@@ -75,10 +71,9 @@ namespace System.IO
private static IEnumerable<String> EnumerateFileSystemNames(String path, String searchPattern, SearchOption searchOption,
bool includeFiles, bool includeDirs)
{
- Contract.Requires(path != null);
- Contract.Requires(searchPattern != null);
- Contract.Requires(searchOption == SearchOption.AllDirectories || searchOption == SearchOption.TopDirectoryOnly);
- Contract.Ensures(Contract.Result<IEnumerable<String>>() != null);
+ Debug.Assert(path != null);
+ Debug.Assert(searchPattern != null);
+ Debug.Assert(searchOption == SearchOption.AllDirectories || searchOption == SearchOption.TopDirectoryOnly);
return FileSystemEnumerableFactory.CreateFileNameIterator(path, path, searchPattern,
includeFiles, includeDirs, searchOption, true);
diff --git a/src/mscorlib/src/System/IO/File.cs b/src/mscorlib/src/System/IO/File.cs
index e34b7aedab..b393feac3f 100644
--- a/src/mscorlib/src/System/IO/File.cs
+++ b/src/mscorlib/src/System/IO/File.cs
@@ -21,7 +21,6 @@ using System.Text;
using Microsoft.Win32.SafeHandles;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.IO
{
@@ -115,16 +114,15 @@ namespace System.IO
throw new ArgumentNullException(nameof(path));
if (path.Length == 0)
throw new ArgumentException(SR.Argument_EmptyPath);
- Contract.EndContractBlock();
return InternalReadAllLines(path, Encoding.UTF8);
}
private static String[] InternalReadAllLines(String path, Encoding encoding)
{
- Contract.Requires(path != null);
- Contract.Requires(encoding != null);
- Contract.Requires(path.Length != 0);
+ Debug.Assert(path != null);
+ Debug.Assert(encoding != null);
+ Debug.Assert(path.Length != 0);
String line;
List<String> lines = new List<String>();
diff --git a/src/mscorlib/src/System/IO/FileSystemEnumerable.cs b/src/mscorlib/src/System/IO/FileSystemEnumerable.cs
index a16aad25c1..9e52d255cc 100644
--- a/src/mscorlib/src/System/IO/FileSystemEnumerable.cs
+++ b/src/mscorlib/src/System/IO/FileSystemEnumerable.cs
@@ -20,7 +20,6 @@ using System.Runtime.InteropServices;
using System.Globalization;
using System.Runtime.Versioning;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Threading;
namespace System.IO
@@ -34,9 +33,9 @@ namespace System.IO
internal static IEnumerable<String> CreateFileNameIterator(String path, String originalUserPath, String searchPattern,
bool includeFiles, bool includeDirs, SearchOption searchOption, bool checkHost)
{
- Contract.Requires(path != null);
- Contract.Requires(originalUserPath != null);
- Contract.Requires(searchPattern != null);
+ Debug.Assert(path != null);
+ Debug.Assert(originalUserPath != null);
+ Debug.Assert(searchPattern != null);
SearchResultHandler<String> handler = new StringResultHandler(includeFiles, includeDirs);
return new FileSystemEnumerableIterator<String>(path, originalUserPath, searchPattern, searchOption, handler, checkHost);
@@ -152,11 +151,11 @@ namespace System.IO
#endif
internal FileSystemEnumerableIterator(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler<TSource> resultHandler, bool checkHost)
{
- Contract.Requires(path != null);
- Contract.Requires(originalUserPath != null);
- Contract.Requires(searchPattern != null);
- Contract.Requires(searchOption == SearchOption.AllDirectories || searchOption == SearchOption.TopDirectoryOnly);
- Contract.Requires(resultHandler != null);
+ Debug.Assert(path != null);
+ Debug.Assert(originalUserPath != null);
+ Debug.Assert(searchPattern != null);
+ Debug.Assert(searchOption == SearchOption.AllDirectories || searchOption == SearchOption.TopDirectoryOnly);
+ Debug.Assert(resultHandler != null);
#if !PLATFORM_UNIX
_setBackOldMode = Interop.Kernel32.SetThreadErrorMode(Interop.Kernel32.SEM_FAILCRITICALERRORS, out _oldMode);
@@ -438,7 +437,7 @@ namespace System.IO
private void AddSearchableDirsToStack(Directory.SearchData localSearchData)
{
- Contract.Requires(localSearchData != null);
+ Debug.Assert(localSearchData != null);
String searchPath = Path.Combine(localSearchData.fullPath, "*");
SafeFindHandle hnd = null;
@@ -494,7 +493,7 @@ namespace System.IO
private static String NormalizeSearchPattern(String searchPattern)
{
- Contract.Requires(searchPattern != null);
+ Debug.Assert(searchPattern != null);
// Make this corner case more useful, like dir
if (searchPattern.Equals("."))
@@ -508,9 +507,9 @@ namespace System.IO
private static String GetNormalizedSearchCriteria(String fullSearchString, String fullPathMod)
{
- Contract.Requires(fullSearchString != null);
- Contract.Requires(fullPathMod != null);
- Contract.Requires(fullSearchString.Length >= fullPathMod.Length);
+ Debug.Assert(fullSearchString != null);
+ Debug.Assert(fullPathMod != null);
+ Debug.Assert(fullSearchString.Length >= fullPathMod.Length);
String searchCriteria = null;
char lastChar = fullPathMod[fullPathMod.Length - 1];
@@ -529,8 +528,8 @@ namespace System.IO
private static String GetFullSearchString(String fullPath, String searchPattern)
{
- Contract.Requires(fullPath != null);
- Contract.Requires(searchPattern != null);
+ Debug.Assert(fullPath != null);
+ Debug.Assert(searchPattern != null);
String tempStr = Path.Combine(fullPath, searchPattern);
@@ -547,7 +546,6 @@ namespace System.IO
internal abstract class SearchResultHandler<TSource>
{
-
internal abstract bool IsResultIncluded(SearchResult result);
internal abstract TSource CreateObject(SearchResult result);
@@ -587,8 +585,8 @@ namespace System.IO
internal SearchResult(String fullPath, String userPath, Win32Native.WIN32_FIND_DATA findData)
{
- Contract.Requires(fullPath != null);
- Contract.Requires(userPath != null);
+ Debug.Assert(fullPath != null);
+ Debug.Assert(userPath != null);
this.fullPath = fullPath;
this.userPath = userPath;
diff --git a/src/mscorlib/src/System/IO/MemoryStream.cs b/src/mscorlib/src/System/IO/MemoryStream.cs
index 2ac7c07db4..330efcc1e7 100644
--- a/src/mscorlib/src/System/IO/MemoryStream.cs
+++ b/src/mscorlib/src/System/IO/MemoryStream.cs
@@ -20,7 +20,6 @@ using System.Runtime;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Threading;
using System.Threading.Tasks;
@@ -39,7 +38,6 @@ namespace System.IO
private byte[] _buffer; // Either allocated internally or externally.
private int _origin; // For user-provided arrays, start at this origin
private int _position; // read/write head.
- [ContractPublicPropertyName("Length")]
private int _length; // Number of bytes within the memory stream
private int _capacity; // length of usable portion of buffer for stream
// Note that _capacity == _buffer.Length for non-user-provided byte[]'s
@@ -64,7 +62,6 @@ namespace System.IO
{
throw new ArgumentOutOfRangeException(nameof(capacity), SR.ArgumentOutOfRange_NegativeCapacity);
}
- Contract.EndContractBlock();
_buffer = capacity != 0 ? new byte[capacity] : Array.Empty<byte>();
_capacity = capacity;
@@ -83,7 +80,6 @@ namespace System.IO
public MemoryStream(byte[] buffer, bool writable)
{
if (buffer == null) throw new ArgumentNullException(nameof(buffer), SR.ArgumentNull_Buffer);
- Contract.EndContractBlock();
_buffer = buffer;
_length = _capacity = buffer.Length;
_writable = writable;
@@ -112,7 +108,6 @@ namespace System.IO
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum);
if (buffer.Length - index < count)
throw new ArgumentException(SR.Argument_InvalidOffLen);
- Contract.EndContractBlock();
_buffer = buffer;
_origin = _position = index;
@@ -125,19 +120,16 @@ namespace System.IO
public override bool CanRead
{
- [Pure]
get { return _isOpen; }
}
public override bool CanSeek
{
- [Pure]
get { return _isOpen; }
}
public override bool CanWrite
{
- [Pure]
get { return _writable; }
}
@@ -301,8 +293,6 @@ namespace System.IO
// Only update the capacity if the MS is expandable and the value is different than the current capacity.
// Special behavior if the MS isn't expandable: we don't throw if value is the same as the current capacity
if (value < Length) throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_SmallCapacity);
- Contract.Ensures(_capacity - _origin == value);
- Contract.EndContractBlock();
if (!_isOpen) __Error.StreamIsClosed();
if (!_expandable && (value != Capacity)) __Error.MemoryStreamNotExpandable();
@@ -345,8 +335,6 @@ namespace System.IO
{
if (value < 0)
throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.Ensures(Position == value);
- Contract.EndContractBlock();
if (!_isOpen) __Error.StreamIsClosed();
@@ -366,7 +354,6 @@ namespace System.IO
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum);
if (buffer.Length - offset < count)
throw new ArgumentException(SR.Argument_InvalidOffLen);
- Contract.EndContractBlock();
if (!_isOpen) __Error.StreamIsClosed();
@@ -431,7 +418,6 @@ namespace System.IO
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum);
if (buffer.Length - offset < count)
throw new ArgumentException(SR.Argument_InvalidOffLen);
- Contract.EndContractBlock(); // contract validation copied from Read(...)
// If cancellation was requested, bail early
if (cancellationToken.IsCancellationRequested)
@@ -464,7 +450,22 @@ namespace System.IO
try
{
- return new ValueTask<int>(Read(destination.Span));
+ // ReadAsync(Memory<byte>,...) needs to delegate to an existing virtual to do the work, in case an existing derived type
+ // has changed or augmented the logic associated with reads. If the Memory wraps an array, we could delegate to
+ // ReadAsync(byte[], ...), but that would defeat part of the purpose, as ReadAsync(byte[], ...) often needs to allocate
+ // a Task<int> for the return value, so we want to delegate to one of the synchronous methods. We could always
+ // delegate to the Read(Span<byte>) method, and that's the most efficient solution when dealing with a concrete
+ // MemoryStream, but if we're dealing with a type derived from MemoryStream, Read(Span<byte>) will end up delegating
+ // to Read(byte[], ...), which requires it to get a byte[] from ArrayPool and copy the data. So, we special-case the
+ // very common case of the Memory<byte> wrapping an array: if it does, we delegate to Read(byte[], ...) with it,
+ // as that will be efficient in both cases, and we fall back to Read(Span<byte>) if the Memory<byte> wrapped something
+ // else; if this is a concrete MemoryStream, that'll be efficient, and only in the case where the Memory<byte> wrapped
+ // something other than an array and this is a MemoryStream-derived type that doesn't override Read(Span<byte>) will
+ // it then fall back to doing the ArrayPool/copy behavior.
+ return new ValueTask<int>(
+ destination.TryGetArray(out ArraySegment<byte> destinationArray) ?
+ Read(destinationArray.Array, destinationArray.Offset, destinationArray.Count) :
+ Read(destination.Span));
}
catch (OperationCanceledException oce)
{
@@ -614,8 +615,6 @@ namespace System.IO
{
throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_StreamLength);
}
- Contract.Ensures(_length - _origin == value);
- Contract.EndContractBlock();
EnsureWriteable();
// Origin wasn't publicly exposed above.
@@ -651,7 +650,6 @@ namespace System.IO
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum);
if (buffer.Length - offset < count)
throw new ArgumentException(SR.Argument_InvalidOffLen);
- Contract.EndContractBlock();
if (!_isOpen) __Error.StreamIsClosed();
EnsureWriteable();
@@ -741,7 +739,6 @@ namespace System.IO
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum);
if (buffer.Length - offset < count)
throw new ArgumentException(SR.Argument_InvalidOffLen);
- Contract.EndContractBlock(); // contract validation copied from Write(...)
// If cancellation is already requested, bail early
if (cancellationToken.IsCancellationRequested)
@@ -771,7 +768,16 @@ namespace System.IO
try
{
- Write(source.Span);
+ // See corresponding comment in ReadAsync for why we don't just always use Write(ReadOnlySpan<byte>).
+ // Unlike ReadAsync, we could delegate to WriteAsync(byte[], ...) here, but we don't for consistency.
+ if (source.DangerousTryGetArray(out ArraySegment<byte> sourceArray))
+ {
+ Write(sourceArray.Array, sourceArray.Offset, sourceArray.Count);
+ }
+ else
+ {
+ Write(source.Span);
+ }
return Task.CompletedTask;
}
catch (OperationCanceledException oce)
@@ -811,7 +817,6 @@ namespace System.IO
{
if (stream == null)
throw new ArgumentNullException(nameof(stream), SR.ArgumentNull_Stream);
- Contract.EndContractBlock();
if (!_isOpen) __Error.StreamIsClosed();
stream.Write(_buffer, _origin, _length - _origin);
diff --git a/src/mscorlib/src/System/IO/Stream.cs b/src/mscorlib/src/System/IO/Stream.cs
index 82fad24c6d..b8df5aaae0 100644
--- a/src/mscorlib/src/System/IO/Stream.cs
+++ b/src/mscorlib/src/System/IO/Stream.cs
@@ -25,7 +25,6 @@ using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
using System.Security;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Reflection;
namespace System.IO
@@ -53,20 +52,17 @@ namespace System.IO
public abstract bool CanRead
{
- [Pure]
get;
}
// If CanSeek is false, Position, Seek, Length, and SetLength should throw.
public abstract bool CanSeek
{
- [Pure]
get;
}
public virtual bool CanTimeout
{
- [Pure]
get
{
return false;
@@ -75,7 +71,6 @@ namespace System.IO
public abstract bool CanWrite
{
- [Pure]
get;
}
@@ -94,7 +89,6 @@ namespace System.IO
{
get
{
- Contract.Ensures(Contract.Result<int>() >= 0);
throw new InvalidOperationException(SR.InvalidOperation_TimeoutsNotSupported);
}
set
@@ -107,7 +101,6 @@ namespace System.IO
{
get
{
- Contract.Ensures(Contract.Result<int>() >= 0);
throw new InvalidOperationException(SR.InvalidOperation_TimeoutsNotSupported);
}
set
@@ -118,36 +111,7 @@ namespace System.IO
public Task CopyToAsync(Stream destination)
{
- int bufferSize = _DefaultCopyBufferSize;
-
- if (CanSeek)
- {
- long length = Length;
- long position = Position;
- if (length <= position) // Handles negative overflows
- {
- // If we go down this branch, it means there are
- // no bytes left in this stream.
-
- // Ideally we would just return Task.CompletedTask here,
- // but CopyToAsync(Stream, int, CancellationToken) was already
- // virtual at the time this optimization was introduced. So
- // if it does things like argument validation (checking if destination
- // is null and throwing an exception), then await fooStream.CopyToAsync(null)
- // would no longer throw if there were no bytes left. On the other hand,
- // we also can't roll our own argument validation and return Task.CompletedTask,
- // because it would be a breaking change if the stream's override didn't throw before,
- // or in a different order. So for simplicity, we just set the bufferSize to 1
- // (not 0 since the default implementation throws for 0) and forward to the virtual method.
- bufferSize = 1;
- }
- else
- {
- long remaining = length - position;
- if (remaining > 0) // In the case of a positive overflow, stick to the default size
- bufferSize = (int)Math.Min(bufferSize, remaining);
- }
- }
+ int bufferSize = GetCopyBufferSize();
return CopyToAsync(destination, bufferSize);
}
@@ -157,6 +121,13 @@ namespace System.IO
return CopyToAsync(destination, bufferSize, CancellationToken.None);
}
+ public Task CopyToAsync(Stream destination, CancellationToken cancellationToken)
+ {
+ int bufferSize = GetCopyBufferSize();
+
+ return CopyToAsync(destination, bufferSize, cancellationToken);
+ }
+
public virtual Task CopyToAsync(Stream destination, Int32 bufferSize, CancellationToken cancellationToken)
{
StreamHelpers.ValidateCopyToArgs(this, destination, bufferSize);
@@ -166,10 +137,10 @@ namespace System.IO
private async Task CopyToAsyncInternal(Stream destination, Int32 bufferSize, CancellationToken cancellationToken)
{
- Contract.Requires(destination != null);
- Contract.Requires(bufferSize > 0);
- Contract.Requires(CanRead);
- Contract.Requires(destination.CanWrite);
+ Debug.Assert(destination != null);
+ Debug.Assert(bufferSize > 0);
+ Debug.Assert(CanRead);
+ Debug.Assert(destination.CanWrite);
byte[] buffer = ArrayPool<byte>.Shared.Rent(bufferSize);
bufferSize = 0; // reuse same field for high water mark to avoid needing another field in the state machine
@@ -195,26 +166,7 @@ namespace System.IO
// the current position.
public void CopyTo(Stream destination)
{
- int bufferSize = _DefaultCopyBufferSize;
-
- if (CanSeek)
- {
- long length = Length;
- long position = Position;
- if (length <= position) // Handles negative overflows
- {
- // No bytes left in stream
- // Call the other overload with a bufferSize of 1,
- // in case it's made virtual in the future
- bufferSize = 1;
- }
- else
- {
- long remaining = length - position;
- if (remaining > 0) // In the case of a positive overflow, stick to the default size
- bufferSize = (int)Math.Min(bufferSize, remaining);
- }
- }
+ int bufferSize = GetCopyBufferSize();
CopyTo(destination, bufferSize);
}
@@ -241,6 +193,36 @@ namespace System.IO
}
}
+ private int GetCopyBufferSize()
+ {
+ int bufferSize = _DefaultCopyBufferSize;
+
+ if (CanSeek)
+ {
+ long length = Length;
+ long position = Position;
+ if (length <= position) // Handles negative overflows
+ {
+ // There are no bytes left in the stream to copy.
+ // However, because CopyTo{Async} is virtual, we need to
+ // ensure that any override is still invoked to provide its
+ // own validation, so we use the smallest legal buffer size here.
+ bufferSize = 1;
+ }
+ else
+ {
+ long remaining = length - position;
+ if (remaining > 0)
+ {
+ // In the case of a positive overflow, stick to the default size
+ bufferSize = (int)Math.Min(bufferSize, remaining);
+ }
+ }
+ }
+
+ return bufferSize;
+ }
+
// Stream used to require that all cleanup logic went into Close(),
// which was thought up before we invented IDisposable. However, we
// need to follow the IDisposable pattern so that users can write
@@ -251,11 +233,8 @@ namespace System.IO
// should put their cleanup starting in V2.
public virtual void Close()
{
- /* These are correct, but we'd have to fix PipeStream & NetworkStream very carefully.
- Contract.Ensures(CanRead == false);
- Contract.Ensures(CanWrite == false);
- Contract.Ensures(CanSeek == false);
- */
+ // Ideally we would assert CanRead == CanWrite == CanSeek = false,
+ // but we'd have to fix PipeStream & NetworkStream very carefully.
Dispose(true);
GC.SuppressFinalize(this);
@@ -263,11 +242,8 @@ namespace System.IO
public void Dispose()
{
- /* These are correct, but we'd have to fix PipeStream & NetworkStream very carefully.
- Contract.Ensures(CanRead == false);
- Contract.Ensures(CanWrite == false);
- Contract.Ensures(CanSeek == false);
- */
+ // Ideally we would assert CanRead == CanWrite == CanSeek = false,
+ // but we'd have to fix PipeStream & NetworkStream very carefully.
Close();
}
@@ -296,13 +272,11 @@ namespace System.IO
[Obsolete("CreateWaitHandle will be removed eventually. Please use \"new ManualResetEvent(false)\" instead.")]
protected virtual WaitHandle CreateWaitHandle()
{
- Contract.Ensures(Contract.Result<WaitHandle>() != null);
return new ManualResetEvent(false);
}
public virtual IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, Object state)
{
- Contract.Ensures(Contract.Result<IAsyncResult>() != null);
return BeginReadInternal(buffer, offset, count, callback, state, serializeAsynchronously: false, apm: true);
}
@@ -310,7 +284,6 @@ namespace System.IO
byte[] buffer, int offset, int count, AsyncCallback callback, Object state,
bool serializeAsynchronously, bool apm)
{
- Contract.Ensures(Contract.Result<IAsyncResult>() != null);
if (!CanRead) __Error.ReadNotSupported();
// To avoid a race with a stream's position pointer & generating race conditions
@@ -372,8 +345,6 @@ namespace System.IO
{
if (asyncResult == null)
throw new ArgumentNullException(nameof(asyncResult));
- Contract.Ensures(Contract.Result<int>() >= 0);
- Contract.EndContractBlock();
var readTask = _activeReadWriteTask;
@@ -471,7 +442,6 @@ namespace System.IO
public virtual IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, Object state)
{
- Contract.Ensures(Contract.Result<IAsyncResult>() != null);
return BeginWriteInternal(buffer, offset, count, callback, state, serializeAsynchronously: false, apm: true);
}
@@ -479,7 +449,6 @@ namespace System.IO
byte[] buffer, int offset, int count, AsyncCallback callback, Object state,
bool serializeAsynchronously, bool apm)
{
- Contract.Ensures(Contract.Result<IAsyncResult>() != null);
if (!CanWrite) __Error.WriteNotSupported();
// To avoid a race condition with a stream's position pointer & generating conditions
@@ -539,9 +508,8 @@ namespace System.IO
private void RunReadWriteTaskWhenReady(Task asyncWaiter, ReadWriteTask readWriteTask)
{
- Debug.Assert(readWriteTask != null); // Should be Contract.Requires, but CCRewrite is doing a poor job with
- // preconditions in async methods that await.
- Debug.Assert(asyncWaiter != null); // Ditto
+ Debug.Assert(readWriteTask != null);
+ Debug.Assert(asyncWaiter != null);
// If the wait has already completed, run the task.
if (asyncWaiter.IsCompleted)
@@ -562,7 +530,7 @@ namespace System.IO
private void RunReadWriteTask(ReadWriteTask readWriteTask)
{
- Contract.Requires(readWriteTask != null);
+ Debug.Assert(readWriteTask != null);
Debug.Assert(_activeReadWriteTask == null, "Expected no other readers or writers");
// Schedule the task. ScheduleAndStart must happen after the write to _activeReadWriteTask to avoid a race.
@@ -585,7 +553,6 @@ namespace System.IO
{
if (asyncResult == null)
throw new ArgumentNullException(nameof(asyncResult));
- Contract.EndContractBlock();
var writeTask = _activeReadWriteTask;
if (writeTask == null)
@@ -652,10 +619,9 @@ namespace System.IO
Stream stream, byte[] buffer, int offset, int count, AsyncCallback callback) :
base(function, state, CancellationToken.None, TaskCreationOptions.DenyChildAttach)
{
- Contract.Requires(function != null);
- Contract.Requires(stream != null);
- Contract.Requires(buffer != null);
- Contract.EndContractBlock();
+ Debug.Assert(function != null);
+ Debug.Assert(stream != null);
+ Debug.Assert(buffer != null);
// Store the arguments
_isRead = isRead;
@@ -807,9 +773,6 @@ namespace System.IO
// significantly for people who are reading one byte at a time.
public virtual int ReadByte()
{
- Contract.Ensures(Contract.Result<int>() >= -1);
- Contract.Ensures(Contract.Result<int>() < 256);
-
byte[] oneByteArray = new byte[1];
int r = Read(oneByteArray, 0, 1);
if (r == 0)
@@ -846,8 +809,6 @@ namespace System.IO
{
if (stream == null)
throw new ArgumentNullException(nameof(stream));
- Contract.Ensures(Contract.Result<Stream>() != null);
- Contract.EndContractBlock();
if (stream is SyncStream)
return stream;
@@ -861,8 +822,6 @@ namespace System.IO
internal IAsyncResult BlockingBeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, Object state)
{
- Contract.Ensures(Contract.Result<IAsyncResult>() != null);
-
// To avoid a race with a stream's position pointer & generating conditions
// with internal buffer indexes in our own streams that
// don't natively support async IO operations when there are multiple
@@ -890,15 +849,11 @@ namespace System.IO
internal static int BlockingEndRead(IAsyncResult asyncResult)
{
- Contract.Ensures(Contract.Result<int>() >= 0);
-
return SynchronousAsyncResult.EndRead(asyncResult);
}
internal IAsyncResult BlockingBeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, Object state)
{
- Contract.Ensures(Contract.Result<IAsyncResult>() != null);
-
// To avoid a race condition with a stream's position pointer & generating conditions
// with internal buffer indexes in our own streams that
// don't natively support async IO operations when there are multiple
@@ -935,19 +890,16 @@ namespace System.IO
public override bool CanRead
{
- [Pure]
get { return true; }
}
public override bool CanWrite
{
- [Pure]
get { return true; }
}
public override bool CanSeek
{
- [Pure]
get { return true; }
}
@@ -1007,7 +959,6 @@ namespace System.IO
{
if (asyncResult == null)
throw new ArgumentNullException(nameof(asyncResult));
- Contract.EndContractBlock();
return BlockingEndRead(asyncResult);
}
@@ -1023,7 +974,6 @@ namespace System.IO
{
if (asyncResult == null)
throw new ArgumentNullException(nameof(asyncResult));
- Contract.EndContractBlock();
BlockingEndWrite(asyncResult);
}
@@ -1192,31 +1142,26 @@ namespace System.IO
{
if (stream == null)
throw new ArgumentNullException(nameof(stream));
- Contract.EndContractBlock();
_stream = stream;
}
public override bool CanRead
{
- [Pure]
get { return _stream.CanRead; }
}
public override bool CanWrite
{
- [Pure]
get { return _stream.CanWrite; }
}
public override bool CanSeek
{
- [Pure]
get { return _stream.CanSeek; }
}
public override bool CanTimeout
{
- [Pure]
get
{
return _stream.CanTimeout;
@@ -1356,8 +1301,6 @@ namespace System.IO
{
if (asyncResult == null)
throw new ArgumentNullException(nameof(asyncResult));
- Contract.Ensures(Contract.Result<int>() >= 0);
- Contract.EndContractBlock();
lock (_stream)
return _stream.EndRead(asyncResult);
@@ -1415,7 +1358,6 @@ namespace System.IO
{
if (asyncResult == null)
throw new ArgumentNullException(nameof(asyncResult));
- Contract.EndContractBlock();
lock (_stream)
_stream.EndWrite(asyncResult);
diff --git a/src/mscorlib/src/System/IO/StreamReader.cs b/src/mscorlib/src/System/IO/StreamReader.cs
index 9ff9187663..092bf69bc5 100644
--- a/src/mscorlib/src/System/IO/StreamReader.cs
+++ b/src/mscorlib/src/System/IO/StreamReader.cs
@@ -7,7 +7,6 @@ using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
-using System.Diagnostics.Contracts;
using System.Threading.Tasks;
namespace System.IO
@@ -148,7 +147,6 @@ namespace System.IO
throw new ArgumentException(SR.Argument_StreamNotReadable);
if (bufferSize <= 0)
throw new ArgumentOutOfRangeException(nameof(bufferSize), SR.ArgumentOutOfRange_NeedPosNum);
- Contract.EndContractBlock();
Init(stream, encoding, detectEncodingFromByteOrderMarks, bufferSize, leaveOpen);
}
@@ -180,7 +178,6 @@ namespace System.IO
throw new ArgumentException(SR.Argument_EmptyPath);
if (bufferSize <= 0)
throw new ArgumentOutOfRangeException(nameof(bufferSize), SR.ArgumentOutOfRange_NeedPosNum);
- Contract.EndContractBlock();
Stream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, DefaultFileStreamBufferSize, FileOptions.SequentialScan);
Init(stream, encoding, detectEncodingFromByteOrderMarks, bufferSize, false);
@@ -303,7 +300,6 @@ namespace System.IO
}
}
- [Pure]
public override int Peek() {
if (stream == null)
__Error.ReaderClosed();
@@ -339,7 +335,6 @@ namespace System.IO
throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum);
if (buffer.Length - index < count)
throw new ArgumentException(SR.Argument_InvalidOffLen);
- Contract.EndContractBlock();
if (stream == null)
__Error.ReaderClosed();
@@ -397,7 +392,6 @@ namespace System.IO
throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum);
if (buffer.Length - index < count)
throw new ArgumentException(SR.Argument_InvalidOffLen);
- Contract.EndContractBlock();
if (stream == null)
__Error.ReaderClosed();
@@ -873,7 +867,6 @@ namespace System.IO
throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum);
if (buffer.Length - index < count)
throw new ArgumentException(SR.Argument_InvalidOffLen);
- Contract.EndContractBlock();
// If we have been inherited into a subclass, the following implementation could be incorrect
// since it does not call through to Read() which a subclass might have overriden.
@@ -1059,7 +1052,6 @@ namespace System.IO
throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum);
if (buffer.Length - index < count)
throw new ArgumentException(SR.Argument_InvalidOffLen);
- Contract.EndContractBlock();
// If we have been inherited into a subclass, the following implementation could be incorrect
// since it does not call through to Read() which a subclass might have overriden.
@@ -1173,7 +1165,6 @@ namespace System.IO
return -1;
}
- [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
public override int Read(char[] buffer, int index, int count) {
return 0;
}
diff --git a/src/mscorlib/src/System/IO/TextReader.cs b/src/mscorlib/src/System/IO/TextReader.cs
index 2531778d6d..9ef4f9fd0c 100644
--- a/src/mscorlib/src/System/IO/TextReader.cs
+++ b/src/mscorlib/src/System/IO/TextReader.cs
@@ -17,8 +17,8 @@
using System.Text;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
+using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
-using System.Diagnostics.Contracts;
using System.Threading;
using System.Threading.Tasks;
@@ -31,7 +31,6 @@ namespace System.IO {
// This class is intended for character input, not bytes.
// There are methods on the Stream class for reading bytes.
internal abstract class TextReader : MarshalByRefObject, IDisposable {
-
public static readonly TextReader Null = new NullTextReader();
protected TextReader() {}
@@ -65,11 +64,8 @@ namespace System.IO {
//
// This default method simply returns -1.
//
- [Pure]
public virtual int Peek()
{
- Contract.Ensures(Contract.Result<int>() >= -1);
-
return -1;
}
@@ -80,7 +76,6 @@ namespace System.IO {
//
public virtual int Read()
{
- Contract.Ensures(Contract.Result<int>() >= -1);
return -1;
}
@@ -99,9 +94,6 @@ namespace System.IO {
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum);
if (buffer.Length - index < count)
throw new ArgumentException(SR.Argument_InvalidOffLen);
- Contract.Ensures(Contract.Result<int>() >= 0);
- Contract.Ensures(Contract.Result<int>() <= Contract.OldValue(count));
- Contract.EndContractBlock();
int n = 0;
do {
@@ -116,8 +108,6 @@ namespace System.IO {
// TextReader, and returns them as one string.
public virtual String ReadToEnd()
{
- Contract.Ensures(Contract.Result<String>() != null);
-
char[] chars = new char[4096];
int len;
StringBuilder sb = new StringBuilder(4096);
@@ -133,9 +123,6 @@ namespace System.IO {
//
public virtual int ReadBlock([In, Out] char[] buffer, int index, int count)
{
- Contract.Ensures(Contract.Result<int>() >= 0);
- Contract.Ensures(Contract.Result<int>() <= count);
-
int i, n = 0;
do {
n += (i = Read(buffer, index + n, count - n));
@@ -196,17 +183,16 @@ namespace System.IO {
throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum);
if (buffer.Length - index < count)
throw new ArgumentException(SR.Argument_InvalidOffLen);
- Contract.EndContractBlock();
return ReadAsyncInternal(buffer, index, count);
}
internal virtual Task<int> ReadAsyncInternal(char[] buffer, int index, int count)
{
- Contract.Requires(buffer != null);
- Contract.Requires(index >= 0);
- Contract.Requires(count >= 0);
- Contract.Requires(buffer.Length - index >= count);
+ Debug.Assert(buffer != null);
+ Debug.Assert(index >= 0);
+ Debug.Assert(count >= 0);
+ Debug.Assert(buffer.Length - index >= count);
var tuple = new Tuple<TextReader, char[], int, int>(this, buffer, index, count);
return Task<int>.Factory.StartNew(state =>
@@ -226,17 +212,16 @@ namespace System.IO {
if (buffer.Length - index < count)
throw new ArgumentException(SR.Argument_InvalidOffLen);
- Contract.EndContractBlock();
return ReadBlockAsyncInternal(buffer, index, count);
}
private async Task<int> ReadBlockAsyncInternal(char[] buffer, int index, int count)
{
- Contract.Requires(buffer != null);
- Contract.Requires(index >= 0);
- Contract.Requires(count >= 0);
- Contract.Requires(buffer.Length - index >= count);
+ Debug.Assert(buffer != null);
+ Debug.Assert(index >= 0);
+ Debug.Assert(count >= 0);
+ Debug.Assert(buffer.Length - index >= count);
int i, n = 0;
do
@@ -253,8 +238,6 @@ namespace System.IO {
{
if (reader==null)
throw new ArgumentNullException(nameof(reader));
- Contract.Ensures(Contract.Result<TextReader>() != null);
- Contract.EndContractBlock();
if (reader is SyncTextReader)
return reader;
@@ -266,7 +249,6 @@ namespace System.IO {
{
public NullTextReader(){}
- [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
public override int Read(char[] buffer, int index, int count)
{
return 0;
@@ -314,7 +296,6 @@ namespace System.IO {
return _in.Read();
}
- [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
[MethodImplAttribute(MethodImplOptions.Synchronized)]
public override int Read([In, Out] char[] buffer, int index, int count)
{
@@ -365,7 +346,6 @@ namespace System.IO {
if (buffer.Length - index < count)
throw new ArgumentException(SR.Argument_InvalidOffLen);
- Contract.EndContractBlock();
return Task.FromResult(ReadBlock(buffer, index, count));
}
@@ -379,7 +359,6 @@ namespace System.IO {
throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum);
if (buffer.Length - index < count)
throw new ArgumentException(SR.Argument_InvalidOffLen);
- Contract.EndContractBlock();
return Task.FromResult(Read(buffer, index, count));
}
diff --git a/src/mscorlib/src/System/IO/UnmanagedMemoryAccessor.cs b/src/mscorlib/src/System/IO/UnmanagedMemoryAccessor.cs
index 5f6f588cbe..43f286919b 100644
--- a/src/mscorlib/src/System/IO/UnmanagedMemoryAccessor.cs
+++ b/src/mscorlib/src/System/IO/UnmanagedMemoryAccessor.cs
@@ -20,7 +20,6 @@ using System.Runtime.ConstrainedExecution;
using System.Runtime.Versioning;
using Microsoft.Win32.SafeHandles;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.IO
{
@@ -31,7 +30,6 @@ namespace System.IO
{
private SafeBuffer _buffer;
private Int64 _offset;
- [ContractPublicPropertyName("Capacity")]
private Int64 _capacity;
private FileAccess _access;
private bool _isOpen;
@@ -79,7 +77,6 @@ namespace System.IO
{
throw new ArgumentOutOfRangeException(nameof(access));
}
- Contract.EndContractBlock();
if (_isOpen)
{
@@ -504,7 +501,6 @@ namespace System.IO
{
throw new ArgumentOutOfRangeException(nameof(position), SR.ArgumentOutOfRange_NeedNonNegNum);
}
- Contract.EndContractBlock();
if (!_isOpen)
{
@@ -555,7 +551,6 @@ namespace System.IO
{
throw new ArgumentException(SR.Argument_OffsetAndLengthOutOfBounds);
}
- Contract.EndContractBlock();
if (!CanRead)
{
if (!_isOpen)
@@ -905,7 +900,6 @@ namespace System.IO
{
throw new ArgumentOutOfRangeException(nameof(position), SR.ArgumentOutOfRange_NeedNonNegNum);
}
- Contract.EndContractBlock();
if (!_isOpen)
{
@@ -961,7 +955,6 @@ namespace System.IO
{
throw new ArgumentOutOfRangeException(nameof(position), SR.ArgumentOutOfRange_PositionLessThanCapacityRequired);
}
- Contract.EndContractBlock();
if (!_isOpen)
{
@@ -1041,7 +1034,6 @@ namespace System.IO
{
throw new ArgumentOutOfRangeException(nameof(position), SR.ArgumentOutOfRange_NeedNonNegNum);
}
- Contract.EndContractBlock();
if (position > _capacity - sizeOfType)
{
if (position >= _capacity)
@@ -1069,7 +1061,6 @@ namespace System.IO
{
throw new ArgumentOutOfRangeException(nameof(position), SR.ArgumentOutOfRange_NeedNonNegNum);
}
- Contract.EndContractBlock();
if (position > _capacity - sizeOfType)
{
if (position >= _capacity)
diff --git a/src/mscorlib/src/System/IO/__Error.cs b/src/mscorlib/src/System/IO/__Error.cs
index 6af1fcfadc..ea58db37a8 100644
--- a/src/mscorlib/src/System/IO/__Error.cs
+++ b/src/mscorlib/src/System/IO/__Error.cs
@@ -21,11 +21,9 @@ using Win32Native = Microsoft.Win32.Win32Native;
using System.Text;
using System.Globalization;
using System.Security;
-using System.Diagnostics.Contracts;
namespace System.IO
{
- [Pure]
internal static class __Error
{
internal static void EndOfFile()
diff --git a/src/mscorlib/src/System/IntPtr.cs b/src/mscorlib/src/System/IntPtr.cs
index e3439801ff..76a8ea92d9 100644
--- a/src/mscorlib/src/System/IntPtr.cs
+++ b/src/mscorlib/src/System/IntPtr.cs
@@ -20,7 +20,6 @@ namespace System
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
using System.Security;
- using System.Diagnostics.Contracts;
[Serializable]
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
@@ -31,7 +30,6 @@ namespace System
public static readonly IntPtr Zero;
// fast way to compare IntPtr to (IntPtr)0 while IntPtr.Zero doesn't work due to slow statics access
- [Pure]
internal unsafe bool IsNull()
{
return (_value == null);
@@ -82,7 +80,6 @@ namespace System
{
throw new ArgumentNullException(nameof(info));
}
- Contract.EndContractBlock();
#if BIT64
info.AddValue("value", (long)(_value));
#else // !BIT64 (32)
@@ -146,8 +143,6 @@ namespace System
public unsafe String ToString(String format)
{
- Contract.Ensures(Contract.Result<String>() != null);
-
#if BIT64
return ((long)_value).ToString(format, CultureInfo.InvariantCulture);
#else // !BIT64 (32)
@@ -249,7 +244,6 @@ namespace System
public static int Size
{
- [Pure]
[System.Runtime.Versioning.NonVersionable]
get
{
diff --git a/src/mscorlib/src/System/Math.CoreCLR.cs b/src/mscorlib/src/System/Math.CoreCLR.cs
new file mode 100644
index 0000000000..92eb5cf525
--- /dev/null
+++ b/src/mscorlib/src/System/Math.CoreCLR.cs
@@ -0,0 +1,85 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/*============================================================
+**
+**
+**
+** Purpose: Some floating-point math operations
+**
+**
+===========================================================*/
+
+//This class contains only static members and doesn't require serialization.
+
+using System.Runtime.CompilerServices;
+
+namespace System
+{
+ public static partial class Math
+ {
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern double Abs(double value);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern float Abs(float value);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern double Acos(double d);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern double Asin(double d);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern double Atan(double d);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern double Atan2(double y, double x);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern double Ceiling(double a);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern double Cos(double d);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern double Cosh(double value);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern double Exp(double d);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern double Floor(double d);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern double Log(double d);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern double Log10(double d);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern double Pow(double x, double y);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern double Sin(double a);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern double Sinh(double value);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern double Sqrt(double d);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern double Tan(double a);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern double Tanh(double value);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ private static extern double FMod(double x, double y);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ private static extern unsafe double ModF(double x, double* intptr);
+ }
+}
diff --git a/src/mscorlib/src/System/MathF.CoreCLR.cs b/src/mscorlib/src/System/MathF.CoreCLR.cs
new file mode 100644
index 0000000000..0e4dcee737
--- /dev/null
+++ b/src/mscorlib/src/System/MathF.CoreCLR.cs
@@ -0,0 +1,76 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/*============================================================
+**
+** Purpose: Some single-precision floating-point math operations
+**
+===========================================================*/
+
+//This class contains only static members and doesn't require serialization.
+
+using System.Runtime.CompilerServices;
+
+namespace System
+{
+ public static partial class MathF
+ {
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern float Acos(float x);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern float Asin(float x);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern float Atan(float x);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern float Atan2(float y, float x);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern float Ceiling(float x);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern float Cos(float x);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern float Cosh(float x);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern float Exp(float x);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern float Floor(float x);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern float Log(float x);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern float Log10(float x);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern float Pow(float x, float y);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern float Sin(float x);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern float Sinh(float x);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern float Sqrt(float x);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern float Tan(float x);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern float Tanh(float x);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ private static extern float FMod(float x, float y);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ private static extern unsafe float ModF(float x, float* intptr);
+ }
+}
diff --git a/src/mscorlib/src/System/MissingMemberException.cs b/src/mscorlib/src/System/MissingMemberException.cs
index def3c39824..44ceaaf1e1 100644
--- a/src/mscorlib/src/System/MissingMemberException.cs
+++ b/src/mscorlib/src/System/MissingMemberException.cs
@@ -17,7 +17,6 @@ using System.Runtime.Serialization;
using System.Runtime.CompilerServices;
using System.Globalization;
using System.Runtime.Versioning;
-using System.Diagnostics.Contracts;
namespace System
{
diff --git a/src/mscorlib/src/System/MulticastDelegate.cs b/src/mscorlib/src/System/MulticastDelegate.cs
index 8a5d3e5140..0ab8ef80e7 100644
--- a/src/mscorlib/src/System/MulticastDelegate.cs
+++ b/src/mscorlib/src/System/MulticastDelegate.cs
@@ -8,7 +8,6 @@ using System.Runtime;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Reflection.Emit;
namespace System
@@ -410,8 +409,6 @@ namespace System
// This method returns the Invocation list of this multicast delegate.
public override sealed Delegate[] GetInvocationList()
{
- Contract.Ensures(Contract.Result<Delegate[]>() != null);
-
Delegate[] del;
Object[] invocationList = _invocationList as Object[];
if (invocationList == null)
diff --git a/src/mscorlib/src/System/Nullable.cs b/src/mscorlib/src/System/Nullable.cs
index a2c7c350c9..f9ee9acdc7 100644
--- a/src/mscorlib/src/System/Nullable.cs
+++ b/src/mscorlib/src/System/Nullable.cs
@@ -11,7 +11,6 @@ using System.Collections.Generic;
using System.Runtime;
using System.Runtime.CompilerServices;
using System.Security;
-using System.Diagnostics.Contracts;
namespace System
{
@@ -147,7 +146,6 @@ namespace System
{
throw new ArgumentNullException(nameof(nullableType));
}
- Contract.EndContractBlock();
Type result = null;
if (nullableType.IsGenericType && !nullableType.IsGenericTypeDefinition)
{
diff --git a/src/mscorlib/src/System/Number.cs b/src/mscorlib/src/System/Number.cs
index 0eaa0b2285..3e581ac06d 100644
--- a/src/mscorlib/src/System/Number.cs
+++ b/src/mscorlib/src/System/Number.cs
@@ -11,7 +11,6 @@ using System.Runtime.Versioning;
using System.Security;
using System.Text;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System
{
diff --git a/src/mscorlib/src/System/Object.cs b/src/mscorlib/src/System/Object.cs
index 8df1caa9e5..8d74aaeed0 100644
--- a/src/mscorlib/src/System/Object.cs
+++ b/src/mscorlib/src/System/Object.cs
@@ -15,12 +15,12 @@
namespace System
{
using System;
+ using System.Diagnostics;
using System.Runtime;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
using System.Runtime.Versioning;
- using System.Diagnostics.Contracts;
using CultureInfo = System.Globalization.CultureInfo;
using FieldInfo = System.Reflection.FieldInfo;
using BindingFlags = System.Reflection.BindingFlags;
@@ -97,7 +97,6 @@ namespace System
// Returns a Type object which represent this object instance.
//
- [Pure]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern Type GetType();
@@ -121,8 +120,8 @@ namespace System
//
private void FieldSetter(String typeName, String fieldName, Object val)
{
- Contract.Requires(typeName != null);
- Contract.Requires(fieldName != null);
+ Debug.Assert(typeName != null);
+ Debug.Assert(fieldName != null);
// Extract the field info object
FieldInfo fldInfo = GetFieldInfo(typeName, fieldName);
@@ -151,8 +150,8 @@ namespace System
//
private void FieldGetter(String typeName, String fieldName, ref Object val)
{
- Contract.Requires(typeName != null);
- Contract.Requires(fieldName != null);
+ Debug.Assert(typeName != null);
+ Debug.Assert(fieldName != null);
// Extract the field info object
FieldInfo fldInfo = GetFieldInfo(typeName, fieldName);
@@ -165,9 +164,8 @@ namespace System
//
private FieldInfo GetFieldInfo(String typeName, String fieldName)
{
- Contract.Requires(typeName != null);
- Contract.Requires(fieldName != null);
- Contract.Ensures(Contract.Result<FieldInfo>() != null);
+ Debug.Assert(typeName != null);
+ Debug.Assert(fieldName != null);
Type t = GetType();
while (null != t)
diff --git a/src/mscorlib/src/System/ParseNumbers.cs b/src/mscorlib/src/System/ParseNumbers.cs
deleted file mode 100644
index 5287e27669..0000000000
--- a/src/mscorlib/src/System/ParseNumbers.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*============================================================
-**
-**
-**
-** Purpose: Methods for Parsing numbers and Strings.
-** All methods are implemented in native.
-**
-**
-===========================================================*/
-
-//This class contains only static members and does not need to be serializable.
-
-using System;
-using System.Runtime.CompilerServices;
-using System.Runtime.Versioning;
-
-namespace System
-{
- internal static class ParseNumbers
- {
- internal const int PrintAsI1 = 0x40;
- internal const int PrintAsI2 = 0x80;
- internal const int PrintAsI4 = 0x100;
- internal const int TreatAsUnsigned = 0x200;
- internal const int TreatAsI1 = 0x400;
- internal const int TreatAsI2 = 0x800;
- internal const int IsTight = 0x1000;
- internal const int NoSpace = 0x2000;
-
- //
- //
- // NATIVE METHODS
- // For comments on these methods please see $\src\vm\COMUtilNative.cpp
- //
- public unsafe static long StringToLong(System.String s, int radix, int flags)
- {
- return StringToLong(s, radix, flags, null);
- }
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public unsafe extern static long StringToLong(System.String s, int radix, int flags, int* currPos);
-
- public unsafe static long StringToLong(System.String s, int radix, int flags, ref int currPos)
- {
- fixed (int* ppos = &currPos)
- {
- return StringToLong(s, radix, flags, ppos);
- }
- }
-
- public unsafe static int StringToInt(System.String s, int radix, int flags)
- {
- return StringToInt(s, radix, flags, null);
- }
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public unsafe extern static int StringToInt(System.String s, int radix, int flags, int* currPos);
-
- public unsafe static int StringToInt(System.String s, int radix, int flags, ref int currPos)
- {
- fixed (int* ppos = &currPos)
- {
- return StringToInt(s, radix, flags, ppos);
- }
- }
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public extern static String IntToString(int l, int radix, int width, char paddingChar, int flags);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public extern static String LongToString(long l, int radix, int width, char paddingChar, int flags);
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/Assembly.CoreCLR.cs b/src/mscorlib/src/System/Reflection/Assembly.CoreCLR.cs
index d437e05e31..23b4793964 100644
--- a/src/mscorlib/src/System/Reflection/Assembly.CoreCLR.cs
+++ b/src/mscorlib/src/System/Reflection/Assembly.CoreCLR.cs
@@ -7,7 +7,6 @@ using System.IO;
using System.Configuration.Assemblies;
using StackCrawlMark = System.Threading.StackCrawlMark;
using System.Runtime.Serialization;
-using System.Diagnostics.Contracts;
using System.Runtime.Loader;
namespace System.Reflection
@@ -114,9 +113,6 @@ namespace System.Reflection
[System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static Assembly Load(String assemblyString)
{
- Contract.Ensures(Contract.Result<Assembly>() != null);
- Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly);
-
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return RuntimeAssembly.InternalLoad(assemblyString, ref stackMark);
}
@@ -157,9 +153,6 @@ namespace System.Reflection
[System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static Assembly Load(AssemblyName assemblyRef)
{
- Contract.Ensures(Contract.Result<Assembly>() != null);
- Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly);
-
AssemblyName modifiedAssemblyRef = null;
if (assemblyRef != null && assemblyRef.CodeBase != null)
{
@@ -180,9 +173,6 @@ namespace System.Reflection
[System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
internal static Assembly Load(AssemblyName assemblyRef, IntPtr ptrLoadContextBinder)
{
- Contract.Ensures(Contract.Result<Assembly>() != null);
- Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly);
-
AssemblyName modifiedAssemblyRef = null;
if (assemblyRef != null && assemblyRef.CodeBase != null)
{
@@ -206,9 +196,6 @@ namespace System.Reflection
public static Assembly Load(byte[] rawAssembly,
byte[] rawSymbolStore)
{
- Contract.Ensures(Contract.Result<Assembly>() != null);
- Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly);
-
AppDomain.CheckLoadByteArraySupported();
if (rawAssembly == null)
@@ -223,9 +210,6 @@ namespace System.Reflection
public static Assembly LoadFile(String path)
{
- Contract.Ensures(Contract.Result<Assembly>() != null);
- Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly);
-
AppDomain.CheckLoadFileSupported();
Assembly result = null;
diff --git a/src/mscorlib/src/System/Reflection/AssemblyName.cs b/src/mscorlib/src/System/Reflection/AssemblyName.cs
index fe9a2b1268..865a6cfa70 100644
--- a/src/mscorlib/src/System/Reflection/AssemblyName.cs
+++ b/src/mscorlib/src/System/Reflection/AssemblyName.cs
@@ -24,7 +24,6 @@ namespace System.Reflection
using System.Runtime.Serialization;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
- using System.Diagnostics.Contracts;
using System.Text;
public sealed class AssemblyName : ICloneable, ISerializable, IDeserializationCallback
@@ -192,7 +191,6 @@ namespace System.Reflection
{
if (assemblyFile == null)
throw new ArgumentNullException(nameof(assemblyFile));
- Contract.EndContractBlock();
// Assembly.GetNameInternal() will not demand path discovery
// permission, so do that first.
@@ -310,7 +308,6 @@ namespace System.Reflection
{
if (assemblyName == null)
throw new ArgumentNullException(nameof(assemblyName));
- Contract.EndContractBlock();
if ((assemblyName.Length == 0) ||
(assemblyName[0] == '\0'))
throw new ArgumentException(SR.Format_StringZeroLength);
diff --git a/src/mscorlib/src/System/Reflection/Associates.cs b/src/mscorlib/src/System/Reflection/Associates.cs
index ed06cb46fc..381146bf5e 100644
--- a/src/mscorlib/src/System/Reflection/Associates.cs
+++ b/src/mscorlib/src/System/Reflection/Associates.cs
@@ -7,7 +7,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Reflection
{
diff --git a/src/mscorlib/src/System/Reflection/CustomAttribute.cs b/src/mscorlib/src/System/Reflection/CustomAttribute.cs
index 1dd88a23a5..7f50286996 100644
--- a/src/mscorlib/src/System/Reflection/CustomAttribute.cs
+++ b/src/mscorlib/src/System/Reflection/CustomAttribute.cs
@@ -16,7 +16,6 @@ using System.Globalization;
using System.Security;
using System.Runtime.ConstrainedExecution;
using System.Runtime.Versioning;
-using System.Diagnostics.Contracts;
namespace System.Reflection
{
@@ -35,7 +34,6 @@ namespace System.Reflection
{
if (target == null)
throw new ArgumentNullException(nameof(target));
- Contract.EndContractBlock();
return target.GetCustomAttributesData();
}
@@ -44,7 +42,6 @@ namespace System.Reflection
{
if (target == null)
throw new ArgumentNullException(nameof(target));
- Contract.EndContractBlock();
return target.GetCustomAttributesData();
}
@@ -53,7 +50,6 @@ namespace System.Reflection
{
if (target == null)
throw new ArgumentNullException(nameof(target));
- Contract.EndContractBlock();
return target.GetCustomAttributesData();
}
@@ -1004,7 +1000,6 @@ namespace System.Reflection
{
if (customAttributeModule == null)
throw new ArgumentNullException(nameof(customAttributeModule));
- Contract.EndContractBlock();
Debug.Assert(customAttributeCtorParameters != null);
Debug.Assert(customAttributeNamedParameters != null);
@@ -1055,7 +1050,6 @@ namespace System.Reflection
{
if (argumentName == null)
throw new ArgumentNullException(nameof(argumentName));
- Contract.EndContractBlock();
m_argumentName = argumentName;
m_fieldOrProperty = fieldOrProperty;
@@ -1133,7 +1127,7 @@ namespace System.Reflection
#region Internal Static Members
internal static bool IsDefined(RuntimeType type, RuntimeType caType, bool inherit)
{
- Contract.Requires(type != null);
+ Debug.Assert(type != null);
if (type.GetElementType() != null)
return false;
@@ -1162,8 +1156,8 @@ namespace System.Reflection
internal static bool IsDefined(RuntimeMethodInfo method, RuntimeType caType, bool inherit)
{
- Contract.Requires(method != null);
- Contract.Requires(caType != null);
+ Debug.Assert(method != null);
+ Debug.Assert(caType != null);
if (PseudoCustomAttribute.IsDefined(method, caType))
return true;
@@ -1189,8 +1183,8 @@ namespace System.Reflection
internal static bool IsDefined(RuntimeConstructorInfo ctor, RuntimeType caType)
{
- Contract.Requires(ctor != null);
- Contract.Requires(caType != null);
+ Debug.Assert(ctor != null);
+ Debug.Assert(caType != null);
if (PseudoCustomAttribute.IsDefined(ctor, caType))
return true;
@@ -1200,8 +1194,8 @@ namespace System.Reflection
internal static bool IsDefined(RuntimePropertyInfo property, RuntimeType caType)
{
- Contract.Requires(property != null);
- Contract.Requires(caType != null);
+ Debug.Assert(property != null);
+ Debug.Assert(caType != null);
if (PseudoCustomAttribute.IsDefined(property, caType))
return true;
@@ -1211,8 +1205,8 @@ namespace System.Reflection
internal static bool IsDefined(RuntimeEventInfo e, RuntimeType caType)
{
- Contract.Requires(e != null);
- Contract.Requires(caType != null);
+ Debug.Assert(e != null);
+ Debug.Assert(caType != null);
if (PseudoCustomAttribute.IsDefined(e, caType))
return true;
@@ -1222,8 +1216,8 @@ namespace System.Reflection
internal static bool IsDefined(RuntimeFieldInfo field, RuntimeType caType)
{
- Contract.Requires(field != null);
- Contract.Requires(caType != null);
+ Debug.Assert(field != null);
+ Debug.Assert(caType != null);
if (PseudoCustomAttribute.IsDefined(field, caType))
return true;
@@ -1233,8 +1227,8 @@ namespace System.Reflection
internal static bool IsDefined(RuntimeParameterInfo parameter, RuntimeType caType)
{
- Contract.Requires(parameter != null);
- Contract.Requires(caType != null);
+ Debug.Assert(parameter != null);
+ Debug.Assert(caType != null);
if (PseudoCustomAttribute.IsDefined(parameter, caType))
return true;
@@ -1244,8 +1238,8 @@ namespace System.Reflection
internal static bool IsDefined(RuntimeAssembly assembly, RuntimeType caType)
{
- Contract.Requires(assembly != null);
- Contract.Requires(caType != null);
+ Debug.Assert(assembly != null);
+ Debug.Assert(caType != null);
if (PseudoCustomAttribute.IsDefined(assembly, caType))
return true;
@@ -1255,8 +1249,8 @@ namespace System.Reflection
internal static bool IsDefined(RuntimeModule module, RuntimeType caType)
{
- Contract.Requires(module != null);
- Contract.Requires(caType != null);
+ Debug.Assert(module != null);
+ Debug.Assert(caType != null);
if (PseudoCustomAttribute.IsDefined(module, caType))
return true;
@@ -1266,8 +1260,8 @@ namespace System.Reflection
internal static Object[] GetCustomAttributes(RuntimeType type, RuntimeType caType, bool inherit)
{
- Contract.Requires(type != null);
- Contract.Requires(caType != null);
+ Debug.Assert(type != null);
+ Debug.Assert(caType != null);
if (type.GetElementType() != null)
return (caType.IsValueType) ? Array.Empty<Object>() : CreateAttributeArrayHelper(caType, 0);
@@ -1313,8 +1307,8 @@ namespace System.Reflection
internal static Object[] GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, bool inherit)
{
- Contract.Requires(method != null);
- Contract.Requires(caType != null);
+ Debug.Assert(method != null);
+ Debug.Assert(caType != null);
if (method.IsGenericMethod && !method.IsGenericMethodDefinition)
method = method.GetGenericMethodDefinition() as RuntimeMethodInfo;
@@ -1357,8 +1351,8 @@ namespace System.Reflection
internal static Object[] GetCustomAttributes(RuntimeConstructorInfo ctor, RuntimeType caType)
{
- Contract.Requires(ctor != null);
- Contract.Requires(caType != null);
+ Debug.Assert(ctor != null);
+ Debug.Assert(caType != null);
int pcaCount = 0;
Attribute[] pca = PseudoCustomAttribute.GetCustomAttributes(ctor, caType, out pcaCount);
@@ -1369,8 +1363,8 @@ namespace System.Reflection
internal static Object[] GetCustomAttributes(RuntimePropertyInfo property, RuntimeType caType)
{
- Contract.Requires(property != null);
- Contract.Requires(caType != null);
+ Debug.Assert(property != null);
+ Debug.Assert(caType != null);
int pcaCount = 0;
Attribute[] pca = PseudoCustomAttribute.GetCustomAttributes(property, caType, out pcaCount);
@@ -1382,8 +1376,8 @@ namespace System.Reflection
internal static Object[] GetCustomAttributes(RuntimeEventInfo e, RuntimeType caType)
{
- Contract.Requires(e != null);
- Contract.Requires(caType != null);
+ Debug.Assert(e != null);
+ Debug.Assert(caType != null);
int pcaCount = 0;
Attribute[] pca = PseudoCustomAttribute.GetCustomAttributes(e, caType, out pcaCount);
@@ -1394,8 +1388,8 @@ namespace System.Reflection
internal static Object[] GetCustomAttributes(RuntimeFieldInfo field, RuntimeType caType)
{
- Contract.Requires(field != null);
- Contract.Requires(caType != null);
+ Debug.Assert(field != null);
+ Debug.Assert(caType != null);
int pcaCount = 0;
Attribute[] pca = PseudoCustomAttribute.GetCustomAttributes(field, caType, out pcaCount);
@@ -1406,8 +1400,8 @@ namespace System.Reflection
internal static Object[] GetCustomAttributes(RuntimeParameterInfo parameter, RuntimeType caType)
{
- Contract.Requires(parameter != null);
- Contract.Requires(caType != null);
+ Debug.Assert(parameter != null);
+ Debug.Assert(caType != null);
int pcaCount = 0;
Attribute[] pca = PseudoCustomAttribute.GetCustomAttributes(parameter, caType, out pcaCount);
@@ -1418,8 +1412,8 @@ namespace System.Reflection
internal static Object[] GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
{
- Contract.Requires(assembly != null);
- Contract.Requires(caType != null);
+ Debug.Assert(assembly != null);
+ Debug.Assert(caType != null);
int pcaCount = 0;
Attribute[] pca = PseudoCustomAttribute.GetCustomAttributes(assembly, caType, out pcaCount);
@@ -1431,8 +1425,8 @@ namespace System.Reflection
internal static Object[] GetCustomAttributes(RuntimeModule module, RuntimeType caType)
{
- Contract.Requires(module != null);
- Contract.Requires(caType != null);
+ Debug.Assert(module != null);
+ Debug.Assert(caType != null);
int pcaCount = 0;
Attribute[] pca = PseudoCustomAttribute.GetCustomAttributes(module, caType, out pcaCount);
@@ -1457,7 +1451,6 @@ namespace System.Reflection
{
if (decoratedModule.Assembly.ReflectionOnly)
throw new InvalidOperationException(SR.Arg_ReflectionOnlyCA);
- Contract.EndContractBlock();
CustomAttributeRecord[] car = CustomAttributeData.GetCustomAttributeRecords(decoratedModule, decoratedMetadataToken);
@@ -1513,7 +1506,6 @@ namespace System.Reflection
{
if (decoratedModule.Assembly.ReflectionOnly)
throw new InvalidOperationException(SR.Arg_ReflectionOnlyCA);
- Contract.EndContractBlock();
MetadataImport scope = decoratedModule.MetadataImport;
CustomAttributeRecord[] car = CustomAttributeData.GetCustomAttributeRecords(decoratedModule, decoratedMetadataToken);
@@ -1936,8 +1928,8 @@ namespace System.Reflection
#region Internal Static
internal static Attribute[] GetCustomAttributes(RuntimeType type, RuntimeType caType, out int count)
{
- Contract.Requires(type != null);
- Contract.Requires(caType != null);
+ Debug.Assert(type != null);
+ Debug.Assert(caType != null);
count = 0;
@@ -1983,8 +1975,8 @@ namespace System.Reflection
internal static Attribute[] GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, out int count)
{
- Contract.Requires(method != null);
- Contract.Requires(caType != null);
+ Debug.Assert(method != null);
+ Debug.Assert(caType != null);
count = 0;
@@ -2031,8 +2023,8 @@ namespace System.Reflection
internal static Attribute[] GetCustomAttributes(RuntimeParameterInfo parameter, RuntimeType caType, out int count)
{
- Contract.Requires(parameter != null);
- Contract.Requires(caType != null);
+ Debug.Assert(parameter != null);
+ Debug.Assert(caType != null);
count = 0;
@@ -2114,8 +2106,8 @@ namespace System.Reflection
internal static Attribute[] GetCustomAttributes(RuntimeFieldInfo field, RuntimeType caType, out int count)
{
- Contract.Requires(field != null);
- Contract.Requires(caType != null);
+ Debug.Assert(field != null);
+ Debug.Assert(caType != null);
count = 0;
@@ -2329,7 +2321,7 @@ namespace System.Reflection
case TypeAttributes.ExplicitLayout: layoutKind = LayoutKind.Explicit; break;
case TypeAttributes.AutoLayout: layoutKind = LayoutKind.Auto; break;
case TypeAttributes.SequentialLayout: layoutKind = LayoutKind.Sequential; break;
- default: Contract.Assume(false); break;
+ default: Debug.Fail("Unreachable code"); break;
}
CharSet charSet = CharSet.None;
@@ -2338,7 +2330,7 @@ namespace System.Reflection
case TypeAttributes.AnsiClass: charSet = CharSet.Ansi; break;
case TypeAttributes.AutoClass: charSet = CharSet.Auto; break;
case TypeAttributes.UnicodeClass: charSet = CharSet.Unicode; break;
- default: Contract.Assume(false); break;
+ default: Debug.Fail("Unreachable code"); break;
}
type.GetRuntimeModule().MetadataImport.GetClassLayout(type.MetadataToken, out pack, out size);
diff --git a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs
index 82f460138b..bcd70c3b87 100644
--- a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs
@@ -27,7 +27,6 @@ namespace System.Reflection.Emit
using System;
using System.Collections.Generic;
using System.Diagnostics;
- using System.Diagnostics.Contracts;
using System.Diagnostics.SymbolStore;
using CultureInfo = System.Globalization.CultureInfo;
using System.IO;
@@ -164,7 +163,7 @@ namespace System.Reflection.Emit
internal ModuleBuilder GetModuleBuilder(InternalModuleBuilder module)
{
- Contract.Requires(module != null);
+ Debug.Assert(module != null);
Debug.Assert(this.InternalAssembly == module.Assembly);
lock (SyncRoot)
@@ -283,8 +282,6 @@ namespace System.Reflection.Emit
AssemblyName name,
AssemblyBuilderAccess access)
{
- Contract.Ensures(Contract.Result<AssemblyBuilder>() != null);
-
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return InternalDefineDynamicAssembly(name, access,
ref stackMark, null);
@@ -296,8 +293,6 @@ namespace System.Reflection.Emit
AssemblyBuilderAccess access,
IEnumerable<CustomAttributeBuilder> assemblyAttributes)
{
- Contract.Ensures(Contract.Result<AssemblyBuilder>() != null);
-
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return InternalDefineDynamicAssembly(name,
access,
@@ -344,8 +339,6 @@ namespace System.Reflection.Emit
public ModuleBuilder DefineDynamicModule(
String name)
{
- Contract.Ensures(Contract.Result<ModuleBuilder>() != null);
-
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return DefineDynamicModuleInternal(name, false, ref stackMark);
}
@@ -355,8 +348,6 @@ namespace System.Reflection.Emit
String name,
bool emitSymbolInfo) // specify if emit symbol info or not
{
- Contract.Ensures(Contract.Result<ModuleBuilder>() != null);
-
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return DefineDynamicModuleInternal(name, emitSymbolInfo, ref stackMark);
}
@@ -383,8 +374,6 @@ namespace System.Reflection.Emit
throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
if (name[0] == '\0')
throw new ArgumentException(SR.Argument_InvalidName, nameof(name));
- Contract.Ensures(Contract.Result<ModuleBuilder>() != null);
- Contract.EndContractBlock();
BCLDebug.Log("DYNIL", "## DYNIL LOGGING: AssemblyBuilder.DefineDynamicModule( " + name + " )");
@@ -682,7 +671,6 @@ namespace System.Reflection.Emit
throw new ArgumentNullException(nameof(name));
if (name.Length == 0)
throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
- Contract.EndContractBlock();
BCLDebug.Log("DYNIL", "## DYNIL LOGGING: AssemblyBuilder.GetDynamicModule( " + name + " )");
int size = m_assemblyData.m_moduleBuilderList.Count;
@@ -707,7 +695,6 @@ namespace System.Reflection.Emit
throw new ArgumentNullException(nameof(con));
if (binaryAttribute == null)
throw new ArgumentNullException(nameof(binaryAttribute));
- Contract.EndContractBlock();
lock (SyncRoot)
{
@@ -742,7 +729,6 @@ namespace System.Reflection.Emit
{
throw new ArgumentNullException(nameof(customBuilder));
}
- Contract.EndContractBlock();
lock (SyncRoot)
{
diff --git a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderData.cs b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderData.cs
index 901588079a..99c055a991 100644
--- a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderData.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderData.cs
@@ -18,7 +18,6 @@ namespace System.Reflection.Emit
using System.IO;
using System.Runtime.Versioning;
using System.Diagnostics.SymbolStore;
- using System.Diagnostics.Contracts;
// This is a package private class. This class hold all of the managed
// data member for AssemblyBuilder. Note that what ever data members added to
diff --git a/src/mscorlib/src/System/Reflection/Emit/ConstructorBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/ConstructorBuilder.cs
index 3ca9b2eb9d..47b6f08914 100644
--- a/src/mscorlib/src/System/Reflection/Emit/ConstructorBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/ConstructorBuilder.cs
@@ -13,7 +13,6 @@ namespace System.Reflection.Emit
using System.Diagnostics.SymbolStore;
using System.Security;
using System.Runtime.InteropServices;
- using System.Diagnostics.Contracts;
public sealed class ConstructorBuilder : ConstructorInfo
{
@@ -105,7 +104,6 @@ namespace System.Reflection.Emit
throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
- [Pure]
public override ParameterInfo[] GetParameters()
{
ConstructorInfo rci = GetTypeBuilder().GetConstructor(m_methodBuilder.m_parameterTypes);
diff --git a/src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs
index cf5bd11de6..cdc9f469b3 100644
--- a/src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs
@@ -21,7 +21,6 @@ using System.Text;
using System.Runtime.InteropServices;
using System.Globalization;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Reflection.Emit
{
@@ -121,7 +120,6 @@ namespace System.Reflection.Emit
throw new ArgumentException(SR.Arg_ArrayLengthsDiffer, "namedProperties, propertyValues");
if (namedFields.Length != fieldValues.Length)
throw new ArgumentException(SR.Arg_ArrayLengthsDiffer, "namedFields, fieldValues");
- Contract.EndContractBlock();
if ((con.Attributes & MethodAttributes.Static) == MethodAttributes.Static ||
(con.Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Private)
diff --git a/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs b/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs
index b592053f9f..5570233ff1 100644
--- a/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs
@@ -16,7 +16,6 @@ namespace System.Reflection.Emit
using System.Threading;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
- using System.Diagnostics.Contracts;
using System.Security;
internal class DynamicILGenerator : ILGenerator
@@ -49,7 +48,6 @@ namespace System.Reflection.Emit
LocalBuilder localBuilder;
if (localType == null)
throw new ArgumentNullException(nameof(localType));
- Contract.EndContractBlock();
RuntimeType rtType = localType as RuntimeType;
@@ -72,7 +70,6 @@ namespace System.Reflection.Emit
{
if (meth == null)
throw new ArgumentNullException(nameof(meth));
- Contract.EndContractBlock();
int stackchange = 0;
int token = 0;
@@ -128,7 +125,6 @@ namespace System.Reflection.Emit
{
if (con == null)
throw new ArgumentNullException(nameof(con));
- Contract.EndContractBlock();
RuntimeConstructorInfo rtConstructor = con as RuntimeConstructorInfo;
if (rtConstructor == null)
@@ -156,7 +152,6 @@ namespace System.Reflection.Emit
{
if (type == null)
throw new ArgumentNullException(nameof(type));
- Contract.EndContractBlock();
RuntimeType rtType = type as RuntimeType;
@@ -173,7 +168,6 @@ namespace System.Reflection.Emit
{
if (field == null)
throw new ArgumentNullException(nameof(field));
- Contract.EndContractBlock();
RuntimeFieldInfo runtimeField = field as RuntimeFieldInfo;
if (runtimeField == null)
@@ -194,7 +188,6 @@ namespace System.Reflection.Emit
{
if (str == null)
throw new ArgumentNullException(nameof(str));
- Contract.EndContractBlock();
int tempVal = GetTokenForString(str);
EnsureCapacity(7);
@@ -261,7 +254,6 @@ namespace System.Reflection.Emit
if (methodInfo.DeclaringType != null && methodInfo.DeclaringType.ContainsGenericParameters)
throw new ArgumentException(SR.Argument_GenericsInvalid, nameof(methodInfo));
- Contract.EndContractBlock();
int tk;
int stackchange = 0;
@@ -292,7 +284,6 @@ namespace System.Reflection.Emit
{
if (signature == null)
throw new ArgumentNullException(nameof(signature));
- Contract.EndContractBlock();
int stackchange = 0;
EnsureCapacity(7);
@@ -343,7 +334,6 @@ namespace System.Reflection.Emit
{
if (CurrExcStackCount == 0)
throw new NotSupportedException(SR.Argument_NotInExceptionBlock);
- Contract.EndContractBlock();
__ExceptionInfo current = CurrExcStack[CurrExcStackCount - 1];
@@ -389,13 +379,11 @@ namespace System.Reflection.Emit
// debugger related calls.
//
//
- [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
public override void UsingNamespace(String ns)
{
throw new NotSupportedException(SR.InvalidOperation_NotAllowedInDynamicMethod);
}
- [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
public override void MarkSequencePoint(ISymbolDocumentWriter document,
int startLine,
int startColumn,
diff --git a/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs b/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs
index 07d886fcca..4462135dae 100644
--- a/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs
@@ -15,7 +15,6 @@ namespace System.Reflection.Emit
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Diagnostics;
- using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
public sealed class DynamicMethod : MethodInfo
@@ -220,7 +219,6 @@ namespace System.Reflection.Emit
throw new NotSupportedException(SR.NotSupported_DynamicMethodFlags);
if ((attributes & MethodAttributes.MemberAccessMask) != MethodAttributes.Public)
throw new NotSupportedException(SR.NotSupported_DynamicMethodFlags);
- Contract.EndContractBlock();
// only standard or varargs supported
if (callingConvention != CallingConventions.Standard && callingConvention != CallingConventions.VarArgs)
@@ -431,7 +429,6 @@ namespace System.Reflection.Emit
public override MethodInfo GetBaseDefinition() { return this; }
- [Pure]
public override ParameterInfo[] GetParameters() { return m_dynMethod.GetParameters(); }
public override MethodImplAttributes GetMethodImplementationFlags() { return m_dynMethod.GetMethodImplementationFlags(); }
@@ -464,7 +461,6 @@ namespace System.Reflection.Emit
{
if ((CallingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs)
throw new NotSupportedException(SR.NotSupported_CallToVarArg);
- Contract.EndContractBlock();
//
// We do not demand any permission here because the caller already has access
@@ -648,7 +644,6 @@ namespace System.Reflection.Emit
return this;
}
- [Pure]
public override ParameterInfo[] GetParameters()
{
ParameterInfo[] privateParameters = LoadParameters();
@@ -677,7 +672,6 @@ namespace System.Reflection.Emit
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
if (attributeType.IsAssignableFrom(typeof(MethodImplAttribute)))
return new Object[] { new MethodImplAttribute((MethodImplOptions)GetMethodImplementationFlags()) };
@@ -695,7 +689,6 @@ namespace System.Reflection.Emit
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
if (attributeType.IsAssignableFrom(typeof(MethodImplAttribute)))
return true;
diff --git a/src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs
index a36882b036..53566c16b1 100644
--- a/src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs
@@ -17,7 +17,6 @@ namespace System.Reflection.Emit
{
using System;
using System.Diagnostics.CodeAnalysis;
- using System.Diagnostics.Contracts;
using System.Reflection;
using System.Runtime.InteropServices;
using CultureInfo = System.Globalization.CultureInfo;
@@ -293,9 +292,6 @@ namespace System.Reflection.Emit
return m_typeBuilder.HasElementType;
}
- // About the SuppressMessageAttribute here - CCRewrite wants us to repeat the base type's precondition
- // here, but it will always be true. Rather than adding dead code, I'll silence the warning.
- [SuppressMessage("Microsoft.Contracts", "CC1055")]
// Legacy: JScript needs it.
public override Type GetEnumUnderlyingType()
{
diff --git a/src/mscorlib/src/System/Reflection/Emit/EventBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/EventBuilder.cs
index ef60d05172..ff1512829c 100644
--- a/src/mscorlib/src/System/Reflection/Emit/EventBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/EventBuilder.cs
@@ -16,7 +16,6 @@
using System;
using System.Reflection;
using System.Runtime.InteropServices;
-using System.Diagnostics.Contracts;
namespace System.Reflection.Emit
{
@@ -59,7 +58,6 @@ namespace System.Reflection.Emit
{
throw new ArgumentNullException(nameof(mdBuilder));
}
- Contract.EndContractBlock();
m_type.ThrowIfCreated();
TypeBuilder.DefineMethodSemantics(
@@ -97,7 +95,6 @@ namespace System.Reflection.Emit
throw new ArgumentNullException(nameof(con));
if (binaryAttribute == null)
throw new ArgumentNullException(nameof(binaryAttribute));
- Contract.EndContractBlock();
m_type.ThrowIfCreated();
TypeBuilder.DefineCustomAttribute(
@@ -115,7 +112,6 @@ namespace System.Reflection.Emit
{
throw new ArgumentNullException(nameof(customBuilder));
}
- Contract.EndContractBlock();
m_type.ThrowIfCreated();
customBuilder.CreateCustomAttribute(m_module, m_evToken.Token);
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs
index d0e9d3483c..2c4850921c 100644
--- a/src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs
@@ -10,7 +10,6 @@ namespace System.Reflection.Emit
using System;
using CultureInfo = System.Globalization.CultureInfo;
using System.Reflection;
- using System.Diagnostics.Contracts;
public sealed class FieldBuilder : FieldInfo
{
@@ -41,7 +40,6 @@ namespace System.Reflection.Emit
if (type == typeof(void))
throw new ArgumentException(SR.Argument_BadFieldType);
- Contract.EndContractBlock();
m_fieldName = fieldName;
m_typeBuilder = typeBuilder;
@@ -191,7 +189,6 @@ namespace System.Reflection.Emit
if (binaryAttribute == null)
throw new ArgumentNullException(nameof(binaryAttribute));
- Contract.EndContractBlock();
ModuleBuilder module = m_typeBuilder.Module as ModuleBuilder;
@@ -205,7 +202,6 @@ namespace System.Reflection.Emit
{
if (customBuilder == null)
throw new ArgumentNullException(nameof(customBuilder));
- Contract.EndContractBlock();
m_typeBuilder.ThrowIfCreated();
diff --git a/src/mscorlib/src/System/Reflection/Emit/FlowControl.cs b/src/mscorlib/src/System/Reflection/Emit/FlowControl.cs
index e02278c777..8905a7f1d9 100644
--- a/src/mscorlib/src/System/Reflection/Emit/FlowControl.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/FlowControl.cs
@@ -16,7 +16,6 @@ using System;
namespace System.Reflection.Emit
{
-
public enum FlowControl
{
Branch = 0,
diff --git a/src/mscorlib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs
index 8256d0e6d5..c682b2861d 100644
--- a/src/mscorlib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs
@@ -9,7 +9,6 @@ using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
-using System.Diagnostics.Contracts;
namespace System.Reflection.Emit
{
@@ -82,7 +81,6 @@ namespace System.Reflection.Emit
{
if (rank <= 0)
throw new IndexOutOfRangeException();
- Contract.EndContractBlock();
string szrank = "";
if (rank == 1)
@@ -200,7 +198,6 @@ namespace System.Reflection.Emit
public override bool IsAssignableFrom(Type c) { throw new NotSupportedException(); }
- [Pure]
public override bool IsSubclassOf(Type c) { throw new NotSupportedException(); }
#endregion
diff --git a/src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs b/src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs
index 52e8b30e33..75a282a24e 100644
--- a/src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs
@@ -31,9 +31,7 @@ namespace System.Reflection.Emit
internal static T[] EnlargeArray<T>(T[] incoming, int requiredSize)
{
- Contract.Requires(incoming != null);
- Contract.Ensures(Contract.Result<T[]>() != null);
- Contract.Ensures(Contract.Result<T[]>().Length == requiredSize);
+ Debug.Assert(incoming != null);
T[] temp = new T[requiredSize];
Array.Copy(incoming, 0, temp, 0, incoming.Length);
@@ -47,9 +45,7 @@ namespace System.Reflection.Emit
private static byte[] EnlargeArray(byte[] incoming, int requiredSize)
{
- Contract.Requires(incoming != null);
- Contract.Ensures(Contract.Result<byte[]>() != null);
- Contract.Ensures(Contract.Result<byte[]>().Length == requiredSize);
+ Debug.Assert(incoming != null);
byte[] temp = new byte[requiredSize];
Buffer.BlockCopy(incoming, 0, temp, 0, incoming.Length);
@@ -108,8 +104,8 @@ namespace System.Reflection.Emit
internal ILGenerator(MethodInfo methodBuilder, int size)
{
- Contract.Requires(methodBuilder != null);
- Contract.Requires(methodBuilder is MethodBuilder || methodBuilder is DynamicMethod);
+ Debug.Assert(methodBuilder != null);
+ Debug.Assert(methodBuilder is MethodBuilder || methodBuilder is DynamicMethod);
if (size < defaultSize)
{
@@ -288,7 +284,7 @@ namespace System.Reflection.Emit
__ExceptionInfo[] temp;
if (m_currExcStackCount != 0)
{
- throw new NotSupportedException(SR.GetResourceString(ResId.Argument_UnclosedExceptionBlock));
+ throw new NotSupportedException(SR.Argument_UnclosedExceptionBlock);
}
if (m_exceptionCount == 0)
@@ -466,7 +462,6 @@ namespace System.Reflection.Emit
{
if (meth == null)
throw new ArgumentNullException(nameof(meth));
- Contract.EndContractBlock();
if (opcode.Equals(OpCodes.Call) || opcode.Equals(OpCodes.Callvirt) || opcode.Equals(OpCodes.Newobj))
{
@@ -544,7 +539,6 @@ namespace System.Reflection.Emit
if (!(opcode.Equals(OpCodes.Call) || opcode.Equals(OpCodes.Callvirt) || opcode.Equals(OpCodes.Newobj)))
throw new ArgumentException(SR.Argument_NotMethodCallOpcode, nameof(opcode));
- Contract.EndContractBlock();
int stackchange = 0;
int tk = GetMethodToken(methodInfo, optionalParameterTypes, false);
@@ -577,7 +571,6 @@ namespace System.Reflection.Emit
{
if (signature == null)
throw new ArgumentNullException(nameof(signature));
- Contract.EndContractBlock();
int stackchange = 0;
ModuleBuilder modBuilder = (ModuleBuilder)m_methodBuilder.Module;
@@ -612,7 +605,6 @@ namespace System.Reflection.Emit
{
if (con == null)
throw new ArgumentNullException(nameof(con));
- Contract.EndContractBlock();
int stackchange = 0;
@@ -749,7 +741,6 @@ namespace System.Reflection.Emit
{
if (labels == null)
throw new ArgumentNullException(nameof(labels));
- Contract.EndContractBlock();
// Emitting a switch table
@@ -800,7 +791,6 @@ namespace System.Reflection.Emit
{
throw new ArgumentNullException(nameof(local));
}
- Contract.EndContractBlock();
int tempVal = local.GetLocalIndex();
if (local.GetMethodBuilder() != m_methodBuilder)
{
@@ -1124,7 +1114,6 @@ namespace System.Reflection.Emit
{
throw new ArgumentException(SR.Argument_NotExceptionType);
}
- Contract.EndContractBlock();
ConstructorInfo con = excType.GetConstructor(Type.EmptyTypes);
if (con == null)
{
@@ -1197,7 +1186,6 @@ namespace System.Reflection.Emit
{
throw new ArgumentNullException(nameof(fld));
}
- Contract.EndContractBlock();
MethodInfo prop = GetConsoleType().GetMethod("get_Out");
Emit(OpCodes.Call, prop);
@@ -1279,7 +1267,6 @@ namespace System.Reflection.Emit
if (usingNamespace.Length == 0)
throw new ArgumentException(SR.Argument_EmptyName, nameof(usingNamespace));
- Contract.EndContractBlock();
int index;
MethodBuilder methodBuilder = m_methodBuilder as MethodBuilder;
@@ -1308,7 +1295,6 @@ namespace System.Reflection.Emit
{
throw new ArgumentOutOfRangeException(nameof(startLine));
}
- Contract.EndContractBlock();
m_LineNumberInfo.AddLineNumberInfo(document, m_length, startLine, startColumn, endLine, endColumn);
}
@@ -1566,7 +1552,7 @@ namespace System.Reflection.Emit
// not having a nesting relation.
internal bool IsInner(__ExceptionInfo exc)
{
- Contract.Requires(exc != null);
+ Debug.Assert(exc != null);
Debug.Assert(m_currentCatch > 0, "m_currentCatch > 0");
Debug.Assert(exc.m_currentCatch > 0, "exc.m_currentCatch > 0");
@@ -1681,7 +1667,6 @@ namespace System.Reflection.Emit
{
throw new ArgumentException(SR.Argument_UnmatchingSymScope);
}
- Contract.EndContractBlock();
// make sure that arrays are large enough to hold addition info
EnsureCapacity();
diff --git a/src/mscorlib/src/System/Reflection/Emit/MethodBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/MethodBuilder.cs
index 530a5ee092..fda22ab1d6 100644
--- a/src/mscorlib/src/System/Reflection/Emit/MethodBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/MethodBuilder.cs
@@ -16,7 +16,6 @@ namespace System.Reflection.Emit
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Diagnostics;
- using System.Diagnostics.Contracts;
public sealed class MethodBuilder : MethodInfo
{
@@ -91,7 +90,6 @@ namespace System.Reflection.Emit
if (mod == null)
throw new ArgumentNullException(nameof(mod));
- Contract.EndContractBlock();
if (parameterTypes != null)
{
@@ -195,7 +193,6 @@ namespace System.Reflection.Emit
{
throw new ArgumentNullException(nameof(il));
}
- Contract.EndContractBlock();
__ExceptionInfo[] excp;
int counter = 0;
@@ -612,7 +609,6 @@ namespace System.Reflection.Emit
}
}
- [Pure]
public override ParameterInfo[] GetParameters()
{
if (!m_bIsBaked || m_containingType == null || m_containingType.BakedRuntimeType == null)
@@ -679,7 +675,6 @@ namespace System.Reflection.Emit
if (names.Length == 0)
throw new ArgumentException(SR.Arg_EmptyArray, nameof(names));
- Contract.EndContractBlock();
if (m_inst != null)
throw new InvalidOperationException(SR.InvalidOperation_GenericParametersAlreadySet);
@@ -825,7 +820,6 @@ namespace System.Reflection.Emit
{
if (position < 0)
throw new ArgumentOutOfRangeException(SR.ArgumentOutOfRange_ParamSequence);
- Contract.EndContractBlock();
ThrowIfGeneric();
m_containingType.ThrowIfCreated();
@@ -859,8 +853,6 @@ namespace System.Reflection.Emit
public ILGenerator GetILGenerator()
{
- Contract.Ensures(Contract.Result<ILGenerator>() != null);
-
ThrowIfGeneric();
ThrowIfShouldNotHaveBody();
@@ -871,8 +863,6 @@ namespace System.Reflection.Emit
public ILGenerator GetILGenerator(int size)
{
- Contract.Ensures(Contract.Result<ILGenerator>() != null);
-
ThrowIfGeneric();
ThrowIfShouldNotHaveBody();
@@ -922,7 +912,6 @@ namespace System.Reflection.Emit
throw new ArgumentNullException(nameof(con));
if (binaryAttribute == null)
throw new ArgumentNullException(nameof(binaryAttribute));
- Contract.EndContractBlock();
ThrowIfGeneric();
@@ -939,7 +928,6 @@ namespace System.Reflection.Emit
{
if (customBuilder == null)
throw new ArgumentNullException(nameof(customBuilder));
- Contract.EndContractBlock();
ThrowIfGeneric();
diff --git a/src/mscorlib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs b/src/mscorlib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs
index be4bfd5f48..471f25feb8 100644
--- a/src/mscorlib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs
@@ -8,7 +8,6 @@ using System;
using System.Reflection;
using System.Collections;
using System.Globalization;
-using System.Diagnostics.Contracts;
namespace System.Reflection.Emit
{
@@ -19,7 +18,6 @@ namespace System.Reflection.Emit
{
if (!method.IsGenericMethodDefinition)
throw new InvalidOperationException();
- Contract.EndContractBlock();
return new MethodBuilderInstantiation(method, inst);
}
@@ -56,7 +54,6 @@ namespace System.Reflection.Emit
#endregion
#region MethodBase Members
- [Pure]
public override ParameterInfo[] GetParameters() { throw new NotSupportedException(); }
public override MethodImplAttributes GetMethodImplementationFlags() { return m_method.GetMethodImplementationFlags(); }
public override RuntimeMethodHandle MethodHandle { get { throw new NotSupportedException(SR.NotSupported_DynamicModule); } }
diff --git a/src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs
index 1c65bf91c2..c7e6e59f42 100644
--- a/src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs
@@ -21,7 +21,6 @@ namespace System.Reflection.Emit
using System.Runtime.Versioning;
using System.Runtime.CompilerServices;
using System.Diagnostics;
- using System.Diagnostics.Contracts;
internal sealed class InternalModuleBuilder : RuntimeModule
{
@@ -269,7 +268,6 @@ namespace System.Reflection.Emit
if (con == null)
throw new ArgumentNullException(nameof(con));
- Contract.EndContractBlock();
int tr;
int mr = 0;
@@ -824,7 +822,6 @@ namespace System.Reflection.Emit
public override Assembly Assembly
{
- [Pure]
get
{
return m_assemblyBuilder;
@@ -838,8 +835,6 @@ namespace System.Reflection.Emit
#region Define Type
public TypeBuilder DefineType(String name)
{
- Contract.Ensures(Contract.Result<TypeBuilder>() != null);
-
lock (SyncRoot)
{
return DefineTypeNoLock(name, TypeAttributes.NotPublic, null, null, PackingSize.Unspecified, TypeBuilder.UnspecifiedTypeSize);
@@ -848,8 +843,6 @@ namespace System.Reflection.Emit
public TypeBuilder DefineType(String name, TypeAttributes attr)
{
- Contract.Ensures(Contract.Result<TypeBuilder>() != null);
-
lock (SyncRoot)
{
return DefineTypeNoLock(name, attr, null, null, PackingSize.Unspecified, TypeBuilder.UnspecifiedTypeSize);
@@ -858,8 +851,6 @@ namespace System.Reflection.Emit
public TypeBuilder DefineType(String name, TypeAttributes attr, Type parent)
{
- Contract.Ensures(Contract.Result<TypeBuilder>() != null);
-
lock (SyncRoot)
{
// Why do we only call CheckContext here? Why don't we call it in the other overloads?
@@ -871,8 +862,6 @@ namespace System.Reflection.Emit
public TypeBuilder DefineType(String name, TypeAttributes attr, Type parent, int typesize)
{
- Contract.Ensures(Contract.Result<TypeBuilder>() != null);
-
lock (SyncRoot)
{
return DefineTypeNoLock(name, attr, parent, null, PackingSize.Unspecified, typesize);
@@ -881,8 +870,6 @@ namespace System.Reflection.Emit
public TypeBuilder DefineType(String name, TypeAttributes attr, Type parent, PackingSize packingSize, int typesize)
{
- Contract.Ensures(Contract.Result<TypeBuilder>() != null);
-
lock (SyncRoot)
{
return DefineTypeNoLock(name, attr, parent, null, packingSize, typesize);
@@ -891,8 +878,6 @@ namespace System.Reflection.Emit
public TypeBuilder DefineType(String name, TypeAttributes attr, Type parent, Type[] interfaces)
{
- Contract.Ensures(Contract.Result<TypeBuilder>() != null);
-
lock (SyncRoot)
{
return DefineTypeNoLock(name, attr, parent, interfaces, PackingSize.Unspecified, TypeBuilder.UnspecifiedTypeSize);
@@ -901,15 +886,11 @@ namespace System.Reflection.Emit
private TypeBuilder DefineTypeNoLock(String name, TypeAttributes attr, Type parent, Type[] interfaces, PackingSize packingSize, int typesize)
{
- Contract.Ensures(Contract.Result<TypeBuilder>() != null);
-
return new TypeBuilder(name, attr, parent, interfaces, this, packingSize, typesize, null); ;
}
public TypeBuilder DefineType(String name, TypeAttributes attr, Type parent, PackingSize packsize)
{
- Contract.Ensures(Contract.Result<TypeBuilder>() != null);
-
lock (SyncRoot)
{
return DefineTypeNoLock(name, attr, parent, packsize);
@@ -918,8 +899,6 @@ namespace System.Reflection.Emit
private TypeBuilder DefineTypeNoLock(String name, TypeAttributes attr, Type parent, PackingSize packsize)
{
- Contract.Ensures(Contract.Result<TypeBuilder>() != null);
-
return new TypeBuilder(name, attr, parent, null, this, packsize, TypeBuilder.UnspecifiedTypeSize, null);
}
@@ -931,8 +910,6 @@ namespace System.Reflection.Emit
// Nested enum types can be defined manually using ModuleBuilder.DefineType.
public EnumBuilder DefineEnum(String name, TypeAttributes visibility, Type underlyingType)
{
- Contract.Ensures(Contract.Result<EnumBuilder>() != null);
-
CheckContext(underlyingType);
lock (SyncRoot)
{
@@ -957,8 +934,6 @@ namespace System.Reflection.Emit
private EnumBuilder DefineEnumNoLock(String name, TypeAttributes visibility, Type underlyingType)
{
- Contract.Ensures(Contract.Result<EnumBuilder>() != null);
-
return new EnumBuilder(name, underlyingType, visibility, this);
}
@@ -971,16 +946,12 @@ namespace System.Reflection.Emit
#region Define Global Method
public MethodBuilder DefineGlobalMethod(String name, MethodAttributes attributes, Type returnType, Type[] parameterTypes)
{
- Contract.Ensures(Contract.Result<MethodBuilder>() != null);
-
return DefineGlobalMethod(name, attributes, CallingConventions.Standard, returnType, parameterTypes);
}
public MethodBuilder DefineGlobalMethod(String name, MethodAttributes attributes, CallingConventions callingConvention,
Type returnType, Type[] parameterTypes)
{
- Contract.Ensures(Contract.Result<MethodBuilder>() != null);
-
return DefineGlobalMethod(name, attributes, callingConvention, returnType, null, null, parameterTypes, null, null);
}
@@ -1011,8 +982,6 @@ namespace System.Reflection.Emit
if ((attributes & MethodAttributes.Static) == 0)
throw new ArgumentException(SR.Argument_GlobalFunctionHasToBeStatic);
- Contract.Ensures(Contract.Result<MethodBuilder>() != null);
- Contract.EndContractBlock();
CheckContext(returnType);
CheckContext(requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers, parameterTypes);
@@ -1054,7 +1023,6 @@ namespace System.Reflection.Emit
// This method will define an initialized Data in .sdata.
// We will create a fake TypeDef to represent the data with size. This TypeDef
// will be the signature for the Field.
- Contract.Ensures(Contract.Result<FieldBuilder>() != null);
lock (SyncRoot)
{
@@ -1071,8 +1039,6 @@ namespace System.Reflection.Emit
{
throw new InvalidOperationException(SR.InvalidOperation_GlobalsHaveBeenCreated);
}
- Contract.Ensures(Contract.Result<FieldBuilder>() != null);
- Contract.EndContractBlock();
m_moduleData.m_fHasGlobal = true;
return m_moduleData.m_globalTypeBuilder.DefineInitializedData(name, data, attributes);
@@ -1080,8 +1046,6 @@ namespace System.Reflection.Emit
public FieldBuilder DefineUninitializedData(String name, int size, FieldAttributes attributes)
{
- Contract.Ensures(Contract.Result<FieldBuilder>() != null);
-
lock (SyncRoot)
{
return DefineUninitializedDataNoLock(name, size, attributes);
@@ -1098,8 +1062,6 @@ namespace System.Reflection.Emit
{
throw new InvalidOperationException(SR.InvalidOperation_GlobalsHaveBeenCreated);
}
- Contract.Ensures(Contract.Result<FieldBuilder>() != null);
- Contract.EndContractBlock();
m_moduleData.m_fHasGlobal = true;
return m_moduleData.m_globalTypeBuilder.DefineUninitializedData(name, size, attributes);
@@ -1134,7 +1096,6 @@ namespace System.Reflection.Emit
{
if (type == null)
throw new ArgumentNullException(nameof(type));
- Contract.EndContractBlock();
CheckContext(type);
@@ -1251,7 +1212,6 @@ namespace System.Reflection.Emit
// return the MethodDef token.
if (method == null)
throw new ArgumentNullException(nameof(method));
- Contract.EndContractBlock();
int tr;
int mr = 0;
@@ -1443,7 +1403,6 @@ namespace System.Reflection.Emit
if (arrayClass.IsArray == false)
throw new ArgumentException(SR.Argument_HasToBeArrayClass);
- Contract.EndContractBlock();
CheckContext(returnType, arrayClass);
CheckContext(parameterTypes);
@@ -1500,7 +1459,6 @@ namespace System.Reflection.Emit
{
throw new ArgumentNullException(nameof(field));
}
- Contract.EndContractBlock();
int tr;
int mr = 0;
@@ -1589,7 +1547,6 @@ namespace System.Reflection.Emit
{
throw new ArgumentNullException(nameof(str));
}
- Contract.EndContractBlock();
// Returns a token representing a String constant. If the string
// value has already been defined, the existing token will be returned.
@@ -1605,7 +1562,6 @@ namespace System.Reflection.Emit
{
throw new ArgumentNullException(nameof(sigHelper));
}
- Contract.EndContractBlock();
int sigLength;
byte[] sigBytes;
@@ -1618,7 +1574,6 @@ namespace System.Reflection.Emit
{
if (sigBytes == null)
throw new ArgumentNullException(nameof(sigBytes));
- Contract.EndContractBlock();
byte[] localSigBytes = new byte[sigBytes.Length];
Buffer.BlockCopy(sigBytes, 0, localSigBytes, 0, sigBytes.Length);
@@ -1636,7 +1591,6 @@ namespace System.Reflection.Emit
throw new ArgumentNullException(nameof(con));
if (binaryAttribute == null)
throw new ArgumentNullException(nameof(binaryAttribute));
- Contract.EndContractBlock();
TypeBuilder.DefineCustomAttribute(
this,
@@ -1652,7 +1606,6 @@ namespace System.Reflection.Emit
{
throw new ArgumentNullException(nameof(customBuilder));
}
- Contract.EndContractBlock();
customBuilder.CreateCustomAttribute(this, 1); // This is hard coding the module token to 1
}
@@ -1696,7 +1649,6 @@ namespace System.Reflection.Emit
// url cannot be null but can be an empty string
if (url == null)
throw new ArgumentNullException(nameof(url));
- Contract.EndContractBlock();
lock (SyncRoot)
{
@@ -1715,7 +1667,6 @@ namespace System.Reflection.Emit
return m_iSymWriter.DefineDocument(url, language, languageVendor, documentType);
}
- [Pure]
public bool IsTransient()
{
return InternalModule.IsTransientInternal();
diff --git a/src/mscorlib/src/System/Reflection/Emit/ModuleBuilderData.cs b/src/mscorlib/src/System/Reflection/Emit/ModuleBuilderData.cs
index c597dbe6b4..0364ae52ab 100644
--- a/src/mscorlib/src/System/Reflection/Emit/ModuleBuilderData.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/ModuleBuilderData.cs
@@ -4,7 +4,6 @@
using System;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Globalization;
using System.IO;
using System.Reflection;
diff --git a/src/mscorlib/src/System/Reflection/Emit/OpCodeType.cs b/src/mscorlib/src/System/Reflection/Emit/OpCodeType.cs
index 8bf9ffd40d..17435c5768 100644
--- a/src/mscorlib/src/System/Reflection/Emit/OpCodeType.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/OpCodeType.cs
@@ -16,7 +16,6 @@ using System;
namespace System.Reflection.Emit
{
-
public enum OpCodeType
{
[Obsolete("This API has been deprecated. http://go.microsoft.com/fwlink/?linkid=14202")]
diff --git a/src/mscorlib/src/System/Reflection/Emit/OpCodes.cs b/src/mscorlib/src/System/Reflection/Emit/OpCodes.cs
index bb2913ebfc..81257bdd4b 100644
--- a/src/mscorlib/src/System/Reflection/Emit/OpCodes.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/OpCodes.cs
@@ -16,7 +16,6 @@ using System;
namespace System.Reflection.Emit
{
-
///<summary>
/// Internal enum OpCodeValues for opcode values.
///</summary>
@@ -263,7 +262,6 @@ namespace System.Reflection.Emit
/// <seealso topic='IL Instruction Set Specification'/>
public class OpCodes
{
-
private OpCodes()
{
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/Opcode.cs b/src/mscorlib/src/System/Reflection/Emit/Opcode.cs
index 37768be9d7..72967cdfca 100644
--- a/src/mscorlib/src/System/Reflection/Emit/Opcode.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/Opcode.cs
@@ -4,7 +4,6 @@
using System;
using System.Threading;
-using System.Diagnostics.Contracts;
namespace System.Reflection.Emit
{
@@ -157,7 +156,6 @@ namespace System.Reflection.Emit
}
}
- [Pure]
public override bool Equals(Object obj)
{
if (obj is OpCode)
@@ -166,19 +164,16 @@ namespace System.Reflection.Emit
return false;
}
- [Pure]
public bool Equals(OpCode obj)
{
return obj.Value == Value;
}
- [Pure]
public static bool operator ==(OpCode a, OpCode b)
{
return a.Equals(b);
}
- [Pure]
public static bool operator !=(OpCode a, OpCode b)
{
return !(a == b);
diff --git a/src/mscorlib/src/System/Reflection/Emit/OperandType.cs b/src/mscorlib/src/System/Reflection/Emit/OperandType.cs
index 33fe193398..6257c56745 100644
--- a/src/mscorlib/src/System/Reflection/Emit/OperandType.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/OperandType.cs
@@ -16,7 +16,6 @@ using System;
namespace System.Reflection.Emit
{
-
public enum OperandType
{
InlineBrTarget = 0,
diff --git a/src/mscorlib/src/System/Reflection/Emit/ParameterBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/ParameterBuilder.cs
index 636825956a..6f61cac5a7 100644
--- a/src/mscorlib/src/System/Reflection/Emit/ParameterBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/ParameterBuilder.cs
@@ -16,7 +16,6 @@
using System.Runtime.InteropServices;
using System;
using System.Reflection;
-using System.Diagnostics.Contracts;
namespace System.Reflection.Emit
{
@@ -40,7 +39,6 @@ namespace System.Reflection.Emit
throw new ArgumentNullException(nameof(con));
if (binaryAttribute == null)
throw new ArgumentNullException(nameof(binaryAttribute));
- Contract.EndContractBlock();
TypeBuilder.DefineCustomAttribute(
m_methodBuilder.GetModuleBuilder(),
@@ -57,7 +55,6 @@ namespace System.Reflection.Emit
{
throw new ArgumentNullException(nameof(customBuilder));
}
- Contract.EndContractBlock();
customBuilder.CreateCustomAttribute((ModuleBuilder)(m_methodBuilder.GetModule()), m_pdToken.Token);
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs
index 6dbcba251f..9344b53a09 100644
--- a/src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs
@@ -19,7 +19,6 @@ namespace System.Reflection.Emit
using System.Reflection;
using CultureInfo = System.Globalization.CultureInfo;
using System.Runtime.InteropServices;
- using System.Diagnostics.Contracts;
//
// A PropertyBuilder is always associated with a TypeBuilder. The TypeBuilder.DefineProperty
@@ -47,7 +46,6 @@ namespace System.Reflection.Emit
throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
if (name[0] == '\0')
throw new ArgumentException(SR.Argument_IllegalName, nameof(name));
- Contract.EndContractBlock();
m_name = name;
m_moduleBuilder = mod;
diff --git a/src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs b/src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs
index fd1a8e70fe..94d2b12dce 100644
--- a/src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs
@@ -7,7 +7,6 @@
using System.Text;
using System;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -289,8 +288,8 @@ namespace System.Reflection.Emit
// This function will not increase the argument count. It only fills in bytes
// in the signature based on clsArgument. This helper is called for return type.
- Contract.Requires(clsArgument != null);
- Contract.Requires((optionalCustomModifiers == null && requiredCustomModifiers == null) || !clsArgument.ContainsGenericParameters);
+ Debug.Assert(clsArgument != null);
+ Debug.Assert((optionalCustomModifiers == null && requiredCustomModifiers == null) || !clsArgument.ContainsGenericParameters);
if (optionalCustomModifiers != null)
{
diff --git a/src/mscorlib/src/System/Reflection/Emit/StackBehaviour.cs b/src/mscorlib/src/System/Reflection/Emit/StackBehaviour.cs
index 9e45cd3fe0..3e64b48798 100644
--- a/src/mscorlib/src/System/Reflection/Emit/StackBehaviour.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/StackBehaviour.cs
@@ -16,7 +16,6 @@ using System;
namespace System.Reflection.Emit
{
-
public enum StackBehaviour
{
Pop0 = 0,
diff --git a/src/mscorlib/src/System/Reflection/Emit/SymbolMethod.cs b/src/mscorlib/src/System/Reflection/Emit/SymbolMethod.cs
index 42713b86db..5e5668ac7b 100644
--- a/src/mscorlib/src/System/Reflection/Emit/SymbolMethod.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/SymbolMethod.cs
@@ -9,7 +9,6 @@ namespace System.Reflection.Emit
using System.Runtime.InteropServices;
using System;
using System.Reflection;
- using System.Diagnostics.Contracts;
using CultureInfo = System.Globalization.CultureInfo;
internal sealed class SymbolMethod : MethodInfo
@@ -96,7 +95,6 @@ namespace System.Reflection.Emit
#endregion
#region MethodBase Overrides
- [Pure]
public override ParameterInfo[] GetParameters()
{
throw new NotSupportedException(SR.NotSupported_SymbolMethod);
diff --git a/src/mscorlib/src/System/Reflection/Emit/SymbolType.cs b/src/mscorlib/src/System/Reflection/Emit/SymbolType.cs
index ca2f7d9d6e..6057c1da72 100644
--- a/src/mscorlib/src/System/Reflection/Emit/SymbolType.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/SymbolType.cs
@@ -9,7 +9,6 @@ namespace System.Reflection.Emit
using System.Runtime.InteropServices;
using System;
using System.Reflection;
- using System.Diagnostics.Contracts;
using CultureInfo = System.Globalization.CultureInfo;
internal enum TypeKind
@@ -234,7 +233,6 @@ namespace System.Reflection.Emit
{
if (baseType == null)
throw new ArgumentNullException(nameof(baseType));
- Contract.EndContractBlock();
m_baseType = baseType;
}
@@ -294,7 +292,6 @@ namespace System.Reflection.Emit
{
if (rank <= 0)
throw new IndexOutOfRangeException();
- Contract.EndContractBlock();
string szrank = "";
if (rank == 1)
@@ -316,7 +313,6 @@ namespace System.Reflection.Emit
{
if (!IsArray)
throw new NotSupportedException(SR.NotSupported_SubclassOverride);
- Contract.EndContractBlock();
return m_cRank;
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs
index 2f550a4e40..c07f9e736e 100644
--- a/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs
@@ -17,7 +17,6 @@ namespace System.Reflection.Emit
using System.Threading;
using System.Runtime.Versioning;
using System.Diagnostics;
- using System.Diagnostics.Contracts;
public enum PackingSize
@@ -55,7 +54,6 @@ namespace System.Reflection.Emit
if (binaryAttribute == null)
throw new ArgumentNullException(nameof(binaryAttribute));
- Contract.EndContractBlock();
m_con = con;
m_binaryAttribute = binaryAttribute;
@@ -65,7 +63,6 @@ namespace System.Reflection.Emit
{
if (customBuilder == null)
throw new ArgumentNullException(nameof(customBuilder));
- Contract.EndContractBlock();
m_customBuilder = customBuilder;
}
@@ -106,7 +103,6 @@ namespace System.Reflection.Emit
if (type.GetGenericTypeDefinition() != method.DeclaringType)
throw new ArgumentException(SR.Argument_InvalidMethodDeclaringType, nameof(type));
- Contract.EndContractBlock();
// The following converts from Type or TypeBuilder of G<T> to TypeBuilderInstantiation G<T>. These types
// both logically represent the same thing. The runtime displays a similar convention by having
@@ -126,7 +122,6 @@ namespace System.Reflection.Emit
if (!constructor.DeclaringType.IsGenericTypeDefinition)
throw new ArgumentException(SR.Argument_ConstructorNeedGenericDeclaringType, nameof(constructor));
- Contract.EndContractBlock();
if (!(type is TypeBuilderInstantiation))
throw new ArgumentException(SR.Argument_NeedNonGenericType, nameof(type));
@@ -147,7 +142,6 @@ namespace System.Reflection.Emit
if (!field.DeclaringType.IsGenericTypeDefinition)
throw new ArgumentException(SR.Argument_FieldNeedGenericDeclaringType, nameof(field));
- Contract.EndContractBlock();
if (!(type is TypeBuilderInstantiation))
throw new ArgumentException(SR.Argument_NeedNonGenericType, nameof(type));
@@ -267,7 +261,6 @@ namespace System.Reflection.Emit
#endregion
#region Internal\Private Static Members
- [Pure]
internal static bool IsTypeEqual(Type t1, Type t2)
{
// Maybe we are lucky that they are equal in the first place
@@ -482,7 +475,7 @@ namespace System.Reflection.Emit
// ctor for generic method parameter
internal TypeBuilder(string szName, int genParamPos, MethodBuilder declMeth)
{
- Contract.Requires(declMeth != null);
+ Debug.Assert(declMeth != null);
m_declMeth = declMeth;
m_DeclaringType = m_declMeth.GetTypeBuilder();
m_module = declMeth.GetModuleBuilder();
@@ -492,7 +485,7 @@ namespace System.Reflection.Emit
// ctor for generic type parameter
private TypeBuilder(string szName, int genParamPos, TypeBuilder declType)
{
- Contract.Requires(declType != null);
+ Debug.Assert(declType != null);
m_DeclaringType = declType;
m_module = declType.GetModuleBuilder();
InitAsGenericParam(szName, genParamPos);
@@ -534,7 +527,6 @@ namespace System.Reflection.Emit
if (fullname.Length > 1023)
throw new ArgumentException(SR.Argument_TypeNameTooLong, nameof(fullname));
- Contract.EndContractBlock();
int i;
m_module = module;
@@ -634,7 +626,6 @@ namespace System.Reflection.Emit
if (size <= 0 || size >= 0x003f0000)
throw new ArgumentException(SR.Argument_BadSizeForData);
- Contract.EndContractBlock();
ThrowIfCreated();
@@ -694,7 +685,6 @@ namespace System.Reflection.Emit
}
}
- [Pure]
public bool IsCreated()
{
return m_hasBeenCreated;
@@ -825,7 +815,6 @@ namespace System.Reflection.Emit
{
if (!IsCreated())
throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
- Contract.EndContractBlock();
return m_bakedRuntimeType.GUID;
}
@@ -836,7 +825,6 @@ namespace System.Reflection.Emit
{
if (!IsCreated())
throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
- Contract.EndContractBlock();
return m_bakedRuntimeType.InvokeMember(name, invokeAttr, binder, target, args, modifiers, culture, namedParameters);
}
@@ -885,7 +873,6 @@ namespace System.Reflection.Emit
{
if (!IsCreated())
throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
- Contract.EndContractBlock();
return m_bakedRuntimeType.GetConstructor(bindingAttr, binder, callConvention, types, modifiers);
}
@@ -894,7 +881,6 @@ namespace System.Reflection.Emit
{
if (!IsCreated())
throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
- Contract.EndContractBlock();
return m_bakedRuntimeType.GetConstructors(bindingAttr);
}
@@ -904,7 +890,6 @@ namespace System.Reflection.Emit
{
if (!IsCreated())
throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
- Contract.EndContractBlock();
if (types == null)
{
@@ -920,7 +905,6 @@ namespace System.Reflection.Emit
{
if (!IsCreated())
throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
- Contract.EndContractBlock();
return m_bakedRuntimeType.GetMethods(bindingAttr);
}
@@ -929,7 +913,6 @@ namespace System.Reflection.Emit
{
if (!IsCreated())
throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
- Contract.EndContractBlock();
return m_bakedRuntimeType.GetField(name, bindingAttr);
}
@@ -938,7 +921,6 @@ namespace System.Reflection.Emit
{
if (!IsCreated())
throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
- Contract.EndContractBlock();
return m_bakedRuntimeType.GetFields(bindingAttr);
}
@@ -947,7 +929,6 @@ namespace System.Reflection.Emit
{
if (!IsCreated())
throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
- Contract.EndContractBlock();
return m_bakedRuntimeType.GetInterface(name, ignoreCase);
}
@@ -971,7 +952,6 @@ namespace System.Reflection.Emit
{
if (!IsCreated())
throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
- Contract.EndContractBlock();
return m_bakedRuntimeType.GetEvent(name, bindingAttr);
}
@@ -980,7 +960,6 @@ namespace System.Reflection.Emit
{
if (!IsCreated())
throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
- Contract.EndContractBlock();
return m_bakedRuntimeType.GetEvents();
}
@@ -995,7 +974,6 @@ namespace System.Reflection.Emit
{
if (!IsCreated())
throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
- Contract.EndContractBlock();
return m_bakedRuntimeType.GetProperties(bindingAttr);
}
@@ -1004,7 +982,6 @@ namespace System.Reflection.Emit
{
if (!IsCreated())
throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
- Contract.EndContractBlock();
return m_bakedRuntimeType.GetNestedTypes(bindingAttr);
}
@@ -1013,7 +990,6 @@ namespace System.Reflection.Emit
{
if (!IsCreated())
throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
- Contract.EndContractBlock();
return m_bakedRuntimeType.GetNestedType(name, bindingAttr);
}
@@ -1022,7 +998,6 @@ namespace System.Reflection.Emit
{
if (!IsCreated())
throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
- Contract.EndContractBlock();
return m_bakedRuntimeType.GetMember(name, type, bindingAttr);
}
@@ -1031,7 +1006,6 @@ namespace System.Reflection.Emit
{
if (!IsCreated())
throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
- Contract.EndContractBlock();
return m_bakedRuntimeType.GetInterfaceMap(interfaceType);
}
@@ -1040,7 +1014,6 @@ namespace System.Reflection.Emit
{
if (!IsCreated())
throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
- Contract.EndContractBlock();
return m_bakedRuntimeType.GetEvents(bindingAttr);
}
@@ -1049,7 +1022,6 @@ namespace System.Reflection.Emit
{
if (!IsCreated())
throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
- Contract.EndContractBlock();
return m_bakedRuntimeType.GetMembers(bindingAttr);
}
@@ -1160,7 +1132,6 @@ namespace System.Reflection.Emit
get { return false; }
}
- [Pure]
public override bool IsSubclassOf(Type c)
{
Type p = this;
@@ -1221,7 +1192,6 @@ namespace System.Reflection.Emit
{
if (rank <= 0)
throw new IndexOutOfRangeException();
- Contract.EndContractBlock();
string szrank = "";
if (rank == 1)
@@ -1245,7 +1215,6 @@ namespace System.Reflection.Emit
{
if (!IsCreated())
throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
- Contract.EndContractBlock();
return CustomAttribute.GetCustomAttributes(m_bakedRuntimeType, typeof(object) as RuntimeType, inherit);
}
@@ -1257,7 +1226,6 @@ namespace System.Reflection.Emit
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
@@ -1274,7 +1242,6 @@ namespace System.Reflection.Emit
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
@@ -1310,7 +1277,6 @@ namespace System.Reflection.Emit
if (names.Length == 0)
throw new ArgumentException();
- Contract.EndContractBlock();
for (int i = 0; i < names.Length; i++)
if (names[i] == null)
@@ -1363,7 +1329,6 @@ namespace System.Reflection.Emit
if (methodInfoDeclaration == null)
throw new ArgumentNullException(nameof(methodInfoDeclaration));
- Contract.EndContractBlock();
ThrowIfCreated();
@@ -1382,30 +1347,22 @@ namespace System.Reflection.Emit
public MethodBuilder DefineMethod(String name, MethodAttributes attributes, Type returnType, Type[] parameterTypes)
{
- Contract.Ensures(Contract.Result<MethodBuilder>() != null);
-
return DefineMethod(name, attributes, CallingConventions.Standard, returnType, parameterTypes);
}
public MethodBuilder DefineMethod(String name, MethodAttributes attributes)
{
- Contract.Ensures(Contract.Result<MethodBuilder>() != null);
-
return DefineMethod(name, attributes, CallingConventions.Standard, null, null);
}
public MethodBuilder DefineMethod(String name, MethodAttributes attributes, CallingConventions callingConvention)
{
- Contract.Ensures(Contract.Result<MethodBuilder>() != null);
-
return DefineMethod(name, attributes, callingConvention, null, null);
}
public MethodBuilder DefineMethod(String name, MethodAttributes attributes, CallingConventions callingConvention,
Type returnType, Type[] parameterTypes)
{
- Contract.Ensures(Contract.Result<MethodBuilder>() != null);
-
return DefineMethod(name, attributes, callingConvention, returnType, null, null, parameterTypes, null, null);
}
@@ -1413,8 +1370,6 @@ namespace System.Reflection.Emit
Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers)
{
- Contract.Ensures(Contract.Result<MethodBuilder>() != null);
-
lock (SyncRoot)
{
return DefineMethodNoLock(name, attributes, callingConvention, returnType, returnTypeRequiredCustomModifiers,
@@ -1432,8 +1387,6 @@ namespace System.Reflection.Emit
if (name.Length == 0)
throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
- Contract.Ensures(Contract.Result<MethodBuilder>() != null);
- Contract.EndContractBlock();
CheckContext(returnType);
CheckContext(returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes);
@@ -1736,7 +1689,6 @@ namespace System.Reflection.Emit
{
if (data == null)
throw new ArgumentNullException(nameof(data));
- Contract.EndContractBlock();
// This method will define an initialized Data in .sdata.
// We will create a fake TypeDef to represent the data with size. This TypeDef
@@ -1804,7 +1756,6 @@ namespace System.Reflection.Emit
throw new ArgumentNullException(nameof(name));
if (name.Length == 0)
throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
- Contract.EndContractBlock();
CheckContext(returnType);
CheckContext(returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes);
@@ -1861,7 +1812,6 @@ namespace System.Reflection.Emit
throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
if (name[0] == '\0')
throw new ArgumentException(SR.Argument_IllegalName, nameof(name));
- Contract.EndContractBlock();
int tkType;
EventToken evToken;
@@ -2149,7 +2099,6 @@ namespace System.Reflection.Emit
{
throw new ArgumentNullException(nameof(interfaceType));
}
- Contract.EndContractBlock();
CheckContext(interfaceType);
@@ -2180,7 +2129,6 @@ namespace System.Reflection.Emit
if (binaryAttribute == null)
throw new ArgumentNullException(nameof(binaryAttribute));
- Contract.EndContractBlock();
TypeBuilder.DefineCustomAttribute(m_module, m_tdType.Token, ((ModuleBuilder)m_module).GetConstructorToken(con).Token,
binaryAttribute, false, false);
@@ -2190,7 +2138,6 @@ namespace System.Reflection.Emit
{
if (customBuilder == null)
throw new ArgumentNullException(nameof(customBuilder));
- Contract.EndContractBlock();
customBuilder.CreateCustomAttribute((ModuleBuilder)m_module, m_tdType.Token);
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs b/src/mscorlib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs
index ab5b7eeaa5..ed2e1be866 100644
--- a/src/mscorlib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs
@@ -8,7 +8,7 @@ using System;
using System.Reflection;
using System.Collections;
using System.Globalization;
-using System.Diagnostics.Contracts;
+using System.Diagnostics;
namespace System.Reflection.Emit
{
@@ -23,14 +23,13 @@ namespace System.Reflection.Emit
#region Static Members
internal static Type MakeGenericType(Type type, Type[] typeArguments)
{
- Contract.Requires(type != null, "this is only called from RuntimeType.MakeGenericType and TypeBuilder.MakeGenericType so 'type' cannot be null");
+ Debug.Assert(type != null, "this is only called from RuntimeType.MakeGenericType and TypeBuilder.MakeGenericType so 'type' cannot be null");
if (!type.IsGenericTypeDefinition)
throw new InvalidOperationException();
if (typeArguments == null)
throw new ArgumentNullException(nameof(typeArguments));
- Contract.EndContractBlock();
foreach (Type t in typeArguments)
{
@@ -94,7 +93,6 @@ namespace System.Reflection.Emit
{
if (rank <= 0)
throw new IndexOutOfRangeException();
- Contract.EndContractBlock();
string comma = "";
for (int i = 1; i < rank; i++)
@@ -225,7 +223,6 @@ namespace System.Reflection.Emit
public override Type MakeGenericType(params Type[] inst) { throw new InvalidOperationException(SR.Arg_NotGenericTypeDefinition); }
public override bool IsAssignableFrom(Type c) { throw new NotSupportedException(); }
- [Pure]
public override bool IsSubclassOf(Type c)
{
throw new NotSupportedException();
diff --git a/src/mscorlib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs b/src/mscorlib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs
index 3894d9115b..9c406f81cb 100644
--- a/src/mscorlib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs
@@ -10,7 +10,6 @@ using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Reflection.Emit
{
@@ -55,7 +54,6 @@ namespace System.Reflection.Emit
#endregion
#region MethodBase Members
- [Pure]
public override ParameterInfo[] GetParameters() { return m_method.GetParameters(); }
public override MethodImplAttributes GetMethodImplementationFlags() { return m_method.GetMethodImplementationFlags(); }
public override RuntimeMethodHandle MethodHandle { get { return m_method.MethodHandle; } }
@@ -73,7 +71,6 @@ namespace System.Reflection.Emit
{
if (!IsGenericMethodDefinition)
throw new InvalidOperationException(SR.Arg_NotGenericMethodDefinition);
- Contract.EndContractBlock();
return MethodBuilderInstantiation.MakeGenericMethod(this, typeArgs);
}
@@ -151,7 +148,6 @@ namespace System.Reflection.Emit
#endregion
#region MethodBase Members
- [Pure]
public override ParameterInfo[] GetParameters() { return m_ctor.GetParameters(); }
public override MethodImplAttributes GetMethodImplementationFlags() { return m_ctor.GetMethodImplementationFlags(); }
public override RuntimeMethodHandle MethodHandle { get { return m_ctor.MethodHandle; } }
diff --git a/src/mscorlib/src/System/Reflection/ExceptionHandlingClause.cs b/src/mscorlib/src/System/Reflection/ExceptionHandlingClause.cs
index a61ed5e385..66ad4eb7a9 100644
--- a/src/mscorlib/src/System/Reflection/ExceptionHandlingClause.cs
+++ b/src/mscorlib/src/System/Reflection/ExceptionHandlingClause.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Globalization;
-using System.Diagnostics.Contracts;
namespace System.Reflection
{
@@ -16,7 +15,6 @@ namespace System.Reflection
#region Private Data Members
private MethodBody m_methodBody;
- [ContractPublicPropertyName("Flags")]
private ExceptionHandlingClauseOptions m_flags;
private int m_tryOffset;
private int m_tryLength;
diff --git a/src/mscorlib/src/System/Reflection/MdImport.cs b/src/mscorlib/src/System/Reflection/MdImport.cs
index 9230ffa9ef..d2de707528 100644
--- a/src/mscorlib/src/System/Reflection/MdImport.cs
+++ b/src/mscorlib/src/System/Reflection/MdImport.cs
@@ -16,7 +16,6 @@ using System.Text;
using System.Runtime.InteropServices;
using System.Configuration.Assemblies;
using System.Runtime.Versioning;
-using System.Diagnostics.Contracts;
namespace System.Reflection
{
@@ -171,7 +170,6 @@ namespace System.Reflection
{
if (index < 0 || index >= m_length)
throw new IndexOutOfRangeException();
- Contract.EndContractBlock();
unsafe
{
@@ -262,7 +260,7 @@ namespace System.Reflection
{
get
{
- Contract.Requires(0 <= index && index < Length);
+ Debug.Assert(0 <= index && index < Length);
if (largeResult != null)
return largeResult[index];
diff --git a/src/mscorlib/src/System/Reflection/RtFieldInfo.cs b/src/mscorlib/src/System/Reflection/RtFieldInfo.cs
index 856d254d47..e4b592d117 100644
--- a/src/mscorlib/src/System/Reflection/RtFieldInfo.cs
+++ b/src/mscorlib/src/System/Reflection/RtFieldInfo.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Threading;
@@ -286,7 +285,6 @@ namespace System.Reflection
{
if (obj.IsNull)
throw new ArgumentException(SR.Arg_TypedReference_Null);
- Contract.EndContractBlock();
unsafe
{
@@ -309,7 +307,6 @@ namespace System.Reflection
{
if (obj.IsNull)
throw new ArgumentException(SR.Arg_TypedReference_Null);
- Contract.EndContractBlock();
unsafe
{
diff --git a/src/mscorlib/src/System/Reflection/RuntimeAssembly.cs b/src/mscorlib/src/System/Reflection/RuntimeAssembly.cs
index cd9c715eec..138955baec 100644
--- a/src/mscorlib/src/System/Reflection/RuntimeAssembly.cs
+++ b/src/mscorlib/src/System/Reflection/RuntimeAssembly.cs
@@ -14,7 +14,6 @@ using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Threading;
-using System.Diagnostics.Contracts;
namespace System.Reflection
{
@@ -247,7 +246,6 @@ namespace System.Reflection
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
@@ -261,7 +259,6 @@ namespace System.Reflection
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
@@ -309,7 +306,6 @@ namespace System.Reflection
{
if (assemblyString == null)
throw new ArgumentNullException(nameof(assemblyString));
- Contract.EndContractBlock();
if ((assemblyString.Length == 0) ||
(assemblyString[0] == '\0'))
@@ -344,7 +340,6 @@ namespace System.Reflection
{
if (assemblyRef == null)
throw new ArgumentNullException(nameof(assemblyRef));
- Contract.EndContractBlock();
if (assemblyRef.CodeBase != null)
{
@@ -732,7 +727,6 @@ namespace System.Reflection
{
if (culture == null)
throw new ArgumentNullException(nameof(culture));
- Contract.EndContractBlock();
String name = GetSimpleName() + ".resources";
diff --git a/src/mscorlib/src/System/Reflection/RuntimeConstructorInfo.cs b/src/mscorlib/src/System/Reflection/RuntimeConstructorInfo.cs
index 9b11a858df..e7a548e870 100644
--- a/src/mscorlib/src/System/Reflection/RuntimeConstructorInfo.cs
+++ b/src/mscorlib/src/System/Reflection/RuntimeConstructorInfo.cs
@@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Globalization;
using RuntimeTypeCache = System.RuntimeType.RuntimeTypeCache;
@@ -75,8 +74,6 @@ namespace System.Reflection
RuntimeMethodHandleInternal handle, RuntimeType declaringType, RuntimeTypeCache reflectedTypeCache,
MethodAttributes methodAttributes, BindingFlags bindingFlags)
{
- Contract.Ensures(methodAttributes == RuntimeMethodHandle.GetAttributes(handle));
-
m_bindingFlags = bindingFlags;
m_reflectedTypeCache = reflectedTypeCache;
m_declaringType = declaringType;
@@ -161,7 +158,6 @@ namespace System.Reflection
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
@@ -175,7 +171,6 @@ namespace System.Reflection
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
@@ -244,7 +239,6 @@ namespace System.Reflection
return m_parameters;
}
- [Pure]
public override ParameterInfo[] GetParameters()
{
ParameterInfo[] parameters = GetParametersNoCopy();
@@ -293,7 +287,6 @@ namespace System.Reflection
{
if (declaringType == null)
throw new ArgumentNullException(nameof(declaringType));
- Contract.EndContractBlock();
// ctor is ReflectOnly
if (declaringType is ReflectionOnlyType)
diff --git a/src/mscorlib/src/System/Reflection/RuntimeEventInfo.cs b/src/mscorlib/src/System/Reflection/RuntimeEventInfo.cs
index beea874c9d..bd8c451fe7 100644
--- a/src/mscorlib/src/System/Reflection/RuntimeEventInfo.cs
+++ b/src/mscorlib/src/System/Reflection/RuntimeEventInfo.cs
@@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using RuntimeTypeCache = System.RuntimeType.RuntimeTypeCache;
namespace System.Reflection
@@ -32,8 +31,8 @@ namespace System.Reflection
}
internal RuntimeEventInfo(int tkEvent, RuntimeType declaredType, RuntimeTypeCache reflectedTypeCache, out bool isPrivate)
{
- Contract.Requires(declaredType != null);
- Contract.Requires(reflectedTypeCache != null);
+ Debug.Assert(declaredType != null);
+ Debug.Assert(reflectedTypeCache != null);
Debug.Assert(!reflectedTypeCache.IsGlobal);
MetadataImport scope = declaredType.GetRuntimeModule().MetadataImport;
@@ -90,7 +89,6 @@ namespace System.Reflection
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
@@ -104,7 +102,6 @@ namespace System.Reflection
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
diff --git a/src/mscorlib/src/System/Reflection/RuntimeFieldInfo.cs b/src/mscorlib/src/System/Reflection/RuntimeFieldInfo.cs
index 9f1f634093..56f89e618f 100644
--- a/src/mscorlib/src/System/Reflection/RuntimeFieldInfo.cs
+++ b/src/mscorlib/src/System/Reflection/RuntimeFieldInfo.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
-using System.Diagnostics.Contracts;
using RuntimeTypeCache = System.RuntimeType.RuntimeTypeCache;
namespace System.Reflection
@@ -88,7 +87,6 @@ namespace System.Reflection
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
@@ -102,7 +100,6 @@ namespace System.Reflection
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
diff --git a/src/mscorlib/src/System/Reflection/RuntimeMethodInfo.cs b/src/mscorlib/src/System/Reflection/RuntimeMethodInfo.cs
index 6addf74718..1419175b65 100644
--- a/src/mscorlib/src/System/Reflection/RuntimeMethodInfo.cs
+++ b/src/mscorlib/src/System/Reflection/RuntimeMethodInfo.cs
@@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Globalization;
using System.Security;
using System.Text;
@@ -69,8 +68,6 @@ namespace System.Reflection
RuntimeMethodHandleInternal handle, RuntimeType declaringType,
RuntimeTypeCache reflectedTypeCache, MethodAttributes methodAttributes, BindingFlags bindingFlags, object keepalive)
{
- Contract.Ensures(!m_handle.IsNull());
-
Debug.Assert(!handle.IsNullHandle());
Debug.Assert(methodAttributes == RuntimeMethodHandle.GetAttributes(handle));
@@ -258,7 +255,6 @@ namespace System.Reflection
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
@@ -272,7 +268,6 @@ namespace System.Reflection
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
@@ -356,7 +351,6 @@ namespace System.Reflection
return m_parameters;
}
- [System.Diagnostics.Contracts.Pure]
public override ParameterInfo[] GetParameters()
{
FetchNonReturnParameters();
@@ -544,8 +538,6 @@ namespace System.Reflection
{
get
{
- Contract.Ensures(m_returnParameter != null);
-
FetchReturnParameter();
return m_returnParameter as ParameterInfo;
}
@@ -617,7 +609,6 @@ namespace System.Reflection
// Validate the parameters.
if (delegateType == null)
throw new ArgumentNullException(nameof(delegateType));
- Contract.EndContractBlock();
RuntimeType rtType = delegateType as RuntimeType;
if (rtType == null)
@@ -642,7 +633,6 @@ namespace System.Reflection
{
if (methodInstantiation == null)
throw new ArgumentNullException(nameof(methodInstantiation));
- Contract.EndContractBlock();
RuntimeType[] methodInstantionRuntimeType = new RuntimeType[methodInstantiation.Length];
@@ -711,7 +701,6 @@ namespace System.Reflection
{
if (!IsGenericMethod)
throw new InvalidOperationException();
- Contract.EndContractBlock();
return RuntimeType.GetMethodBase(m_declaringType, RuntimeMethodHandle.StripMethodInstantiation(this)) as MethodInfo;
}
diff --git a/src/mscorlib/src/System/Reflection/RuntimeModule.cs b/src/mscorlib/src/System/Reflection/RuntimeModule.cs
index f9b733736d..2ddbb27884 100644
--- a/src/mscorlib/src/System/Reflection/RuntimeModule.cs
+++ b/src/mscorlib/src/System/Reflection/RuntimeModule.cs
@@ -8,7 +8,6 @@ using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Security;
using System.Globalization;
-using System.Diagnostics.Contracts;
namespace System.Reflection
{
@@ -414,7 +413,6 @@ namespace System.Reflection
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
@@ -428,7 +426,6 @@ namespace System.Reflection
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
@@ -570,7 +567,6 @@ namespace System.Reflection
public override Assembly Assembly
{
- [Pure]
get
{
return GetRuntimeAssembly();
diff --git a/src/mscorlib/src/System/Reflection/RuntimeParameterInfo.cs b/src/mscorlib/src/System/Reflection/RuntimeParameterInfo.cs
index 8f070b6827..5048af3950 100644
--- a/src/mscorlib/src/System/Reflection/RuntimeParameterInfo.cs
+++ b/src/mscorlib/src/System/Reflection/RuntimeParameterInfo.cs
@@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
using MdToken = System.Reflection.MetadataToken;
@@ -186,7 +185,7 @@ namespace System.Reflection
Signature signature, MetadataImport scope, int tkParamDef,
int position, ParameterAttributes attributes, MemberInfo member)
{
- Contract.Requires(member != null);
+ Debug.Assert(member != null);
Debug.Assert(MdToken.IsNullToken(tkParamDef) == scope.Equals(MetadataImport.EmptyImport));
Debug.Assert(MdToken.IsNullToken(tkParamDef) || MdToken.IsTokenOfType(tkParamDef, MetadataTokenType.ParamDef));
@@ -397,7 +396,7 @@ namespace System.Reflection
private static Decimal GetRawDecimalConstant(CustomAttributeData attr)
{
- Contract.Requires(attr.Constructor.DeclaringType == typeof(DecimalConstantAttribute));
+ Debug.Assert(attr.Constructor.DeclaringType == typeof(DecimalConstantAttribute));
foreach (CustomAttributeNamedArgument namedArgument in attr.NamedArguments)
{
@@ -441,8 +440,8 @@ namespace System.Reflection
private static DateTime GetRawDateTimeConstant(CustomAttributeData attr)
{
- Contract.Requires(attr.Constructor.DeclaringType == typeof(DateTimeConstantAttribute));
- Contract.Requires(attr.ConstructorArguments.Count == 1);
+ Debug.Assert(attr.Constructor.DeclaringType == typeof(DateTimeConstantAttribute));
+ Debug.Assert(attr.ConstructorArguments.Count == 1);
foreach (CustomAttributeNamedArgument namedArgument in attr.NamedArguments)
{
@@ -518,7 +517,6 @@ namespace System.Reflection
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
if (MdToken.IsNullToken(m_tkParamDef))
return Array.Empty<Object>();
@@ -535,7 +533,6 @@ namespace System.Reflection
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
if (MdToken.IsNullToken(m_tkParamDef))
return false;
diff --git a/src/mscorlib/src/System/Reflection/RuntimePropertyInfo.cs b/src/mscorlib/src/System/Reflection/RuntimePropertyInfo.cs
index 2d54d75224..2315e42574 100644
--- a/src/mscorlib/src/System/Reflection/RuntimePropertyInfo.cs
+++ b/src/mscorlib/src/System/Reflection/RuntimePropertyInfo.cs
@@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Globalization;
using System.Text;
using RuntimeTypeCache = System.RuntimeType.RuntimeTypeCache;
@@ -32,8 +31,8 @@ namespace System.Reflection
internal RuntimePropertyInfo(
int tkProperty, RuntimeType declaredType, RuntimeTypeCache reflectedTypeCache, out bool isPrivate)
{
- Contract.Requires(declaredType != null);
- Contract.Requires(reflectedTypeCache != null);
+ Debug.Assert(declaredType != null);
+ Debug.Assert(reflectedTypeCache != null);
Debug.Assert(!reflectedTypeCache.IsGlobal);
MetadataImport scope = declaredType.GetRuntimeModule().MetadataImport;
@@ -111,9 +110,9 @@ namespace System.Reflection
// End Class
//
- Contract.Requires(Name.Equals(target.Name));
- Contract.Requires(this != target);
- Contract.Requires(this.ReflectedType == target.ReflectedType);
+ Debug.Assert(Name.Equals(target.Name));
+ Debug.Assert(this != target);
+ Debug.Assert(this.ReflectedType == target.ReflectedType);
return Signature.CompareSig(this.Signature, target.Signature);
}
@@ -155,7 +154,6 @@ namespace System.Reflection
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
@@ -169,7 +167,6 @@ namespace System.Reflection
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
diff --git a/src/mscorlib/src/System/ResId.cs b/src/mscorlib/src/System/ResId.cs
deleted file mode 100644
index 7be46145b0..0000000000
--- a/src/mscorlib/src/System/ResId.cs
+++ /dev/null
@@ -1,97 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*============================================================
-**
-**
-**
-** Purpose: Contains identifiers for each of the resources
-** specified in resources.txt
-**
-**
-===========================================================*/
-//This class contains only static members and does not need to be serializable.
-
-using System.Configuration.Assemblies;
-using System;
-
-namespace System
-{
- internal static class ResId
- {
- // Only statics, does not need to be marked with the serializable attribute
- internal const String Arg_ArrayLengthsDiffer = "Arg_ArrayLengthsDiffer";
- internal const String Argument_InvalidNumberOfMembers = "Argument_InvalidNumberOfMembers";
- internal const String Argument_UnequalMembers = "Argument_UnequalMembers";
- internal const String Argument_SpecifyValueSize = "Argument_SpecifyValueSize";
- internal const String Argument_UnmatchingSymScope = "Argument_UnmatchingSymScope";
- internal const String Argument_NotInExceptionBlock = "Argument_NotInExceptionBlock";
- internal const String Argument_NotExceptionType = "Argument_NotExceptionType";
- internal const String Argument_InvalidLabel = "Argument_InvalidLabel";
- internal const String Argument_UnclosedExceptionBlock = "Argument_UnclosedExceptionBlock";
- internal const String Argument_MissingDefaultConstructor = "Argument_MissingDefaultConstructor";
- internal const String Argument_TooManyFinallyClause = "Argument_TooManyFinallyClause";
- internal const String Argument_NotInTheSameModuleBuilder = "Argument_NotInTheSameModuleBuilder";
- internal const String Argument_BadCurrentLocalVariable = "Argument_BadCurrentLocalVariable";
- internal const String Argument_DuplicateModuleName = "Argument_DuplicateModuleName";
- internal const String Argument_BadPersistableModuleInTransientAssembly = "Argument_BadPersistableModuleInTransientAssembly";
- internal const String Argument_HasToBeArrayClass = "Argument_HasToBeArrayClass";
- internal const String Argument_InvalidDirectory = "Argument_InvalidDirectory";
-
- internal const String MissingType = "MissingType";
- internal const String MissingModule = "MissingModule";
-
- internal const String ArgumentOutOfRange_Index = "ArgumentOutOfRange_Index";
- internal const String ArgumentOutOfRange_Range = "ArgumentOutOfRange_Range";
-
- internal const String ExecutionEngine_YoureHosed = "ExecutionEngine_YoureHosed";
-
- internal const String Format_NeedSingleChar = "Format_NeedSingleChar";
- internal const String Format_StringZeroLength = "Format_StringZeroLength";
-
- internal const String InvalidOperation_EnumEnded = "InvalidOperation_EnumEnded";
- internal const String InvalidOperation_EnumFailedVersion = "InvalidOperation_EnumFailedVersion";
- internal const String InvalidOperation_EnumNotStarted = "InvalidOperation_EnumNotStarted";
- internal const String InvalidOperation_EnumOpCantHappen = "InvalidOperation_EnumOpCantHappen";
- internal const String InvalidOperation_InternalState = "InvalidOperation_InternalState";
- internal const String InvalidOperation_ModifyRONumFmtInfo = "InvalidOperation_ModifyRONumFmtInfo";
- internal const String InvalidOperation_MethodBaked = "InvalidOperation_MethodBaked";
- internal const String InvalidOperation_NotADebugModule = "InvalidOperation_NotADebugModule";
- internal const String InvalidOperation_MethodHasBody = "InvalidOperation_MethodHasBody";
- internal const String InvalidOperation_OpenLocalVariableScope = "InvalidOperation_OpenLocalVariableScope";
- internal const String InvalidOperation_TypeHasBeenCreated = "InvalidOperation_TypeHasBeenCreated";
- internal const String InvalidOperation_RefedAssemblyNotSaved = "InvalidOperation_RefedAssemblyNotSaved";
- internal const String InvalidOperation_AssemblyHasBeenSaved = "InvalidOperation_AssemblyHasBeenSaved";
- internal const String InvalidOperation_ModuleHasBeenSaved = "InvalidOperation_ModuleHasBeenSaved";
- internal const String InvalidOperation_CannotAlterAssembly = "InvalidOperation_CannotAlterAssembly";
-
- internal const String NotSupported_CannotSaveModuleIndividually = "NotSupported_CannotSaveModuleIndividually";
- internal const String NotSupported_Constructor = "NotSupported_Constructor";
- internal const String NotSupported_Method = "NotSupported_Method";
- internal const String NotSupported_NYI = "NotSupported_NYI";
- internal const String NotSupported_DynamicModule = "NotSupported_DynamicModule";
- internal const String NotSupported_NotDynamicModule = "NotSupported_NotDynamicModule";
- internal const String NotSupported_NotAllTypesAreBaked = "NotSupported_NotAllTypesAreBaked";
- internal const String NotSupported_SortedListNestedWrite = "NotSupported_SortedListNestedWrite";
-
-
- internal const String Serialization_ArrayInvalidLength = "Serialization_ArrayInvalidLength";
- internal const String Serialization_ArrayNoLength = "Serialization_ArrayNoLength";
- internal const String Serialization_CannotGetType = "Serialization_CannotGetType";
- internal const String Serialization_InsufficientState = "Serialization_InsufficientState";
- internal const String Serialization_InvalidID = "Serialization_InvalidID";
- internal const String Serialization_MalformedArray = "Serialization_MalformedArray";
- internal const String Serialization_MultipleMembers = "Serialization_MultipleMembers";
- internal const String Serialization_NoID = "Serialization_NoID";
- internal const String Serialization_NoType = "Serialization_NoType";
- internal const String Serialization_NoBaseType = "Serialization_NoBaseType";
- internal const String Serialization_NullSignature = "Serialization_NullSignature";
- internal const String Serialization_UnknownMember = "Serialization_UnknownMember";
- internal const String Serialization_BadParameterInfo = "Serialization_BadParameterInfo";
- internal const String Serialization_NoParameterInfo = "Serialization_NoParameterInfo";
-
- internal const String WeakReference_NoLongerValid = "WeakReference_NoLongerValid";
- internal const String Loader_InvalidPath = "Loader_InvalidPath";
- }
-}
diff --git a/src/mscorlib/src/System/Resources/FileBasedResourceGroveler.cs b/src/mscorlib/src/System/Resources/FileBasedResourceGroveler.cs
index 7d445deba2..58c99242a8 100644
--- a/src/mscorlib/src/System/Resources/FileBasedResourceGroveler.cs
+++ b/src/mscorlib/src/System/Resources/FileBasedResourceGroveler.cs
@@ -26,7 +26,6 @@ namespace System.Resources
using System.Text;
using System.Threading;
using System.Diagnostics;
- using System.Diagnostics.Contracts;
internal class FileBasedResourceGroveler : IResourceGroveler
{
diff --git a/src/mscorlib/src/System/Resources/ManifestBasedResourceGroveler.cs b/src/mscorlib/src/System/Resources/ManifestBasedResourceGroveler.cs
index a4e698276f..4548b93dd4 100644
--- a/src/mscorlib/src/System/Resources/ManifestBasedResourceGroveler.cs
+++ b/src/mscorlib/src/System/Resources/ManifestBasedResourceGroveler.cs
@@ -28,7 +28,6 @@ namespace System.Resources
using System.Text;
using System.Threading;
using System.Diagnostics;
- using System.Diagnostics.Contracts;
using Microsoft.Win32;
//
@@ -48,7 +47,7 @@ namespace System.Resources
{
// here and below: convert asserts to preconditions where appropriate when we get
// contracts story in place.
- Contract.Requires(mediator != null, "mediator shouldn't be null; check caller");
+ Debug.Assert(mediator != null, "mediator shouldn't be null; check caller");
_mediator = mediator;
}
@@ -317,8 +316,8 @@ namespace System.Resources
private Stream GetManifestResourceStream(RuntimeAssembly satellite, String fileName, ref StackCrawlMark stackMark)
{
- Contract.Requires(satellite != null, "satellite shouldn't be null; check caller");
- Contract.Requires(fileName != null, "fileName shouldn't be null; check caller");
+ Debug.Assert(satellite != null, "satellite shouldn't be null; check caller");
+ Debug.Assert(fileName != null, "fileName shouldn't be null; check caller");
// If we're looking in the main assembly AND if the main assembly was the person who
// created the ResourceManager, skip a security check for private manifest resources.
@@ -341,8 +340,8 @@ namespace System.Resources
[System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
private Stream CaseInsensitiveManifestResourceStreamLookup(RuntimeAssembly satellite, String name)
{
- Contract.Requires(satellite != null, "satellite shouldn't be null; check caller");
- Contract.Requires(name != null, "name shouldn't be null; check caller");
+ Debug.Assert(satellite != null, "satellite shouldn't be null; check caller");
+ Debug.Assert(name != null, "name shouldn't be null; check caller");
StringBuilder sb = new StringBuilder();
if (_mediator.LocationInfo != null)
diff --git a/src/mscorlib/src/System/Resources/ResourceManager.cs b/src/mscorlib/src/System/Resources/ResourceManager.cs
index 7c565adbbb..0e9780169a 100644
--- a/src/mscorlib/src/System/Resources/ResourceManager.cs
+++ b/src/mscorlib/src/System/Resources/ResourceManager.cs
@@ -31,7 +31,6 @@ namespace System.Resources
using System.Collections.Generic;
using System.Runtime.Versioning;
using System.Diagnostics;
- using System.Diagnostics.Contracts;
#if FEATURE_APPX
//
@@ -281,7 +280,6 @@ namespace System.Resources
throw new ArgumentNullException(nameof(baseName));
if (null == resourceDir)
throw new ArgumentNullException(nameof(resourceDir));
- Contract.EndContractBlock();
BaseNameField = baseName;
@@ -306,7 +304,6 @@ namespace System.Resources
if (null == assembly)
throw new ArgumentNullException(nameof(assembly));
- Contract.EndContractBlock();
if (!(assembly is RuntimeAssembly))
throw new ArgumentException(SR.Argument_MustBeRuntimeAssembly);
@@ -336,7 +333,6 @@ namespace System.Resources
throw new ArgumentNullException(nameof(baseName));
if (null == assembly)
throw new ArgumentNullException(nameof(assembly));
- Contract.EndContractBlock();
if (!(assembly is RuntimeAssembly))
throw new ArgumentException(SR.Argument_MustBeRuntimeAssembly);
@@ -363,7 +359,6 @@ namespace System.Resources
{
if (null == resourceSource)
throw new ArgumentNullException(nameof(resourceSource));
- Contract.EndContractBlock();
if (!(resourceSource is RuntimeType))
throw new ArgumentException(SR.Argument_MustBeRuntimeType);
@@ -597,7 +592,6 @@ namespace System.Resources
{
if (null == culture)
throw new ArgumentNullException(nameof(culture));
- Contract.EndContractBlock();
Dictionary<String, ResourceSet> localResourceSets = _resourceSets;
ResourceSet rs;
@@ -756,7 +750,6 @@ namespace System.Resources
{
throw new ArgumentNullException(nameof(a), SR.ArgumentNull_Assembly);
}
- Contract.EndContractBlock();
// Return null. The calling code will use the assembly version instead to avoid potential type
// and library loads caused by CA lookup. NetCF uses the assembly version always.
@@ -1086,7 +1079,6 @@ namespace System.Resources
{
if (null == name)
throw new ArgumentNullException(nameof(name));
- Contract.EndContractBlock();
#if FEATURE_APPX
if (s_IsAppXModel)
@@ -1196,7 +1188,6 @@ namespace System.Resources
{
if (null == name)
throw new ArgumentNullException(nameof(name));
- Contract.EndContractBlock();
#if FEATURE_APPX
if (s_IsAppXModel)
diff --git a/src/mscorlib/src/System/Resources/ResourceReader.cs b/src/mscorlib/src/System/Resources/ResourceReader.cs
index 9734343f92..0658032f7d 100644
--- a/src/mscorlib/src/System/Resources/ResourceReader.cs
+++ b/src/mscorlib/src/System/Resources/ResourceReader.cs
@@ -134,7 +134,6 @@ namespace System.Resources
throw new ArgumentNullException(nameof(stream));
if (!stream.CanRead)
throw new ArgumentException(SR.Argument_StreamNotReadable);
- Contract.EndContractBlock();
_resCache = new Dictionary<String, ResourceLocator>(FastResourceComparer.Default);
_store = new BinaryReader(stream, Encoding.UTF8);
@@ -151,9 +150,9 @@ namespace System.Resources
// and values, coupled to this ResourceReader).
internal ResourceReader(Stream stream, Dictionary<String, ResourceLocator> resCache)
{
- Contract.Requires(stream != null, "Need a stream!");
- Contract.Requires(stream.CanRead, "Stream should be readable!");
- Contract.Requires(resCache != null, "Need a Dictionary!");
+ Debug.Assert(stream != null, "Need a stream!");
+ Debug.Assert(stream.CanRead, "Stream should be readable!");
+ Debug.Assert(resCache != null, "Need a Dictionary!");
_resCache = resCache;
_store = new BinaryReader(stream, Encoding.UTF8);
@@ -420,20 +419,9 @@ namespace System.Resources
String s = null;
char* charPtr = (char*)_ums.PositionPointer;
-#if IA64
- if (((int)charPtr & 1) != 0) {
- char[] destArray = new char[byteLen/2];
- fixed(char* pDest = destArray) {
- Buffer.Memcpy((byte*)pDest, (byte*)charPtr, byteLen);
- }
- s = new String(destArray);
- }
- else {
-#endif //IA64
+
s = new String(charPtr, 0, byteLen / 2);
-#if IA64
- }
-#endif //IA64
+
_ums.Position += byteLen;
dataOffset = _store.ReadInt32();
if (dataOffset < 0 || dataOffset >= _store.BaseStream.Length - _dataSectionOffset)
@@ -1057,7 +1045,6 @@ namespace System.Resources
{
if (resourceName == null)
throw new ArgumentNullException(nameof(resourceName));
- Contract.EndContractBlock();
if (_resCache == null)
throw new InvalidOperationException(SR.ResourceReaderIsClosed);
@@ -1122,7 +1109,7 @@ namespace System.Resources
private String TypeNameFromTypeCode(ResourceTypeCode typeCode)
{
- Contract.Requires(typeCode >= 0, "can't be negative");
+ Debug.Assert(typeCode >= 0, "can't be negative");
if (typeCode < ResourceTypeCode.StartOfUserTypes)
{
Debug.Assert(!String.Equals(typeCode.ToString(), "LastPrimitive"), "Change ResourceTypeCode metadata order so LastPrimitive isn't what Enum.ToString prefers.");
@@ -1181,8 +1168,8 @@ namespace System.Resources
{
get
{
- if (_currentName == ENUM_DONE) throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumEnded));
- if (!_currentIsValid) throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumNotStarted));
+ if (_currentName == ENUM_DONE) throw new InvalidOperationException(SR.InvalidOperation_EnumEnded);
+ if (!_currentIsValid) throw new InvalidOperationException(SR.InvalidOperation_EnumNotStarted);
if (_reader._resCache == null) throw new InvalidOperationException(SR.ResourceReaderIsClosed);
return _reader.AllocateStringForNameIndex(_currentName, out _dataPosition);
@@ -1210,8 +1197,8 @@ namespace System.Resources
{
get
{
- if (_currentName == ENUM_DONE) throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumEnded));
- if (!_currentIsValid) throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumNotStarted));
+ if (_currentName == ENUM_DONE) throw new InvalidOperationException(SR.InvalidOperation_EnumEnded);
+ if (!_currentIsValid) throw new InvalidOperationException(SR.InvalidOperation_EnumNotStarted);
if (_reader._resCache == null) throw new InvalidOperationException(SR.ResourceReaderIsClosed);
String key;
@@ -1248,8 +1235,8 @@ namespace System.Resources
{
get
{
- if (_currentName == ENUM_DONE) throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumEnded));
- if (!_currentIsValid) throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumNotStarted));
+ if (_currentName == ENUM_DONE) throw new InvalidOperationException(SR.InvalidOperation_EnumEnded);
+ if (!_currentIsValid) throw new InvalidOperationException(SR.InvalidOperation_EnumNotStarted);
if (_reader._resCache == null) throw new InvalidOperationException(SR.ResourceReaderIsClosed);
// Consider using _resCache here, eventually, if
diff --git a/src/mscorlib/src/System/Resources/ResourceSet.cs b/src/mscorlib/src/System/Resources/ResourceSet.cs
index deb9763d5d..9e5a72c431 100644
--- a/src/mscorlib/src/System/Resources/ResourceSet.cs
+++ b/src/mscorlib/src/System/Resources/ResourceSet.cs
@@ -16,7 +16,6 @@
using System.Collections;
using System.IO;
using System.Reflection;
-using System.Diagnostics.Contracts;
namespace System.Resources
{
@@ -72,7 +71,6 @@ namespace System.Resources
{
if (reader == null)
throw new ArgumentNullException(nameof(reader));
- Contract.EndContractBlock();
Reader = reader;
CommonInit();
ReadResources();
@@ -229,7 +227,6 @@ namespace System.Resources
{
if (name == null)
throw new ArgumentNullException(nameof(name));
- Contract.EndContractBlock();
Hashtable copyOfTable = Table; // Avoid a race with Dispose
diff --git a/src/mscorlib/src/System/Resources/__FastResourceComparer.cs b/src/mscorlib/src/System/Resources/__FastResourceComparer.cs
index 8bce02abc3..30d935ad53 100644
--- a/src/mscorlib/src/System/Resources/__FastResourceComparer.cs
+++ b/src/mscorlib/src/System/Resources/__FastResourceComparer.cs
@@ -18,7 +18,6 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Resources
{
diff --git a/src/mscorlib/src/System/RtType.cs b/src/mscorlib/src/System/RtType.cs
index 2d70354a48..e5bc0c5293 100644
--- a/src/mscorlib/src/System/RtType.cs
+++ b/src/mscorlib/src/System/RtType.cs
@@ -28,7 +28,6 @@ using System.Runtime.InteropServices;
using DebuggerStepThroughAttribute = System.Diagnostics.DebuggerStepThroughAttribute;
using MdToken = System.Reflection.MetadataToken;
using System.Runtime.Versioning;
-using System.Diagnostics.Contracts;
namespace System
{
@@ -103,7 +102,7 @@ namespace System
{
get
{
- Contract.Requires(index < Count);
+ Debug.Assert(index < Count);
return (_items != null) ? _items[index] : _item;
}
}
@@ -856,8 +855,8 @@ namespace System
private unsafe void PopulateRtFields(Filter filter,
IntPtr* ppFieldHandles, int count, RuntimeType declaringType, ref ListBuilder<RuntimeFieldInfo> list)
{
- Contract.Requires(declaringType != null);
- Contract.Requires(ReflectedType != null);
+ Debug.Assert(declaringType != null);
+ Debug.Assert(ReflectedType != null);
bool needsStaticFieldForGeneric = RuntimeTypeHandle.HasInstantiation(declaringType) && !RuntimeTypeHandle.ContainsGenericVariables(declaringType);
bool isInherited = declaringType != ReflectedType;
@@ -908,8 +907,8 @@ namespace System
private unsafe void PopulateLiteralFields(Filter filter, RuntimeType declaringType, ref ListBuilder<RuntimeFieldInfo> list)
{
- Contract.Requires(declaringType != null);
- Contract.Requires(ReflectedType != null);
+ Debug.Assert(declaringType != null);
+ Debug.Assert(ReflectedType != null);
int tkDeclaringType = RuntimeTypeHandle.GetToken(declaringType);
@@ -1127,7 +1126,7 @@ namespace System
private unsafe RuntimeEventInfo[] PopulateEvents(Filter filter)
{
- Contract.Requires(ReflectedType != null);
+ Debug.Assert(ReflectedType != null);
// Do not create the dictionary if we are filtering the properties by name already
Dictionary<String, RuntimeEventInfo> csEventInfos = filter.CaseSensitive() ? null :
@@ -1219,7 +1218,7 @@ namespace System
private unsafe RuntimePropertyInfo[] PopulateProperties(Filter filter)
{
- Contract.Requires(ReflectedType != null);
+ Debug.Assert(ReflectedType != null);
// m_csMemberInfos can be null at this point. It will be initialized when Insert
// is called in Populate after this returns.
@@ -1761,7 +1760,6 @@ namespace System
{
if (typeName == null)
throw new ArgumentNullException(nameof(typeName));
- Contract.EndContractBlock();
return RuntimeTypeHandle.GetTypeByName(
typeName, throwOnError, ignoreCase, reflectionOnly, ref stackMark, false);
@@ -1975,7 +1973,7 @@ namespace System
return property;
}
- Contract.Assume(false, "Unreachable code");
+ Debug.Fail("Unreachable code");
throw new SystemException();
}
@@ -1991,7 +1989,6 @@ namespace System
{
if (genericArguments == null)
throw new ArgumentNullException();
- Contract.EndContractBlock();
for (int i = 0; i < genericArguments.Length; i++)
{
@@ -2177,8 +2174,8 @@ namespace System
string name, bool prefixLookup)
{
#region Preconditions
- Contract.Requires(memberInfo != null);
- Contract.Requires(name == null || (bindingFlags & BindingFlags.IgnoreCase) == 0 || (name.ToLower(CultureInfo.InvariantCulture).Equals(name)));
+ Debug.Assert(memberInfo != null);
+ Debug.Assert(name == null || (bindingFlags & BindingFlags.IgnoreCase) == 0 || (name.ToLower(CultureInfo.InvariantCulture).Equals(name)));
#endregion
#region Filter by Public & Private
@@ -2259,7 +2256,7 @@ namespace System
private static bool FilterApplyType(
Type type, BindingFlags bindingFlags, string name, bool prefixLookup, string ns)
{
- Contract.Requires((object)type != null);
+ Debug.Assert((object)type != null);
Debug.Assert(type is RuntimeType);
bool isPublic = type.IsNestedPublic || type.IsPublic;
@@ -2294,7 +2291,7 @@ namespace System
private static bool FilterApplyMethodBase(
MethodBase methodBase, BindingFlags methodFlags, BindingFlags bindingFlags, CallingConventions callConv, Type[] argumentTypes)
{
- Contract.Requires(methodBase != null);
+ Debug.Assert(methodBase != null);
bindingFlags ^= BindingFlags.DeclaredOnly;
@@ -2721,7 +2718,6 @@ namespace System
if ((object)ifaceType == null)
throw new ArgumentNullException(nameof(ifaceType));
- Contract.EndContractBlock();
RuntimeType ifaceRtType = ifaceType as RuntimeType;
@@ -2864,7 +2860,6 @@ namespace System
String name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
{
if (name == null) throw new ArgumentNullException();
- Contract.EndContractBlock();
ListBuilder<PropertyInfo> candidates = GetPropertyCandidates(name, bindingAttr, types, false);
@@ -2904,7 +2899,6 @@ namespace System
public override EventInfo GetEvent(String name, BindingFlags bindingAttr)
{
if (name == null) throw new ArgumentNullException();
- Contract.EndContractBlock();
bool ignoreCase;
MemberListType listType;
@@ -2933,7 +2927,6 @@ namespace System
public override FieldInfo GetField(String name, BindingFlags bindingAttr)
{
if (name == null) throw new ArgumentNullException();
- Contract.EndContractBlock();
bool ignoreCase;
MemberListType listType;
@@ -2973,7 +2966,6 @@ namespace System
public override Type GetInterface(String fullname, bool ignoreCase)
{
if (fullname == null) throw new ArgumentNullException();
- Contract.EndContractBlock();
BindingFlags bindingAttr = BindingFlags.Public | BindingFlags.NonPublic;
@@ -3009,7 +3001,6 @@ namespace System
public override Type GetNestedType(String fullname, BindingFlags bindingAttr)
{
if (fullname == null) throw new ArgumentNullException();
- Contract.EndContractBlock();
bool ignoreCase;
bindingAttr &= ~BindingFlags.Static;
@@ -3040,7 +3031,6 @@ namespace System
public override MemberInfo[] GetMember(String name, MemberTypes type, BindingFlags bindingAttr)
{
if (name == null) throw new ArgumentNullException();
- Contract.EndContractBlock();
ListBuilder<MethodInfo> methods = new ListBuilder<MethodInfo>();
ListBuilder<ConstructorInfo> constructors = new ListBuilder<ConstructorInfo>();
@@ -3233,7 +3223,6 @@ namespace System
{
if (!IsGenericParameter)
throw new InvalidOperationException(SR.Arg_NotGenericParameter);
- Contract.EndContractBlock();
IRuntimeMethodInfo declaringMethod = RuntimeTypeHandle.GetDeclaringMethod(this);
@@ -3251,12 +3240,10 @@ namespace System
return RuntimeTypeHandle.IsInstanceOfType(this, o);
}
- [Pure]
public override bool IsSubclassOf(Type type)
{
if ((object)type == null)
throw new ArgumentNullException(nameof(type));
- Contract.EndContractBlock();
RuntimeType rtType = type as RuntimeType;
if (rtType == null)
return false;
@@ -3520,7 +3507,6 @@ namespace System
{
if (!IsGenericParameter)
throw new InvalidOperationException(SR.Arg_NotGenericParameter);
- Contract.EndContractBlock();
GenericParameterAttributes attributes;
@@ -3577,7 +3563,6 @@ namespace System
{
if (!IsEnum)
throw new ArgumentException(SR.Arg_MustBeEnum, "enumType");
- Contract.EndContractBlock();
String[] ret = Enum.InternalGetNames(this);
@@ -3593,7 +3578,6 @@ namespace System
{
if (!IsEnum)
throw new ArgumentException(SR.Arg_MustBeEnum, "enumType");
- Contract.EndContractBlock();
// Get all of the values
ulong[] values = Enum.InternalGetValues(this);
@@ -3614,7 +3598,6 @@ namespace System
{
if (!IsEnum)
throw new ArgumentException(SR.Arg_MustBeEnum, "enumType");
- Contract.EndContractBlock();
return Enum.InternalGetUnderlyingType(this);
}
@@ -3623,7 +3606,6 @@ namespace System
{
if (value == null)
throw new ArgumentNullException(nameof(value));
- Contract.EndContractBlock();
// Check if both of them are of the same type
RuntimeType valueType = (RuntimeType)value.GetType();
@@ -3670,7 +3652,6 @@ namespace System
{
if (value == null)
throw new ArgumentNullException(nameof(value));
- Contract.EndContractBlock();
Type valueType = value.GetType();
@@ -3703,7 +3684,6 @@ namespace System
{
if (instantiation == null)
throw new ArgumentNullException(nameof(instantiation));
- Contract.EndContractBlock();
RuntimeType[] instantiationRuntimeType = new RuntimeType[instantiation.Length];
@@ -3778,7 +3758,6 @@ namespace System
{
if (!IsGenericParameter)
throw new InvalidOperationException(SR.Arg_NotGenericParameter);
- Contract.EndContractBlock();
return new RuntimeTypeHandle(this).GetGenericVariableIndex();
}
@@ -3788,7 +3767,6 @@ namespace System
{
if (!IsGenericType)
throw new InvalidOperationException(SR.InvalidOperation_NotGenericType);
- Contract.EndContractBlock();
return RuntimeTypeHandle.GetGenericTypeDefinition(this);
}
@@ -3812,7 +3790,6 @@ namespace System
{
if (!IsGenericParameter)
throw new InvalidOperationException(SR.Arg_NotGenericParameter);
- Contract.EndContractBlock();
Type[] constraints = new RuntimeTypeHandle(this).GetConstraints();
@@ -3838,7 +3815,6 @@ namespace System
{
if (rank <= 0)
throw new IndexOutOfRangeException();
- Contract.EndContractBlock();
return new RuntimeTypeHandle(this).MakeArray(rank);
}
@@ -4007,7 +3983,6 @@ namespace System
{
if (IsGenericParameter)
throw new InvalidOperationException(SR.Arg_GenericParameter);
- Contract.EndContractBlock();
#region Preconditions
if ((bindingFlags & InvocationMask) == 0)
@@ -4455,7 +4430,6 @@ namespace System
#endregion
#region Object Overrides
- [Pure]
public override bool Equals(object obj)
{
// ComObjects are identified by the instance of the Type object and not the TypeHandle.
@@ -4490,7 +4464,6 @@ namespace System
{
if ((object)attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
@@ -4504,7 +4477,6 @@ namespace System
{
if ((object)attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
@@ -4617,7 +4589,6 @@ namespace System
if (ContainsGenericParameters)
throw new ArgumentException(
SR.Format(SR.Acc_CreateGenericEx, this));
- Contract.EndContractBlock();
Type elementType = this.GetRootElementType();
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs b/src/mscorlib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs
index e81823eb16..e8e0d60202 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs
@@ -10,17 +10,10 @@
//
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-using System;
-using System.Collections.Concurrent;
-using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-using System.Diagnostics.Contracts;
using System.Runtime.ExceptionServices;
-using System.Security;
using System.Threading;
using System.Threading.Tasks;
-
#if FEATURE_COMINTEROP
using System.Runtime.InteropServices.WindowsRuntime;
#endif // FEATURE_COMINTEROP
@@ -34,23 +27,17 @@ namespace System.Runtime.CompilerServices
public struct AsyncVoidMethodBuilder
{
/// <summary>The synchronization context associated with this operation.</summary>
- private SynchronizationContext m_synchronizationContext;
- /// <summary>State related to the IAsyncStateMachine.</summary>
- private AsyncMethodBuilderCore m_coreState; // mutable struct: must not be readonly
- /// <summary>Task used for debugging and logging purposes only. Lazily initialized.</summary>
- private Task m_task;
+ private SynchronizationContext _synchronizationContext;
+ /// <summary>The builder this void builder wraps.</summary>
+ private AsyncTaskMethodBuilder _builder; // mutable struct: must not be readonly
/// <summary>Initializes a new <see cref="AsyncVoidMethodBuilder"/>.</summary>
/// <returns>The initialized <see cref="AsyncVoidMethodBuilder"/>.</returns>
public static AsyncVoidMethodBuilder Create()
{
- // Capture the current sync context. If there isn't one, use the dummy s_noContextCaptured
- // instance; this allows us to tell the state of no captured context apart from the state
- // of an improperly constructed builder instance.
SynchronizationContext sc = SynchronizationContext.CurrentNoFlow;
- if (sc != null)
- sc.OperationStarted();
- return new AsyncVoidMethodBuilder() { m_synchronizationContext = sc };
+ sc?.OperationStarted();
+ return new AsyncVoidMethodBuilder() { _synchronizationContext = sc };
}
/// <summary>Initiates the builder's execution with the associated state machine.</summary>
@@ -58,39 +45,15 @@ namespace System.Runtime.CompilerServices
/// <param name="stateMachine">The state machine instance, passed by reference.</param>
/// <exception cref="System.ArgumentNullException">The <paramref name="stateMachine"/> argument was null (Nothing in Visual Basic).</exception>
[DebuggerStepThrough]
- public void Start<TStateMachine>(ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine
- {
- // See comment on AsyncMethodBuilderCore.Start
- // AsyncMethodBuilderCore.Start(ref stateMachine);
-
- if (stateMachine == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.stateMachine);
- Contract.EndContractBlock();
-
- // Run the MoveNext method within a copy-on-write ExecutionContext scope.
- // This allows us to undo any ExecutionContext changes made in MoveNext,
- // so that they won't "leak" out of the first await.
-
- Thread currentThread = Thread.CurrentThread;
- ExecutionContextSwitcher ecs = default(ExecutionContextSwitcher);
- try
- {
- ExecutionContext.EstablishCopyOnWriteScope(currentThread, ref ecs);
- stateMachine.MoveNext();
- }
- finally
- {
- ecs.Undo(currentThread);
- }
- }
+ public void Start<TStateMachine>(ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine =>
+ _builder.Start(ref stateMachine);
/// <summary>Associates the builder with the state machine it represents.</summary>
/// <param name="stateMachine">The heap-allocated state machine object.</param>
/// <exception cref="System.ArgumentNullException">The <paramref name="stateMachine"/> argument was null (Nothing in Visual Basic).</exception>
/// <exception cref="System.InvalidOperationException">The builder is incorrectly initialized.</exception>
- public void SetStateMachine(IAsyncStateMachine stateMachine)
- {
- m_coreState.SetStateMachine(stateMachine); // argument validation handled by AsyncMethodBuilderCore
- }
+ public void SetStateMachine(IAsyncStateMachine stateMachine) =>
+ _builder.SetStateMachine(stateMachine);
/// <summary>
/// Schedules the specified state machine to be pushed forward when the specified awaiter completes.
@@ -102,41 +65,8 @@ namespace System.Runtime.CompilerServices
public void AwaitOnCompleted<TAwaiter, TStateMachine>(
ref TAwaiter awaiter, ref TStateMachine stateMachine)
where TAwaiter : INotifyCompletion
- where TStateMachine : IAsyncStateMachine
- {
- try
- {
- AsyncMethodBuilderCore.MoveNextRunner runnerToInitialize = null;
- var continuation = m_coreState.GetCompletionAction(AsyncCausalityTracer.LoggingOn ? this.Task : null, ref runnerToInitialize);
- Debug.Assert(continuation != null, "GetCompletionAction should always return a valid action.");
-
- // If this is our first await, such that we've not yet boxed the state machine, do so now.
- if (m_coreState.m_stateMachine == null)
- {
- if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCreation(CausalityTraceLevel.Required, this.Task.Id, "Async: " + stateMachine.GetType().Name, 0);
-
- // Box the state machine, then tell the boxed instance to call back into its own builder,
- // so we can cache the boxed reference. NOTE: The language compiler may choose to use
- // a class instead of a struct for the state machine for debugging purposes; in such cases,
- // the stateMachine will already be an object.
- m_coreState.PostBoxInitialization(stateMachine, runnerToInitialize, null);
- }
-
- awaiter.OnCompleted(continuation);
- }
- catch (Exception exc)
- {
- // Prevent exceptions from leaking to the call site, which could
- // then allow multiple flows of execution through the same async method
- // if the awaiter had already scheduled the continuation by the time
- // the exception was thrown. We propagate the exception on the
- // ThreadPool because we can trust it to not throw, unlike
- // if we were to go to a user-supplied SynchronizationContext,
- // whose Post method could easily throw.
- AsyncMethodBuilderCore.ThrowAsync(exc, targetContext: null);
- }
- }
+ where TStateMachine : IAsyncStateMachine =>
+ _builder.AwaitOnCompleted(ref awaiter, ref stateMachine);
/// <summary>
/// Schedules the specified state machine to be pushed forward when the specified awaiter completes.
@@ -148,45 +78,23 @@ namespace System.Runtime.CompilerServices
public void AwaitUnsafeOnCompleted<TAwaiter, TStateMachine>(
ref TAwaiter awaiter, ref TStateMachine stateMachine)
where TAwaiter : ICriticalNotifyCompletion
- where TStateMachine : IAsyncStateMachine
- {
- try
- {
- AsyncMethodBuilderCore.MoveNextRunner runnerToInitialize = null;
- var continuation = m_coreState.GetCompletionAction(AsyncCausalityTracer.LoggingOn ? this.Task : null, ref runnerToInitialize);
- Debug.Assert(continuation != null, "GetCompletionAction should always return a valid action.");
-
- // If this is our first await, such that we've not yet boxed the state machine, do so now.
- if (m_coreState.m_stateMachine == null)
- {
- if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCreation(CausalityTraceLevel.Required, this.Task.Id, "Async: " + stateMachine.GetType().Name, 0);
-
- // Box the state machine, then tell the boxed instance to call back into its own builder,
- // so we can cache the boxed reference. NOTE: The language compiler may choose to use
- // a class instead of a struct for the state machine for debugging purposes; in such cases,
- // the stateMachine will already be an object.
- m_coreState.PostBoxInitialization(stateMachine, runnerToInitialize, null);
- }
-
- awaiter.UnsafeOnCompleted(continuation);
- }
- catch (Exception e)
- {
- AsyncMethodBuilderCore.ThrowAsync(e, targetContext: null);
- }
- }
+ where TStateMachine : IAsyncStateMachine =>
+ _builder.AwaitUnsafeOnCompleted(ref awaiter, ref stateMachine);
/// <summary>Completes the method builder successfully.</summary>
public void SetResult()
{
if (AsyncCausalityTracer.LoggingOn)
+ {
AsyncCausalityTracer.TraceOperationCompletion(CausalityTraceLevel.Required, this.Task.Id, AsyncCausalityStatus.Completed);
+ }
- if (m_synchronizationContext != null)
+ if (_synchronizationContext != null)
{
NotifySynchronizationContextOfCompletion();
}
+
+ // No need to call _builder.SetResult, as no one pays attention to the task's completion.
}
/// <summary>Faults the method builder with an exception.</summary>
@@ -195,19 +103,23 @@ namespace System.Runtime.CompilerServices
/// <exception cref="System.InvalidOperationException">The builder is not initialized.</exception>
public void SetException(Exception exception)
{
- if (exception == null) throw new ArgumentNullException(nameof(exception));
- Contract.EndContractBlock();
+ if (exception == null)
+ {
+ ThrowHelper.ThrowArgumentNullException(ExceptionArgument.exception);
+ }
if (AsyncCausalityTracer.LoggingOn)
+ {
AsyncCausalityTracer.TraceOperationCompletion(CausalityTraceLevel.Required, this.Task.Id, AsyncCausalityStatus.Error);
+ }
- if (m_synchronizationContext != null)
+ if (_synchronizationContext != null)
{
// If we captured a synchronization context, Post the throwing of the exception to it
// and decrement its outstanding operation count.
try
{
- AsyncMethodBuilderCore.ThrowAsync(exception, targetContext: m_synchronizationContext);
+ AsyncMethodBuilderCore.ThrowAsync(exception, targetContext: _synchronizationContext);
}
finally
{
@@ -221,15 +133,17 @@ namespace System.Runtime.CompilerServices
// file or a CLR host.
AsyncMethodBuilderCore.ThrowAsync(exception, targetContext: null);
}
+
+ // No need to call _builder.SetException, as no one pays attention to the task's completion.
}
/// <summary>Notifies the current synchronization context that the operation completed.</summary>
private void NotifySynchronizationContextOfCompletion()
{
- Debug.Assert(m_synchronizationContext != null, "Must only be used with a non-null context.");
+ Debug.Assert(_synchronizationContext != null, "Must only be used with a non-null context.");
try
{
- m_synchronizationContext.OperationCompleted();
+ _synchronizationContext.OperationCompleted();
}
catch (Exception exc)
{
@@ -240,7 +154,7 @@ namespace System.Runtime.CompilerServices
}
/// <summary>Lazily instantiate the Task in a non-thread-safe manner.</summary>
- private Task Task => m_task ?? (m_task = new Task());
+ private Task Task => _builder.Task;
/// <summary>
/// Gets an object that may be used to uniquely identify this builder to the debugger.
@@ -249,7 +163,7 @@ namespace System.Runtime.CompilerServices
/// This property lazily instantiates the ID in a non-thread-safe manner.
/// It must only be used by the debugger and AsyncCausalityTracer in a single-threaded manner.
/// </remarks>
- private object ObjectIdForDebugger { get { return this.Task; } }
+ internal object ObjectIdForDebugger => _builder.ObjectIdForDebugger;
}
/// <summary>
@@ -267,54 +181,25 @@ namespace System.Runtime.CompilerServices
private readonly static Task<VoidTaskResult> s_cachedCompleted = AsyncTaskMethodBuilder<VoidTaskResult>.s_defaultResultTask;
/// <summary>The generic builder object to which this non-generic instance delegates.</summary>
- private AsyncTaskMethodBuilder<VoidTaskResult> m_builder; // mutable struct: must not be readonly
+ private AsyncTaskMethodBuilder<VoidTaskResult> m_builder; // mutable struct: must not be readonly. Debugger depends on the exact name of this field.
/// <summary>Initializes a new <see cref="AsyncTaskMethodBuilder"/>.</summary>
/// <returns>The initialized <see cref="AsyncTaskMethodBuilder"/>.</returns>
- public static AsyncTaskMethodBuilder Create()
- {
- return default(AsyncTaskMethodBuilder);
- // Note: If ATMB<T>.Create is modified to do any initialization, this
- // method needs to be updated to do m_builder = ATMB<T>.Create().
- }
+ public static AsyncTaskMethodBuilder Create() => default(AsyncTaskMethodBuilder);
/// <summary>Initiates the builder's execution with the associated state machine.</summary>
/// <typeparam name="TStateMachine">Specifies the type of the state machine.</typeparam>
/// <param name="stateMachine">The state machine instance, passed by reference.</param>
[DebuggerStepThrough]
- public void Start<TStateMachine>(ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine
- {
- // See comment on AsyncMethodBuilderCore.Start
- // AsyncMethodBuilderCore.Start(ref stateMachine);
-
- if (stateMachine == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.stateMachine);
- Contract.EndContractBlock();
-
- // Run the MoveNext method within a copy-on-write ExecutionContext scope.
- // This allows us to undo any ExecutionContext changes made in MoveNext,
- // so that they won't "leak" out of the first await.
-
- Thread currentThread = Thread.CurrentThread;
- ExecutionContextSwitcher ecs = default(ExecutionContextSwitcher);
- try
- {
- ExecutionContext.EstablishCopyOnWriteScope(currentThread, ref ecs);
- stateMachine.MoveNext();
- }
- finally
- {
- ecs.Undo(currentThread);
- }
- }
+ public void Start<TStateMachine>(ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine =>
+ m_builder.Start(ref stateMachine);
/// <summary>Associates the builder with the state machine it represents.</summary>
/// <param name="stateMachine">The heap-allocated state machine object.</param>
/// <exception cref="System.ArgumentNullException">The <paramref name="stateMachine"/> argument was null (Nothing in Visual Basic).</exception>
/// <exception cref="System.InvalidOperationException">The builder is incorrectly initialized.</exception>
- public void SetStateMachine(IAsyncStateMachine stateMachine)
- {
- m_builder.SetStateMachine(stateMachine); // argument validation handled by AsyncMethodBuilderCore
- }
+ public void SetStateMachine(IAsyncStateMachine stateMachine) =>
+ m_builder.SetStateMachine(stateMachine);
/// <summary>
/// Schedules the specified state machine to be pushed forward when the specified awaiter completes.
@@ -326,10 +211,8 @@ namespace System.Runtime.CompilerServices
public void AwaitOnCompleted<TAwaiter, TStateMachine>(
ref TAwaiter awaiter, ref TStateMachine stateMachine)
where TAwaiter : INotifyCompletion
- where TStateMachine : IAsyncStateMachine
- {
- m_builder.AwaitOnCompleted<TAwaiter, TStateMachine>(ref awaiter, ref stateMachine);
- }
+ where TStateMachine : IAsyncStateMachine =>
+ m_builder.AwaitOnCompleted(ref awaiter, ref stateMachine);
/// <summary>
/// Schedules the specified state machine to be pushed forward when the specified awaiter completes.
@@ -341,10 +224,8 @@ namespace System.Runtime.CompilerServices
public void AwaitUnsafeOnCompleted<TAwaiter, TStateMachine>(
ref TAwaiter awaiter, ref TStateMachine stateMachine)
where TAwaiter : ICriticalNotifyCompletion
- where TStateMachine : IAsyncStateMachine
- {
- m_builder.AwaitUnsafeOnCompleted<TAwaiter, TStateMachine>(ref awaiter, ref stateMachine);
- }
+ where TStateMachine : IAsyncStateMachine =>
+ m_builder.AwaitUnsafeOnCompleted(ref awaiter, ref stateMachine);
/// <summary>Gets the <see cref="System.Threading.Tasks.Task"/> for this builder.</summary>
/// <returns>The <see cref="System.Threading.Tasks.Task"/> representing the builder's asynchronous operation.</returns>
@@ -352,7 +233,7 @@ namespace System.Runtime.CompilerServices
public Task Task
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- get { return m_builder.Task; }
+ get => m_builder.Task;
}
/// <summary>
@@ -361,12 +242,7 @@ namespace System.Runtime.CompilerServices
/// </summary>
/// <exception cref="System.InvalidOperationException">The builder is not initialized.</exception>
/// <exception cref="System.InvalidOperationException">The task has already completed.</exception>
- public void SetResult()
- {
- // Accessing AsyncTaskMethodBuilder.s_cachedCompleted is faster than
- // accessing AsyncTaskMethodBuilder<T>.s_defaultResultTask.
- m_builder.SetResult(s_cachedCompleted);
- }
+ public void SetResult() => m_builder.SetResult(s_cachedCompleted); // Using s_cachedCompleted is faster than using s_defaultResultTask.
/// <summary>
/// Completes the <see cref="System.Threading.Tasks.Task"/> in the
@@ -376,7 +252,7 @@ namespace System.Runtime.CompilerServices
/// <exception cref="System.ArgumentNullException">The <paramref name="exception"/> argument is null (Nothing in Visual Basic).</exception>
/// <exception cref="System.InvalidOperationException">The builder is not initialized.</exception>
/// <exception cref="System.InvalidOperationException">The task has already completed.</exception>
- public void SetException(Exception exception) { m_builder.SetException(exception); }
+ public void SetException(Exception exception) => m_builder.SetException(exception);
/// <summary>
/// Called by the debugger to request notification when the first wait operation
@@ -385,10 +261,7 @@ namespace System.Runtime.CompilerServices
/// <param name="enabled">
/// true to enable notification; false to disable a previously set notification.
/// </param>
- internal void SetNotificationForWaitCompletion(bool enabled)
- {
- m_builder.SetNotificationForWaitCompletion(enabled);
- }
+ internal void SetNotificationForWaitCompletion(bool enabled) => m_builder.SetNotificationForWaitCompletion(enabled);
/// <summary>
/// Gets an object that may be used to uniquely identify this builder to the debugger.
@@ -398,7 +271,7 @@ namespace System.Runtime.CompilerServices
/// It must only be used by the debugger and tracing purposes, and only in a single-threaded manner
/// when no other threads are in the middle of accessing this property or this.Task.
/// </remarks>
- private object ObjectIdForDebugger { get { return this.Task; } }
+ internal object ObjectIdForDebugger => m_builder.ObjectIdForDebugger;
}
/// <summary>
@@ -415,16 +288,8 @@ namespace System.Runtime.CompilerServices
/// <summary>A cached task for default(TResult).</summary>
internal readonly static Task<TResult> s_defaultResultTask = AsyncTaskCache.CreateCacheableTask(default(TResult));
- // WARNING: For performance reasons, the m_task field is lazily initialized.
- // For correct results, the struct AsyncTaskMethodBuilder<TResult> must
- // always be used from the same location/copy, at least until m_task is
- // initialized. If that guarantee is broken, the field could end up being
- // initialized on the wrong copy.
-
- /// <summary>State related to the IAsyncStateMachine.</summary>
- private AsyncMethodBuilderCore m_coreState; // mutable struct: must not be readonly
/// <summary>The lazily-initialized built task.</summary>
- private Task<TResult> m_task; // lazily-initialized: must not be readonly
+ private Task<TResult> m_task; // lazily-initialized: must not be readonly. Debugger depends on the exact name of this field.
/// <summary>Initializes a new <see cref="AsyncTaskMethodBuilder"/>.</summary>
/// <returns>The initialized <see cref="AsyncTaskMethodBuilder"/>.</returns>
@@ -442,11 +307,10 @@ namespace System.Runtime.CompilerServices
[DebuggerStepThrough]
public void Start<TStateMachine>(ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine
{
- // See comment on AsyncMethodBuilderCore.Start
- // AsyncMethodBuilderCore.Start(ref stateMachine);
-
- if (stateMachine == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.stateMachine);
- Contract.EndContractBlock();
+ if (stateMachine == null) // TStateMachines are generally non-nullable value types, so this check will be elided
+ {
+ ThrowHelper.ThrowArgumentNullException(ExceptionArgument.stateMachine);
+ }
// Run the MoveNext method within a copy-on-write ExecutionContext scope.
// This allows us to undo any ExecutionContext changes made in MoveNext,
@@ -471,7 +335,20 @@ namespace System.Runtime.CompilerServices
/// <exception cref="System.InvalidOperationException">The builder is incorrectly initialized.</exception>
public void SetStateMachine(IAsyncStateMachine stateMachine)
{
- m_coreState.SetStateMachine(stateMachine); // argument validation handled by AsyncMethodBuilderCore
+ if (stateMachine == null)
+ {
+ ThrowHelper.ThrowArgumentNullException(ExceptionArgument.stateMachine);
+ }
+
+ if (m_task != null)
+ {
+ ThrowHelper.ThrowInvalidOperationException(ExceptionResource.AsyncMethodBuilder_InstanceNotInitialized);
+ }
+
+ // SetStateMachine was originally needed in order to store the boxed state machine reference into
+ // the boxed copy. Now that a normal box is no longer used, SetStateMachine is also legacy. We need not
+ // do anything here, and thus assert to ensure we're not calling this from our own implementations.
+ Debug.Fail("SetStateMachine should not be used.");
}
/// <summary>
@@ -488,25 +365,7 @@ namespace System.Runtime.CompilerServices
{
try
{
- AsyncMethodBuilderCore.MoveNextRunner runnerToInitialize = null;
- var continuation = m_coreState.GetCompletionAction(AsyncCausalityTracer.LoggingOn ? this.Task : null, ref runnerToInitialize);
- Debug.Assert(continuation != null, "GetCompletionAction should always return a valid action.");
-
- // If this is our first await, such that we've not yet boxed the state machine, do so now.
- if (m_coreState.m_stateMachine == null)
- {
- // Force the Task to be initialized prior to the first suspending await so
- // that the original stack-based builder has a reference to the right Task.
- Task builtTask = this.Task;
-
- // Box the state machine, then tell the boxed instance to call back into its own builder,
- // so we can cache the boxed reference. NOTE: The language compiler may choose to use
- // a class instead of a struct for the state machine for debugging purposes; in such cases,
- // the stateMachine will already be an object.
- m_coreState.PostBoxInitialization(stateMachine, runnerToInitialize, builtTask);
- }
-
- awaiter.OnCompleted(continuation);
+ awaiter.OnCompleted(GetStateMachineBox(ref stateMachine).MoveNextAction);
}
catch (Exception e)
{
@@ -526,32 +385,231 @@ namespace System.Runtime.CompilerServices
where TAwaiter : ICriticalNotifyCompletion
where TStateMachine : IAsyncStateMachine
{
+ IAsyncStateMachineBox box = GetStateMachineBox(ref stateMachine);
+
+ // TODO https://github.com/dotnet/coreclr/issues/12877:
+ // Once the JIT is able to recognize "awaiter is ITaskAwaiter" and "awaiter is IConfiguredTaskAwaiter",
+ // use those in order to a) consolidate a lot of this code, and b) handle all Task/Task<T> and not just
+ // the few types special-cased here. For now, handle common {Configured}TaskAwaiter. Having the types
+ // explicitly listed here allows the JIT to generate the best code for them; otherwise we'll fall through
+ // to the later workaround.
+ if (typeof(TAwaiter) == typeof(TaskAwaiter) ||
+ typeof(TAwaiter) == typeof(TaskAwaiter<object>) ||
+ typeof(TAwaiter) == typeof(TaskAwaiter<string>) ||
+ typeof(TAwaiter) == typeof(TaskAwaiter<byte[]>) ||
+ typeof(TAwaiter) == typeof(TaskAwaiter<bool>) ||
+ typeof(TAwaiter) == typeof(TaskAwaiter<byte>) ||
+ typeof(TAwaiter) == typeof(TaskAwaiter<int>) ||
+ typeof(TAwaiter) == typeof(TaskAwaiter<long>))
+ {
+ ref TaskAwaiter ta = ref Unsafe.As<TAwaiter, TaskAwaiter>(ref awaiter); // relies on TaskAwaiter/TaskAwaiter<T> having the same layout
+ TaskAwaiter.UnsafeOnCompletedInternal(ta.m_task, box, continueOnCapturedContext: true);
+ }
+ else if (
+ typeof(TAwaiter) == typeof(ConfiguredTaskAwaitable.ConfiguredTaskAwaiter) ||
+ typeof(TAwaiter) == typeof(ConfiguredTaskAwaitable<object>.ConfiguredTaskAwaiter) ||
+ typeof(TAwaiter) == typeof(ConfiguredTaskAwaitable<string>.ConfiguredTaskAwaiter) ||
+ typeof(TAwaiter) == typeof(ConfiguredTaskAwaitable<byte[]>.ConfiguredTaskAwaiter) ||
+ typeof(TAwaiter) == typeof(ConfiguredTaskAwaitable<bool>.ConfiguredTaskAwaiter) ||
+ typeof(TAwaiter) == typeof(ConfiguredTaskAwaitable<byte>.ConfiguredTaskAwaiter) ||
+ typeof(TAwaiter) == typeof(ConfiguredTaskAwaitable<int>.ConfiguredTaskAwaiter) ||
+ typeof(TAwaiter) == typeof(ConfiguredTaskAwaitable<long>.ConfiguredTaskAwaiter))
+ {
+ ref ConfiguredTaskAwaitable.ConfiguredTaskAwaiter ta = ref Unsafe.As<TAwaiter, ConfiguredTaskAwaitable.ConfiguredTaskAwaiter>(ref awaiter);
+ TaskAwaiter.UnsafeOnCompletedInternal(ta.m_task, box, ta.m_continueOnCapturedContext);
+ }
+
+ // Handle common {Configured}ValueTaskAwaiter<T> types. Unfortunately these need to be special-cased
+ // individually, as we don't have good way to extract the task from a ValueTaskAwaiter<T> when we don't
+ // know what the T is; we could make ValueTaskAwaiter<T> implement an IValueTaskAwaiter interface, but
+ // calling a GetTask method on that would end up boxing the awaiter. This hard-coded list here is
+ // somewhat arbitrary and is based on types currently in use with ValueTask<T> in coreclr/corefx.
+ else if (typeof(TAwaiter) == typeof(ValueTaskAwaiter<int>))
+ {
+ var vta = (ValueTaskAwaiter<int>)(object)awaiter;
+ TaskAwaiter.UnsafeOnCompletedInternal(vta.AsTask(), box, continueOnCapturedContext: true);
+ }
+ else if (typeof(TAwaiter) == typeof(ConfiguredValueTaskAwaitable<int>.ConfiguredValueTaskAwaiter))
+ {
+ var vta = (ConfiguredValueTaskAwaitable<int>.ConfiguredValueTaskAwaiter)(object)awaiter;
+ TaskAwaiter.UnsafeOnCompletedInternal(vta.AsTask(), box, vta._continueOnCapturedContext);
+ }
+ else if (typeof(TAwaiter) == typeof(ConfiguredValueTaskAwaitable<System.IO.Stream>.ConfiguredValueTaskAwaiter))
+ {
+ var vta = (ConfiguredValueTaskAwaitable<System.IO.Stream>.ConfiguredValueTaskAwaiter)(object)awaiter;
+ TaskAwaiter.UnsafeOnCompletedInternal(vta.AsTask(), box, vta._continueOnCapturedContext);
+ }
+ else if (typeof(TAwaiter) == typeof(ConfiguredValueTaskAwaitable<ArraySegment<byte>>.ConfiguredValueTaskAwaiter))
+ {
+ var vta = (ConfiguredValueTaskAwaitable<ArraySegment<byte>>.ConfiguredValueTaskAwaiter)(object)awaiter;
+ TaskAwaiter.UnsafeOnCompletedInternal(vta.AsTask(), box, vta._continueOnCapturedContext);
+ }
+ else if (typeof(TAwaiter) == typeof(ConfiguredValueTaskAwaitable<object>.ConfiguredValueTaskAwaiter))
+ {
+ var vta = (ConfiguredValueTaskAwaitable<object>.ConfiguredValueTaskAwaiter)(object)awaiter;
+ TaskAwaiter.UnsafeOnCompletedInternal(vta.AsTask(), box, vta._continueOnCapturedContext);
+ }
+
+ // To catch all Task/Task<T> awaits, do the currently more expensive interface checks.
+ // Eventually these and the above Task/Task<T> checks should be replaced by "is" checks,
+ // once that's recognized and optimized by the JIT. We do these after all of the hardcoded
+ // checks above so that they don't incur the costs of these checks.
+ else if (InterfaceIsCheckWorkaround<TAwaiter>.IsITaskAwaiter)
+ {
+ ref TaskAwaiter ta = ref Unsafe.As<TAwaiter, TaskAwaiter>(ref awaiter);
+ TaskAwaiter.UnsafeOnCompletedInternal(ta.m_task, box, continueOnCapturedContext: true);
+ }
+ else if (InterfaceIsCheckWorkaround<TAwaiter>.IsIConfiguredTaskAwaiter)
+ {
+ ref ConfiguredTaskAwaitable.ConfiguredTaskAwaiter ta = ref Unsafe.As<TAwaiter, ConfiguredTaskAwaitable.ConfiguredTaskAwaiter>(ref awaiter);
+ TaskAwaiter.UnsafeOnCompletedInternal(ta.m_task, box, ta.m_continueOnCapturedContext);
+ }
+
+ // The awaiter isn't specially known. Fall back to doing a normal await.
+ else
+ {
+ // TODO https://github.com/dotnet/coreclr/issues/14177:
+ // Move the code back into this method once the JIT is able to
+ // elide it successfully when one of the previous branches is hit.
+ AwaitArbitraryAwaiterUnsafeOnCompleted(ref awaiter, box);
+ }
+ }
+
+ /// <summary>Schedules the specified state machine to be pushed forward when the specified awaiter completes.</summary>
+ /// <typeparam name="TAwaiter">Specifies the type of the awaiter.</typeparam>
+ /// <param name="awaiter">The awaiter.</param>
+ /// <param name="box">The state machine box.</param>
+ private static void AwaitArbitraryAwaiterUnsafeOnCompleted<TAwaiter>(ref TAwaiter awaiter, IAsyncStateMachineBox box)
+ where TAwaiter : ICriticalNotifyCompletion
+ {
try
{
- AsyncMethodBuilderCore.MoveNextRunner runnerToInitialize = null;
- var continuation = m_coreState.GetCompletionAction(AsyncCausalityTracer.LoggingOn ? this.Task : null, ref runnerToInitialize);
- Debug.Assert(continuation != null, "GetCompletionAction should always return a valid action.");
+ awaiter.UnsafeOnCompleted(box.MoveNextAction);
+ }
+ catch (Exception e)
+ {
+ AsyncMethodBuilderCore.ThrowAsync(e, targetContext: null);
+ }
+ }
- // If this is our first await, such that we've not yet boxed the state machine, do so now.
- if (m_coreState.m_stateMachine == null)
+ /// <summary>Gets the "boxed" state machine object.</summary>
+ /// <typeparam name="TStateMachine">Specifies the type of the async state machine.</typeparam>
+ /// <param name="stateMachine">The state machine.</param>
+ /// <returns>The "boxed" state machine.</returns>
+ private IAsyncStateMachineBox GetStateMachineBox<TStateMachine>(
+ ref TStateMachine stateMachine)
+ where TStateMachine : IAsyncStateMachine
+ {
+ ExecutionContext currentContext = ExecutionContext.Capture();
+
+ // Check first for the most common case: not the first yield in an async method.
+ // In this case, the first yield will have already "boxed" the state machine in
+ // a strongly-typed manner into an AsyncStateMachineBox. It will already contain
+ // the state machine as well as a MoveNextDelegate and a context. The only thing
+ // we might need to do is update the context if that's changed since it was stored.
+ if (m_task is AsyncStateMachineBox<TStateMachine> stronglyTypedBox)
+ {
+ if (stronglyTypedBox.Context != currentContext)
{
- // Force the Task to be initialized prior to the first suspending await so
- // that the original stack-based builder has a reference to the right Task.
- Task<TResult> builtTask = this.Task;
-
- // Box the state machine, then tell the boxed instance to call back into its own builder,
- // so we can cache the boxed reference. NOTE: The language compiler may choose to use
- // a class instead of a struct for the state machine for debugging purposes; in such cases,
- // the stateMachine will already be an object.
- m_coreState.PostBoxInitialization(stateMachine, runnerToInitialize, builtTask);
+ stronglyTypedBox.Context = currentContext;
+ }
+ return stronglyTypedBox;
+ }
+
+ // The least common case: we have a weakly-typed boxed. This results if the debugger
+ // or some other use of reflection accesses a property like ObjectIdForDebugger or a
+ // method like SetNotificationForWaitCompletion prior to the first await happening. In
+ // such situations, we need to get an object to represent the builder, but we don't yet
+ // know the type of the state machine, and thus can't use TStateMachine. Instead, we
+ // use the IAsyncStateMachine interface, which all TStateMachines implement. This will
+ // result in a boxing allocation when storing the TStateMachine if it's a struct, but
+ // this only happens in active debugging scenarios where such performance impact doesn't
+ // matter.
+ if (m_task is AsyncStateMachineBox<IAsyncStateMachine> weaklyTypedBox)
+ {
+ // If this is the first await, we won't yet have a state machine, so store it.
+ if (weaklyTypedBox.StateMachine == null)
+ {
+ Debugger.NotifyOfCrossThreadDependency(); // same explanation as with usage below
+ weaklyTypedBox.StateMachine = stateMachine;
}
- awaiter.UnsafeOnCompleted(continuation);
+ // Update the context. This only happens with a debugger, so no need to spend
+ // extra IL checking for equality before doing the assignment.
+ weaklyTypedBox.Context = currentContext;
+ return weaklyTypedBox;
}
- catch (Exception e)
+
+ // Alert a listening debugger that we can't make forward progress unless it slips threads.
+ // If we don't do this, and a method that uses "await foo;" is invoked through funceval,
+ // we could end up hooking up a callback to push forward the async method's state machine,
+ // the debugger would then abort the funceval after it takes too long, and then continuing
+ // execution could result in another callback being hooked up. At that point we have
+ // multiple callbacks registered to push the state machine, which could result in bad behavior.
+ Debugger.NotifyOfCrossThreadDependency();
+
+ // At this point, m_task should really be null, in which case we want to create the box.
+ // However, in a variety of debugger-related (erroneous) situations, it might be non-null,
+ // e.g. if the Task property is examined in a Watch window, forcing it to be lazily-intialized
+ // as a Task<TResult> rather than as an AsyncStateMachineBox. The worst that happens in such
+ // cases is we lose the ability to properly step in the debugger, as the debugger uses that
+ // object's identity to track this specific builder/state machine. As such, we proceed to
+ // overwrite whatever's there anyway, even if it's non-null.
+ var box = new AsyncStateMachineBox<TStateMachine>();
+ m_task = box; // important: this must be done before storing stateMachine into box.StateMachine!
+ box.StateMachine = stateMachine;
+ box.Context = currentContext;
+ return box;
+ }
+
+ /// <summary>A strongly-typed box for Task-based async state machines.</summary>
+ /// <typeparam name="TStateMachine">Specifies the type of the state machine.</typeparam>
+ /// <typeparam name="TResult">Specifies the type of the Task's result.</typeparam>
+ private sealed class AsyncStateMachineBox<TStateMachine> :
+ Task<TResult>, IAsyncStateMachineBox
+ where TStateMachine : IAsyncStateMachine
+ {
+ /// <summary>Delegate used to invoke on an ExecutionContext when passed an instance of this box type.</summary>
+ private static readonly ContextCallback s_callback = s => ((AsyncStateMachineBox<TStateMachine>)s).StateMachine.MoveNext();
+
+ /// <summary>A delegate to the <see cref="MoveNext"/> method.</summary>
+ private Action _moveNextAction;
+ /// <summary>The state machine itself.</summary>
+ public TStateMachine StateMachine; // mutable struct; do not make this readonly
+ /// <summary>Captured ExecutionContext with which to invoke <see cref="MoveNextAction"/>; may be null.</summary>
+ public ExecutionContext Context;
+
+ /// <summary>A delegate to the <see cref="MoveNext"/> method.</summary>
+ public Action MoveNextAction =>
+ _moveNextAction ??
+ (_moveNextAction = AsyncCausalityTracer.LoggingOn ? AsyncMethodBuilderCore.OutputAsyncCausalityEvents(this, new Action(MoveNext)) : new Action(MoveNext));
+
+ /// <summary>Calls MoveNext on <see cref="StateMachine"/></summary>
+ public void MoveNext()
{
- AsyncMethodBuilderCore.ThrowAsync(e, targetContext: null);
+ if (Context == null)
+ {
+ StateMachine.MoveNext();
+ }
+ else
+ {
+ ExecutionContext.Run(Context, s_callback, this);
+ }
}
+
+ /// <summary>
+ /// Calls MoveNext on <see cref="StateMachine"/>. Implements ITaskCompletionAction.Invoke so
+ /// that the state machine object may be queued directly as a continuation into a Task's
+ /// continuation slot/list.
+ /// </summary>
+ /// <param name="completedTask">The completing task that caused this method to be invoked, if there was one.</param>
+ void ITaskCompletionAction.Invoke(Task completedTask) => MoveNext();
+
+ /// <summary>Signals to Task's continuation logic that <see cref="Invoke"/> runs arbitrary user code via MoveNext.</summary>
+ bool ITaskCompletionAction.InvokeMayRunArbitraryCode => true;
+
+ /// <summary>Gets the state machine as a boxed object. This should only be used for debugging purposes.</summary>
+ IAsyncStateMachine IAsyncStateMachineBox.GetStateMachineObject() => StateMachine; // likely boxes, only use for debugging
}
/// <summary>Gets the <see cref="System.Threading.Tasks.Task{TResult}"/> for this builder.</summary>
@@ -559,12 +617,33 @@ namespace System.Runtime.CompilerServices
public Task<TResult> Task
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- get { return m_task ?? InitializeTask(); }
+ get => m_task ?? InitializeTaskAsPromise();
}
- /// <summary>Initializes the task, which must not yet be initialized.</summary>
+ /// <summary>
+ /// Initializes the task, which must not yet be initialized. Used only when the Task is being forced into
+ /// existence when no state machine is needed, e.g. when the builder is being synchronously completed with
+ /// an exception, when the builder is being used out of the context of an async method, etc.
+ /// </summary>
[MethodImpl(MethodImplOptions.NoInlining)]
- private Task<TResult> InitializeTask() => (m_task = new Task<TResult>());
+ private Task<TResult> InitializeTaskAsPromise()
+ {
+ Debug.Assert(m_task == null);
+ return (m_task = new Task<TResult>());
+ }
+
+ /// <summary>
+ /// Initializes the task, which must not yet be initialized. Used only when the Task is being forced into
+ /// existence due to the debugger trying to enable step-out/step-over/etc. prior to the first await yielding
+ /// in an async method. In that case, we don't know the actual TStateMachine type, so we're forced to
+ /// use IAsyncStateMachine instead.
+ /// </summary>
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private Task<TResult> InitializeTaskAsStateMachineBox()
+ {
+ Debug.Assert(m_task == null);
+ return (m_task = new AsyncStateMachineBox<IAsyncStateMachine>());
+ }
/// <summary>
/// Completes the <see cref="System.Threading.Tasks.Task{TResult}"/> in the
@@ -579,7 +658,7 @@ namespace System.Runtime.CompilerServices
if (m_task == null)
{
m_task = GetTaskForResult(result);
- Debug.Assert(m_task != null, "GetTaskForResult should never return null");
+ Debug.Assert(m_task != null, $"{nameof(GetTaskForResult)} should never return null");
}
else
{
@@ -630,8 +709,8 @@ namespace System.Runtime.CompilerServices
/// <exception cref="System.InvalidOperationException">The task has already completed.</exception>
internal void SetResult(Task<TResult> completedTask)
{
- Contract.Requires(completedTask != null, "Expected non-null task");
- Contract.Requires(completedTask.Status == TaskStatus.RanToCompletion, "Expected a successfully completed task");
+ Debug.Assert(completedTask != null, "Expected non-null task");
+ Debug.Assert(completedTask.IsCompletedSuccessfully, "Expected a successfully completed task");
// Get the currently stored task, which will be non-null if get_Task has already been accessed.
// If there isn't one, store the supplied completed task.
@@ -655,30 +734,26 @@ namespace System.Runtime.CompilerServices
/// <exception cref="System.InvalidOperationException">The task has already completed.</exception>
public void SetException(Exception exception)
{
- if (exception == null) throw new ArgumentNullException(nameof(exception));
- Contract.EndContractBlock();
-
-
- var task = m_task;
- if (task == null)
+ if (exception == null)
{
- // Get the task, forcing initialization if it hasn't already been initialized.
- task = this.Task;
+ ThrowHelper.ThrowArgumentNullException(ExceptionArgument.exception);
}
+ // Get the task, forcing initialization if it hasn't already been initialized.
+ Task<TResult> task = this.Task;
+
// If the exception represents cancellation, cancel the task. Otherwise, fault the task.
var oce = exception as OperationCanceledException;
bool successfullySet = oce != null ?
task.TrySetCanceled(oce.CancellationToken, oce) :
task.TrySetException(exception);
- // Unlike with TaskCompletionSource, we do not need to spin here until m_task is completed,
+ // Unlike with TaskCompletionSource, we do not need to spin here until _taskAndStateMachine is completed,
// since AsyncTaskMethodBuilder.SetException should not be immediately followed by any code
// that depends on the task having completely completed. Moreover, with correct usage,
// SetResult or SetException should only be called once, so the Try* methods should always
// return true, so no spinning would be necessary anyway (the spinning in TCS is only relevant
// if another thread completes the task first).
-
if (!successfullySet)
{
ThrowHelper.ThrowInvalidOperationException(ExceptionResource.TaskT_TransitionToFinal_AlreadyCompleted);
@@ -699,7 +774,17 @@ namespace System.Runtime.CompilerServices
internal void SetNotificationForWaitCompletion(bool enabled)
{
// Get the task (forcing initialization if not already initialized), and set debug notification
- this.Task.SetNotificationForWaitCompletion(enabled);
+ (m_task ?? InitializeTaskAsStateMachineBox()).SetNotificationForWaitCompletion(enabled);
+
+ // NOTE: It's important that the debugger use builder.SetNotificationForWaitCompletion
+ // rather than builder.Task.SetNotificationForWaitCompletion. Even though the latter will
+ // lazily-initialize the task as well, it'll initialize it to a Task<T> (which is important
+ // to minimize size for cases where an ATMB is used directly by user code to avoid the
+ // allocation overhead of a TaskCompletionSource). If that's done prior to the first await,
+ // the GetMoveNextDelegate code, which needs an AsyncStateMachineBox, will end up creating
+ // a new box and overwriting the previously created task. That'll change the object identity
+ // of the task being used for wait completion notification, and no notification will
+ // ever arrive, breaking step-out behavior when stepping out before the first yielding await.
}
/// <summary>
@@ -708,9 +793,9 @@ namespace System.Runtime.CompilerServices
/// <remarks>
/// This property lazily instantiates the ID in a non-thread-safe manner.
/// It must only be used by the debugger and tracing purposes, and only in a single-threaded manner
- /// when no other threads are in the middle of accessing this property or this.Task.
+ /// when no other threads are in the middle of accessing this or other members that lazily initialize the task.
/// </remarks>
- private object ObjectIdForDebugger { get { return this.Task; } }
+ internal object ObjectIdForDebugger => m_task ?? InitializeTaskAsStateMachineBox();
/// <summary>
/// Gets a task for the specified result. This will either
@@ -721,10 +806,6 @@ namespace System.Runtime.CompilerServices
[MethodImpl(MethodImplOptions.AggressiveInlining)] // method looks long, but for a given TResult it results in a relatively small amount of asm
internal static Task<TResult> GetTaskForResult(TResult result)
{
- Contract.Ensures(
- EqualityComparer<TResult>.Default.Equals(result, Contract.Result<Task<TResult>>().Result),
- "The returned task's Result must return the same value as the specified result value.");
-
// The goal of this function is to be give back a cached task if possible,
// or to otherwise give back a new task. To give back a cached task,
// we need to be able to evaluate the incoming result value, and we need
@@ -837,144 +918,58 @@ namespace System.Runtime.CompilerServices
/// <typeparam name="TResult">Specifies the result type.</typeparam>
/// <param name="result">The result for the task.</param>
/// <returns>The cacheable task.</returns>
- internal static Task<TResult> CreateCacheableTask<TResult>(TResult result)
- {
- return new Task<TResult>(false, result, (TaskCreationOptions)InternalTaskOptions.DoNotDispose, default(CancellationToken));
- }
+ internal static Task<TResult> CreateCacheableTask<TResult>(TResult result) =>
+ new Task<TResult>(false, result, (TaskCreationOptions)InternalTaskOptions.DoNotDispose, default(CancellationToken));
}
- /// <summary>Holds state related to the builder's IAsyncStateMachine.</summary>
- /// <remarks>This is a mutable struct. Be very delicate with it.</remarks>
- internal struct AsyncMethodBuilderCore
+ /// <summary>Temporary workaround for https://github.com/dotnet/coreclr/issues/12877.</summary>
+ internal static class InterfaceIsCheckWorkaround<TAwaiter>
{
- /// <summary>A reference to the heap-allocated state machine object associated with this builder.</summary>
- internal IAsyncStateMachine m_stateMachine;
- /// <summary>A cached Action delegate used when dealing with a default ExecutionContext.</summary>
- internal Action m_defaultContextAction;
-
- // This method is copy&pasted into the public Start methods to avoid size overhead of valuetype generic instantiations.
- // Ideally, we would build intrinsics to get the raw ref address and raw code address of MoveNext, and just use the shared implementation.
-
- /// <summary>Associates the builder with the state machine it represents.</summary>
- /// <param name="stateMachine">The heap-allocated state machine object.</param>
- /// <exception cref="System.ArgumentNullException">The <paramref name="stateMachine"/> argument was null (Nothing in Visual Basic).</exception>
- /// <exception cref="System.InvalidOperationException">The builder is incorrectly initialized.</exception>
- public void SetStateMachine(IAsyncStateMachine stateMachine)
- {
- if (stateMachine == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.stateMachine);
- Contract.EndContractBlock();
- if (m_stateMachine != null) ThrowHelper.ThrowInvalidOperationException(ExceptionResource.AsyncMethodBuilder_InstanceNotInitialized);
- m_stateMachine = stateMachine;
- }
+ internal static readonly bool IsITaskAwaiter = typeof(TAwaiter).GetInterface("ITaskAwaiter") != null;
+ internal static readonly bool IsIConfiguredTaskAwaiter = typeof(TAwaiter).GetInterface("IConfiguredTaskAwaiter") != null;
+ }
+ /// <summary>
+ /// An interface implemented by all <see cref="AsyncStateMachineBox{TStateMachine, TResult}"/> instances, regardless of generics.
+ /// </summary>
+ interface IAsyncStateMachineBox : ITaskCompletionAction
+ {
/// <summary>
- /// Gets the Action to use with an awaiter's OnCompleted or UnsafeOnCompleted method.
- /// On first invocation, the supplied state machine will be boxed.
+ /// Gets an action for moving forward the contained state machine.
+ /// This will lazily-allocate the delegate as needed.
/// </summary>
- /// <typeparam name="TMethodBuilder">Specifies the type of the method builder used.</typeparam>
- /// <typeparam name="TStateMachine">Specifies the type of the state machine used.</typeparam>
- /// <param name="builder">The builder.</param>
- /// <param name="stateMachine">The state machine.</param>
- /// <returns>An Action to provide to the awaiter.</returns>
- internal Action GetCompletionAction(Task taskForTracing, ref MoveNextRunner runnerToInitialize)
- {
- Debug.Assert(m_defaultContextAction == null || m_stateMachine != null,
- "Expected non-null m_stateMachine on non-null m_defaultContextAction");
-
- // Alert a listening debugger that we can't make forward progress unless it slips threads.
- // If we don't do this, and a method that uses "await foo;" is invoked through funceval,
- // we could end up hooking up a callback to push forward the async method's state machine,
- // the debugger would then abort the funceval after it takes too long, and then continuing
- // execution could result in another callback being hooked up. At that point we have
- // multiple callbacks registered to push the state machine, which could result in bad behavior.
- Debugger.NotifyOfCrossThreadDependency();
-
- // The builder needs to flow ExecutionContext, so capture it.
- var capturedContext = ExecutionContext.Capture();
-
- // If the ExecutionContext is the default context, try to use a cached delegate, creating one if necessary.
- Action action;
- MoveNextRunner runner;
- if (capturedContext == ExecutionContext.Default)
- {
- // Get the cached delegate, and if it's non-null, return it.
- action = m_defaultContextAction;
- if (action != null)
- {
- Debug.Assert(m_stateMachine != null, "If the delegate was set, the state machine should have been as well.");
- return action;
- }
+ Action MoveNextAction { get; }
- // There wasn't a cached delegate, so create one and cache it.
- // The delegate won't be usable until we set the MoveNextRunner's target state machine.
- runner = new MoveNextRunner(m_stateMachine);
-
- action = new Action(runner.RunWithDefaultContext);
- if (taskForTracing != null)
- {
- action = OutputAsyncCausalityEvents(taskForTracing, action);
- }
- m_defaultContextAction = action;
- }
- // Otherwise, create an Action that flows this context. The context may be null.
- // The delegate won't be usable until we set the MoveNextRunner's target state machine.
- else
- {
- var runnerWithContext = new MoveNextRunnerWithContext(capturedContext, m_stateMachine);
- runner = runnerWithContext;
- action = new Action(runnerWithContext.RunWithCapturedContext);
-
- if (taskForTracing != null)
- {
- action = OutputAsyncCausalityEvents(taskForTracing, action);
- }
-
- // NOTE: If capturedContext is null, we could create the Action to point directly
- // to m_stateMachine.MoveNext. However, that follows a much more expensive
- // delegate creation path.
- }
-
- if (m_stateMachine == null)
- runnerToInitialize = runner;
-
- return action;
- }
+ /// <summary>Gets the state machine as a boxed object. This should only be used for debugging purposes.</summary>
+ IAsyncStateMachine GetStateMachineObject();
+ }
- private Action OutputAsyncCausalityEvents(Task innerTask, Action continuation)
- {
- return CreateContinuationWrapper(continuation, () =>
+ /// <summary>Shared helpers for manipulating state related to async state machines.</summary>
+ internal static class AsyncMethodBuilderCore // debugger depends on this exact name
+ {
+ internal static Action OutputAsyncCausalityEvents(Task task, Action continuation) =>
+ CreateContinuationWrapper(continuation, (innerContinuation, innerTask) =>
{
AsyncCausalityTracer.TraceSynchronousWorkStart(CausalityTraceLevel.Required, innerTask.Id, CausalitySynchronousWork.Execution);
-
- // Invoke the original continuation
- continuation.Invoke();
-
+ innerContinuation.Invoke(); // Invoke the original continuation
AsyncCausalityTracer.TraceSynchronousWorkCompletion(CausalityTraceLevel.Required, CausalitySynchronousWork.Execution);
- }, innerTask);
- }
-
- internal void PostBoxInitialization(IAsyncStateMachine stateMachine, MoveNextRunner runner, Task builtTask)
- {
- if (builtTask != null)
- {
- if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCreation(CausalityTraceLevel.Required, builtTask.Id, "Async: " + stateMachine.GetType().Name, 0);
-
- if (System.Threading.Tasks.Task.s_asyncDebuggingEnabled)
- System.Threading.Tasks.Task.AddToActiveTasks(builtTask);
- }
-
- m_stateMachine = stateMachine;
- m_stateMachine.SetStateMachine(m_stateMachine);
+ }, task);
- Debug.Assert(runner.m_stateMachine == null, "The runner's state machine should not yet have been populated.");
- Debug.Assert(m_stateMachine != null, "The builder's state machine field should have been initialized.");
+ internal static Action CreateContinuationWrapper(Action continuation, Action<Action,Task> invokeAction, Task innerTask) =>
+ new ContinuationWrapper(continuation, invokeAction, innerTask).Invoke;
- // Now that we have the state machine, store it into the runner that the action delegate points to.
- // And return the action.
- runner.m_stateMachine = m_stateMachine; // only after this line is the Action delegate usable
+ internal static Action TryGetStateMachineForDebugger(Action action) // debugger depends on this exact name/signature
+ {
+ object target = action.Target;
+ return
+ target is IAsyncStateMachineBox sm ? sm.GetStateMachineObject().MoveNext :
+ target is ContinuationWrapper cw ? TryGetStateMachineForDebugger(cw._continuation) :
+ action;
}
+ internal static Task TryGetContinuationTask(Action continuation) =>
+ (continuation?.Target as ContinuationWrapper)?._innerTask;
+
/// <summary>Throws the exception on the ThreadPool.</summary>
/// <param name="exception">The exception to propagate.</param>
/// <param name="targetContext">The target context on which to propagate the exception. Null to use the ThreadPool.</param>
@@ -1010,59 +1005,6 @@ namespace System.Runtime.CompilerServices
}
}
- /// <summary>Provides the ability to invoke a state machine's MoveNext method under a supplied ExecutionContext.</summary>
- internal sealed class MoveNextRunnerWithContext : MoveNextRunner
- {
- /// <summary>The context with which to run MoveNext.</summary>
- private readonly ExecutionContext m_context;
-
- /// <summary>Initializes the runner.</summary>
- /// <param name="context">The context with which to run MoveNext.</param>
- internal MoveNextRunnerWithContext(ExecutionContext context, IAsyncStateMachine stateMachine) : base(stateMachine)
- {
- m_context = context;
- }
-
- /// <summary>Invokes MoveNext under the provided context.</summary>
- internal void RunWithCapturedContext()
- {
- Debug.Assert(m_stateMachine != null, "The state machine must have been set before calling Run.");
-
- if (m_context != null)
- {
- // Use the context and callback to invoke m_stateMachine.MoveNext.
- ExecutionContext.Run(m_context, InvokeMoveNextCallback, m_stateMachine);
- }
- else
- {
- m_stateMachine.MoveNext();
- }
- }
- }
-
- /// <summary>Provides the ability to invoke a state machine's MoveNext method.</summary>
- internal class MoveNextRunner
- {
- /// <summary>The state machine whose MoveNext method should be invoked.</summary>
- internal IAsyncStateMachine m_stateMachine;
-
- /// <summary>Initializes the runner.</summary>
- internal MoveNextRunner(IAsyncStateMachine stateMachine)
- {
- m_stateMachine = stateMachine;
- }
-
- /// <summary>Invokes MoveNext under the default context.</summary>
- internal void RunWithDefaultContext()
- {
- Debug.Assert(m_stateMachine != null, "The state machine must have been set before calling Run.");
- ExecutionContext.Run(ExecutionContext.Default, InvokeMoveNextCallback, m_stateMachine);
- }
-
- /// <summary>Gets a delegate to the InvokeMoveNext method.</summary>
- protected static readonly ContextCallback InvokeMoveNextCallback = sm => ((IAsyncStateMachine)sm).MoveNext();
- }
-
/// <summary>
/// Logically we pass just an Action (delegate) to a task for its action to 'ContinueWith' when it completes.
/// However debuggers and profilers need more information about what that action is. (In particular what
@@ -1071,66 +1013,23 @@ namespace System.Runtime.CompilerServices
/// (like the action after that (which is also a ContinuationWrapper and thus form a linked list).
// We also store that task if the action is associate with at task.
/// </summary>
- private class ContinuationWrapper
+ private sealed class ContinuationWrapper
{
- internal readonly Action m_continuation; // This is continuation which will happen after m_invokeAction (and is probably a ContinuationWrapper)
- private readonly Action m_invokeAction; // This wrapper is an action that wraps another action, this is that Action.
- internal readonly Task m_innerTask; // If the continuation is logically going to invoke a task, this is that task (may be null)
+ private readonly Action<Action, Task> _invokeAction; // This wrapper is an action that wraps another action, this is that Action.
+ internal readonly Action _continuation; // This is continuation which will happen after m_invokeAction (and is probably a ContinuationWrapper)
+ internal readonly Task _innerTask; // If the continuation is logically going to invoke a task, this is that task (may be null)
- internal ContinuationWrapper(Action continuation, Action invokeAction, Task innerTask)
+ internal ContinuationWrapper(Action continuation, Action<Action, Task> invokeAction, Task innerTask)
{
- Contract.Requires(continuation != null, "Expected non-null continuation");
-
- // If we don't have a task, see if our continuation is a wrapper and use that.
- if (innerTask == null)
- innerTask = TryGetContinuationTask(continuation);
+ Debug.Assert(continuation != null, "Expected non-null continuation");
+ Debug.Assert(invokeAction != null, "Expected non-null continuation");
- m_continuation = continuation;
- m_innerTask = innerTask;
- m_invokeAction = invokeAction;
+ _invokeAction = invokeAction;
+ _continuation = continuation;
+ _innerTask = innerTask ?? TryGetContinuationTask(continuation); // if we don't have a task, see if our continuation is a wrapper and use that.
}
- internal void Invoke()
- {
- m_invokeAction();
- }
- }
-
- internal static Action CreateContinuationWrapper(Action continuation, Action invokeAction, Task innerTask = null)
- {
- return new ContinuationWrapper(continuation, invokeAction, innerTask).Invoke;
- }
-
- internal static Action TryGetStateMachineForDebugger(Action action)
- {
- object target = action.Target;
- var runner = target as AsyncMethodBuilderCore.MoveNextRunner;
- if (runner != null)
- {
- return new Action(runner.m_stateMachine.MoveNext);
- }
-
- var continuationWrapper = target as ContinuationWrapper;
- if (continuationWrapper != null)
- {
- return TryGetStateMachineForDebugger(continuationWrapper.m_continuation);
- }
-
- return action;
- }
-
- ///<summary>
- /// Given an action, see if it is a continuation wrapper and has a Task associated with it. If so return it (null otherwise)
- ///</summary>
- internal static Task TryGetContinuationTask(Action action)
- {
- if (action != null)
- {
- var asWrapper = action.Target as ContinuationWrapper;
- if (asWrapper != null)
- return asWrapper.m_innerTask;
- }
- return null;
+ internal void Invoke() => _invokeAction(_continuation, _innerTask);
}
}
}
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs b/src/mscorlib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs
index 0338b18bee..b46c598ce3 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs
@@ -21,7 +21,6 @@ namespace System.Runtime.CompilerServices
using System.Runtime.Serialization;
using System.Threading;
using System.Runtime.Versioning;
- using System.Diagnostics.Contracts;
public static class RuntimeHelpers
{
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/TaskAwaiter.cs b/src/mscorlib/src/System/Runtime/CompilerServices/TaskAwaiter.cs
index c35658e54c..e13f05fe38 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/TaskAwaiter.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/TaskAwaiter.cs
@@ -40,7 +40,6 @@
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
-using System.Diagnostics.Contracts;
using System.Security;
using System.Threading;
using System.Threading.Tasks;
@@ -56,16 +55,19 @@ namespace System.Runtime.CompilerServices
{
/// <summary>Provides an awaiter for awaiting a <see cref="System.Threading.Tasks.Task"/>.</summary>
/// <remarks>This type is intended for compiler use only.</remarks>
- public struct TaskAwaiter : ICriticalNotifyCompletion
+ public struct TaskAwaiter : ICriticalNotifyCompletion, ITaskAwaiter
{
+ // WARNING: Unsafe.As is used to access the generic TaskAwaiter<> as TaskAwaiter.
+ // Its layout must remain the same.
+
/// <summary>The task being awaited.</summary>
- private readonly Task m_task;
+ internal readonly Task m_task;
/// <summary>Initializes the <see cref="TaskAwaiter"/>.</summary>
/// <param name="task">The <see cref="System.Threading.Tasks.Task"/> to be awaited.</param>
internal TaskAwaiter(Task task)
{
- Contract.Requires(task != null, "Constructing an awaiter requires a task to await.");
+ Debug.Assert(task != null, "Constructing an awaiter requires a task to await.");
m_task = task;
}
@@ -152,8 +154,8 @@ namespace System.Runtime.CompilerServices
/// <summary>Throws an exception to handle a task that completed in a state other than RanToCompletion.</summary>
private static void ThrowForNonSuccess(Task task)
{
- Contract.Requires(task.IsCompleted, "Task must have been completed by now.");
- Contract.Requires(task.Status != TaskStatus.RanToCompletion, "Task should not be completed successfully.");
+ Debug.Assert(task.IsCompleted, "Task must have been completed by now.");
+ Debug.Assert(task.Status != TaskStatus.RanToCompletion, "Task should not be completed successfully.");
// Handle whether the task has been canceled or faulted
switch (task.Status)
@@ -212,6 +214,30 @@ namespace System.Runtime.CompilerServices
task.SetContinuationForAwait(continuation, continueOnCapturedContext, flowExecutionContext);
}
+ /// <summary>Schedules the continuation onto the <see cref="System.Threading.Tasks.Task"/> associated with this <see cref="TaskAwaiter"/>.</summary>
+ /// <param name="task">The task being awaited.</param>
+ /// <param name="continuation">The action to invoke when the await operation completes.</param>
+ /// <param name="continueOnCapturedContext">Whether to capture and marshal back to the current context.</param>
+ /// <param name="flowExecutionContext">Whether to flow ExecutionContext across the await.</param>
+ /// <exception cref="System.ArgumentNullException">The <paramref name="continuation"/> argument is null (Nothing in Visual Basic).</exception>
+ /// <exception cref="System.NullReferenceException">The awaiter was not properly initialized.</exception>
+ /// <remarks>This method is intended for compiler user rather than use directly in code.</remarks>
+ internal static void UnsafeOnCompletedInternal(Task task, IAsyncStateMachineBox stateMachineBox, bool continueOnCapturedContext)
+ {
+ Debug.Assert(stateMachineBox != null);
+
+ // If TaskWait* ETW events are enabled, trace a beginning event for this await
+ // and set up an ending event to be traced when the asynchronous await completes.
+ if (TplEtwProvider.Log.IsEnabled() || Task.s_asyncDebuggingEnabled)
+ {
+ task.SetContinuationForAwait(OutputWaitEtwEvents(task, stateMachineBox.MoveNextAction), continueOnCapturedContext, flowExecutionContext: false);
+ }
+ else
+ {
+ task.UnsafeSetContinuationForAwait(stateMachineBox, continueOnCapturedContext);
+ }
+ }
+
/// <summary>
/// Outputs a WaitBegin ETW event, and augments the continuation action to output a WaitEnd ETW event.
/// </summary>
@@ -220,8 +246,8 @@ namespace System.Runtime.CompilerServices
/// <returns>The action to use as the actual continuation.</returns>
private static Action OutputWaitEtwEvents(Task task, Action continuation)
{
- Contract.Requires(task != null, "Need a task to wait on");
- Contract.Requires(continuation != null, "Need a continuation to invoke when the wait completes");
+ Debug.Assert(task != null, "Need a task to wait on");
+ Debug.Assert(continuation != null, "Need a continuation to invoke when the wait completes");
if (Task.s_asyncDebuggingEnabled)
{
@@ -249,46 +275,52 @@ namespace System.Runtime.CompilerServices
// is enabled, and in doing so it allows us to pass the awaited task's information into the end event
// in a purely pay-for-play manner (the alternatively would be to increase the size of TaskAwaiter
// just for this ETW purpose, not pay-for-play, since GetResult would need to know whether a real yield occurred).
- return AsyncMethodBuilderCore.CreateContinuationWrapper(continuation, () =>
+ return AsyncMethodBuilderCore.CreateContinuationWrapper(continuation, (innerContinuation,innerTask) =>
{
if (Task.s_asyncDebuggingEnabled)
{
- Task.RemoveFromActiveTasks(task.Id);
+ Task.RemoveFromActiveTasks(innerTask.Id);
}
+ TplEtwProvider innerEtwLog = TplEtwProvider.Log;
+
// ETW event for Task Wait End.
Guid prevActivityId = new Guid();
- bool bEtwLogEnabled = etwLog.IsEnabled();
+ bool bEtwLogEnabled = innerEtwLog.IsEnabled();
if (bEtwLogEnabled)
{
var currentTaskAtEnd = Task.InternalCurrent;
- etwLog.TaskWaitEnd(
+ innerEtwLog.TaskWaitEnd(
(currentTaskAtEnd != null ? currentTaskAtEnd.m_taskScheduler.Id : TaskScheduler.Default.Id),
(currentTaskAtEnd != null ? currentTaskAtEnd.Id : 0),
- task.Id);
+ innerTask.Id);
// Ensure the continuation runs under the activity ID of the task that completed for the
// case the antecendent is a promise (in the other cases this is already the case).
- if (etwLog.TasksSetActivityIds && (task.Options & (TaskCreationOptions)InternalTaskOptions.PromiseTask) != 0)
- EventSource.SetCurrentThreadActivityId(TplEtwProvider.CreateGuidForTaskID(task.Id), out prevActivityId);
+ if (innerEtwLog.TasksSetActivityIds && (innerTask.Options & (TaskCreationOptions)InternalTaskOptions.PromiseTask) != 0)
+ EventSource.SetCurrentThreadActivityId(TplEtwProvider.CreateGuidForTaskID(innerTask.Id), out prevActivityId);
}
+
// Invoke the original continuation provided to OnCompleted.
- continuation();
+ innerContinuation();
if (bEtwLogEnabled)
{
- etwLog.TaskWaitContinuationComplete(task.Id);
- if (etwLog.TasksSetActivityIds && (task.Options & (TaskCreationOptions)InternalTaskOptions.PromiseTask) != 0)
+ innerEtwLog.TaskWaitContinuationComplete(innerTask.Id);
+ if (innerEtwLog.TasksSetActivityIds && (innerTask.Options & (TaskCreationOptions)InternalTaskOptions.PromiseTask) != 0)
EventSource.SetCurrentThreadActivityId(prevActivityId);
}
- });
+ }, task);
}
}
/// <summary>Provides an awaiter for awaiting a <see cref="System.Threading.Tasks.Task{TResult}"/>.</summary>
/// <remarks>This type is intended for compiler use only.</remarks>
- public struct TaskAwaiter<TResult> : ICriticalNotifyCompletion
+ public struct TaskAwaiter<TResult> : ICriticalNotifyCompletion, ITaskAwaiter
{
+ // WARNING: Unsafe.As is used to access TaskAwaiter<> as the non-generic TaskAwaiter.
+ // Its layout must remain the same.
+
/// <summary>The task being awaited.</summary>
private readonly Task<TResult> m_task;
@@ -296,7 +328,7 @@ namespace System.Runtime.CompilerServices
/// <param name="task">The <see cref="System.Threading.Tasks.Task{TResult}"/> to be awaited.</param>
internal TaskAwaiter(Task<TResult> task)
{
- Contract.Requires(task != null, "Constructing an awaiter requires a task to await.");
+ Debug.Assert(task != null, "Constructing an awaiter requires a task to await.");
m_task = task;
}
@@ -340,6 +372,20 @@ namespace System.Runtime.CompilerServices
}
}
+ /// <summary>
+ /// Marker interface used to know whether a particular awaiter is either a
+ /// TaskAwaiter or a TaskAwaiter`1. It must not be implemented by any other
+ /// awaiters.
+ /// </summary>
+ internal interface ITaskAwaiter { }
+
+ /// <summary>
+ /// Marker interface used to know whether a particular awaiter is either a
+ /// CTA.ConfiguredTaskAwaiter or a CTA`1.ConfiguredTaskAwaiter. It must not
+ /// be implemented by any other awaiters.
+ /// </summary>
+ internal interface IConfiguredTaskAwaiter { }
+
/// <summary>Provides an awaitable object that allows for configured awaits on <see cref="System.Threading.Tasks.Task"/>.</summary>
/// <remarks>This type is intended for compiler use only.</remarks>
public struct ConfiguredTaskAwaitable
@@ -354,7 +400,7 @@ namespace System.Runtime.CompilerServices
/// </param>
internal ConfiguredTaskAwaitable(Task task, bool continueOnCapturedContext)
{
- Contract.Requires(task != null, "Constructing an awaitable requires a task to await.");
+ Debug.Assert(task != null, "Constructing an awaitable requires a task to await.");
m_configuredTaskAwaiter = new ConfiguredTaskAwaitable.ConfiguredTaskAwaiter(task, continueOnCapturedContext);
}
@@ -367,12 +413,15 @@ namespace System.Runtime.CompilerServices
/// <summary>Provides an awaiter for a <see cref="ConfiguredTaskAwaitable"/>.</summary>
/// <remarks>This type is intended for compiler use only.</remarks>
- public struct ConfiguredTaskAwaiter : ICriticalNotifyCompletion
+ public struct ConfiguredTaskAwaiter : ICriticalNotifyCompletion, IConfiguredTaskAwaiter
{
+ // WARNING: Unsafe.As is used to access the generic ConfiguredTaskAwaiter as this.
+ // Its layout must remain the same.
+
/// <summary>The task being awaited.</summary>
- private readonly Task m_task;
+ internal readonly Task m_task;
/// <summary>Whether to attempt marshaling back to the original context.</summary>
- private readonly bool m_continueOnCapturedContext;
+ internal readonly bool m_continueOnCapturedContext;
/// <summary>Initializes the <see cref="ConfiguredTaskAwaiter"/>.</summary>
/// <param name="task">The <see cref="System.Threading.Tasks.Task"/> to await.</param>
@@ -382,7 +431,7 @@ namespace System.Runtime.CompilerServices
/// </param>
internal ConfiguredTaskAwaiter(Task task, bool continueOnCapturedContext)
{
- Contract.Requires(task != null, "Constructing an awaiter requires a task to await.");
+ Debug.Assert(task != null, "Constructing an awaiter requires a task to await.");
m_task = task;
m_continueOnCapturedContext = continueOnCapturedContext;
}
@@ -453,8 +502,11 @@ namespace System.Runtime.CompilerServices
/// <summary>Provides an awaiter for a <see cref="ConfiguredTaskAwaitable{TResult}"/>.</summary>
/// <remarks>This type is intended for compiler use only.</remarks>
- public struct ConfiguredTaskAwaiter : ICriticalNotifyCompletion
+ public struct ConfiguredTaskAwaiter : ICriticalNotifyCompletion, IConfiguredTaskAwaiter
{
+ // WARNING: Unsafe.As is used to access this as the non-generic ConfiguredTaskAwaiter.
+ // Its layout must remain the same.
+
/// <summary>The task being awaited.</summary>
private readonly Task<TResult> m_task;
/// <summary>Whether to attempt marshaling back to the original context.</summary>
@@ -467,7 +519,7 @@ namespace System.Runtime.CompilerServices
/// </param>
internal ConfiguredTaskAwaiter(Task<TResult> task, bool continueOnCapturedContext)
{
- Contract.Requires(task != null, "Constructing an awaiter requires a task to await.");
+ Debug.Assert(task != null, "Constructing an awaiter requires a task to await.");
m_task = task;
m_continueOnCapturedContext = continueOnCapturedContext;
}
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/TypeDependencyAttribute.cs b/src/mscorlib/src/System/Runtime/CompilerServices/TypeDependencyAttribute.cs
index 929cbe7608..3e386fa8b7 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/TypeDependencyAttribute.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/TypeDependencyAttribute.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System;
-using System.Diagnostics.Contracts;
namespace System.Runtime.CompilerServices
{
@@ -17,7 +16,6 @@ namespace System.Runtime.CompilerServices
public TypeDependencyAttribute(string typeName)
{
if (typeName == null) throw new ArgumentNullException(nameof(typeName));
- Contract.EndContractBlock();
this.typeName = typeName;
}
}
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/YieldAwaitable.cs b/src/mscorlib/src/System/Runtime/CompilerServices/YieldAwaitable.cs
index f1c7772526..8a7450bdb5 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/YieldAwaitable.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/YieldAwaitable.cs
@@ -24,7 +24,6 @@
using System;
using System.Security;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Diagnostics.Tracing;
using System.Threading;
using System.Threading.Tasks;
@@ -77,7 +76,6 @@ namespace System.Runtime.CompilerServices
{
// Validate arguments
if (continuation == null) throw new ArgumentNullException(nameof(continuation));
- Contract.EndContractBlock();
if (TplEtwProvider.Log.IsEnabled())
{
@@ -124,26 +122,26 @@ namespace System.Runtime.CompilerServices
// fire the correlation ETW event
TplEtwProvider.Log.AwaitTaskContinuationScheduled(TaskScheduler.Current.Id, (currentTask != null) ? currentTask.Id : 0, continuationId);
- return AsyncMethodBuilderCore.CreateContinuationWrapper(continuation, () =>
+ return AsyncMethodBuilderCore.CreateContinuationWrapper(continuation, (innerContinuation,continuationIdTask) =>
{
var etwLog = TplEtwProvider.Log;
- etwLog.TaskWaitContinuationStarted(continuationId);
+ etwLog.TaskWaitContinuationStarted(((Task<int>)continuationIdTask).Result);
// ETW event for Task Wait End.
Guid prevActivityId = new Guid();
// Ensure the continuation runs under the correlated activity ID generated above
if (etwLog.TasksSetActivityIds)
- EventSource.SetCurrentThreadActivityId(TplEtwProvider.CreateGuidForTaskID(continuationId), out prevActivityId);
+ EventSource.SetCurrentThreadActivityId(TplEtwProvider.CreateGuidForTaskID(((Task<int>)continuationIdTask).Result), out prevActivityId);
// Invoke the original continuation provided to OnCompleted.
- continuation();
+ innerContinuation();
// Restore activity ID
if (etwLog.TasksSetActivityIds)
EventSource.SetCurrentThreadActivityId(prevActivityId);
- etwLog.TaskWaitContinuationComplete(continuationId);
- });
+ etwLog.TaskWaitContinuationComplete(((Task<int>)continuationIdTask).Result);
+ }, Task.FromResult(continuationId)); // pass the ID in a task to avoid a closure
}
/// <summary>WaitCallback that invokes the Action supplied as object state.</summary>
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/jithelpers.cs b/src/mscorlib/src/System/Runtime/CompilerServices/jithelpers.cs
index e140286cba..ef217d153f 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/jithelpers.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/jithelpers.cs
@@ -12,7 +12,6 @@ using System.Threading;
using System.Runtime;
using System.Runtime.Versioning;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using System.Security;
@@ -147,15 +146,6 @@ namespace System.Runtime.CompilerServices
throw new InvalidOperationException();
}
#else // _DEBUG
- // The IL body of this method is not critical, but its body will be replaced with unsafe code, so
- // this method is effectively critical
- [FriendAccessAllowed]
- static internal T UnsafeCast<T>(Object o) where T : class
- {
- // The body of this function will be replaced by the EE with unsafe code that just returns o!!!
- // See getILIntrinsicImplementation for how this happens.
- throw new InvalidOperationException();
- }
static internal int UnsafeEnumCast<T>(T val) where T : struct // Actually T must be 4 byte (or less) enum
{
diff --git a/src/mscorlib/src/System/Runtime/GcSettings.cs b/src/mscorlib/src/System/Runtime/GcSettings.cs
index ecb28e6034..6e08aa3dc5 100644
--- a/src/mscorlib/src/System/Runtime/GcSettings.cs
+++ b/src/mscorlib/src/System/Runtime/GcSettings.cs
@@ -6,7 +6,6 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
-using System.Diagnostics.Contracts;
namespace System.Runtime
{
@@ -50,7 +49,6 @@ namespace System.Runtime
{
throw new ArgumentOutOfRangeException(SR.ArgumentOutOfRange_Enum);
}
- Contract.EndContractBlock();
if (GC.SetGCLatencyMode((int)value) == (int)SetLatencyModeStatus.NoGCInProgress)
throw new InvalidOperationException("The NoGCRegion mode is in progress. End it and then set a different mode.");
@@ -72,7 +70,6 @@ namespace System.Runtime
{
throw new ArgumentOutOfRangeException(SR.ArgumentOutOfRange_Enum);
}
- Contract.EndContractBlock();
GC.SetLOHCompactionMode((int)value);
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/Attributes.cs b/src/mscorlib/src/System/Runtime/InteropServices/Attributes.cs
index 7b50c705b2..4570da9a93 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/Attributes.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/Attributes.cs
@@ -8,7 +8,6 @@
using System;
using System.Reflection;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Runtime.InteropServices
{
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/GcHandle.cs b/src/mscorlib/src/System/Runtime/InteropServices/GcHandle.cs
index 2ee81a9f5c..9b4670bfc0 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/GcHandle.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/GcHandle.cs
@@ -7,7 +7,6 @@ namespace System.Runtime.InteropServices
using System;
using System.Runtime.CompilerServices;
using System.Threading;
- using System.Diagnostics.Contracts;
#if BIT64
using nint = System.Int64;
#else
@@ -61,7 +60,6 @@ namespace System.Runtime.InteropServices
// Make sure the type parameter is within the valid range for the enum.
if ((uint)type > (uint)MaxHandleType)
ThrowArgumentOutOfRangeException_ArgumentOutOfRange_Enum();
- Contract.EndContractBlock();
IntPtr handle = InternalAlloc(value, type);
@@ -160,7 +158,6 @@ namespace System.Runtime.InteropServices
public static GCHandle FromIntPtr(IntPtr value)
{
ValidateHandle(value);
- Contract.EndContractBlock();
#if MDA_SUPPORTED
IntPtr handle = value;
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/Marshal.cs b/src/mscorlib/src/System/Runtime/InteropServices/Marshal.cs
index 1567e0dd1c..39624c1928 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/Marshal.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/Marshal.cs
@@ -29,7 +29,6 @@ namespace System.Runtime.InteropServices
using Win32Native = Microsoft.Win32.Win32Native;
using Microsoft.Win32.SafeHandles;
using System.Diagnostics;
- using System.Diagnostics.Contracts;
using System.Runtime.InteropServices.ComTypes;
using System.StubHelpers;
@@ -187,8 +186,15 @@ namespace System.Runtime.InteropServices
unsafe public static String PtrToStringUTF8(IntPtr ptr)
{
- int nbBytes = System.StubHelpers.StubHelpers.strlen((sbyte*)ptr.ToPointer());
- return PtrToStringUTF8(ptr, nbBytes);
+ if (IntPtr.Zero == ptr)
+ {
+ return null;
+ }
+ else
+ {
+ int nbBytes = System.StubHelpers.StubHelpers.strlen((sbyte*)ptr.ToPointer());
+ return PtrToStringUTF8(ptr, nbBytes);
+ }
}
unsafe public static String PtrToStringUTF8(IntPtr ptr, int byteLen)
@@ -224,7 +230,6 @@ namespace System.Runtime.InteropServices
if (structure == null)
throw new ArgumentNullException(nameof(structure));
// we never had a check for generics here
- Contract.EndContractBlock();
return SizeOfHelper(structure.GetType(), true);
}
@@ -234,7 +239,6 @@ namespace System.Runtime.InteropServices
return SizeOf((object)structure);
}
- [Pure]
public static int SizeOf(Type t)
{
if (t == null)
@@ -243,7 +247,6 @@ namespace System.Runtime.InteropServices
throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(t));
if (t.IsGenericType)
throw new ArgumentException(SR.Argument_NeedNonGenericType, nameof(t));
- Contract.EndContractBlock();
return SizeOfHelper(t, true);
}
@@ -292,7 +295,6 @@ namespace System.Runtime.InteropServices
{
if (t == null)
throw new ArgumentNullException(nameof(t));
- Contract.EndContractBlock();
FieldInfo f = t.GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (f == null)
@@ -864,7 +866,6 @@ namespace System.Runtime.InteropServices
{
if (m == null)
throw new ArgumentNullException(nameof(m));
- Contract.EndContractBlock();
RuntimeMethodInfo rmi = m as RuntimeMethodInfo;
@@ -881,7 +882,6 @@ namespace System.Runtime.InteropServices
{
if (c == null)
throw new ArgumentNullException(nameof(c));
- Contract.EndContractBlock();
MethodInfo[] mi = c.GetMethods();
if (mi != null)
@@ -984,7 +984,6 @@ namespace System.Runtime.InteropServices
{
if (m == null)
throw new ArgumentNullException(nameof(m));
- Contract.EndContractBlock();
RuntimeModule rtModule = m as RuntimeModule;
if (rtModule == null)
@@ -1196,7 +1195,6 @@ namespace System.Runtime.InteropServices
{
if (typeInfo == null)
throw new ArgumentNullException(nameof(typeInfo));
- Contract.EndContractBlock();
String strTypeLibName = null;
String strDocString = null;
@@ -1512,7 +1510,6 @@ namespace System.Runtime.InteropServices
{
if (o == null)
throw new ArgumentNullException(nameof(o));
- Contract.EndContractBlock();
__ComObject co = null;
@@ -1568,7 +1565,6 @@ namespace System.Runtime.InteropServices
throw new ArgumentException(SR.Argument_TypeNotComObject, nameof(t));
if (t.IsGenericType)
throw new ArgumentException(SR.Argument_NeedNonGenericType, nameof(t));
- Contract.EndContractBlock();
if (t.IsWindowsRuntimeObject)
throw new ArgumentException(SR.Argument_TypeIsWinRTType, nameof(t));
@@ -1694,7 +1690,6 @@ namespace System.Runtime.InteropServices
throw new ArgumentException(SR.Argument_TypeMustNotBeComImport, nameof(type));
if (type.IsGenericType)
throw new ArgumentException(SR.Argument_NeedNonGenericType, nameof(type));
- Contract.EndContractBlock();
IList<CustomAttributeData> cas = CustomAttributeData.GetCustomAttributes(type);
for (int i = 0; i < cas.Count; i++)
@@ -1791,7 +1786,6 @@ namespace System.Runtime.InteropServices
if (t == null)
throw new ArgumentNullException(nameof(t));
- Contract.EndContractBlock();
if ((t as RuntimeType) == null)
throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(t));
@@ -1818,7 +1812,6 @@ namespace System.Runtime.InteropServices
{
if (d == null)
throw new ArgumentNullException(nameof(d));
- Contract.EndContractBlock();
return GetFunctionPointerForDelegateInternal(d);
}
@@ -1837,7 +1830,6 @@ namespace System.Runtime.InteropServices
{
throw new ArgumentNullException(nameof(s));
}
- Contract.EndContractBlock();
return s.MarshalToBSTR();
}
@@ -1848,7 +1840,6 @@ namespace System.Runtime.InteropServices
{
throw new ArgumentNullException(nameof(s));
}
- Contract.EndContractBlock();
return s.MarshalToString(globalAlloc: false, unicode: false);
}
@@ -1859,7 +1850,6 @@ namespace System.Runtime.InteropServices
{
throw new ArgumentNullException(nameof(s));
}
- Contract.EndContractBlock();
return s.MarshalToString(globalAlloc: false, unicode: true);
}
@@ -1894,7 +1884,6 @@ namespace System.Runtime.InteropServices
{
throw new ArgumentNullException(nameof(s));
}
- Contract.EndContractBlock();
return s.MarshalToString(globalAlloc: true, unicode: false);
}
@@ -1905,7 +1894,6 @@ namespace System.Runtime.InteropServices
{
throw new ArgumentNullException(nameof(s));
}
- Contract.EndContractBlock();
return s.MarshalToString(globalAlloc: true, unicode: true); ;
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/SafeBuffer.cs b/src/mscorlib/src/System/Runtime/InteropServices/SafeBuffer.cs
index 6e6d6ee2b6..4f97875470 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/SafeBuffer.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/SafeBuffer.cs
@@ -73,7 +73,6 @@ using System.Runtime.ConstrainedExecution;
using System.Runtime.Versioning;
using Microsoft.Win32.SafeHandles;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Runtime.InteropServices
{
@@ -100,7 +99,6 @@ namespace System.Runtime.InteropServices
{
if (IntPtr.Size == 4 && numBytes > UInt32.MaxValue)
throw new ArgumentOutOfRangeException(nameof(numBytes), SR.ArgumentOutOfRange_AddressSpace);
- Contract.EndContractBlock();
if (numBytes >= (ulong)Uninitialized)
throw new ArgumentOutOfRangeException(nameof(numBytes), SR.ArgumentOutOfRange_UIntPtrMax);
@@ -117,7 +115,6 @@ namespace System.Runtime.InteropServices
{
if (IntPtr.Size == 4 && numElements * sizeOfEachElement > UInt32.MaxValue)
throw new ArgumentOutOfRangeException("numBytes", SR.ArgumentOutOfRange_AddressSpace);
- Contract.EndContractBlock();
if (numElements * sizeOfEachElement >= (ulong)Uninitialized)
throw new ArgumentOutOfRangeException(nameof(numElements), SR.ArgumentOutOfRange_UIntPtrMax);
@@ -235,7 +232,6 @@ namespace System.Runtime.InteropServices
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum);
if (array.Length - index < count)
throw new ArgumentException(SR.Argument_InvalidOffLen);
- Contract.EndContractBlock();
if (_numBytes == Uninitialized)
throw NotInitialized();
@@ -306,7 +302,6 @@ namespace System.Runtime.InteropServices
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum);
if (array.Length - index < count)
throw new ArgumentException(SR.Argument_InvalidOffLen);
- Contract.EndContractBlock();
if (_numBytes == Uninitialized)
throw NotInitialized();
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToCollectionAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToCollectionAdapter.cs
index 88b60583f5..014e63e89d 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToCollectionAdapter.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToCollectionAdapter.cs
@@ -10,7 +10,6 @@ using System.Security;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
@@ -32,7 +31,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
}
// int Count { get }
- [Pure]
internal int Count()
{
IBindableVector _this = Unsafe.As<IBindableVector>(this);
@@ -46,21 +44,18 @@ namespace System.Runtime.InteropServices.WindowsRuntime
}
// bool IsSynchronized { get }
- [Pure]
internal bool IsSynchronized()
{
return false;
}
// object SyncRoot { get }
- [Pure]
internal object SyncRoot()
{
return this;
}
// void CopyTo(Array array, int index)
- [Pure]
internal void CopyTo(Array array, int arrayIndex)
{
if (array == null)
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToListAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToListAdapter.cs
index 655dcbd3bc..122c7a1b13 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToListAdapter.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToListAdapter.cs
@@ -10,7 +10,6 @@ using System.Security;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
@@ -83,14 +82,12 @@ namespace System.Runtime.InteropServices.WindowsRuntime
}
// bool IsFixedSize { get }
- [Pure]
internal bool IsFixedSize()
{
return false;
}
// bool IsReadOnly { get }
- [Pure]
internal bool IsReadOnly()
{
return false;
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIKeyValuePairImpl.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIKeyValuePairImpl.cs
index 86321e6191..92c78f9ea2 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIKeyValuePairImpl.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIKeyValuePairImpl.cs
@@ -6,7 +6,7 @@
using System;
using System.Collections.Generic;
-using System.Diagnostics.Contracts;
+using System.Diagnostics;
namespace System.Runtime.InteropServices.WindowsRuntime
{
@@ -22,13 +22,11 @@ namespace System.Runtime.InteropServices.WindowsRuntime
}
// IKeyValuePair<K, V> implementation
- [Pure]
public K Key
{
get { return _pair.Key; }
}
- [Pure]
public V Value
{
get { return _pair.Value; }
@@ -37,7 +35,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
// Called from the VM to wrap a boxed KeyValuePair with a CLRIKeyValuePairImpl.
internal static object BoxHelper(object pair)
{
- Contract.Requires(pair != null);
+ Debug.Assert(pair != null);
KeyValuePair<K, V> unboxedPair = (KeyValuePair<K, V>)pair;
return new CLRIKeyValuePairImpl<K, V>(ref unboxedPair);
@@ -46,7 +44,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
// Called from the VM to get a boxed KeyValuePair out of a CLRIKeyValuePairImpl.
internal static object UnboxHelper(object wrapper)
{
- Contract.Requires(wrapper != null);
+ Debug.Assert(wrapper != null);
CLRIKeyValuePairImpl<K, V> reference = (CLRIKeyValuePairImpl<K, V>)wrapper;
return reference._pair;
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIPropertyValueImpl.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIPropertyValueImpl.cs
index 75774caae2..12c77a2254 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIPropertyValueImpl.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIPropertyValueImpl.cs
@@ -5,7 +5,7 @@
//
using System;
-using System.Diagnostics.Contracts;
+using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Security;
@@ -52,13 +52,11 @@ namespace System.Runtime.InteropServices.WindowsRuntime
public PropertyType Type
{
- [Pure]
get { return _type; }
}
public bool IsNumericScalar
{
- [Pure]
get
{
return IsNumericScalarImpl(_type, _data);
@@ -77,13 +75,11 @@ namespace System.Runtime.InteropServices.WindowsRuntime
}
}
- [Pure]
public Byte GetUInt8()
{
return CoerceScalarValue<Byte>(PropertyType.UInt8);
}
- [Pure]
public Int16 GetInt16()
{
return CoerceScalarValue<Int16>(PropertyType.Int16);
@@ -94,260 +90,211 @@ namespace System.Runtime.InteropServices.WindowsRuntime
return CoerceScalarValue<UInt16>(PropertyType.UInt16);
}
- [Pure]
public Int32 GetInt32()
{
return CoerceScalarValue<Int32>(PropertyType.Int32);
}
- [Pure]
public UInt32 GetUInt32()
{
return CoerceScalarValue<UInt32>(PropertyType.UInt32);
}
- [Pure]
public Int64 GetInt64()
{
return CoerceScalarValue<Int64>(PropertyType.Int64);
}
- [Pure]
public UInt64 GetUInt64()
{
return CoerceScalarValue<UInt64>(PropertyType.UInt64);
}
- [Pure]
public Single GetSingle()
{
return CoerceScalarValue<Single>(PropertyType.Single);
}
- [Pure]
public Double GetDouble()
{
return CoerceScalarValue<Double>(PropertyType.Double);
}
- [Pure]
public char GetChar16()
{
if (this.Type != PropertyType.Char16)
throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "Char16"), HResults.TYPE_E_TYPEMISMATCH);
- Contract.EndContractBlock();
return (char)_data;
}
- [Pure]
public Boolean GetBoolean()
{
if (this.Type != PropertyType.Boolean)
throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "Boolean"), HResults.TYPE_E_TYPEMISMATCH);
- Contract.EndContractBlock();
return (bool)_data;
}
- [Pure]
public String GetString()
{
return CoerceScalarValue<String>(PropertyType.String);
}
- [Pure]
public Guid GetGuid()
{
return CoerceScalarValue<Guid>(PropertyType.Guid);
}
- [Pure]
public DateTimeOffset GetDateTime()
{
if (this.Type != PropertyType.DateTime)
throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "DateTime"), HResults.TYPE_E_TYPEMISMATCH);
- Contract.EndContractBlock();
return (DateTimeOffset)_data;
}
- [Pure]
public TimeSpan GetTimeSpan()
{
if (this.Type != PropertyType.TimeSpan)
throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "TimeSpan"), HResults.TYPE_E_TYPEMISMATCH);
- Contract.EndContractBlock();
return (TimeSpan)_data;
}
- [Pure]
public Point GetPoint()
{
if (this.Type != PropertyType.Point)
throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "Point"), HResults.TYPE_E_TYPEMISMATCH);
- Contract.EndContractBlock();
return Unbox<Point>(IReferenceFactory.s_pointType);
}
- [Pure]
public Size GetSize()
{
if (this.Type != PropertyType.Size)
throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "Size"), HResults.TYPE_E_TYPEMISMATCH);
- Contract.EndContractBlock();
return Unbox<Size>(IReferenceFactory.s_sizeType);
}
- [Pure]
public Rect GetRect()
{
if (this.Type != PropertyType.Rect)
throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "Rect"), HResults.TYPE_E_TYPEMISMATCH);
- Contract.EndContractBlock();
return Unbox<Rect>(IReferenceFactory.s_rectType);
}
- [Pure]
public Byte[] GetUInt8Array()
{
return CoerceArrayValue<Byte>(PropertyType.UInt8Array);
}
- [Pure]
public Int16[] GetInt16Array()
{
return CoerceArrayValue<Int16>(PropertyType.Int16Array);
}
- [Pure]
public UInt16[] GetUInt16Array()
{
return CoerceArrayValue<UInt16>(PropertyType.UInt16Array);
}
- [Pure]
public Int32[] GetInt32Array()
{
return CoerceArrayValue<Int32>(PropertyType.Int32Array);
}
- [Pure]
public UInt32[] GetUInt32Array()
{
return CoerceArrayValue<UInt32>(PropertyType.UInt32Array);
}
- [Pure]
public Int64[] GetInt64Array()
{
return CoerceArrayValue<Int64>(PropertyType.Int64Array);
}
- [Pure]
public UInt64[] GetUInt64Array()
{
return CoerceArrayValue<UInt64>(PropertyType.UInt64Array);
}
- [Pure]
public Single[] GetSingleArray()
{
return CoerceArrayValue<Single>(PropertyType.SingleArray);
}
- [Pure]
public Double[] GetDoubleArray()
{
return CoerceArrayValue<Double>(PropertyType.DoubleArray);
}
- [Pure]
public char[] GetChar16Array()
{
if (this.Type != PropertyType.Char16Array)
throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "Char16[]"), HResults.TYPE_E_TYPEMISMATCH);
- Contract.EndContractBlock();
return (char[])_data;
}
- [Pure]
public Boolean[] GetBooleanArray()
{
if (this.Type != PropertyType.BooleanArray)
throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "Boolean[]"), HResults.TYPE_E_TYPEMISMATCH);
- Contract.EndContractBlock();
return (bool[])_data;
}
- [Pure]
public String[] GetStringArray()
{
return CoerceArrayValue<String>(PropertyType.StringArray);
}
- [Pure]
public Object[] GetInspectableArray()
{
if (this.Type != PropertyType.InspectableArray)
throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "Inspectable[]"), HResults.TYPE_E_TYPEMISMATCH);
- Contract.EndContractBlock();
return (Object[])_data;
}
- [Pure]
public Guid[] GetGuidArray()
{
return CoerceArrayValue<Guid>(PropertyType.GuidArray);
}
- [Pure]
public DateTimeOffset[] GetDateTimeArray()
{
if (this.Type != PropertyType.DateTimeArray)
throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "DateTimeOffset[]"), HResults.TYPE_E_TYPEMISMATCH);
- Contract.EndContractBlock();
return (DateTimeOffset[])_data;
}
- [Pure]
public TimeSpan[] GetTimeSpanArray()
{
if (this.Type != PropertyType.TimeSpanArray)
throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "TimeSpan[]"), HResults.TYPE_E_TYPEMISMATCH);
- Contract.EndContractBlock();
return (TimeSpan[])_data;
}
- [Pure]
public Point[] GetPointArray()
{
if (this.Type != PropertyType.PointArray)
throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "Point[]"), HResults.TYPE_E_TYPEMISMATCH);
- Contract.EndContractBlock();
return UnboxArray<Point>(IReferenceFactory.s_pointType);
}
- [Pure]
public Size[] GetSizeArray()
{
if (this.Type != PropertyType.SizeArray)
throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "Size[]"), HResults.TYPE_E_TYPEMISMATCH);
- Contract.EndContractBlock();
return UnboxArray<Size>(IReferenceFactory.s_sizeType);
}
- [Pure]
public Rect[] GetRectArray()
{
if (this.Type != PropertyType.RectArray)
throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "Rect[]"), HResults.TYPE_E_TYPEMISMATCH);
- Contract.EndContractBlock();
return UnboxArray<Rect>(IReferenceFactory.s_rectType);
}
@@ -531,11 +478,10 @@ namespace System.Runtime.InteropServices.WindowsRuntime
}
// Unbox the data stored in the property value to a structurally equivilent type
- [Pure]
private unsafe T Unbox<T>(Type expectedBoxedType) where T : struct
{
- Contract.Requires(expectedBoxedType != null);
- Contract.Requires(Marshal.SizeOf(expectedBoxedType) == Marshal.SizeOf(typeof(T)));
+ Debug.Assert(expectedBoxedType != null);
+ Debug.Assert(Marshal.SizeOf(expectedBoxedType) == Marshal.SizeOf(typeof(T)));
if (_data.GetType() != expectedBoxedType)
{
@@ -554,11 +500,10 @@ namespace System.Runtime.InteropServices.WindowsRuntime
}
// Convert the array stored in the property value to a structurally equivilent array type
- [Pure]
private unsafe T[] UnboxArray<T>(Type expectedArrayElementType) where T : struct
{
- Contract.Requires(expectedArrayElementType != null);
- Contract.Requires(Marshal.SizeOf(expectedArrayElementType) == Marshal.SizeOf(typeof(T)));
+ Debug.Assert(expectedArrayElementType != null);
+ Debug.Assert(Marshal.SizeOf(expectedArrayElementType) == Marshal.SizeOf(typeof(T)));
Array dataArray = _data as Array;
if (dataArray == null || _data.GetType().GetElementType() != expectedArrayElementType)
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIReferenceImpl.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIReferenceImpl.cs
index 3afd87ab12..d8fa4b3cae 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIReferenceImpl.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIReferenceImpl.cs
@@ -7,7 +7,6 @@
using System;
using System.Collections;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Reflection;
using System.Security;
@@ -55,7 +54,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
[System.Runtime.CompilerServices.FriendAccessAllowed]
internal static Object UnboxHelper(Object wrapper)
{
- Contract.Requires(wrapper != null);
+ Debug.Assert(wrapper != null);
IReference<T> reference = (IReference<T>)wrapper;
Debug.Assert(reference != null, "CLRIReferenceImpl::UnboxHelper - QI'ed for IReference<" + typeof(T) + ">, but that failed.");
return reference.Value;
@@ -218,7 +217,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
[System.Runtime.CompilerServices.FriendAccessAllowed]
internal static Object UnboxHelper(Object wrapper)
{
- Contract.Requires(wrapper != null);
+ Debug.Assert(wrapper != null);
IReferenceArray<T> reference = (IReferenceArray<T>)wrapper;
Debug.Assert(reference != null, "CLRIReferenceArrayImpl::UnboxHelper - QI'ed for IReferenceArray<" + typeof(T) + ">, but that failed.");
T[] marshaled = reference.Value;
@@ -235,8 +234,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
internal static Object CreateIReference(Object obj)
{
- Contract.Requires(obj != null, "Null should not be boxed.");
- Contract.Ensures(Contract.Result<Object>() != null);
+ Debug.Assert(obj != null, "Null should not be boxed.");
Type type = obj.GetType();
@@ -311,9 +309,8 @@ namespace System.Runtime.InteropServices.WindowsRuntime
internal static Object CreateIReferenceArray(Array obj)
{
- Contract.Requires(obj != null);
- Contract.Requires(obj.GetType().IsArray);
- Contract.Ensures(Contract.Result<Object>() != null);
+ Debug.Assert(obj != null);
+ Debug.Assert(obj.GetType().IsArray);
Type type = obj.GetType().GetElementType();
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs
index 5a4a5e8a7b..188d1033b3 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs
@@ -45,7 +45,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
{
if (data == null)
throw new ArgumentNullException(nameof(data));
- Contract.EndContractBlock();
firstItemIndex = 0;
lastItemIndex = data.Count - 1;
@@ -177,11 +176,11 @@ namespace System.Runtime.InteropServices.WindowsRuntime
internal IKeyValuePairEnumerator(KeyValuePair<TKey, TValue>[] items, int first, int end)
{
- Contract.Requires(items != null);
- Contract.Requires(first >= 0);
- Contract.Requires(end >= 0);
- Contract.Requires(first < items.Length);
- Contract.Requires(end < items.Length);
+ Debug.Assert(items != null);
+ Debug.Assert(first >= 0);
+ Debug.Assert(end >= 0);
+ Debug.Assert(first < items.Length);
+ Debug.Assert(end < items.Length);
_array = items;
_start = first;
@@ -203,8 +202,8 @@ namespace System.Runtime.InteropServices.WindowsRuntime
{
get
{
- if (_current < _start) throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumNotStarted));
- if (_current > _end) throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumEnded));
+ if (_current < _start) throw new InvalidOperationException(SR.InvalidOperation_EnumNotStarted);
+ if (_current > _end) throw new InvalidOperationException(SR.InvalidOperation_EnumEnded);
return new CLRIKeyValuePairImpl<TKey, TValue>(ref _array[_current]);
}
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CustomPropertyImpl.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CustomPropertyImpl.cs
index 63565a39b8..ae58844273 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CustomPropertyImpl.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CustomPropertyImpl.cs
@@ -8,7 +8,6 @@ using System;
using System.Security;
using System.Reflection;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryToMapAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryToMapAdapter.cs
index 6325966f82..5d9f332a61 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryToMapAdapter.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryToMapAdapter.cs
@@ -11,7 +11,6 @@ using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryValueCollection.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryValueCollection.cs
index 6be0ddd9f0..d441a2fbf8 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryValueCollection.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryValueCollection.cs
@@ -6,7 +6,6 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.WindowsRuntime;
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/EnumeratorToIteratorAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/EnumeratorToIteratorAdapter.cs
index e7bc95ead4..95158b093d 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/EnumeratorToIteratorAdapter.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/EnumeratorToIteratorAdapter.cs
@@ -8,7 +8,6 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
@@ -74,7 +73,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
internal EnumeratorToIteratorAdapter(IEnumerator<T> enumerator)
{
- Contract.Requires(enumerator != null);
+ Debug.Assert(enumerator != null);
m_enumerator = enumerator;
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/EventRegistrationTokenTable.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/EventRegistrationTokenTable.cs
index 974da48a42..2ecd4181db 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/EventRegistrationTokenTable.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/EventRegistrationTokenTable.cs
@@ -6,7 +6,7 @@
using System;
using System.Collections.Generic;
-using System.Diagnostics.Contracts;
+using System.Diagnostics;
using System.Threading;
namespace System.Runtime.InteropServices.WindowsRuntime
@@ -73,7 +73,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
private EventRegistrationToken AddEventHandlerNoLock(T handler)
{
- Contract.Requires(handler != null);
+ Debug.Assert(handler != null);
// Get a registration token, making sure that we haven't already used the value. This should be quite
// rare, but in the case it does happen, just keep trying until we find one that's unused.
@@ -127,7 +127,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
// 2. Use it as a guess to quickly see if the handler was really assigned this token value
private static EventRegistrationToken GetPreferredToken(T handler)
{
- Contract.Requires(handler != null);
+ Debug.Assert(handler != null);
// We want to generate a token value that has the following properties:
// 1. is quickly obtained from the handler instance
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IClosable.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IClosable.cs
index b7cd87acfc..564b86e685 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IClosable.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IClosable.cs
@@ -8,7 +8,6 @@ using System;
using System.Security;
using System.Collections;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
namespace System.Runtime.InteropServices.WindowsRuntime
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ICustomProperty.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ICustomProperty.cs
index 3ff4ffd098..07fb8f171a 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ICustomProperty.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ICustomProperty.cs
@@ -5,7 +5,6 @@
//
using System;
-using System.Diagnostics.Contracts;
namespace System.Runtime.InteropServices.WindowsRuntime
{
@@ -16,35 +15,29 @@ namespace System.Runtime.InteropServices.WindowsRuntime
{
Type Type
{
- [Pure]
get;
}
string Name
{
- [Pure]
get;
}
- [Pure]
object GetValue(object target);
void SetValue(object target, object value);
- [Pure]
object GetValue(object target, object indexValue);
void SetValue(object target, object value, object indexValue);
bool CanWrite
{
- [Pure]
get;
}
bool CanRead
{
- [Pure]
get;
}
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ICustomPropertyProvider.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ICustomPropertyProvider.cs
index 0c9fc3609b..bbe4d5e734 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ICustomPropertyProvider.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ICustomPropertyProvider.cs
@@ -7,7 +7,7 @@
using System;
using System.StubHelpers;
using System.Reflection;
-using System.Diagnostics.Contracts;
+using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Collections;
using System.Collections.Generic;
@@ -27,8 +27,8 @@ namespace System.Runtime.InteropServices.WindowsRuntime
//
static internal ICustomProperty CreateProperty(object target, string propertyName)
{
- Contract.Requires(target != null);
- Contract.Requires(propertyName != null);
+ Debug.Assert(target != null);
+ Debug.Assert(propertyName != null);
IGetProxyTarget proxy = target as IGetProxyTarget;
if (proxy != null)
@@ -51,8 +51,8 @@ namespace System.Runtime.InteropServices.WindowsRuntime
//
static internal unsafe ICustomProperty CreateIndexedProperty(object target, string propertyName, TypeNameNative* pIndexedParamType)
{
- Contract.Requires(target != null);
- Contract.Requires(propertyName != null);
+ Debug.Assert(target != null);
+ Debug.Assert(propertyName != null);
Type indexedParamType = null;
SystemTypeMarshaler.ConvertToManaged(pIndexedParamType, ref indexedParamType);
@@ -62,8 +62,8 @@ namespace System.Runtime.InteropServices.WindowsRuntime
static internal ICustomProperty CreateIndexedProperty(object target, string propertyName, Type indexedParamType)
{
- Contract.Requires(target != null);
- Contract.Requires(propertyName != null);
+ Debug.Assert(target != null);
+ Debug.Assert(propertyName != null);
IGetProxyTarget proxy = target as IGetProxyTarget;
if (proxy != null)
@@ -243,7 +243,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
//
// IBindableVector implementation (forwards to IBindableVector / IVector<T>)
//
- [Pure]
object IBindableVector.GetAt(uint index)
{
IBindableVector bindableVector = GetIBindableVectorNoThrow();
@@ -259,7 +258,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
}
}
- [Pure]
uint IBindableVector.Size
{
get
@@ -278,7 +276,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
}
}
- [Pure]
IBindableVectorView IBindableVector.GetView()
{
IBindableVector bindableVector = GetIBindableVectorNoThrow();
@@ -303,13 +300,11 @@ namespace System.Runtime.InteropServices.WindowsRuntime
_vectorView = vectorView;
}
- [Pure]
object IBindableVectorView.GetAt(uint index)
{
return _vectorView.GetAt(index);
}
- [Pure]
uint IBindableVectorView.Size
{
get
@@ -318,7 +313,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
}
}
- [Pure]
bool IBindableVectorView.IndexOf(object value, out uint index)
{
return _vectorView.IndexOf(ConvertTo<T>(value), out index);
@@ -330,7 +324,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
}
}
- [Pure]
bool IBindableVector.IndexOf(object value, out uint index)
{
IBindableVector bindableVector = GetIBindableVectorNoThrow();
@@ -456,7 +449,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
//
// IBindableVectorView implementation (forwarding to IBindableVectorView or IVectorView<T>)
//
- [Pure]
object IBindableVectorView.GetAt(uint index)
{
IBindableVectorView bindableVectorView = GetIBindableVectorViewNoThrow();
@@ -466,7 +458,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
return GetVectorViewOfT().GetAt(index);
}
- [Pure]
uint IBindableVectorView.Size
{
get
@@ -479,7 +470,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
}
}
- [Pure]
bool IBindableVectorView.IndexOf(object value, out uint index)
{
IBindableVectorView bindableVectorView = GetIBindableVectorViewNoThrow();
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IIterable.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IIterable.cs
index 30ce895423..a44591245f 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IIterable.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IIterable.cs
@@ -6,7 +6,6 @@
using System;
using System.Collections.Generic;
-using System.Diagnostics.Contracts;
// Windows.Foundation.Collections.IIterable`1 cannot be referenced from managed code because it's hidden
// by the metadata adapter. We redeclare the interface manually to be able to talk to native WinRT objects.
@@ -18,7 +17,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
[WindowsRuntimeImport]
internal interface IIterable<T> : IEnumerable<T>
{
- [Pure]
IIterator<T> First();
}
@@ -27,7 +25,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
[WindowsRuntimeImport]
internal interface IBindableIterable
{
- [Pure]
IBindableIterator First();
}
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IIterator.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IIterator.cs
index 83817494df..00d622b711 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IIterator.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IIterator.cs
@@ -5,7 +5,6 @@
//
using System;
-using System.Diagnostics.Contracts;
namespace System.Runtime.InteropServices.WindowsRuntime
{
@@ -14,13 +13,11 @@ namespace System.Runtime.InteropServices.WindowsRuntime
[Guid("6a79e863-4300-459a-9966-cbb660963ee1")]
internal interface IIterator<T>
{
- [Pure]
T Current
{
get;
}
- [Pure]
bool HasCurrent
{
get;
@@ -28,7 +25,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
bool MoveNext();
- [Pure]
int GetMany([Out] T[] items);
}
@@ -37,13 +33,11 @@ namespace System.Runtime.InteropServices.WindowsRuntime
[Guid("6a1d6c07-076d-49f2-8314-f52c9c9a8331")]
internal interface IBindableIterator
{
- [Pure]
object Current
{
get;
}
- [Pure]
bool HasCurrent
{
get;
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IMap.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IMap.cs
index 1f954a66b0..02dff54eac 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IMap.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IMap.cs
@@ -6,7 +6,6 @@
using System;
using System.Collections.Generic;
-using System.Diagnostics.Contracts;
// Windows.Foundation.Collections.IMap`2, IMapView`2, and IKeyValuePair`2 cannot be referenced from
// managed code because they're hidden by the metadata adapter. We redeclare the interfaces manually
@@ -19,13 +18,9 @@ namespace System.Runtime.InteropServices.WindowsRuntime
[WindowsRuntimeImport]
internal interface IMap<K, V> : IIterable<IKeyValuePair<K, V>>
{
- [Pure]
V Lookup(K key);
- [Pure]
uint Size { get; }
- [Pure]
bool HasKey(K key);
- [Pure]
IReadOnlyDictionary<K, V> GetView(); // Really an IMapView<K, V>
bool Insert(K key, V value);
void Remove(K key);
@@ -37,13 +32,9 @@ namespace System.Runtime.InteropServices.WindowsRuntime
[WindowsRuntimeImport]
internal interface IMapView<K, V> : IIterable<IKeyValuePair<K, V>>
{
- [Pure]
V Lookup(K key);
- [Pure]
uint Size { get; }
- [Pure]
bool HasKey(K key);
- [Pure]
void Split(out IMapView<K, V> first, out IMapView<K, V> second);
}
@@ -52,9 +43,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
[WindowsRuntimeImport]
internal interface IKeyValuePair<K, V>
{
- [Pure]
K Key { get; }
- [Pure]
V Value { get; }
}
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IMapViewToIReadOnlyDictionaryAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IMapViewToIReadOnlyDictionaryAdapter.cs
index f309cfd0d8..aa7bf76750 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IMapViewToIReadOnlyDictionaryAdapter.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IMapViewToIReadOnlyDictionaryAdapter.cs
@@ -9,7 +9,6 @@ using System.Security;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
@@ -36,7 +35,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
{
if (key == null)
throw new ArgumentNullException(nameof(key));
- Contract.EndContractBlock();
IMapView<K, V> _this = Unsafe.As<IMapView<K, V>>(this);
return Lookup(_this, key);
@@ -59,7 +57,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
}
// bool ContainsKey(K key)
- [Pure]
internal bool ContainsKey<K, V>(K key)
{
if (key == null)
@@ -105,7 +102,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
private static V Lookup<K, V>(IMapView<K, V> _this, K key)
{
- Contract.Requires(null != key);
+ Debug.Assert(null != key);
try
{
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IPropertyValue.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IPropertyValue.cs
index a2b07b2ea7..8a67119496 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IPropertyValue.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IPropertyValue.cs
@@ -5,7 +5,6 @@
//
using System;
-using System.Diagnostics.Contracts;
namespace System.Runtime.InteropServices.WindowsRuntime
{
@@ -16,125 +15,86 @@ namespace System.Runtime.InteropServices.WindowsRuntime
{
PropertyType Type
{
- [Pure]
get;
}
bool IsNumericScalar
{
- [Pure]
get;
}
- [Pure]
Byte GetUInt8();
- [Pure]
Int16 GetInt16();
- [Pure]
UInt16 GetUInt16();
- [Pure]
Int32 GetInt32();
- [Pure]
UInt32 GetUInt32();
- [Pure]
Int64 GetInt64();
- [Pure]
UInt64 GetUInt64();
- [Pure]
Single GetSingle();
- [Pure]
Double GetDouble();
- [Pure]
char GetChar16();
- [Pure]
Boolean GetBoolean();
- [Pure]
String GetString();
- [Pure]
Guid GetGuid();
- [Pure]
DateTimeOffset GetDateTime();
- [Pure]
TimeSpan GetTimeSpan();
- [Pure]
Point GetPoint();
- [Pure]
Size GetSize();
- [Pure]
Rect GetRect();
- [Pure]
Byte[] GetUInt8Array();
- [Pure]
Int16[] GetInt16Array();
- [Pure]
UInt16[] GetUInt16Array();
- [Pure]
Int32[] GetInt32Array();
- [Pure]
UInt32[] GetUInt32Array();
- [Pure]
Int64[] GetInt64Array();
- [Pure]
UInt64[] GetUInt64Array();
- [Pure]
Single[] GetSingleArray();
- [Pure]
Double[] GetDoubleArray();
- [Pure]
char[] GetChar16Array();
- [Pure]
Boolean[] GetBooleanArray();
- [Pure]
String[] GetStringArray();
- [Pure]
object[] GetInspectableArray();
- [Pure]
Guid[] GetGuidArray();
- [Pure]
DateTimeOffset[] GetDateTimeArray();
- [Pure]
TimeSpan[] GetTimeSpanArray();
- [Pure]
Point[] GetPointArray();
- [Pure]
Size[] GetSizeArray();
- [Pure]
Rect[] GetRectArray();
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IReadOnlyDictionaryToIMapViewAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IReadOnlyDictionaryToIMapViewAdapter.cs
index ef9959b764..f5bc58a7e5 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IReadOnlyDictionaryToIMapViewAdapter.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IReadOnlyDictionaryToIMapViewAdapter.cs
@@ -9,7 +9,6 @@ using System.Security;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IReadOnlyListToIVectorViewAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IReadOnlyListToIVectorViewAdapter.cs
index a3e7b868ee..c69115d1eb 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IReadOnlyListToIVectorViewAdapter.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IReadOnlyListToIVectorViewAdapter.cs
@@ -9,7 +9,6 @@ using System.Security;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IVector.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IVector.cs
index e88f4f3b9f..f00a7d3504 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IVector.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IVector.cs
@@ -6,7 +6,6 @@
using System;
using System.Collections.Generic;
-using System.Diagnostics.Contracts;
// Windows.Foundation.Collections.IVector`1 and IVectorView`1 cannot be referenced from managed
// code because they're hidden by the metadata adapter. We redeclare the interfaces manually
@@ -19,13 +18,9 @@ namespace System.Runtime.InteropServices.WindowsRuntime
[WindowsRuntimeImport]
internal interface IVector<T> : IIterable<T>
{
- [Pure]
T GetAt(uint index);
- [Pure]
uint Size { get; }
- [Pure]
IReadOnlyList<T> GetView(); // Really an IVectorView<T>.
- [Pure]
bool IndexOf(T value, out uint index);
void SetAt(uint index, T value);
void InsertAt(uint index, T value);
@@ -33,7 +28,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
void Append(T value);
void RemoveAtEnd();
void Clear();
- [Pure]
uint GetMany(uint startIndex, [Out] T[] items);
void ReplaceAll(T[] items);
}
@@ -44,13 +38,9 @@ namespace System.Runtime.InteropServices.WindowsRuntime
[WindowsRuntimeImport]
internal interface IVector_Raw<T> : IIterable<T>
{
- [Pure]
T GetAt(uint index);
- [Pure]
uint Size { get; }
- [Pure]
IVectorView<T> GetView();
- [Pure]
bool IndexOf(T value, out uint index);
void SetAt(uint index, T value);
void InsertAt(uint index, T value);
@@ -65,13 +55,9 @@ namespace System.Runtime.InteropServices.WindowsRuntime
[WindowsRuntimeImport]
internal interface IVectorView<T> : IIterable<T>
{
- [Pure]
T GetAt(uint index);
- [Pure]
uint Size { get; }
- [Pure]
bool IndexOf(T value, out uint index);
- [Pure]
uint GetMany(uint startIndex, [Out] T[] items);
}
@@ -80,13 +66,9 @@ namespace System.Runtime.InteropServices.WindowsRuntime
[WindowsRuntimeImport]
internal interface IBindableVector : IBindableIterable
{
- [Pure]
object GetAt(uint index);
- [Pure]
uint Size { get; }
- [Pure]
IBindableVectorView GetView();
- [Pure]
bool IndexOf(object value, out uint index);
void SetAt(uint index, object value);
void InsertAt(uint index, object value);
@@ -101,11 +83,8 @@ namespace System.Runtime.InteropServices.WindowsRuntime
[WindowsRuntimeImport]
internal interface IBindableVectorView : IBindableIterable
{
- [Pure]
object GetAt(uint index);
- [Pure]
uint Size { get; }
- [Pure]
bool IndexOf(object value, out uint index);
}
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IVectorViewToIReadOnlyListAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IVectorViewToIReadOnlyListAdapter.cs
index 1a5f291da8..1445670680 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IVectorViewToIReadOnlyListAdapter.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IVectorViewToIReadOnlyListAdapter.cs
@@ -9,7 +9,6 @@ using System.Security;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IteratorToEnumeratorAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IteratorToEnumeratorAdapter.cs
index 321dba2ab0..7bc2fa06a9 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IteratorToEnumeratorAdapter.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IteratorToEnumeratorAdapter.cs
@@ -8,7 +8,6 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Security;
@@ -109,7 +108,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
internal IteratorToEnumeratorAdapter(IIterator<T> iterator)
{
- Contract.Requires(iterator != null);
+ Debug.Assert(iterator != null);
m_iterator = iterator;
m_hadCurrent = true;
m_isInitialized = false;
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToBindableVectorAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToBindableVectorAdapter.cs
index 5ba5e1e2ec..c0c8769b5a 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToBindableVectorAdapter.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToBindableVectorAdapter.cs
@@ -11,7 +11,6 @@ using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToBindableVectorViewAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToBindableVectorViewAdapter.cs
index 75c9b9d086..e92b879b1d 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToBindableVectorViewAdapter.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToBindableVectorViewAdapter.cs
@@ -10,7 +10,6 @@ using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
-using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
@@ -27,7 +26,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
if (list == null)
throw new ArgumentNullException(nameof(list));
- Contract.EndContractBlock();
this.list = list;
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToVectorAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToVectorAdapter.cs
index f138bcbae8..4f23f639f2 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToVectorAdapter.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToVectorAdapter.cs
@@ -11,7 +11,6 @@ using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ManagedActivationFactory.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ManagedActivationFactory.cs
index 12b13ac79b..82ef71c783 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ManagedActivationFactory.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ManagedActivationFactory.cs
@@ -5,7 +5,6 @@
//
using System;
-using System.Diagnostics.Contracts;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapToCollectionAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapToCollectionAdapter.cs
index 11ed78676f..8cc189b162 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapToCollectionAdapter.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapToCollectionAdapter.cs
@@ -9,7 +9,6 @@ using System.Security;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
@@ -34,7 +33,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
}
// int Count { get }
- [Pure]
internal int Count<K, V>()
{
object _this = Unsafe.As<object>(this);
@@ -145,7 +143,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
if (array.Length - arrayIndex < Count<K, V>())
throw new ArgumentException(SR.Argument_InsufficientSpaceToCopyCollection);
- Contract.EndContractBlock();
IIterable<KeyValuePair<K, V>> _this = Unsafe.As<IIterable<KeyValuePair<K, V>>>(this);
foreach (KeyValuePair<K, V> mapping in _this)
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapToDictionaryAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapToDictionaryAdapter.cs
index 296b453b85..a69acb7eeb 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapToDictionaryAdapter.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapToDictionaryAdapter.cs
@@ -9,7 +9,6 @@ using System.Security;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
@@ -36,7 +35,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
if (key == null)
throw new ArgumentNullException(nameof(key));
- Contract.EndContractBlock();
IMap<K, V> _this = Unsafe.As<IMap<K, V>>(this);
return Lookup(_this, key);
@@ -48,7 +46,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
if (key == null)
throw new ArgumentNullException(nameof(key));
- Contract.EndContractBlock();
IMap<K, V> _this = Unsafe.As<IMap<K, V>>(this);
Insert(_this, key, value);
@@ -71,7 +68,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
}
// bool ContainsKey(K key)
- [Pure]
internal bool ContainsKey<K, V>(K key)
{
if (key == null)
@@ -90,7 +86,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
if (ContainsKey<K, V>(key))
throw new ArgumentException(SR.Argument_AddingDuplicate);
- Contract.EndContractBlock();
IMap<K, V> _this = Unsafe.As<IMap<K, V>>(this);
Insert(_this, key, value);
@@ -149,7 +144,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
private static V Lookup<K, V>(IMap<K, V> _this, K key)
{
- Contract.Requires(null != key);
+ Debug.Assert(null != key);
try
{
@@ -165,7 +160,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
private static bool Insert<K, V>(IMap<K, V> _this, K key, V value)
{
- Contract.Requires(null != key);
+ Debug.Assert(null != key);
bool replaced = _this.Insert(key, value);
return replaced;
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapViewToReadOnlyCollectionAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapViewToReadOnlyCollectionAdapter.cs
index a006d905d1..16e21e21a1 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapViewToReadOnlyCollectionAdapter.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapViewToReadOnlyCollectionAdapter.cs
@@ -9,7 +9,6 @@ using System.Security;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
@@ -34,7 +33,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
}
// int Count { get }
- [Pure]
internal int Count<K, V>()
{
object _this = Unsafe.As<object>(this);
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/PropertyValue.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/PropertyValue.cs
index 8a3e2066cf..f083eb29b8 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/PropertyValue.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/PropertyValue.cs
@@ -5,7 +5,6 @@
//
using System;
-using System.Diagnostics.Contracts;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorToCollectionAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorToCollectionAdapter.cs
index 71de208c3e..ff10971f91 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorToCollectionAdapter.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorToCollectionAdapter.cs
@@ -9,7 +9,6 @@ using System.Security;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
@@ -31,7 +30,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
}
// int Count { get }
- [Pure]
internal int Count<T>()
{
IVector<T> _this = Unsafe.As<IVector<T>>(this);
@@ -88,7 +86,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
if (array.Length - arrayIndex < Count<T>())
throw new ArgumentException(SR.Argument_InsufficientSpaceToCopyCollection);
- Contract.EndContractBlock();
IVector<T> _this = Unsafe.As<IVector<T>>(this);
int count = Count<T>();
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorToListAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorToListAdapter.cs
index 4d0163e8f9..3e4e5ad67d 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorToListAdapter.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorToListAdapter.cs
@@ -9,7 +9,6 @@ using System.Security;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorViewToReadOnlyCollectionAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorViewToReadOnlyCollectionAdapter.cs
index 9925eea2d0..679060bf4d 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorViewToReadOnlyCollectionAdapter.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorViewToReadOnlyCollectionAdapter.cs
@@ -9,7 +9,6 @@ using System.Security;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
@@ -31,7 +30,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
}
// int Count { get }
- [Pure]
internal int Count<T>()
{
IVectorView<T> _this = Unsafe.As<IVectorView<T>>(this);
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs
index 1d07a022f4..916ddcc9b6 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs
@@ -7,7 +7,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -32,7 +31,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
throw new ArgumentNullException(nameof(addMethod));
if (removeMethod == null)
throw new ArgumentNullException(nameof(removeMethod));
- Contract.EndContractBlock();
// Managed code allows adding a null event handler, the effect is a no-op. To match this behavior
// for WinRT events, we simply ignore attempts to add null.
@@ -58,7 +56,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
{
if (removeMethod == null)
throw new ArgumentNullException(nameof(removeMethod));
- Contract.EndContractBlock();
// Managed code allows removing a null event handler, the effect is a no-op. To match this behavior
// for WinRT events, we simply ignore attempts to remove null.
@@ -82,7 +79,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
{
if (removeMethod == null)
throw new ArgumentNullException(nameof(removeMethod));
- Contract.EndContractBlock();
// Delegate to managed event registration implementation or native event registration implementation
// They have completely different implementation because native side has its own unique problem to solve -
@@ -217,8 +213,8 @@ namespace System.Runtime.InteropServices.WindowsRuntime
Action<EventRegistrationToken> removeMethod,
T handler)
{
- Contract.Requires(addMethod != null);
- Contract.Requires(removeMethod != null);
+ Debug.Assert(addMethod != null);
+ Debug.Assert(removeMethod != null);
// Add the method, and make a note of the token -> delegate mapping.
object instance = removeMethod.Target;
@@ -248,9 +244,9 @@ namespace System.Runtime.InteropServices.WindowsRuntime
// Get the event registration token table for an event. These are indexed by the remove method of the event.
private static Dictionary<object, EventRegistrationTokenList> GetEventRegistrationTokenTable(object instance, Action<EventRegistrationToken> removeMethod)
{
- Contract.Requires(instance != null);
- Contract.Requires(removeMethod != null);
- Contract.Requires(s_eventRegistrations != null);
+ Debug.Assert(instance != null);
+ Debug.Assert(removeMethod != null);
+ Debug.Assert(s_eventRegistrations != null);
lock (s_eventRegistrations)
{
@@ -274,7 +270,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
internal static void RemoveEventHandler<T>(Action<EventRegistrationToken> removeMethod, T handler)
{
- Contract.Requires(removeMethod != null);
+ Debug.Assert(removeMethod != null);
object instance = removeMethod.Target;
Dictionary<object, EventRegistrationTokenList> registrationTokens = GetEventRegistrationTokenTable(instance, removeMethod);
@@ -315,7 +311,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
internal static void RemoveAllEventHandlers(Action<EventRegistrationToken> removeMethod)
{
- Contract.Requires(removeMethod != null);
+ Debug.Assert(removeMethod != null);
object instance = removeMethod.Target;
Dictionary<object, EventRegistrationTokenList> registrationTokens = GetEventRegistrationTokenTable(instance, removeMethod);
@@ -480,7 +476,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
{
// Time to destroy cache for this IUnknown */type instance
// because the total token list count has dropped to 0 and we don't have any events subscribed
- Contract.Requires(s_eventRegistrations != null);
+ Debug.Assert(s_eventRegistrations != null);
BCLDebug.Log("INTEROP", "[WinRT_Eventing] Removing " + _key + " from cache" + "\n");
s_eventRegistrations.Remove(_key);
@@ -634,16 +630,16 @@ namespace System.Runtime.InteropServices.WindowsRuntime
private static ConditionalWeakTable<object, EventRegistrationTokenListWithCount> GetEventRegistrationTokenTableNoCreate(object instance, Action<EventRegistrationToken> removeMethod, out TokenListCount tokenListCount)
{
- Contract.Requires(instance != null);
- Contract.Requires(removeMethod != null);
+ Debug.Assert(instance != null);
+ Debug.Assert(removeMethod != null);
return GetEventRegistrationTokenTableInternal(instance, removeMethod, out tokenListCount, /* createIfNotFound = */ false);
}
private static ConditionalWeakTable<object, EventRegistrationTokenListWithCount> GetOrCreateEventRegistrationTokenTable(object instance, Action<EventRegistrationToken> removeMethod, out TokenListCount tokenListCount)
{
- Contract.Requires(instance != null);
- Contract.Requires(removeMethod != null);
+ Debug.Assert(instance != null);
+ Debug.Assert(removeMethod != null);
return GetEventRegistrationTokenTableInternal(instance, removeMethod, out tokenListCount, /* createIfNotFound = */ true);
}
@@ -651,9 +647,9 @@ namespace System.Runtime.InteropServices.WindowsRuntime
// Get the event registration token table for an event. These are indexed by the remove method of the event.
private static ConditionalWeakTable<object, EventRegistrationTokenListWithCount> GetEventRegistrationTokenTableInternal(object instance, Action<EventRegistrationToken> removeMethod, out TokenListCount tokenListCount, bool createIfNotFound)
{
- Contract.Requires(instance != null);
- Contract.Requires(removeMethod != null);
- Contract.Requires(s_eventRegistrations != null);
+ Debug.Assert(instance != null);
+ Debug.Assert(removeMethod != null);
+ Debug.Assert(s_eventRegistrations != null);
EventCacheKey eventCacheKey;
eventCacheKey.target = instance;
@@ -1045,7 +1041,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
internal static unsafe string HStringToString(IntPtr hstring)
{
- Contract.Requires(Environment.IsWinRTSupported);
+ Debug.Assert(Environment.IsWinRTSupported);
// There is no difference between a null and empty HSTRING
if (hstring == IntPtr.Zero)
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMetadata.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMetadata.cs
index 0f28d3b080..b218b114b4 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMetadata.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMetadata.cs
@@ -7,7 +7,6 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
-using System.Diagnostics.Contracts;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Aes.PlatformNotSupported.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Aes.PlatformNotSupported.cs
new file mode 100644
index 0000000000..68c0a13526
--- /dev/null
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Aes.PlatformNotSupported.cs
@@ -0,0 +1,74 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.Intrinsics;
+
+namespace System.Runtime.Intrinsics.X86
+{
+ /// <summary>
+ /// This class provides access to Intel AES hardware instructions via intrinsics
+ /// </summary>
+ [CLSCompliant(false)]
+ public static class Aes
+ {
+ public static bool IsSupported { get { return false; } }
+
+ /// <summary>
+ /// __m128i _mm_aesdec_si128 (__m128i a, __m128i RoundKey)
+ /// </summary>
+ public static Vector128<sbyte> Decrypt(Vector128<sbyte> value, Vector128<sbyte> roundKey) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_aesdec_si128 (__m128i a, __m128i RoundKey)
+ /// </summary>
+ public static Vector128<byte> Decrypt(Vector128<byte> value, Vector128<byte> roundKey) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_aesdeclast_si128 (__m128i a, __m128i RoundKey)
+ /// </summary>
+ public static Vector128<sbyte> DecryptLast(Vector128<sbyte> value, Vector128<sbyte> roundKey) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_aesdeclast_si128 (__m128i a, __m128i RoundKey)
+ /// </summary>
+ public static Vector128<byte> DecryptLast(Vector128<byte> value, Vector128<byte> roundKey) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_aesenc_si128 (__m128i a, __m128i RoundKey)
+ /// </summary>
+ public static Vector128<sbyte> Encrypt(Vector128<sbyte> value, Vector128<sbyte> roundKey) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_aesenc_si128 (__m128i a, __m128i RoundKey)
+ /// </summary>
+ public static Vector128<byte> Encrypt(Vector128<byte> value, Vector128<byte> roundKey) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_aesenclast_si128 (__m128i a, __m128i RoundKey)
+ /// </summary>
+ public static Vector128<sbyte> EncryptLast(Vector128<sbyte> value, Vector128<sbyte> roundKey) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_aesenclast_si128 (__m128i a, __m128i RoundKey)
+ /// </summary>
+ public static Vector128<byte> EncryptLast(Vector128<byte> value, Vector128<byte> roundKey) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_aesimc_si128 (__m128i a)
+ /// </summary>
+ public static Vector128<sbyte> InvisibleMixColumn(Vector128<sbyte> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_aesimc_si128 (__m128i a)
+ /// </summary>
+ public static Vector128<byte> InvisibleMixColumn(Vector128<byte> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_aeskeygenassist_si128 (__m128i a, const int imm8)
+ /// </summary>
+ public static Vector128<sbyte> KeygenAssist(Vector128<sbyte> value, byte control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_aeskeygenassist_si128 (__m128i a, const int imm8)
+ /// </summary>
+ public static Vector128<byte> KeygenAssist(Vector128<byte> value, byte control) { throw new PlatformNotSupportedException(); }
+
+ }
+
+}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Aes.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Aes.cs
index 43aebc990c..b3c2a3da47 100644
--- a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Aes.cs
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Aes.cs
@@ -13,61 +13,61 @@ namespace System.Runtime.Intrinsics.X86
[CLSCompliant(false)]
public static class Aes
{
- public static bool IsSupported { get { return false; } }
+ public static bool IsSupported { get => IsSupported; }
/// <summary>
/// __m128i _mm_aesdec_si128 (__m128i a, __m128i RoundKey)
/// </summary>
- public static Vector128<sbyte> Decrypt(Vector128<sbyte> value, Vector128<sbyte> roundKey) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> Decrypt(Vector128<sbyte> value, Vector128<sbyte> roundKey) => Decrypt(value, roundKey);
/// <summary>
/// __m128i _mm_aesdec_si128 (__m128i a, __m128i RoundKey)
/// </summary>
- public static Vector128<byte> Decrypt(Vector128<byte> value, Vector128<byte> roundKey) { throw new NotImplementedException(); }
+ public static Vector128<byte> Decrypt(Vector128<byte> value, Vector128<byte> roundKey) => Decrypt(value, roundKey);
/// <summary>
/// __m128i _mm_aesdeclast_si128 (__m128i a, __m128i RoundKey)
/// </summary>
- public static Vector128<sbyte> DecryptLast(Vector128<sbyte> value, Vector128<sbyte> roundKey) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> DecryptLast(Vector128<sbyte> value, Vector128<sbyte> roundKey) => DecryptLast(value, roundKey);
/// <summary>
/// __m128i _mm_aesdeclast_si128 (__m128i a, __m128i RoundKey)
/// </summary>
- public static Vector128<byte> DecryptLast(Vector128<byte> value, Vector128<byte> roundKey) { throw new NotImplementedException(); }
+ public static Vector128<byte> DecryptLast(Vector128<byte> value, Vector128<byte> roundKey) => DecryptLast(value, roundKey);
/// <summary>
/// __m128i _mm_aesenc_si128 (__m128i a, __m128i RoundKey)
/// </summary>
- public static Vector128<sbyte> Encrypt(Vector128<sbyte> value, Vector128<sbyte> roundKey) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> Encrypt(Vector128<sbyte> value, Vector128<sbyte> roundKey) => Encrypt(value, roundKey);
/// <summary>
/// __m128i _mm_aesenc_si128 (__m128i a, __m128i RoundKey)
/// </summary>
- public static Vector128<byte> Encrypt(Vector128<byte> value, Vector128<byte> roundKey) { throw new NotImplementedException(); }
+ public static Vector128<byte> Encrypt(Vector128<byte> value, Vector128<byte> roundKey) => Encrypt(value, roundKey);
/// <summary>
/// __m128i _mm_aesenclast_si128 (__m128i a, __m128i RoundKey)
/// </summary>
- public static Vector128<sbyte> EncryptLast(Vector128<sbyte> value, Vector128<sbyte> roundKey) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> EncryptLast(Vector128<sbyte> value, Vector128<sbyte> roundKey) => EncryptLast(value, roundKey);
/// <summary>
/// __m128i _mm_aesenclast_si128 (__m128i a, __m128i RoundKey)
/// </summary>
- public static Vector128<byte> EncryptLast(Vector128<byte> value, Vector128<byte> roundKey) { throw new NotImplementedException(); }
+ public static Vector128<byte> EncryptLast(Vector128<byte> value, Vector128<byte> roundKey) => EncryptLast(value, roundKey);
/// <summary>
/// __m128i _mm_aesimc_si128 (__m128i a)
/// </summary>
- public static Vector128<sbyte> InvisibleMixColumn(Vector128<sbyte> value) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> InvisibleMixColumn(Vector128<sbyte> value) => InvisibleMixColumn(value);
/// <summary>
/// __m128i _mm_aesimc_si128 (__m128i a)
/// </summary>
- public static Vector128<byte> InvisibleMixColumn(Vector128<byte> value) { throw new NotImplementedException(); }
+ public static Vector128<byte> InvisibleMixColumn(Vector128<byte> value) => InvisibleMixColumn(value);
/// <summary>
/// __m128i _mm_aeskeygenassist_si128 (__m128i a, const int imm8)
/// </summary>
- public static Vector128<sbyte> KeygenAssist(Vector128<sbyte> value, byte control) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> KeygenAssist(Vector128<sbyte> value, byte control) => KeygenAssist(value, control);
/// <summary>
/// __m128i _mm_aeskeygenassist_si128 (__m128i a, const int imm8)
/// </summary>
- public static Vector128<byte> KeygenAssist(Vector128<byte> value, byte control) { throw new NotImplementedException(); }
+ public static Vector128<byte> KeygenAssist(Vector128<byte> value, byte control) => KeygenAssist(value, control);
}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Avx.PlatformNotSupported.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Avx.PlatformNotSupported.cs
new file mode 100644
index 0000000000..4eb9e3bb03
--- /dev/null
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Avx.PlatformNotSupported.cs
@@ -0,0 +1,996 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.Intrinsics;
+
+namespace System.Runtime.Intrinsics.X86
+{
+ /// <summary>
+ /// This class provides access to Intel AVX hardware instructions via intrinsics
+ /// </summary>
+ [CLSCompliant(false)]
+ public static class Avx
+ {
+ public static bool IsSupported { get { return false; } }
+
+ /// <summary>
+ /// __m256 _mm256_add_ps (__m256 a, __m256 b)
+ /// </summary>
+ public static Vector256<float> Add(Vector256<float> left, Vector256<float> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_add_pd (__m256d a, __m256d b)
+ /// </summary>
+ public static Vector256<double> Add(Vector256<double> left, Vector256<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_addsub_ps (__m256 a, __m256 b)
+ /// </summary>
+ public static Vector256<float> AddSubtract(Vector256<float> left, Vector256<float> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_addsub_pd (__m256d a, __m256d b)
+ /// </summary>
+ public static Vector256<double> AddSubtract(Vector256<double> left, Vector256<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_and_ps (__m256 a, __m256 b)
+ /// </summary>
+ public static Vector256<float> And(Vector256<float> left, Vector256<float> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_and_pd (__m256d a, __m256d b)
+ /// </summary>
+ public static Vector256<double> And(Vector256<double> left, Vector256<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_andnot_ps (__m256 a, __m256 b)
+ /// </summary>
+ public static Vector256<float> AndNot(Vector256<float> left, Vector256<float> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_andnot_pd (__m256d a, __m256d b)
+ /// </summary>
+ public static Vector256<double> AndNot(Vector256<double> left, Vector256<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_blend_ps (__m256 a, __m256 b, const int imm8)
+ /// </summary>
+ public static Vector256<float> Blend(Vector256<float> left, Vector256<float> right, byte control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_blend_pd (__m256d a, __m256d b, const int imm8)
+ /// </summary>
+ public static Vector256<double> Blend(Vector256<double> left, Vector256<double> right, byte control) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_blendv_ps (__m256 a, __m256 b, __m256 mask)
+ /// </summary>
+ public static Vector256<float> BlendVariable(Vector256<float> left, Vector256<float> right, Vector256<float> mask) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_blendv_pd (__m256d a, __m256d b, __m256d mask)
+ /// </summary>
+ public static Vector256<double> BlendVariable(Vector256<double> left, Vector256<double> right, Vector256<double> mask) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_broadcast_ss (float const * mem_addr)
+ /// </summary>
+ public static Vector128<float> BroadcastElementToVector128(ref float source) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_broadcast_ss (float const * mem_addr)
+ /// </summary>
+ public static Vector256<float> BroadcastElementToVector256(ref float source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_broadcast_sd (double const * mem_addr)
+ /// </summary>
+ public static Vector256<double> BroadcastElementToVector256(ref double source) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_broadcast_ps (__m128 const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<float> BroadcastVector128ToVector256(float* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_broadcast_pd (__m128d const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<double> BroadcastVector128ToVector256(double* address) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_ceil_ps (__m256 a)
+ /// </summary>
+ public static Vector256<float> Ceiling(Vector256<float> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_ceil_pd (__m256d a)
+ /// </summary>
+ public static Vector256<double> Ceiling(Vector256<double> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_cmp_ps (__m128 a, __m128 b, const int imm8)
+ /// </summary>
+ public static Vector128<float> Compare(Vector128<float> left, Vector128<float> right, FloatComparisonMode mode) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_cmp_pd (__m128d a, __m128d b, const int imm8)
+ /// </summary>
+ public static Vector128<double> Compare(Vector128<double> left, Vector128<double> right, FloatComparisonMode mode) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256 _mm256_cmp_ps (__m256 a, __m256 b, const int imm8)
+ /// </summary>
+ public static Vector256<float> Compare(Vector256<float> left, Vector256<float> right, FloatComparisonMode mode) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_cmp_pd (__m256d a, __m256d b, const int imm8)
+ /// </summary>
+ public static Vector256<double> Compare(Vector256<double> left, Vector256<double> right, FloatComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm256_cvtpd_epi32 (__m256d a)
+ /// </summary>
+ public static Vector128<int> ConvertToVector128Int(Vector256<double> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128 _mm256_cvtpd_ps (__m256d a)
+ /// </summary>
+ public static Vector128<float> ConvertToVector128Float(Vector256<double> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_cvtps_epi32 (__m256 a)
+ /// </summary>
+ public static Vector256<int> ConvertToVector256Int(Vector256<float> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256 _mm256_cvtepi32_ps (__m256i a)
+ /// </summary>
+ public static Vector256<float> ConvertToVector256Float(Vector256<int> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_cvtps_pd (__m128 a)
+ /// </summary>
+ public static Vector256<double> ConvertToVector256Double(Vector256<float> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_cvtepi32_pd (__m128i a)
+ /// </summary>
+ public static Vector256<double> ConvertToVector256Double(Vector256<int> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm256_cvttpd_epi32 (__m256d a)
+ /// </summary>
+ public static Vector128<int> ConvertToVector128IntWithTruncation(Vector256<double> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_cvttps_epi32 (__m256 a)
+ /// </summary>
+ public static Vector256<int> ConvertToVector256IntWithTruncation(Vector256<float> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_div_ps (__m256 a, __m256 b)
+ /// </summary>
+ public static Vector256<float> Divide(Vector256<float> left, Vector256<float> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_div_pd (__m256d a, __m256d b)
+ /// </summary>
+ public static Vector256<double> Divide(Vector256<double> left, Vector256<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_dp_ps (__m256 a, __m256 b, const int imm8)
+ /// </summary>
+ public static Vector256<float> DotProduct(Vector256<float> left, Vector256<float> right, byte control) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_moveldup_ps (__m256 a)
+ /// </summary>
+ public static Vector256<float> DuplicateEvenIndexed(Vector256<float> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_movedup_pd (__m256d a)
+ /// </summary>
+ public static Vector256<double> DuplicateEvenIndexed(Vector256<double> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_movehdup_ps (__m256 a)
+ /// </summary>
+ public static Vector256<float> DuplicateOddIndexed(Vector256<float> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __int8 _mm256_extract_epi8 (__m256i a, const int index)
+ /// </summary>
+ public static sbyte ExtractSbyte<T>(Vector256<T> value, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __int8 _mm256_extract_epi8 (__m256i a, const int index)
+ /// </summary>
+ public static byte ExtractByte<T>(Vector256<T> value, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __int16 _mm256_extract_epi16 (__m256i a, const int index)
+ /// </summary>
+ public static short ExtractShort<T>(Vector256<T> value, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __int16 _mm256_extract_epi16 (__m256i a, const int index)
+ /// </summary>
+ public static ushort ExtractUshort<T>(Vector256<T> value, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __int32 _mm256_extract_epi32 (__m256i a, const int index)
+ /// </summary>
+ public static int ExtractInt<T>(Vector256<T> value, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __int32 _mm256_extract_epi32 (__m256i a, const int index)
+ /// </summary>
+ public static uint ExtractUint<T>(Vector256<T> value, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __int64 _mm256_extract_epi64 (__m256i a, const int index)
+ /// </summary>
+ public static long ExtractLong<T>(Vector256<T> value, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __int64 _mm256_extract_epi64 (__m256i a, const int index)
+ /// </summary>
+ public static ulong ExtractUlong<T>(Vector256<T> value, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm256_extractf128_ps (__m256 a, const int imm8)
+ /// __m128d _mm256_extractf128_pd (__m256d a, const int imm8)
+ /// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector128<T> ExtractVector128<T>(Vector256<T> value, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8)
+ /// </summary>
+ public static unsafe void ExtractVector128(byte* address, Vector256<byte> value, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8)
+ /// </summary>
+ public static unsafe void ExtractVector128(sbyte* address, Vector256<sbyte> value, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8)
+ /// </summary>
+ public static unsafe void ExtractVector128(short* address, Vector256<short> value, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8)
+ /// </summary>
+ public static unsafe void ExtractVector128(ushort* address, Vector256<ushort> value, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8)
+ /// </summary>
+ public static unsafe void ExtractVector128(int* address, Vector256<int> value, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8)
+ /// </summary>
+ public static unsafe void ExtractVector128(uint* address, Vector256<uint> value, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8)
+ /// </summary>
+ public static unsafe void ExtractVector128(long* address, Vector256<long> value, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8)
+ /// </summary>
+ public static unsafe void ExtractVector128(ulong* address, Vector256<ulong> value, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128 _mm256_extractf128_ps (__m256 a, const int imm8)
+ /// </summary>
+ public static unsafe void ExtractVector128(float* address, Vector256<float> value, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm256_extractf128_pd (__m256d a, const int imm8)
+ /// </summary>
+ public static unsafe void ExtractVector128(double* address, Vector256<double> value, byte index) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256d _mm256_castpd128_pd256 (__m128d a)
+ /// __m256 _mm256_castps128_ps256 (__m128 a)
+ /// __m256i _mm256_castsi128_si256 (__m128i a)
+ /// </summary>
+ public static Vector256<T> ExtendToVector256<T>(Vector128<T> value) where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_floor_ps (__m256 a)
+ /// </summary>
+ public static Vector256<float> Floor(Vector256<float> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_floor_pd (__m256d a)
+ /// </summary>
+ public static Vector256<double> Floor(Vector256<double> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128d _mm256_castpd256_pd128 (__m256d a)
+ /// __m128 _mm256_castps256_ps128 (__m256 a)
+ /// __m128i _mm256_castsi256_si128 (__m256i a)
+ /// </summary>
+ public static Vector128<T> GetLowerHalf<T>(Vector256<T> value) where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_hadd_ps (__m256 a, __m256 b)
+ /// </summary>
+ public static Vector256<float> HorizontalAdd(Vector256<float> left, Vector256<float> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_hadd_pd (__m256d a, __m256d b)
+ /// </summary>
+ public static Vector256<double> HorizontalAdd(Vector256<double> left, Vector256<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_hsub_ps (__m256 a, __m256 b)
+ /// </summary>
+ public static Vector256<float> HorizontalSubtract(Vector256<float> left, Vector256<float> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_hsub_pd (__m256d a, __m256d b)
+ /// </summary>
+ public static Vector256<double> HorizontalSubtract(Vector256<double> left, Vector256<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_insert_epi8 (__m256i a, __int8 i, const int index)
+ /// </summary>
+ public static Vector256<T> InsertSbyte<T>(Vector256<T> value, sbyte data, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_insert_epi8 (__m256i a, __int8 i, const int index)
+ /// </summary>
+ public static Vector256<T> InsertByte<T>(Vector256<T> value, byte data, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_insert_epi16 (__m256i a, __int16 i, const int index)
+ /// </summary>
+ public static Vector256<T> InsertShort<T>(Vector256<T> value, short data, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_insert_epi16 (__m256i a, __int16 i, const int index)
+ /// </summary>
+ public static Vector256<T> InsertUshort<T>(Vector256<T> value, ushort data, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_insert_epi32 (__m256i a, __int32 i, const int index)
+ /// </summary>
+ public static Vector256<T> InsertInt<T>(Vector256<T> value, int data, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_insert_epi32 (__m256i a, __int32 i, const int index)
+ /// </summary>
+ public static Vector256<T> InsertUint<T>(Vector256<T> value, uint data, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_insert_epi64 (__m256i a, __int64 i, const int index)
+ /// </summary>
+ public static Vector256<T> InsertLong<T>(Vector256<T> value, long data, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_insert_epi64 (__m256i a, __int64 i, const int index)
+ /// </summary>
+ public static Vector256<T> InsertUlong<T>(Vector256<T> value, ulong data, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_insertf128_ps (__m256 a, __m128 b, int imm8)
+ /// __m256d _mm256_insertf128_pd (__m256d a, __m128d b, int imm8)
+ /// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8)
+ /// </summary>
+ public static Vector256<T> Insert<T>(Vector256<T> value, Vector128<T> data, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8)
+ /// </summary>
+ public static unsafe Vector256<sbyte> Insert(Vector256<sbyte> value, sbyte* address, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8)
+ /// </summary>
+ public static unsafe Vector256<byte> Insert(Vector256<byte> value, byte* address, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8)
+ /// </summary>
+ public static unsafe Vector256<short> Insert(Vector256<short> value, short* address, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8)
+ /// </summary>
+ public static unsafe Vector256<ushort> Insert(Vector256<ushort> value, ushort* address, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8)
+ /// </summary>
+ public static unsafe Vector256<int> Insert(Vector256<int> value, int* address, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8)
+ /// </summary>
+ public static unsafe Vector256<uint> Insert(Vector256<uint> value, uint* address, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8)
+ /// </summary>
+ public static unsafe Vector256<long> Insert(Vector256<long> value, long* address, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8)
+ /// </summary>
+ public static unsafe Vector256<ulong> Insert(Vector256<ulong> value, ulong* address, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256 _mm256_insertf128_ps (__m256 a, __m128 b, int imm8)
+ /// </summary>
+ public static unsafe Vector256<float> Insert(Vector256<float> value, float* address, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_insertf128_pd (__m256d a, __m128d b, int imm8)
+ /// </summary>
+ public static unsafe Vector256<double> Insert(Vector256<double> value, double* address, byte index) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_loadu_si256 (__m256i const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<sbyte> Load(sbyte* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_loadu_si256 (__m256i const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<byte> Load(byte* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_loadu_si256 (__m256i const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<short> Load(short* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_loadu_si256 (__m256i const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<ushort> Load(ushort* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_loadu_si256 (__m256i const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<int> Load(int* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_loadu_si256 (__m256i const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<uint> Load(uint* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_loadu_si256 (__m256i const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<long> Load(long* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_loadu_si256 (__m256i const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<ulong> Load(ulong* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256 _mm256_loadu_ps (float const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<float> Load(float* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_loadu_pd (double const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<double> Load(double* address) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_load_si256 (__m256i const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<sbyte> LoadAligned(sbyte* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_load_si256 (__m256i const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<byte> LoadAligned(byte* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_load_si256 (__m256i const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<short> LoadAligned(short* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_load_si256 (__m256i const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<ushort> LoadAligned(ushort* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_load_si256 (__m256i const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<int> LoadAligned(int* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_load_si256 (__m256i const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<uint> LoadAligned(uint* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_load_si256 (__m256i const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<long> LoadAligned(long* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_load_si256 (__m256i const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<ulong> LoadAligned(ulong* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256 _mm256_load_ps (float const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<float> LoadAligned(float* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_load_pd (double const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<double> LoadAligned(double* address) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_lddqu_si256 (__m256i const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<sbyte> LoadDqu(sbyte* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_lddqu_si256 (__m256i const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<byte> LoadDqu(byte* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_lddqu_si256 (__m256i const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<short> LoadDqu(short* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_lddqu_si256 (__m256i const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<ushort> LoadDqu(ushort* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_lddqu_si256 (__m256i const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<int> LoadDqu(int* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_lddqu_si256 (__m256i const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<uint> LoadDqu(uint* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_lddqu_si256 (__m256i const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<long> LoadDqu(long* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_lddqu_si256 (__m256i const * mem_addr)
+ /// </summary>
+ public static unsafe Vector256<ulong> LoadDqu(ulong* address) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128d _mm_maskload_pd (double const * mem_addr, __m128i mask)
+ /// </summary>
+ public static unsafe Vector128<float> MaskLoad(float* address, Vector128<uint> mask) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_maskload_pd (double const * mem_addr, __m128i mask)
+ /// </summary>
+ public static unsafe Vector128<double> MaskLoad(double* address, Vector128<ulong> mask) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_maskload_ps (float const * mem_addr, __m256i mask)
+ /// </summary>
+ public static unsafe Vector256<float> MaskLoad(float* address, Vector256<uint> mask) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_maskload_pd (double const * mem_addr, __m256i mask)
+ /// </summary>
+ public static unsafe Vector256<double> MaskLoad(double* address, Vector256<ulong> mask) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// void _mm_maskstore_ps (float * mem_addr, __m128i mask, __m128 a)
+ /// </summary>
+ public static unsafe void MaskStore(float* address, Vector128<float> mask, Vector128<uint> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_maskstore_pd (double * mem_addr, __m128i mask, __m128d a)
+ /// </summary>
+ public static unsafe void MaskStore(double* address, Vector128<double> mask, Vector128<ulong> source) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// void _mm256_maskstore_ps (float * mem_addr, __m256i mask, __m256 a)
+ /// </summary>
+ public static unsafe void MaskStore(float* address, Vector256<float> mask, Vector256<uint> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_maskstore_pd (double * mem_addr, __m256i mask, __m256d a)
+ /// </summary>
+ public static unsafe void MaskStore(double* address, Vector256<double> mask, Vector256<ulong> source) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_max_ps (__m256 a, __m256 b)
+ /// </summary>
+ public static Vector256<float> Max(Vector256<float> left, Vector256<float> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_max_pd (__m256d a, __m256d b)
+ /// </summary>
+ public static Vector256<double> Max(Vector256<double> left, Vector256<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_min_ps (__m256 a, __m256 b)
+ /// </summary>
+ public static Vector256<float> Min(Vector256<float> left, Vector256<float> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_min_pd (__m256d a, __m256d b)
+ /// </summary>
+ public static Vector256<double> Min(Vector256<double> left, Vector256<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm256_movemask_ps (__m256 a)
+ /// </summary>
+ public static int MoveMask(Vector256<float> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// int _mm256_movemask_pd (__m256d a)
+ /// </summary>
+ public static int MoveMask(Vector256<double> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_mul_ps (__m256 a, __m256 b)
+ /// </summary>
+ public static Vector256<float> Multiply(Vector256<float> left, Vector256<float> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_mul_pd (__m256d a, __m256d b)
+ /// </summary>
+ public static Vector256<double> Multiply(Vector256<double> left, Vector256<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_or_ps (__m256 a, __m256 b)
+ /// </summary>
+ public static Vector256<float> Or(Vector256<float> left, Vector256<float> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_or_pd (__m256d a, __m256d b)
+ /// </summary>
+ public static Vector256<double> Or(Vector256<double> left, Vector256<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_permute_ps (__m128 a, int imm8)
+ /// </summary>
+ public static Vector128<float> Permute(Vector128<float> value, byte control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_permute_pd (__m128d a, int imm8)
+ /// </summary>
+ public static Vector128<double> Permute(Vector128<double> value, byte control) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_permute_ps (__m256 a, int imm8)
+ /// </summary>
+ public static Vector256<float> Permute(Vector256<float> value, byte control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_permute_pd (__m256d a, int imm8)
+ /// </summary>
+ public static Vector256<double> Permute(Vector256<double> value, byte control) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_permute2f128_ps (__m256 a, __m256 b, int imm8)
+ /// </summary>
+ public static Vector256<float> Permute2x128(Vector256<float> left, Vector256<float> right, byte control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_permute2f128_pd (__m256d a, __m256d b, int imm8)
+ /// </summary>
+ public static Vector256<double> Permute2x128(Vector256<double> left, Vector256<double> right, byte control) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_permutevar_ps (__m128 a, __m128i b)
+ /// </summary>
+ public static Vector128<float> PermuteVar(Vector128<float> left, Vector128<float> mask) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_permutevar_pd (__m128d a, __m128i b)
+ /// </summary>
+ public static Vector128<double> PermuteVar(Vector128<double> left, Vector128<double> mask) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256 _mm256_permutevar_ps (__m256 a, __m256i b)
+ /// </summary>
+ public static Vector256<float> PermuteVar(Vector256<float> left, Vector256<float> mask) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_permutevar_pd (__m256d a, __m256i b)
+ /// </summary>
+ public static Vector256<double> PermuteVar(Vector256<double> left, Vector256<double> mask) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_rcp_ps (__m256 a)
+ /// </summary>
+ public static Vector256<float> Reciprocal(Vector256<float> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_rsqrt_ps (__m256 a)
+ /// </summary>
+ public static Vector256<float> ReciprocalSqrt(Vector256<float> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_round_ps (__m256 a, int rounding)
+ /// _MM_FROUND_TO_NEAREST_INT |_MM_FROUND_NO_EXC
+ /// </summary>
+ public static Vector256<float> RoundToNearestInteger(Vector256<float> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// _MM_FROUND_TO_NEG_INF |_MM_FROUND_NO_EXC
+ /// </summary>
+ public static Vector256<float> RoundToNegativeInfinity(Vector256<float> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// _MM_FROUND_TO_POS_INF |_MM_FROUND_NO_EXC
+ /// </summary>
+ public static Vector256<float> RoundToPositiveInfinity(Vector256<float> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// _MM_FROUND_TO_ZERO |_MM_FROUND_NO_EXC
+ /// </summary>
+ public static Vector256<float> RoundToZero(Vector256<float> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// _MM_FROUND_CUR_DIRECTION
+ /// </summary>
+ public static Vector256<float> RoundCurrentDirection(Vector256<float> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256d _mm256_round_pd (__m256d a, int rounding)
+ /// _MM_FROUND_TO_NEAREST_INT |_MM_FROUND_NO_EXC
+ /// </summary>
+ public static Vector256<double> RoundToNearestInteger(Vector256<double> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// _MM_FROUND_TO_NEG_INF |_MM_FROUND_NO_EXC
+ /// </summary>
+ public static Vector256<double> RoundToNegativeInfinity(Vector256<double> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// _MM_FROUND_TO_POS_INF |_MM_FROUND_NO_EXC
+ /// </summary>
+ public static Vector256<double> RoundToPositiveInfinity(Vector256<double> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// _MM_FROUND_TO_ZERO |_MM_FROUND_NO_EXC
+ /// </summary>
+ public static Vector256<double> RoundToZero(Vector256<double> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// _MM_FROUND_CUR_DIRECTION
+ /// </summary>
+ public static Vector256<double> RoundCurrentDirection(Vector256<double> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_set_epi8 (char e31, char e30, char e29, char e28, char e27, char e26, char e25, char e24, char e23, char e22, char e21, char e20, char e19, char e18, char e17, char e16, char e15, char e14, char e13, char e12, char e11, char e10, char e9, char e8, char e7, char e6, char e5, char e4, char e3, char e2, char e1, char e0)
+ /// </summary>
+ public static Vector256<sbyte> Set(sbyte e31, sbyte e30, sbyte e29, sbyte e28, sbyte e27, sbyte e26, sbyte e25, sbyte e24, sbyte e23, sbyte e22, sbyte e21, sbyte e20, sbyte e19, sbyte e18, sbyte e17, sbyte e16, sbyte e15, sbyte e14, sbyte e13, sbyte e12, sbyte e11, sbyte e10, sbyte e9, sbyte e8, sbyte e7, sbyte e6, sbyte e5, sbyte e4, sbyte e3, sbyte e2, sbyte e1, sbyte e0) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_set_epi8 (char e31, char e30, char e29, char e28, char e27, char e26, char e25, char e24, char e23, char e22, char e21, char e20, char e19, char e18, char e17, char e16, char e15, char e14, char e13, char e12, char e11, char e10, char e9, char e8, char e7, char e6, char e5, char e4, char e3, char e2, char e1, char e0)
+ /// </summary>
+ public static Vector256<byte> Set(byte e31, byte e30, byte e29, byte e28, byte e27, byte e26, byte e25, byte e24, byte e23, byte e22, byte e21, byte e20, byte e19, byte e18, byte e17, byte e16, byte e15, byte e14, byte e13, byte e12, byte e11, byte e10, byte e9, byte e8, byte e7, byte e6, byte e5, byte e4, byte e3, byte e2, byte e1, byte e0) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_set_epi16 (short e15, short e14, short e13, short e12, short e11, short e10, short e9, short e8, short e7, short e6, short e5, short e4, short e3, short e2, short e1, short e0)
+ /// </summary>
+ public static Vector256<short> Set(short e15, short e14, short e13, short e12, short e11, short e10, short e9, short e8, short e7, short e6, short e5, short e4, short e3, short e2, short e1, short e0) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_set_epi16 (short e15, short e14, short e13, short e12, short e11, short e10, short e9, short e8, short e7, short e6, short e5, short e4, short e3, short e2, short e1, short e0)
+ /// </summary>
+ public static Vector256<ushort> Set(ushort e15, ushort e14, ushort e13, ushort e12, ushort e11, ushort e10, ushort e9, ushort e8, ushort e7, ushort e6, ushort e5, ushort e4, ushort e3, ushort e2, ushort e1, ushort e0) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_set_epi32 (int e7, int e6, int e5, int e4, int e3, int e2, int e1, int e0)
+ /// </summary>
+ public static Vector256<int> Set(int e7, int e6, int e5, int e4, int e3, int e2, int e1, int e0) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_set_epi32 (int e7, int e6, int e5, int e4, int e3, int e2, int e1, int e0)
+ /// </summary>
+ public static Vector256<uint> Set(uint e7, uint e6, uint e5, uint e4, uint e3, uint e2, uint e1, uint e0) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_set_epi64x (__int64 e3, __int64 e2, __int64 e1, __int64 e0)
+ /// </summary>
+ public static Vector256<long> Set(long e3, long e2, long e1, long e0) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_set_epi64x (__int64 e3, __int64 e2, __int64 e1, __int64 e0)
+ /// </summary>
+ public static Vector256<ulong> Set(ulong e3, ulong e2, ulong e1, ulong e0) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256 _mm256_set_ps (float e7, float e6, float e5, float e4, float e3, float e2, float e1, float e0)
+ /// </summary>
+ public static Vector256<float> Set(float e7, float e6, float e5, float e4, float e3, float e2, float e1, float e0) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_set_pd (double e3, double e2, double e1, double e0)
+ /// </summary>
+ public static Vector256<double> Set(double e3, double e2, double e1, double e0) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_set1_epi8 (char a)
+ /// __m256i _mm256_set1_epi16 (short a)
+ /// __m256i _mm256_set1_epi32 (int a)
+ /// __m256i _mm256_set1_epi64x (long long a)
+ /// __m256 _mm256_set1_ps (float a)
+ /// __m256d _mm256_set1_pd (double a)
+ /// </summary>
+ public static Vector256<T> Set1<T>(T value) where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_set_m128 (__m128 hi, __m128 lo)
+ /// __m256d _mm256_set_m128d (__m128d hi, __m128d lo)
+ /// __m256i _mm256_set_m128i (__m128i hi, __m128i lo)
+ /// </summary>
+ public static Vector256<T> SetHiLo<T>(Vector128<T> hi, Vector128<T> lo) where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_setzero_si256 (void)
+ /// __m256 _mm256_setzero_ps (void)
+ /// __m256d _mm256_setzero_pd (void)
+ /// </summary>
+ public static Vector256<T> SetZero<T>() where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_shuffle_ps (__m256 a, __m256 b, const int imm8)
+ /// </summary>
+ public static Vector256<float> Shuffle(Vector256<float> value, Vector256<float> right, byte control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_shuffle_pd (__m256d a, __m256d b, const int imm8)
+ /// </summary>
+ public static Vector256<double> Shuffle(Vector256<double> value, Vector256<double> right, byte control) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_sqrt_ps (__m256 a)
+ /// </summary>
+ public static Vector256<float> Sqrt(Vector256<float> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_sqrt_pd (__m256d a)
+ /// </summary>
+ public static Vector256<double> Sqrt(Vector256<double> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_castpd_ps (__m256d a)
+ /// __m256i _mm256_castpd_si256 (__m256d a)
+ /// __m256d _mm256_castps_pd (__m256 a)
+ /// __m256i _mm256_castps_si256 (__m256 a)
+ /// __m256d _mm256_castsi256_pd (__m256i a)
+ /// __m256 _mm256_castsi256_ps (__m256i a)
+ /// </summary>
+ public static Vector256<U> StaticCast<T, U>(Vector256<T> value) where T : struct where U : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// void _mm256_store_si256 (__m256i * mem_addr, __m256i a)
+ /// </summary>
+ public static unsafe void StoreAligned(sbyte* address, Vector256<sbyte> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_store_si256 (__m256i * mem_addr, __m256i a)
+ /// </summary>
+ public static unsafe void StoreAligned(byte* address, Vector256<byte> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_store_si256 (__m256i * mem_addr, __m256i a)
+ /// </summary>
+ public static unsafe void StoreAligned(short* address, Vector256<short> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_store_si256 (__m256i * mem_addr, __m256i a)
+ /// </summary>
+ public static unsafe void StoreAligned(ushort* address, Vector256<ushort> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_store_si256 (__m256i * mem_addr, __m256i a)
+ /// </summary>
+ public static unsafe void StoreAligned(int* address, Vector256<int> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_store_si256 (__m256i * mem_addr, __m256i a)
+ /// </summary>
+ public static unsafe void StoreAligned(uint* address, Vector256<uint> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_store_si256 (__m256i * mem_addr, __m256i a)
+ /// </summary>
+ public static unsafe void StoreAligned(long* address, Vector256<long> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_store_si256 (__m256i * mem_addr, __m256i a)
+ /// </summary>
+ public static unsafe void StoreAligned(ulong* address, Vector256<ulong> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_store_ps (float * mem_addr, __m256 a)
+ /// </summary>
+ public static unsafe void StoreAligned(float* address, Vector256<float> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_store_pd (double * mem_addr, __m256d a)
+ /// </summary>
+ public static unsafe void StoreAligned(double* address, Vector256<double> source) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// void _mm256_stream_si256 (__m256i * mem_addr, __m256i a)
+ /// </summary>
+ public static unsafe void StoreAlignedNonTemporal(sbyte* address, Vector256<sbyte> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_stream_si256 (__m256i * mem_addr, __m256i a)
+ /// </summary>
+ public static unsafe void StoreAlignedNonTemporal(byte* address, Vector256<byte> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_stream_si256 (__m256i * mem_addr, __m256i a)
+ /// </summary>
+ public static unsafe void StoreAlignedNonTemporal(short* address, Vector256<short> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_stream_si256 (__m256i * mem_addr, __m256i a)
+ /// </summary>
+ public static unsafe void StoreAlignedNonTemporal(ushort* address, Vector256<ushort> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_stream_si256 (__m256i * mem_addr, __m256i a)
+ /// </summary>
+ public static unsafe void StoreAlignedNonTemporal(int* address, Vector256<int> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_stream_si256 (__m256i * mem_addr, __m256i a)
+ /// </summary>
+ public static unsafe void StoreAlignedNonTemporal(uint* address, Vector256<uint> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_stream_si256 (__m256i * mem_addr, __m256i a)
+ /// </summary>
+ public static unsafe void StoreAlignedNonTemporal(long* address, Vector256<long> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_stream_si256 (__m256i * mem_addr, __m256i a)
+ /// </summary>
+ public static unsafe void StoreAlignedNonTemporal(ulong* address, Vector256<ulong> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_stream_ps (float * mem_addr, __m256 a)
+ /// </summary>
+ public static unsafe void StoreAlignedNonTemporal(float* address, Vector256<float> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_stream_pd (double * mem_addr, __m256d a)
+ /// </summary>
+ public static unsafe void StoreAlignedNonTemporal(double* address, Vector256<double> source) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// void _mm256_storeu_si256 (__m256i * mem_addr, __m256i a)
+ /// </summary>
+ public static unsafe void Store(sbyte* address, Vector256<sbyte> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_storeu_si256 (__m256i * mem_addr, __m256i a)
+ /// </summary>
+ public static unsafe void Store(byte* address, Vector256<byte> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_storeu_si256 (__m256i * mem_addr, __m256i a)
+ /// </summary>
+ public static unsafe void Store(short* address, Vector256<short> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_storeu_si256 (__m256i * mem_addr, __m256i a)
+ /// </summary>
+ public static unsafe void Store(ushort* address, Vector256<ushort> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_storeu_si256 (__m256i * mem_addr, __m256i a)
+ /// </summary>
+ public static unsafe void Store(int* address, Vector256<int> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_storeu_si256 (__m256i * mem_addr, __m256i a)
+ /// </summary>
+ public static unsafe void Store(uint* address, Vector256<uint> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_storeu_si256 (__m256i * mem_addr, __m256i a)
+ /// </summary>
+ public static unsafe void Store(long* address, Vector256<long> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_storeu_si256 (__m256i * mem_addr, __m256i a)
+ /// </summary>
+ public static unsafe void Store(ulong* address, Vector256<ulong> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_storeu_ps (float * mem_addr, __m256 a)
+ /// </summary>
+ public static unsafe void Store(float* address, Vector256<float> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_storeu_pd (double * mem_addr, __m256d a)
+ /// </summary>
+ public static unsafe void Store(double* address, Vector256<double> source) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_sub_ps (__m256 a, __m256 b)
+ /// </summary>
+ public static Vector256<float> Subtract(Vector256<float> left, Vector256<float> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_sub_pd (__m256d a, __m256d b)
+ /// </summary>
+ public static Vector256<double> Subtract(Vector256<double> left, Vector256<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_testc_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static bool TestC(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// int _mm_testc_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static bool TestC(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm256_testc_si256 (__m256i a, __m256i b)
+ /// int _mm256_testc_ps (__m256 a, __m256 b)
+ /// int _mm256_testc_pd (__m256d a, __m256d b)
+ /// </summary>
+ public static bool TestC<T>(Vector256<T> left, Vector256<T> right) where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_testnzc_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static bool TestNotZAndNotC(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// int _mm_testnzc_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static bool TestNotZAndNotC(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm256_testnzc_si256 (__m256i a, __m256i b)
+ /// int _mm256_testnzc_ps (__m256 a, __m256 b)
+ /// int _mm256_testnzc_pd (__m256d a, __m256d b)
+ /// </summary>
+ public static bool TestNotZAndNotC<T>(Vector256<T> left, Vector256<T> right) where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_testz_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static bool TestZ(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// int _mm_testz_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static bool TestZ(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm256_testz_si256 (__m256i a, __m256i b)
+ /// int _mm256_testz_ps (__m256 a, __m256 b)
+ /// int _mm256_testz_pd (__m256d a, __m256d b)
+ /// </summary>
+ public static bool TestZ<T>(Vector256<T> left, Vector256<T> right) where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_unpackhi_ps (__m256 a, __m256 b)
+ /// </summary>
+ public static Vector256<float> UnpackHigh(Vector256<float> left, Vector256<float> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_unpackhi_pd (__m256d a, __m256d b)
+ /// </summary>
+ public static Vector256<double> UnpackHigh(Vector256<double> left, Vector256<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_unpacklo_ps (__m256 a, __m256 b)
+ /// </summary>
+ public static Vector256<float> UnpackLow(Vector256<float> left, Vector256<float> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_unpacklo_pd (__m256d a, __m256d b)
+ /// </summary>
+ public static Vector256<double> UnpackLow(Vector256<double> left, Vector256<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256 _mm256_xor_ps (__m256 a, __m256 b)
+ /// </summary>
+ public static Vector256<float> Xor(Vector256<float> left, Vector256<float> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_xor_pd (__m256d a, __m256d b)
+ /// </summary>
+ public static Vector256<double> Xor(Vector256<double> left, Vector256<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// void _mm256_zeroall (void)
+ /// </summary>
+ public static void ZeroAll() { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_zeroupper (void)
+ /// </summary>
+ public static void ZeroUpper() { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256d _mm256_zextpd128_pd256 (__m128d a)
+ /// __m256 _mm256_zextps128_ps256 (__m128 a)
+ /// __m256i _mm256_zextsi128_si256 (__m128i a)
+ /// </summary>
+ public static Vector256<T> ZeroExtendToVector256<T>(Vector128<T> value) where T : struct { throw new PlatformNotSupportedException(); }
+ }
+}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Avx.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Avx.cs
index ad0bfc9e1b..a69a5ea462 100644
--- a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Avx.cs
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Avx.cs
@@ -13,710 +13,710 @@ namespace System.Runtime.Intrinsics.X86
[CLSCompliant(false)]
public static class Avx
{
- public static bool IsSupported { get { return false; } }
+ public static bool IsSupported { get => IsSupported; }
/// <summary>
/// __m256 _mm256_add_ps (__m256 a, __m256 b)
/// </summary>
- public static Vector256<float> Add(Vector256<float> left, Vector256<float> right) { throw new NotImplementedException(); }
+ public static Vector256<float> Add(Vector256<float> left, Vector256<float> right) => Add(left, right);
/// <summary>
/// __m256d _mm256_add_pd (__m256d a, __m256d b)
/// </summary>
- public static Vector256<double> Add(Vector256<double> left, Vector256<double> right) { throw new NotImplementedException(); }
+ public static Vector256<double> Add(Vector256<double> left, Vector256<double> right) => Add(left, right);
/// <summary>
/// __m256 _mm256_addsub_ps (__m256 a, __m256 b)
/// </summary>
- public static Vector256<float> AddSubtract(Vector256<float> left, Vector256<float> right) { throw new NotImplementedException(); }
+ public static Vector256<float> AddSubtract(Vector256<float> left, Vector256<float> right) => AddSubtract(left, right);
/// <summary>
/// __m256d _mm256_addsub_pd (__m256d a, __m256d b)
/// </summary>
- public static Vector256<double> AddSubtract(Vector256<double> left, Vector256<double> right) { throw new NotImplementedException(); }
+ public static Vector256<double> AddSubtract(Vector256<double> left, Vector256<double> right) => AddSubtract(left, right);
/// <summary>
/// __m256 _mm256_and_ps (__m256 a, __m256 b)
/// </summary>
- public static Vector256<float> And(Vector256<float> left, Vector256<float> right) { throw new NotImplementedException(); }
+ public static Vector256<float> And(Vector256<float> left, Vector256<float> right) => And(left, right);
/// <summary>
/// __m256d _mm256_and_pd (__m256d a, __m256d b)
/// </summary>
- public static Vector256<double> And(Vector256<double> left, Vector256<double> right) { throw new NotImplementedException(); }
+ public static Vector256<double> And(Vector256<double> left, Vector256<double> right) => And(left, right);
/// <summary>
/// __m256 _mm256_andnot_ps (__m256 a, __m256 b)
/// </summary>
- public static Vector256<float> AndNot(Vector256<float> left, Vector256<float> right) { throw new NotImplementedException(); }
+ public static Vector256<float> AndNot(Vector256<float> left, Vector256<float> right) => AndNot(left, right);
/// <summary>
/// __m256d _mm256_andnot_pd (__m256d a, __m256d b)
/// </summary>
- public static Vector256<double> AndNot(Vector256<double> left, Vector256<double> right) { throw new NotImplementedException(); }
+ public static Vector256<double> AndNot(Vector256<double> left, Vector256<double> right) => AndNot(left, right);
/// <summary>
/// __m256 _mm256_blend_ps (__m256 a, __m256 b, const int imm8)
/// </summary>
- public static Vector256<float> Blend(Vector256<float> left, Vector256<float> right, byte control) { throw new NotImplementedException(); }
+ public static Vector256<float> Blend(Vector256<float> left, Vector256<float> right, byte control) => Blend(left, right, control);
/// <summary>
/// __m256d _mm256_blend_pd (__m256d a, __m256d b, const int imm8)
/// </summary>
- public static Vector256<double> Blend(Vector256<double> left, Vector256<double> right, byte control) { throw new NotImplementedException(); }
+ public static Vector256<double> Blend(Vector256<double> left, Vector256<double> right, byte control) => Blend(left, right, control);
/// <summary>
/// __m256 _mm256_blendv_ps (__m256 a, __m256 b, __m256 mask)
/// </summary>
- public static Vector256<float> BlendVariable(Vector256<float> left, Vector256<float> right, Vector256<float> mask) { throw new NotImplementedException(); }
+ public static Vector256<float> BlendVariable(Vector256<float> left, Vector256<float> right, Vector256<float> mask) => BlendVariable(left, right, mask);
/// <summary>
/// __m256d _mm256_blendv_pd (__m256d a, __m256d b, __m256d mask)
/// </summary>
- public static Vector256<double> BlendVariable(Vector256<double> left, Vector256<double> right, Vector256<double> mask) { throw new NotImplementedException(); }
+ public static Vector256<double> BlendVariable(Vector256<double> left, Vector256<double> right, Vector256<double> mask) => BlendVariable(left, right, mask);
/// <summary>
/// __m128 _mm_broadcast_ss (float const * mem_addr)
/// </summary>
- public static Vector128<float> BroadcastElementToVector128(ref float source) { throw new NotImplementedException(); }
+ public static Vector128<float> BroadcastElementToVector128(ref float source) => BroadcastElementToVector128(ref source);
/// <summary>
/// __m256 _mm256_broadcast_ss (float const * mem_addr)
/// </summary>
- public static Vector256<float> BroadcastElementToVector256(ref float source) { throw new NotImplementedException(); }
+ public static Vector256<float> BroadcastElementToVector256(ref float source) => BroadcastElementToVector256(ref source);
/// <summary>
/// __m256d _mm256_broadcast_sd (double const * mem_addr)
/// </summary>
- public static Vector256<double> BroadcastElementToVector256(ref double source) { throw new NotImplementedException(); }
+ public static Vector256<double> BroadcastElementToVector256(ref double source) => BroadcastElementToVector256(ref source);
/// <summary>
/// __m256 _mm256_broadcast_ps (__m128 const * mem_addr)
/// </summary>
- public static unsafe Vector256<float> BroadcastVector128ToVector256(float* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<float> BroadcastVector128ToVector256(float* address) => BroadcastVector128ToVector256(address);
/// <summary>
/// __m256d _mm256_broadcast_pd (__m128d const * mem_addr)
/// </summary>
- public static unsafe Vector256<double> BroadcastVector128ToVector256(double* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<double> BroadcastVector128ToVector256(double* address) => BroadcastVector128ToVector256(address);
/// <summary>
/// __m256 _mm256_ceil_ps (__m256 a)
/// </summary>
- public static Vector256<float> Ceiling(Vector256<float> value) { throw new NotImplementedException(); }
+ public static Vector256<float> Ceiling(Vector256<float> value) => Ceiling(value);
/// <summary>
/// __m256d _mm256_ceil_pd (__m256d a)
/// </summary>
- public static Vector256<double> Ceiling(Vector256<double> value) { throw new NotImplementedException(); }
+ public static Vector256<double> Ceiling(Vector256<double> value) => Ceiling(value);
/// <summary>
/// __m128 _mm_cmp_ps (__m128 a, __m128 b, const int imm8)
/// </summary>
- public static Vector128<float> Compare(Vector128<float> left, Vector128<float> right, FloatComparisonMode mode) { throw new NotImplementedException(); }
+ public static Vector128<float> Compare(Vector128<float> left, Vector128<float> right, FloatComparisonMode mode) => Compare(left, right, mode);
/// <summary>
/// __m128d _mm_cmp_pd (__m128d a, __m128d b, const int imm8)
/// </summary>
- public static Vector128<double> Compare(Vector128<double> left, Vector128<double> right, FloatComparisonMode mode) { throw new NotImplementedException(); }
+ public static Vector128<double> Compare(Vector128<double> left, Vector128<double> right, FloatComparisonMode mode) => Compare(left, right, mode);
/// <summary>
/// __m256 _mm256_cmp_ps (__m256 a, __m256 b, const int imm8)
/// </summary>
- public static Vector256<float> Compare(Vector256<float> left, Vector256<float> right, FloatComparisonMode mode) { throw new NotImplementedException(); }
+ public static Vector256<float> Compare(Vector256<float> left, Vector256<float> right, FloatComparisonMode mode) => Compare(left, right, mode);
/// <summary>
/// __m256d _mm256_cmp_pd (__m256d a, __m256d b, const int imm8)
/// </summary>
- public static Vector256<double> Compare(Vector256<double> left, Vector256<double> right, FloatComparisonMode mode) { throw new NotImplementedException(); }
+ public static Vector256<double> Compare(Vector256<double> left, Vector256<double> right, FloatComparisonMode mode) => Compare(left, right, mode);
/// <summary>
/// __m128i _mm256_cvtpd_epi32 (__m256d a)
/// </summary>
- public static Vector128<int> ConvertToVector128Int(Vector256<double> value) { throw new NotImplementedException(); }
+ public static Vector128<int> ConvertToVector128Int(Vector256<double> value) => ConvertToVector128Int(value);
/// <summary>
/// __m128 _mm256_cvtpd_ps (__m256d a)
/// </summary>
- public static Vector128<float> ConvertToVector128Float(Vector256<double> value) { throw new NotImplementedException(); }
+ public static Vector128<float> ConvertToVector128Float(Vector256<double> value) => ConvertToVector128Float(value);
/// <summary>
/// __m256i _mm256_cvtps_epi32 (__m256 a)
/// </summary>
- public static Vector256<int> ConvertToVector256Int(Vector256<float> value) { throw new NotImplementedException(); }
+ public static Vector256<int> ConvertToVector256Int(Vector256<float> value) => ConvertToVector256Int(value);
/// <summary>
/// __m256 _mm256_cvtepi32_ps (__m256i a)
/// </summary>
- public static Vector256<float> ConvertToVector256Float(Vector256<int> value) { throw new NotImplementedException(); }
+ public static Vector256<float> ConvertToVector256Float(Vector256<int> value) => ConvertToVector256Float(value);
/// <summary>
/// __m256d _mm256_cvtps_pd (__m128 a)
/// </summary>
- public static Vector256<double> ConvertToVector256Double(Vector256<float> value) { throw new NotImplementedException(); }
+ public static Vector256<double> ConvertToVector256Double(Vector256<float> value) => ConvertToVector256Double(value);
/// <summary>
/// __m256d _mm256_cvtepi32_pd (__m128i a)
/// </summary>
- public static Vector256<double> ConvertToVector256Double(Vector256<int> value) { throw new NotImplementedException(); }
+ public static Vector256<double> ConvertToVector256Double(Vector256<int> value) => ConvertToVector256Double(value);
/// <summary>
/// __m128i _mm256_cvttpd_epi32 (__m256d a)
/// </summary>
- public static Vector128<int> ConvertToVector128IntWithTruncation(Vector256<double> value) { throw new NotImplementedException(); }
+ public static Vector128<int> ConvertToVector128IntWithTruncation(Vector256<double> value) => ConvertToVector128IntWithTruncation(value);
/// <summary>
/// __m256i _mm256_cvttps_epi32 (__m256 a)
/// </summary>
- public static Vector256<int> ConvertToVector256IntWithTruncation(Vector256<float> value) { throw new NotImplementedException(); }
+ public static Vector256<int> ConvertToVector256IntWithTruncation(Vector256<float> value) => ConvertToVector256IntWithTruncation(value);
/// <summary>
/// __m256 _mm256_div_ps (__m256 a, __m256 b)
/// </summary>
- public static Vector256<float> Divide(Vector256<float> left, Vector256<float> right) { throw new NotImplementedException(); }
+ public static Vector256<float> Divide(Vector256<float> left, Vector256<float> right) => Divide(left, right);
/// <summary>
/// __m256d _mm256_div_pd (__m256d a, __m256d b)
/// </summary>
- public static Vector256<double> Divide(Vector256<double> left, Vector256<double> right) { throw new NotImplementedException(); }
+ public static Vector256<double> Divide(Vector256<double> left, Vector256<double> right) => Divide(left, right);
/// <summary>
/// __m256 _mm256_dp_ps (__m256 a, __m256 b, const int imm8)
/// </summary>
- public static Vector256<float> DotProduct(Vector256<float> left, Vector256<float> right, byte control) { throw new NotImplementedException(); }
+ public static Vector256<float> DotProduct(Vector256<float> left, Vector256<float> right, byte control) => DotProduct(left, right, control);
/// <summary>
/// __m256 _mm256_moveldup_ps (__m256 a)
/// </summary>
- public static Vector256<float> DuplicateEvenIndexed(Vector256<float> value) { throw new NotImplementedException(); }
+ public static Vector256<float> DuplicateEvenIndexed(Vector256<float> value) => DuplicateEvenIndexed(value);
/// <summary>
/// __m256d _mm256_movedup_pd (__m256d a)
/// </summary>
- public static Vector256<double> DuplicateEvenIndexed(Vector256<double> value) { throw new NotImplementedException(); }
+ public static Vector256<double> DuplicateEvenIndexed(Vector256<double> value) => DuplicateEvenIndexed(value);
/// <summary>
/// __m256 _mm256_movehdup_ps (__m256 a)
/// </summary>
- public static Vector256<float> DuplicateOddIndexed(Vector256<float> value) { throw new NotImplementedException(); }
+ public static Vector256<float> DuplicateOddIndexed(Vector256<float> value) => DuplicateOddIndexed(value);
/// <summary>
/// __int8 _mm256_extract_epi8 (__m256i a, const int index)
/// </summary>
- public static sbyte ExtractSbyte<T>(Vector256<T> value, byte index) where T : struct { throw new NotImplementedException(); }
+ public static sbyte ExtractSbyte<T>(Vector256<T> value, byte index) where T : struct => ExtractSbyte<T>(value, index);
/// <summary>
/// __int8 _mm256_extract_epi8 (__m256i a, const int index)
/// </summary>
- public static byte ExtractByte<T>(Vector256<T> value, byte index) where T : struct { throw new NotImplementedException(); }
+ public static byte ExtractByte<T>(Vector256<T> value, byte index) where T : struct => ExtractByte<T>(value, index);
/// <summary>
/// __int16 _mm256_extract_epi16 (__m256i a, const int index)
/// </summary>
- public static short ExtractShort<T>(Vector256<T> value, byte index) where T : struct { throw new NotImplementedException(); }
+ public static short ExtractShort<T>(Vector256<T> value, byte index) where T : struct => ExtractShort<T>(value, index);
/// <summary>
/// __int16 _mm256_extract_epi16 (__m256i a, const int index)
/// </summary>
- public static ushort ExtractUshort<T>(Vector256<T> value, byte index) where T : struct { throw new NotImplementedException(); }
+ public static ushort ExtractUshort<T>(Vector256<T> value, byte index) where T : struct => ExtractUshort<T>(value, index);
/// <summary>
/// __int32 _mm256_extract_epi32 (__m256i a, const int index)
/// </summary>
- public static int ExtractInt<T>(Vector256<T> value, byte index) where T : struct { throw new NotImplementedException(); }
+ public static int ExtractInt<T>(Vector256<T> value, byte index) where T : struct => ExtractInt<T>(value, index);
/// <summary>
/// __int32 _mm256_extract_epi32 (__m256i a, const int index)
/// </summary>
- public static uint ExtractUint<T>(Vector256<T> value, byte index) where T : struct { throw new NotImplementedException(); }
+ public static uint ExtractUint<T>(Vector256<T> value, byte index) where T : struct => ExtractUint<T>(value, index);
/// <summary>
/// __int64 _mm256_extract_epi64 (__m256i a, const int index)
/// </summary>
- public static long ExtractLong<T>(Vector256<T> value, byte index) where T : struct { throw new NotImplementedException(); }
+ public static long ExtractLong<T>(Vector256<T> value, byte index) where T : struct => ExtractLong<T>(value, index);
/// <summary>
/// __int64 _mm256_extract_epi64 (__m256i a, const int index)
/// </summary>
- public static ulong ExtractUlong<T>(Vector256<T> value, byte index) where T : struct { throw new NotImplementedException(); }
+ public static ulong ExtractUlong<T>(Vector256<T> value, byte index) where T : struct => ExtractUlong<T>(value, index);
/// <summary>
/// __m128 _mm256_extractf128_ps (__m256 a, const int imm8)
/// __m128d _mm256_extractf128_pd (__m256d a, const int imm8)
/// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8)
/// </summary>
- public static Vector128<T> ExtractVector128<T>(Vector256<T> value, byte index) where T : struct { throw new NotImplementedException(); }
+ public static Vector128<T> ExtractVector128<T>(Vector256<T> value, byte index) where T : struct => ExtractVector128<T>(value, index);
/// <summary>
/// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8)
/// </summary>
- public static unsafe void ExtractVector128(byte* address, Vector256<byte> value, byte index) { throw new NotImplementedException(); }
+ public static unsafe void ExtractVector128(byte* address, Vector256<byte> value, byte index) => ExtractVector128(address, value, index);
/// <summary>
/// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8)
/// </summary>
- public static unsafe void ExtractVector128(sbyte* address, Vector256<sbyte> value, byte index) { throw new NotImplementedException(); }
+ public static unsafe void ExtractVector128(sbyte* address, Vector256<sbyte> value, byte index) => ExtractVector128(address, value, index);
/// <summary>
/// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8)
/// </summary>
- public static unsafe void ExtractVector128(short* address, Vector256<short> value, byte index) { throw new NotImplementedException(); }
+ public static unsafe void ExtractVector128(short* address, Vector256<short> value, byte index) => ExtractVector128(address, value, index);
/// <summary>
/// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8)
/// </summary>
- public static unsafe void ExtractVector128(ushort* address, Vector256<ushort> value, byte index) { throw new NotImplementedException(); }
+ public static unsafe void ExtractVector128(ushort* address, Vector256<ushort> value, byte index) => ExtractVector128(address, value, index);
/// <summary>
/// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8)
/// </summary>
- public static unsafe void ExtractVector128(int* address, Vector256<int> value, byte index) { throw new NotImplementedException(); }
+ public static unsafe void ExtractVector128(int* address, Vector256<int> value, byte index) => ExtractVector128(address, value, index);
/// <summary>
/// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8)
/// </summary>
- public static unsafe void ExtractVector128(uint* address, Vector256<uint> value, byte index) { throw new NotImplementedException(); }
+ public static unsafe void ExtractVector128(uint* address, Vector256<uint> value, byte index) => ExtractVector128(address, value, index);
/// <summary>
/// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8)
/// </summary>
- public static unsafe void ExtractVector128(long* address, Vector256<long> value, byte index) { throw new NotImplementedException(); }
+ public static unsafe void ExtractVector128(long* address, Vector256<long> value, byte index) => ExtractVector128(address, value, index);
/// <summary>
/// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8)
/// </summary>
- public static unsafe void ExtractVector128(ulong* address, Vector256<ulong> value, byte index) { throw new NotImplementedException(); }
+ public static unsafe void ExtractVector128(ulong* address, Vector256<ulong> value, byte index) => ExtractVector128(address, value, index);
/// <summary>
/// __m128 _mm256_extractf128_ps (__m256 a, const int imm8)
/// </summary>
- public static unsafe void ExtractVector128(float* address, Vector256<float> value, byte index) { throw new NotImplementedException(); }
+ public static unsafe void ExtractVector128(float* address, Vector256<float> value, byte index) => ExtractVector128(address, value, index);
/// <summary>
/// __m128d _mm256_extractf128_pd (__m256d a, const int imm8)
/// </summary>
- public static unsafe void ExtractVector128(double* address, Vector256<double> value, byte index) { throw new NotImplementedException(); }
+ public static unsafe void ExtractVector128(double* address, Vector256<double> value, byte index) => ExtractVector128(address, value, index);
/// <summary>
/// __m256d _mm256_castpd128_pd256 (__m128d a)
/// __m256 _mm256_castps128_ps256 (__m128 a)
/// __m256i _mm256_castsi128_si256 (__m128i a)
/// </summary>
- public static Vector256<T> ExtendToVector256<T>(Vector128<T> value) where T : struct { throw new NotImplementedException(); }
+ public static Vector256<T> ExtendToVector256<T>(Vector128<T> value) where T : struct => ExtendToVector256<T>(value);
/// <summary>
/// __m256 _mm256_floor_ps (__m256 a)
/// </summary>
- public static Vector256<float> Floor(Vector256<float> value) { throw new NotImplementedException(); }
+ public static Vector256<float> Floor(Vector256<float> value) => Floor(value);
/// <summary>
/// __m256d _mm256_floor_pd (__m256d a)
/// </summary>
- public static Vector256<double> Floor(Vector256<double> value) { throw new NotImplementedException(); }
+ public static Vector256<double> Floor(Vector256<double> value) => Floor(value);
/// <summary>
/// __m128d _mm256_castpd256_pd128 (__m256d a)
/// __m128 _mm256_castps256_ps128 (__m256 a)
/// __m128i _mm256_castsi256_si128 (__m256i a)
/// </summary>
- public static Vector128<T> GetLowerHalf<T>(Vector256<T> value) where T : struct { throw new NotImplementedException(); }
+ public static Vector128<T> GetLowerHalf<T>(Vector256<T> value) where T : struct => GetLowerHalf<T>(value);
/// <summary>
/// __m256 _mm256_hadd_ps (__m256 a, __m256 b)
/// </summary>
- public static Vector256<float> HorizontalAdd(Vector256<float> left, Vector256<float> right) { throw new NotImplementedException(); }
+ public static Vector256<float> HorizontalAdd(Vector256<float> left, Vector256<float> right) => HorizontalAdd(left, right);
/// <summary>
/// __m256d _mm256_hadd_pd (__m256d a, __m256d b)
/// </summary>
- public static Vector256<double> HorizontalAdd(Vector256<double> left, Vector256<double> right) { throw new NotImplementedException(); }
+ public static Vector256<double> HorizontalAdd(Vector256<double> left, Vector256<double> right) => HorizontalAdd(left, right);
/// <summary>
/// __m256 _mm256_hsub_ps (__m256 a, __m256 b)
/// </summary>
- public static Vector256<float> HorizontalSubtract(Vector256<float> left, Vector256<float> right) { throw new NotImplementedException(); }
+ public static Vector256<float> HorizontalSubtract(Vector256<float> left, Vector256<float> right) => HorizontalSubtract(left, right);
/// <summary>
/// __m256d _mm256_hsub_pd (__m256d a, __m256d b)
/// </summary>
- public static Vector256<double> HorizontalSubtract(Vector256<double> left, Vector256<double> right) { throw new NotImplementedException(); }
+ public static Vector256<double> HorizontalSubtract(Vector256<double> left, Vector256<double> right) => HorizontalSubtract(left, right);
/// <summary>
/// __m256i _mm256_insert_epi8 (__m256i a, __int8 i, const int index)
/// </summary>
- public static Vector256<T> InsertSbyte<T>(Vector256<T> value, sbyte data, byte index) where T : struct { throw new NotImplementedException(); }
+ public static Vector256<T> InsertSbyte<T>(Vector256<T> value, sbyte data, byte index) where T : struct => InsertSbyte<T>(value, data, index);
/// <summary>
/// __m256i _mm256_insert_epi8 (__m256i a, __int8 i, const int index)
/// </summary>
- public static Vector256<T> InsertByte<T>(Vector256<T> value, byte data, byte index) where T : struct { throw new NotImplementedException(); }
+ public static Vector256<T> InsertByte<T>(Vector256<T> value, byte data, byte index) where T : struct => InsertByte<T>(value, data, index);
/// <summary>
/// __m256i _mm256_insert_epi16 (__m256i a, __int16 i, const int index)
/// </summary>
- public static Vector256<T> InsertShort<T>(Vector256<T> value, short data, byte index) where T : struct { throw new NotImplementedException(); }
+ public static Vector256<T> InsertShort<T>(Vector256<T> value, short data, byte index) where T : struct => InsertShort<T>(value, data, index);
/// <summary>
/// __m256i _mm256_insert_epi16 (__m256i a, __int16 i, const int index)
/// </summary>
- public static Vector256<T> InsertUshort<T>(Vector256<T> value, ushort data, byte index) where T : struct { throw new NotImplementedException(); }
+ public static Vector256<T> InsertUshort<T>(Vector256<T> value, ushort data, byte index) where T : struct => InsertUshort<T>(value, data, index);
/// <summary>
/// __m256i _mm256_insert_epi32 (__m256i a, __int32 i, const int index)
/// </summary>
- public static Vector256<T> InsertInt<T>(Vector256<T> value, int data, byte index) where T : struct { throw new NotImplementedException(); }
+ public static Vector256<T> InsertInt<T>(Vector256<T> value, int data, byte index) where T : struct => InsertInt<T>(value, data, index);
/// <summary>
/// __m256i _mm256_insert_epi32 (__m256i a, __int32 i, const int index)
/// </summary>
- public static Vector256<T> InsertUint<T>(Vector256<T> value, uint data, byte index) where T : struct { throw new NotImplementedException(); }
+ public static Vector256<T> InsertUint<T>(Vector256<T> value, uint data, byte index) where T : struct => InsertUint<T>(value, data, index);
/// <summary>
/// __m256i _mm256_insert_epi64 (__m256i a, __int64 i, const int index)
/// </summary>
- public static Vector256<T> InsertLong<T>(Vector256<T> value, long data, byte index) where T : struct { throw new NotImplementedException(); }
+ public static Vector256<T> InsertLong<T>(Vector256<T> value, long data, byte index) where T : struct => InsertLong<T>(value, data, index);
/// <summary>
/// __m256i _mm256_insert_epi64 (__m256i a, __int64 i, const int index)
/// </summary>
- public static Vector256<T> InsertUlong<T>(Vector256<T> value, ulong data, byte index) where T : struct { throw new NotImplementedException(); }
+ public static Vector256<T> InsertUlong<T>(Vector256<T> value, ulong data, byte index) where T : struct => InsertUlong<T>(value, data, index);
/// <summary>
/// __m256 _mm256_insertf128_ps (__m256 a, __m128 b, int imm8)
/// __m256d _mm256_insertf128_pd (__m256d a, __m128d b, int imm8)
/// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8)
/// </summary>
- public static Vector256<T> Insert<T>(Vector256<T> value, Vector128<T> data, byte index) where T : struct { throw new NotImplementedException(); }
+ public static Vector256<T> Insert<T>(Vector256<T> value, Vector128<T> data, byte index) where T : struct => Insert<T>(value, data, index);
/// <summary>
/// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8)
/// </summary>
- public static unsafe Vector256<sbyte> Insert(Vector256<sbyte> value, sbyte* address, byte index) { throw new NotImplementedException(); }
+ public static unsafe Vector256<sbyte> Insert(Vector256<sbyte> value, sbyte* address, byte index) => Insert(value, address, index);
/// <summary>
/// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8)
/// </summary>
- public static unsafe Vector256<byte> Insert(Vector256<byte> value, byte* address, byte index) { throw new NotImplementedException(); }
+ public static unsafe Vector256<byte> Insert(Vector256<byte> value, byte* address, byte index) => Insert(value, address, index);
/// <summary>
/// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8)
/// </summary>
- public static unsafe Vector256<short> Insert(Vector256<short> value, short* address, byte index) { throw new NotImplementedException(); }
+ public static unsafe Vector256<short> Insert(Vector256<short> value, short* address, byte index) => Insert(value, address, index);
/// <summary>
/// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8)
/// </summary>
- public static unsafe Vector256<ushort> Insert(Vector256<ushort> value, ushort* address, byte index) { throw new NotImplementedException(); }
+ public static unsafe Vector256<ushort> Insert(Vector256<ushort> value, ushort* address, byte index) => Insert(value, address, index);
/// <summary>
/// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8)
/// </summary>
- public static unsafe Vector256<int> Insert(Vector256<int> value, int* address, byte index) { throw new NotImplementedException(); }
+ public static unsafe Vector256<int> Insert(Vector256<int> value, int* address, byte index) => Insert(value, address, index);
/// <summary>
/// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8)
/// </summary>
- public static unsafe Vector256<uint> Insert(Vector256<uint> value, uint* address, byte index) { throw new NotImplementedException(); }
+ public static unsafe Vector256<uint> Insert(Vector256<uint> value, uint* address, byte index) => Insert(value, address, index);
/// <summary>
/// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8)
/// </summary>
- public static unsafe Vector256<long> Insert(Vector256<long> value, long* address, byte index) { throw new NotImplementedException(); }
+ public static unsafe Vector256<long> Insert(Vector256<long> value, long* address, byte index) => Insert(value, address, index);
/// <summary>
/// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8)
/// </summary>
- public static unsafe Vector256<ulong> Insert(Vector256<ulong> value, ulong* address, byte index) { throw new NotImplementedException(); }
+ public static unsafe Vector256<ulong> Insert(Vector256<ulong> value, ulong* address, byte index) => Insert(value, address, index);
/// <summary>
/// __m256 _mm256_insertf128_ps (__m256 a, __m128 b, int imm8)
/// </summary>
- public static unsafe Vector256<float> Insert(Vector256<float> value, float* address, byte index) { throw new NotImplementedException(); }
+ public static unsafe Vector256<float> Insert(Vector256<float> value, float* address, byte index) => Insert(value, address, index);
/// <summary>
/// __m256d _mm256_insertf128_pd (__m256d a, __m128d b, int imm8)
/// </summary>
- public static unsafe Vector256<double> Insert(Vector256<double> value, double* address, byte index) { throw new NotImplementedException(); }
+ public static unsafe Vector256<double> Insert(Vector256<double> value, double* address, byte index) => Insert(value, address, index);
/// <summary>
/// __m256i _mm256_loadu_si256 (__m256i const * mem_addr)
/// </summary>
- public static unsafe Vector256<sbyte> Load(sbyte* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<sbyte> Load(sbyte* address) => Load(address);
/// <summary>
/// __m256i _mm256_loadu_si256 (__m256i const * mem_addr)
/// </summary>
- public static unsafe Vector256<byte> Load(byte* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<byte> Load(byte* address) => Load(address);
/// <summary>
/// __m256i _mm256_loadu_si256 (__m256i const * mem_addr)
/// </summary>
- public static unsafe Vector256<short> Load(short* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<short> Load(short* address) => Load(address);
/// <summary>
/// __m256i _mm256_loadu_si256 (__m256i const * mem_addr)
/// </summary>
- public static unsafe Vector256<ushort> Load(ushort* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<ushort> Load(ushort* address) => Load(address);
/// <summary>
/// __m256i _mm256_loadu_si256 (__m256i const * mem_addr)
/// </summary>
- public static unsafe Vector256<int> Load(int* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<int> Load(int* address) => Load(address);
/// <summary>
/// __m256i _mm256_loadu_si256 (__m256i const * mem_addr)
/// </summary>
- public static unsafe Vector256<uint> Load(uint* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<uint> Load(uint* address) => Load(address);
/// <summary>
/// __m256i _mm256_loadu_si256 (__m256i const * mem_addr)
/// </summary>
- public static unsafe Vector256<long> Load(long* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<long> Load(long* address) => Load(address);
/// <summary>
/// __m256i _mm256_loadu_si256 (__m256i const * mem_addr)
/// </summary>
- public static unsafe Vector256<ulong> Load(ulong* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<ulong> Load(ulong* address) => Load(address);
/// <summary>
/// __m256 _mm256_loadu_ps (float const * mem_addr)
/// </summary>
- public static unsafe Vector256<float> Load(float* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<float> Load(float* address) => Load(address);
/// <summary>
/// __m256d _mm256_loadu_pd (double const * mem_addr)
/// </summary>
- public static unsafe Vector256<double> Load(double* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<double> Load(double* address) => Load(address);
/// <summary>
/// __m256i _mm256_load_si256 (__m256i const * mem_addr)
/// </summary>
- public static unsafe Vector256<sbyte> LoadAligned(sbyte* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<sbyte> LoadAligned(sbyte* address) => LoadAligned(address);
/// <summary>
/// __m256i _mm256_load_si256 (__m256i const * mem_addr)
/// </summary>
- public static unsafe Vector256<byte> LoadAligned(byte* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<byte> LoadAligned(byte* address) => LoadAligned(address);
/// <summary>
/// __m256i _mm256_load_si256 (__m256i const * mem_addr)
/// </summary>
- public static unsafe Vector256<short> LoadAligned(short* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<short> LoadAligned(short* address) => LoadAligned(address);
/// <summary>
/// __m256i _mm256_load_si256 (__m256i const * mem_addr)
/// </summary>
- public static unsafe Vector256<ushort> LoadAligned(ushort* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<ushort> LoadAligned(ushort* address) => LoadAligned(address);
/// <summary>
/// __m256i _mm256_load_si256 (__m256i const * mem_addr)
/// </summary>
- public static unsafe Vector256<int> LoadAligned(int* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<int> LoadAligned(int* address) => LoadAligned(address);
/// <summary>
/// __m256i _mm256_load_si256 (__m256i const * mem_addr)
/// </summary>
- public static unsafe Vector256<uint> LoadAligned(uint* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<uint> LoadAligned(uint* address) => LoadAligned(address);
/// <summary>
/// __m256i _mm256_load_si256 (__m256i const * mem_addr)
/// </summary>
- public static unsafe Vector256<long> LoadAligned(long* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<long> LoadAligned(long* address) => LoadAligned(address);
/// <summary>
/// __m256i _mm256_load_si256 (__m256i const * mem_addr)
/// </summary>
- public static unsafe Vector256<ulong> LoadAligned(ulong* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<ulong> LoadAligned(ulong* address) => LoadAligned(address);
/// <summary>
/// __m256 _mm256_load_ps (float const * mem_addr)
/// </summary>
- public static unsafe Vector256<float> LoadAligned(float* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<float> LoadAligned(float* address) => LoadAligned(address);
/// <summary>
/// __m256d _mm256_load_pd (double const * mem_addr)
/// </summary>
- public static unsafe Vector256<double> LoadAligned(double* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<double> LoadAligned(double* address) => LoadAligned(address);
/// <summary>
/// __m256i _mm256_lddqu_si256 (__m256i const * mem_addr)
/// </summary>
- public static unsafe Vector256<sbyte> LoadDqu(sbyte* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<sbyte> LoadDqu(sbyte* address) => LoadDqu(address);
/// <summary>
/// __m256i _mm256_lddqu_si256 (__m256i const * mem_addr)
/// </summary>
- public static unsafe Vector256<byte> LoadDqu(byte* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<byte> LoadDqu(byte* address) => LoadDqu(address);
/// <summary>
/// __m256i _mm256_lddqu_si256 (__m256i const * mem_addr)
/// </summary>
- public static unsafe Vector256<short> LoadDqu(short* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<short> LoadDqu(short* address) => LoadDqu(address);
/// <summary>
/// __m256i _mm256_lddqu_si256 (__m256i const * mem_addr)
/// </summary>
- public static unsafe Vector256<ushort> LoadDqu(ushort* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<ushort> LoadDqu(ushort* address) => LoadDqu(address);
/// <summary>
/// __m256i _mm256_lddqu_si256 (__m256i const * mem_addr)
/// </summary>
- public static unsafe Vector256<int> LoadDqu(int* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<int> LoadDqu(int* address) => LoadDqu(address);
/// <summary>
/// __m256i _mm256_lddqu_si256 (__m256i const * mem_addr)
/// </summary>
- public static unsafe Vector256<uint> LoadDqu(uint* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<uint> LoadDqu(uint* address) => LoadDqu(address);
/// <summary>
/// __m256i _mm256_lddqu_si256 (__m256i const * mem_addr)
/// </summary>
- public static unsafe Vector256<long> LoadDqu(long* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<long> LoadDqu(long* address) => LoadDqu(address);
/// <summary>
/// __m256i _mm256_lddqu_si256 (__m256i const * mem_addr)
/// </summary>
- public static unsafe Vector256<ulong> LoadDqu(ulong* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<ulong> LoadDqu(ulong* address) => LoadDqu(address);
/// <summary>
/// __m128d _mm_maskload_pd (double const * mem_addr, __m128i mask)
/// </summary>
- public static unsafe Vector128<float> MaskLoad(float* address, Vector128<uint> mask) { throw new NotImplementedException(); }
+ public static unsafe Vector128<float> MaskLoad(float* address, Vector128<uint> mask) => MaskLoad(address, mask);
/// <summary>
/// __m128d _mm_maskload_pd (double const * mem_addr, __m128i mask)
/// </summary>
- public static unsafe Vector128<double> MaskLoad(double* address, Vector128<ulong> mask) { throw new NotImplementedException(); }
+ public static unsafe Vector128<double> MaskLoad(double* address, Vector128<ulong> mask) => MaskLoad(address, mask);
/// <summary>
/// __m256 _mm256_maskload_ps (float const * mem_addr, __m256i mask)
/// </summary>
- public static unsafe Vector256<float> MaskLoad(float* address, Vector256<uint> mask) { throw new NotImplementedException(); }
+ public static unsafe Vector256<float> MaskLoad(float* address, Vector256<uint> mask) => MaskLoad(address, mask);
/// <summary>
/// __m256d _mm256_maskload_pd (double const * mem_addr, __m256i mask)
/// </summary>
- public static unsafe Vector256<double> MaskLoad(double* address, Vector256<ulong> mask) { throw new NotImplementedException(); }
+ public static unsafe Vector256<double> MaskLoad(double* address, Vector256<ulong> mask) => MaskLoad(address, mask);
/// <summary>
/// void _mm_maskstore_ps (float * mem_addr, __m128i mask, __m128 a)
/// </summary>
- public static unsafe void MaskStore(float* address, Vector128<float> mask, Vector128<uint> source) { throw new NotImplementedException(); }
+ public static unsafe void MaskStore(float* address, Vector128<float> mask, Vector128<uint> source) => MaskStore(address, mask, source);
/// <summary>
/// void _mm_maskstore_pd (double * mem_addr, __m128i mask, __m128d a)
/// </summary>
- public static unsafe void MaskStore(double* address, Vector128<double> mask, Vector128<ulong> source) { throw new NotImplementedException(); }
+ public static unsafe void MaskStore(double* address, Vector128<double> mask, Vector128<ulong> source) => MaskStore(address, mask, source);
/// <summary>
/// void _mm256_maskstore_ps (float * mem_addr, __m256i mask, __m256 a)
/// </summary>
- public static unsafe void MaskStore(float* address, Vector256<float> mask, Vector256<uint> source) { throw new NotImplementedException(); }
+ public static unsafe void MaskStore(float* address, Vector256<float> mask, Vector256<uint> source) => MaskStore(address, mask, source);
/// <summary>
/// void _mm256_maskstore_pd (double * mem_addr, __m256i mask, __m256d a)
/// </summary>
- public static unsafe void MaskStore(double* address, Vector256<double> mask, Vector256<ulong> source) { throw new NotImplementedException(); }
+ public static unsafe void MaskStore(double* address, Vector256<double> mask, Vector256<ulong> source) => MaskStore(address, mask, source);
/// <summary>
/// __m256 _mm256_max_ps (__m256 a, __m256 b)
/// </summary>
- public static Vector256<float> Max(Vector256<float> left, Vector256<float> right) { throw new NotImplementedException(); }
+ public static Vector256<float> Max(Vector256<float> left, Vector256<float> right) => Max(left, right);
/// <summary>
/// __m256d _mm256_max_pd (__m256d a, __m256d b)
/// </summary>
- public static Vector256<double> Max(Vector256<double> left, Vector256<double> right) { throw new NotImplementedException(); }
+ public static Vector256<double> Max(Vector256<double> left, Vector256<double> right) => Max(left, right);
/// <summary>
/// __m256 _mm256_min_ps (__m256 a, __m256 b)
/// </summary>
- public static Vector256<float> Min(Vector256<float> left, Vector256<float> right) { throw new NotImplementedException(); }
+ public static Vector256<float> Min(Vector256<float> left, Vector256<float> right) => Min(left, right);
/// <summary>
/// __m256d _mm256_min_pd (__m256d a, __m256d b)
/// </summary>
- public static Vector256<double> Min(Vector256<double> left, Vector256<double> right) { throw new NotImplementedException(); }
+ public static Vector256<double> Min(Vector256<double> left, Vector256<double> right) => Min(left, right);
/// <summary>
/// int _mm256_movemask_ps (__m256 a)
/// </summary>
- public static int MoveMask(Vector256<float> value) { throw new NotImplementedException(); }
+ public static int MoveMask(Vector256<float> value) => MoveMask(value);
/// <summary>
/// int _mm256_movemask_pd (__m256d a)
/// </summary>
- public static int MoveMask(Vector256<double> value) { throw new NotImplementedException(); }
+ public static int MoveMask(Vector256<double> value) => MoveMask(value);
/// <summary>
/// __m256 _mm256_mul_ps (__m256 a, __m256 b)
/// </summary>
- public static Vector256<float> Multiply(Vector256<float> left, Vector256<float> right) { throw new NotImplementedException(); }
+ public static Vector256<float> Multiply(Vector256<float> left, Vector256<float> right) => Multiply(left, right);
/// <summary>
/// __m256d _mm256_mul_pd (__m256d a, __m256d b)
/// </summary>
- public static Vector256<double> Multiply(Vector256<double> left, Vector256<double> right) { throw new NotImplementedException(); }
+ public static Vector256<double> Multiply(Vector256<double> left, Vector256<double> right) => Multiply(left, right);
/// <summary>
/// __m256 _mm256_or_ps (__m256 a, __m256 b)
/// </summary>
- public static Vector256<float> Or(Vector256<float> left, Vector256<float> right) { throw new NotImplementedException(); }
+ public static Vector256<float> Or(Vector256<float> left, Vector256<float> right) => Or(left, right);
/// <summary>
/// __m256d _mm256_or_pd (__m256d a, __m256d b)
/// </summary>
- public static Vector256<double> Or(Vector256<double> left, Vector256<double> right) { throw new NotImplementedException(); }
+ public static Vector256<double> Or(Vector256<double> left, Vector256<double> right) => Or(left, right);
/// <summary>
/// __m128 _mm_permute_ps (__m128 a, int imm8)
/// </summary>
- public static Vector128<float> Permute(Vector128<float> value, byte control) { throw new NotImplementedException(); }
+ public static Vector128<float> Permute(Vector128<float> value, byte control) => Permute(value, control);
/// <summary>
/// __m128d _mm_permute_pd (__m128d a, int imm8)
/// </summary>
- public static Vector128<double> Permute(Vector128<double> value, byte control) { throw new NotImplementedException(); }
+ public static Vector128<double> Permute(Vector128<double> value, byte control) => Permute(value, control);
/// <summary>
/// __m256 _mm256_permute_ps (__m256 a, int imm8)
/// </summary>
- public static Vector256<float> Permute(Vector256<float> value, byte control) { throw new NotImplementedException(); }
+ public static Vector256<float> Permute(Vector256<float> value, byte control) => Permute(value, control);
/// <summary>
/// __m256d _mm256_permute_pd (__m256d a, int imm8)
/// </summary>
- public static Vector256<double> Permute(Vector256<double> value, byte control) { throw new NotImplementedException(); }
+ public static Vector256<double> Permute(Vector256<double> value, byte control) => Permute(value, control);
/// <summary>
/// __m256 _mm256_permute2f128_ps (__m256 a, __m256 b, int imm8)
/// </summary>
- public static Vector256<float> Permute2x128(Vector256<float> left, Vector256<float> right, byte control) { throw new NotImplementedException(); }
+ public static Vector256<float> Permute2x128(Vector256<float> left, Vector256<float> right, byte control) => Permute2x128(left, right, control);
/// <summary>
/// __m256d _mm256_permute2f128_pd (__m256d a, __m256d b, int imm8)
/// </summary>
- public static Vector256<double> Permute2x128(Vector256<double> left, Vector256<double> right, byte control) { throw new NotImplementedException(); }
+ public static Vector256<double> Permute2x128(Vector256<double> left, Vector256<double> right, byte control) => Permute2x128(left, right, control);
/// <summary>
/// __m128 _mm_permutevar_ps (__m128 a, __m128i b)
/// </summary>
- public static Vector128<float> PermuteVar(Vector128<float> left, Vector128<float> mask) { throw new NotImplementedException(); }
+ public static Vector128<float> PermuteVar(Vector128<float> left, Vector128<float> mask) => PermuteVar(left, mask);
/// <summary>
/// __m128d _mm_permutevar_pd (__m128d a, __m128i b)
/// </summary>
- public static Vector128<double> PermuteVar(Vector128<double> left, Vector128<double> mask) { throw new NotImplementedException(); }
+ public static Vector128<double> PermuteVar(Vector128<double> left, Vector128<double> mask) => PermuteVar(left, mask);
/// <summary>
/// __m256 _mm256_permutevar_ps (__m256 a, __m256i b)
/// </summary>
- public static Vector256<float> PermuteVar(Vector256<float> left, Vector256<float> mask) { throw new NotImplementedException(); }
+ public static Vector256<float> PermuteVar(Vector256<float> left, Vector256<float> mask) => PermuteVar(left, mask);
/// <summary>
/// __m256d _mm256_permutevar_pd (__m256d a, __m256i b)
/// </summary>
- public static Vector256<double> PermuteVar(Vector256<double> left, Vector256<double> mask) { throw new NotImplementedException(); }
+ public static Vector256<double> PermuteVar(Vector256<double> left, Vector256<double> mask) => PermuteVar(left, mask);
/// <summary>
/// __m256 _mm256_rcp_ps (__m256 a)
/// </summary>
- public static Vector256<float> Reciprocal(Vector256<float> value) { throw new NotImplementedException(); }
+ public static Vector256<float> Reciprocal(Vector256<float> value) => Reciprocal(value);
/// <summary>
/// __m256 _mm256_rsqrt_ps (__m256 a)
/// </summary>
- public static Vector256<float> ReciprocalSqrt(Vector256<float> value) { throw new NotImplementedException(); }
+ public static Vector256<float> ReciprocalSqrt(Vector256<float> value) => ReciprocalSqrt(value);
/// <summary>
/// __m256 _mm256_round_ps (__m256 a, int rounding)
/// _MM_FROUND_TO_NEAREST_INT |_MM_FROUND_NO_EXC
/// </summary>
- public static Vector256<float> RoundToNearestInteger(Vector256<float> value) { throw new NotImplementedException(); }
+ public static Vector256<float> RoundToNearestInteger(Vector256<float> value) => RoundToNearestInteger(value);
/// <summary>
/// _MM_FROUND_TO_NEG_INF |_MM_FROUND_NO_EXC
/// </summary>
- public static Vector256<float> RoundToNegativeInfinity(Vector256<float> value) { throw new NotImplementedException(); }
+ public static Vector256<float> RoundToNegativeInfinity(Vector256<float> value) => RoundToNegativeInfinity(value);
/// <summary>
/// _MM_FROUND_TO_POS_INF |_MM_FROUND_NO_EXC
/// </summary>
- public static Vector256<float> RoundToPositiveInfinity(Vector256<float> value) { throw new NotImplementedException(); }
+ public static Vector256<float> RoundToPositiveInfinity(Vector256<float> value) => RoundToPositiveInfinity(value);
/// <summary>
/// _MM_FROUND_TO_ZERO |_MM_FROUND_NO_EXC
/// </summary>
- public static Vector256<float> RoundToZero(Vector256<float> value) { throw new NotImplementedException(); }
+ public static Vector256<float> RoundToZero(Vector256<float> value) => RoundToZero(value);
/// <summary>
/// _MM_FROUND_CUR_DIRECTION
/// </summary>
- public static Vector256<float> RoundCurrentDirection(Vector256<float> value) { throw new NotImplementedException(); }
+ public static Vector256<float> RoundCurrentDirection(Vector256<float> value) => RoundCurrentDirection(value);
/// <summary>
/// __m256d _mm256_round_pd (__m256d a, int rounding)
/// _MM_FROUND_TO_NEAREST_INT |_MM_FROUND_NO_EXC
/// </summary>
- public static Vector256<double> RoundToNearestInteger(Vector256<double> value) { throw new NotImplementedException(); }
+ public static Vector256<double> RoundToNearestInteger(Vector256<double> value) => RoundToNearestInteger(value);
/// <summary>
/// _MM_FROUND_TO_NEG_INF |_MM_FROUND_NO_EXC
/// </summary>
- public static Vector256<double> RoundToNegativeInfinity(Vector256<double> value) { throw new NotImplementedException(); }
+ public static Vector256<double> RoundToNegativeInfinity(Vector256<double> value) => RoundToNegativeInfinity(value);
/// <summary>
/// _MM_FROUND_TO_POS_INF |_MM_FROUND_NO_EXC
/// </summary>
- public static Vector256<double> RoundToPositiveInfinity(Vector256<double> value) { throw new NotImplementedException(); }
+ public static Vector256<double> RoundToPositiveInfinity(Vector256<double> value) => RoundToPositiveInfinity(value);
/// <summary>
/// _MM_FROUND_TO_ZERO |_MM_FROUND_NO_EXC
/// </summary>
- public static Vector256<double> RoundToZero(Vector256<double> value) { throw new NotImplementedException(); }
+ public static Vector256<double> RoundToZero(Vector256<double> value) => RoundToZero(value);
/// <summary>
/// _MM_FROUND_CUR_DIRECTION
/// </summary>
- public static Vector256<double> RoundCurrentDirection(Vector256<double> value) { throw new NotImplementedException(); }
+ public static Vector256<double> RoundCurrentDirection(Vector256<double> value) => RoundCurrentDirection(value);
/// <summary>
/// __m256i _mm256_set_epi8 (char e31, char e30, char e29, char e28, char e27, char e26, char e25, char e24, char e23, char e22, char e21, char e20, char e19, char e18, char e17, char e16, char e15, char e14, char e13, char e12, char e11, char e10, char e9, char e8, char e7, char e6, char e5, char e4, char e3, char e2, char e1, char e0)
/// </summary>
- public static Vector256<sbyte> Set(sbyte e31, sbyte e30, sbyte e29, sbyte e28, sbyte e27, sbyte e26, sbyte e25, sbyte e24, sbyte e23, sbyte e22, sbyte e21, sbyte e20, sbyte e19, sbyte e18, sbyte e17, sbyte e16, sbyte e15, sbyte e14, sbyte e13, sbyte e12, sbyte e11, sbyte e10, sbyte e9, sbyte e8, sbyte e7, sbyte e6, sbyte e5, sbyte e4, sbyte e3, sbyte e2, sbyte e1, sbyte e0) { throw new NotImplementedException(); }
+ public static Vector256<sbyte> Set(sbyte e31, sbyte e30, sbyte e29, sbyte e28, sbyte e27, sbyte e26, sbyte e25, sbyte e24, sbyte e23, sbyte e22, sbyte e21, sbyte e20, sbyte e19, sbyte e18, sbyte e17, sbyte e16, sbyte e15, sbyte e14, sbyte e13, sbyte e12, sbyte e11, sbyte e10, sbyte e9, sbyte e8, sbyte e7, sbyte e6, sbyte e5, sbyte e4, sbyte e3, sbyte e2, sbyte e1, sbyte e0) => Set(e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0);
/// <summary>
/// __m256i _mm256_set_epi8 (char e31, char e30, char e29, char e28, char e27, char e26, char e25, char e24, char e23, char e22, char e21, char e20, char e19, char e18, char e17, char e16, char e15, char e14, char e13, char e12, char e11, char e10, char e9, char e8, char e7, char e6, char e5, char e4, char e3, char e2, char e1, char e0)
/// </summary>
- public static Vector256<byte> Set(byte e31, byte e30, byte e29, byte e28, byte e27, byte e26, byte e25, byte e24, byte e23, byte e22, byte e21, byte e20, byte e19, byte e18, byte e17, byte e16, byte e15, byte e14, byte e13, byte e12, byte e11, byte e10, byte e9, byte e8, byte e7, byte e6, byte e5, byte e4, byte e3, byte e2, byte e1, byte e0) { throw new NotImplementedException(); }
+ public static Vector256<byte> Set(byte e31, byte e30, byte e29, byte e28, byte e27, byte e26, byte e25, byte e24, byte e23, byte e22, byte e21, byte e20, byte e19, byte e18, byte e17, byte e16, byte e15, byte e14, byte e13, byte e12, byte e11, byte e10, byte e9, byte e8, byte e7, byte e6, byte e5, byte e4, byte e3, byte e2, byte e1, byte e0) => Set(e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0);
/// <summary>
/// __m256i _mm256_set_epi16 (short e15, short e14, short e13, short e12, short e11, short e10, short e9, short e8, short e7, short e6, short e5, short e4, short e3, short e2, short e1, short e0)
/// </summary>
- public static Vector256<short> Set(short e15, short e14, short e13, short e12, short e11, short e10, short e9, short e8, short e7, short e6, short e5, short e4, short e3, short e2, short e1, short e0) { throw new NotImplementedException(); }
+ public static Vector256<short> Set(short e15, short e14, short e13, short e12, short e11, short e10, short e9, short e8, short e7, short e6, short e5, short e4, short e3, short e2, short e1, short e0) => Set(e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0);
/// <summary>
/// __m256i _mm256_set_epi16 (short e15, short e14, short e13, short e12, short e11, short e10, short e9, short e8, short e7, short e6, short e5, short e4, short e3, short e2, short e1, short e0)
/// </summary>
- public static Vector256<ushort> Set(ushort e15, ushort e14, ushort e13, ushort e12, ushort e11, ushort e10, ushort e9, ushort e8, ushort e7, ushort e6, ushort e5, ushort e4, ushort e3, ushort e2, ushort e1, ushort e0) { throw new NotImplementedException(); }
+ public static Vector256<ushort> Set(ushort e15, ushort e14, ushort e13, ushort e12, ushort e11, ushort e10, ushort e9, ushort e8, ushort e7, ushort e6, ushort e5, ushort e4, ushort e3, ushort e2, ushort e1, ushort e0) => Set(e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0);
/// <summary>
/// __m256i _mm256_set_epi32 (int e7, int e6, int e5, int e4, int e3, int e2, int e1, int e0)
/// </summary>
- public static Vector256<int> Set(int e7, int e6, int e5, int e4, int e3, int e2, int e1, int e0) { throw new NotImplementedException(); }
+ public static Vector256<int> Set(int e7, int e6, int e5, int e4, int e3, int e2, int e1, int e0) => Set(e7, e6, e5, e4, e3, e2, e1, e0);
/// <summary>
/// __m256i _mm256_set_epi32 (int e7, int e6, int e5, int e4, int e3, int e2, int e1, int e0)
/// </summary>
- public static Vector256<uint> Set(uint e7, uint e6, uint e5, uint e4, uint e3, uint e2, uint e1, uint e0) { throw new NotImplementedException(); }
+ public static Vector256<uint> Set(uint e7, uint e6, uint e5, uint e4, uint e3, uint e2, uint e1, uint e0) => Set(e7, e6, e5, e4, e3, e2, e1, e0);
/// <summary>
/// __m256i _mm256_set_epi64x (__int64 e3, __int64 e2, __int64 e1, __int64 e0)
/// </summary>
- public static Vector256<long> Set(long e3, long e2, long e1, long e0) { throw new NotImplementedException(); }
+ public static Vector256<long> Set(long e3, long e2, long e1, long e0) => Set(e3, e2, e1, e0);
/// <summary>
/// __m256i _mm256_set_epi64x (__int64 e3, __int64 e2, __int64 e1, __int64 e0)
/// </summary>
- public static Vector256<ulong> Set(ulong e3, ulong e2, ulong e1, ulong e0) { throw new NotImplementedException(); }
+ public static Vector256<ulong> Set(ulong e3, ulong e2, ulong e1, ulong e0) => Set(e3, e2, e1, e0);
/// <summary>
/// __m256 _mm256_set_ps (float e7, float e6, float e5, float e4, float e3, float e2, float e1, float e0)
/// </summary>
- public static Vector256<float> Set(float e7, float e6, float e5, float e4, float e3, float e2, float e1, float e0) { throw new NotImplementedException(); }
+ public static Vector256<float> Set(float e7, float e6, float e5, float e4, float e3, float e2, float e1, float e0) => Set(e7, e6, e5, e4, e3, e2, e1, e0);
/// <summary>
/// __m256d _mm256_set_pd (double e3, double e2, double e1, double e0)
/// </summary>
- public static Vector256<double> Set(double e3, double e2, double e1, double e0) { throw new NotImplementedException(); }
+ public static Vector256<double> Set(double e3, double e2, double e1, double e0) => Set(e3, e2, e1, e0);
/// <summary>
/// __m256i _mm256_set1_epi8 (char a)
@@ -726,39 +726,39 @@ namespace System.Runtime.Intrinsics.X86
/// __m256 _mm256_set1_ps (float a)
/// __m256d _mm256_set1_pd (double a)
/// </summary>
- public static Vector256<T> Set1<T>(T value) where T : struct { throw new NotImplementedException(); }
+ public static Vector256<T> Set1<T>(T value) where T : struct => Set1<T>(value);
/// <summary>
/// __m256 _mm256_set_m128 (__m128 hi, __m128 lo)
/// __m256d _mm256_set_m128d (__m128d hi, __m128d lo)
/// __m256i _mm256_set_m128i (__m128i hi, __m128i lo)
/// </summary>
- public static Vector256<T> SetHiLo<T>(Vector128<T> hi, Vector128<T> lo) where T : struct { throw new NotImplementedException(); }
+ public static Vector256<T> SetHiLo<T>(Vector128<T> hi, Vector128<T> lo) where T : struct => SetHiLo<T>(hi, lo);
/// <summary>
/// __m256i _mm256_setzero_si256 (void)
/// __m256 _mm256_setzero_ps (void)
/// __m256d _mm256_setzero_pd (void)
/// </summary>
- public static Vector256<T> SetZero<T>() where T : struct { throw new NotImplementedException(); }
+ public static Vector256<T> SetZero<T>() where T : struct => SetZero<T>();
/// <summary>
/// __m256 _mm256_shuffle_ps (__m256 a, __m256 b, const int imm8)
/// </summary>
- public static Vector256<float> Shuffle(Vector256<float> value, Vector256<float> right, byte control) { throw new NotImplementedException(); }
+ public static Vector256<float> Shuffle(Vector256<float> value, Vector256<float> right, byte control) => Shuffle(value, right, control);
/// <summary>
/// __m256d _mm256_shuffle_pd (__m256d a, __m256d b, const int imm8)
/// </summary>
- public static Vector256<double> Shuffle(Vector256<double> value, Vector256<double> right, byte control) { throw new NotImplementedException(); }
+ public static Vector256<double> Shuffle(Vector256<double> value, Vector256<double> right, byte control) => Shuffle(value, right, control);
/// <summary>
/// __m256 _mm256_sqrt_ps (__m256 a)
/// </summary>
- public static Vector256<float> Sqrt(Vector256<float> value) { throw new NotImplementedException(); }
+ public static Vector256<float> Sqrt(Vector256<float> value) => Sqrt(value);
/// <summary>
/// __m256d _mm256_sqrt_pd (__m256d a)
/// </summary>
- public static Vector256<double> Sqrt(Vector256<double> value) { throw new NotImplementedException(); }
+ public static Vector256<double> Sqrt(Vector256<double> value) => Sqrt(value);
/// <summary>
/// __m256 _mm256_castpd_ps (__m256d a)
@@ -768,229 +768,229 @@ namespace System.Runtime.Intrinsics.X86
/// __m256d _mm256_castsi256_pd (__m256i a)
/// __m256 _mm256_castsi256_ps (__m256i a)
/// </summary>
- public static Vector256<U> StaticCast<T, U>(Vector256<T> value) where T : struct where U : struct { throw new NotImplementedException(); }
+ public static Vector256<U> StaticCast<T, U>(Vector256<T> value) where T : struct where U : struct => StaticCast<T, U>(value);
/// <summary>
/// void _mm256_store_si256 (__m256i * mem_addr, __m256i a)
/// </summary>
- public static unsafe void StoreAligned(sbyte* address, Vector256<sbyte> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAligned(sbyte* address, Vector256<sbyte> source) => StoreAligned(address, source);
/// <summary>
/// void _mm256_store_si256 (__m256i * mem_addr, __m256i a)
/// </summary>
- public static unsafe void StoreAligned(byte* address, Vector256<byte> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAligned(byte* address, Vector256<byte> source) => StoreAligned(address, source);
/// <summary>
/// void _mm256_store_si256 (__m256i * mem_addr, __m256i a)
/// </summary>
- public static unsafe void StoreAligned(short* address, Vector256<short> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAligned(short* address, Vector256<short> source) => StoreAligned(address, source);
/// <summary>
/// void _mm256_store_si256 (__m256i * mem_addr, __m256i a)
/// </summary>
- public static unsafe void StoreAligned(ushort* address, Vector256<ushort> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAligned(ushort* address, Vector256<ushort> source) => StoreAligned(address, source);
/// <summary>
/// void _mm256_store_si256 (__m256i * mem_addr, __m256i a)
/// </summary>
- public static unsafe void StoreAligned(int* address, Vector256<int> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAligned(int* address, Vector256<int> source) => StoreAligned(address, source);
/// <summary>
/// void _mm256_store_si256 (__m256i * mem_addr, __m256i a)
/// </summary>
- public static unsafe void StoreAligned(uint* address, Vector256<uint> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAligned(uint* address, Vector256<uint> source) => StoreAligned(address, source);
/// <summary>
/// void _mm256_store_si256 (__m256i * mem_addr, __m256i a)
/// </summary>
- public static unsafe void StoreAligned(long* address, Vector256<long> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAligned(long* address, Vector256<long> source) => StoreAligned(address, source);
/// <summary>
/// void _mm256_store_si256 (__m256i * mem_addr, __m256i a)
/// </summary>
- public static unsafe void StoreAligned(ulong* address, Vector256<ulong> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAligned(ulong* address, Vector256<ulong> source) => StoreAligned(address, source);
/// <summary>
/// void _mm256_store_ps (float * mem_addr, __m256 a)
/// </summary>
- public static unsafe void StoreAligned(float* address, Vector256<float> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAligned(float* address, Vector256<float> source) => StoreAligned(address, source);
/// <summary>
/// void _mm256_store_pd (double * mem_addr, __m256d a)
/// </summary>
- public static unsafe void StoreAligned(double* address, Vector256<double> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAligned(double* address, Vector256<double> source) => StoreAligned(address, source);
/// <summary>
/// void _mm256_stream_si256 (__m256i * mem_addr, __m256i a)
/// </summary>
- public static unsafe void StoreAlignedNonTemporal(sbyte* address, Vector256<sbyte> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAlignedNonTemporal(sbyte* address, Vector256<sbyte> source) => StoreAlignedNonTemporal(address, source);
/// <summary>
/// void _mm256_stream_si256 (__m256i * mem_addr, __m256i a)
/// </summary>
- public static unsafe void StoreAlignedNonTemporal(byte* address, Vector256<byte> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAlignedNonTemporal(byte* address, Vector256<byte> source) => StoreAlignedNonTemporal(address, source);
/// <summary>
/// void _mm256_stream_si256 (__m256i * mem_addr, __m256i a)
/// </summary>
- public static unsafe void StoreAlignedNonTemporal(short* address, Vector256<short> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAlignedNonTemporal(short* address, Vector256<short> source) => StoreAlignedNonTemporal(address, source);
/// <summary>
/// void _mm256_stream_si256 (__m256i * mem_addr, __m256i a)
/// </summary>
- public static unsafe void StoreAlignedNonTemporal(ushort* address, Vector256<ushort> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAlignedNonTemporal(ushort* address, Vector256<ushort> source) => StoreAlignedNonTemporal(address, source);
/// <summary>
/// void _mm256_stream_si256 (__m256i * mem_addr, __m256i a)
/// </summary>
- public static unsafe void StoreAlignedNonTemporal(int* address, Vector256<int> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAlignedNonTemporal(int* address, Vector256<int> source) => StoreAlignedNonTemporal(address, source);
/// <summary>
/// void _mm256_stream_si256 (__m256i * mem_addr, __m256i a)
/// </summary>
- public static unsafe void StoreAlignedNonTemporal(uint* address, Vector256<uint> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAlignedNonTemporal(uint* address, Vector256<uint> source) => StoreAlignedNonTemporal(address, source);
/// <summary>
/// void _mm256_stream_si256 (__m256i * mem_addr, __m256i a)
/// </summary>
- public static unsafe void StoreAlignedNonTemporal(long* address, Vector256<long> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAlignedNonTemporal(long* address, Vector256<long> source) => StoreAlignedNonTemporal(address, source);
/// <summary>
/// void _mm256_stream_si256 (__m256i * mem_addr, __m256i a)
/// </summary>
- public static unsafe void StoreAlignedNonTemporal(ulong* address, Vector256<ulong> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAlignedNonTemporal(ulong* address, Vector256<ulong> source) => StoreAlignedNonTemporal(address, source);
/// <summary>
/// void _mm256_stream_ps (float * mem_addr, __m256 a)
/// </summary>
- public static unsafe void StoreAlignedNonTemporal(float* address, Vector256<float> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAlignedNonTemporal(float* address, Vector256<float> source) => StoreAlignedNonTemporal(address, source);
/// <summary>
/// void _mm256_stream_pd (double * mem_addr, __m256d a)
/// </summary>
- public static unsafe void StoreAlignedNonTemporal(double* address, Vector256<double> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAlignedNonTemporal(double* address, Vector256<double> source) => StoreAlignedNonTemporal(address, source);
/// <summary>
/// void _mm256_storeu_si256 (__m256i * mem_addr, __m256i a)
/// </summary>
- public static unsafe void Store(sbyte* address, Vector256<sbyte> source) { throw new NotImplementedException(); }
+ public static unsafe void Store(sbyte* address, Vector256<sbyte> source) => Store(address, source);
/// <summary>
/// void _mm256_storeu_si256 (__m256i * mem_addr, __m256i a)
/// </summary>
- public static unsafe void Store(byte* address, Vector256<byte> source) { throw new NotImplementedException(); }
+ public static unsafe void Store(byte* address, Vector256<byte> source) => Store(address, source);
/// <summary>
/// void _mm256_storeu_si256 (__m256i * mem_addr, __m256i a)
/// </summary>
- public static unsafe void Store(short* address, Vector256<short> source) { throw new NotImplementedException(); }
+ public static unsafe void Store(short* address, Vector256<short> source) => Store(address, source);
/// <summary>
/// void _mm256_storeu_si256 (__m256i * mem_addr, __m256i a)
/// </summary>
- public static unsafe void Store(ushort* address, Vector256<ushort> source) { throw new NotImplementedException(); }
+ public static unsafe void Store(ushort* address, Vector256<ushort> source) => Store(address, source);
/// <summary>
/// void _mm256_storeu_si256 (__m256i * mem_addr, __m256i a)
/// </summary>
- public static unsafe void Store(int* address, Vector256<int> source) { throw new NotImplementedException(); }
+ public static unsafe void Store(int* address, Vector256<int> source) => Store(address, source);
/// <summary>
/// void _mm256_storeu_si256 (__m256i * mem_addr, __m256i a)
/// </summary>
- public static unsafe void Store(uint* address, Vector256<uint> source) { throw new NotImplementedException(); }
+ public static unsafe void Store(uint* address, Vector256<uint> source) => Store(address, source);
/// <summary>
/// void _mm256_storeu_si256 (__m256i * mem_addr, __m256i a)
/// </summary>
- public static unsafe void Store(long* address, Vector256<long> source) { throw new NotImplementedException(); }
+ public static unsafe void Store(long* address, Vector256<long> source) => Store(address, source);
/// <summary>
/// void _mm256_storeu_si256 (__m256i * mem_addr, __m256i a)
/// </summary>
- public static unsafe void Store(ulong* address, Vector256<ulong> source) { throw new NotImplementedException(); }
+ public static unsafe void Store(ulong* address, Vector256<ulong> source) => Store(address, source);
/// <summary>
/// void _mm256_storeu_ps (float * mem_addr, __m256 a)
/// </summary>
- public static unsafe void Store(float* address, Vector256<float> source) { throw new NotImplementedException(); }
+ public static unsafe void Store(float* address, Vector256<float> source) => Store(address, source);
/// <summary>
/// void _mm256_storeu_pd (double * mem_addr, __m256d a)
/// </summary>
- public static unsafe void Store(double* address, Vector256<double> source) { throw new NotImplementedException(); }
+ public static unsafe void Store(double* address, Vector256<double> source) => Store(address, source);
/// <summary>
/// __m256 _mm256_sub_ps (__m256 a, __m256 b)
/// </summary>
- public static Vector256<float> Subtract(Vector256<float> left, Vector256<float> right) { throw new NotImplementedException(); }
+ public static Vector256<float> Subtract(Vector256<float> left, Vector256<float> right) => Subtract(left, right);
/// <summary>
/// __m256d _mm256_sub_pd (__m256d a, __m256d b)
/// </summary>
- public static Vector256<double> Subtract(Vector256<double> left, Vector256<double> right) { throw new NotImplementedException(); }
+ public static Vector256<double> Subtract(Vector256<double> left, Vector256<double> right) => Subtract(left, right);
/// <summary>
/// int _mm_testc_ps (__m128 a, __m128 b)
/// </summary>
- public static bool TestC(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static bool TestC(Vector128<float> left, Vector128<float> right) => TestC(left, right);
/// <summary>
/// int _mm_testc_pd (__m128d a, __m128d b)
/// </summary>
- public static bool TestC(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static bool TestC(Vector128<double> left, Vector128<double> right) => TestC(left, right);
/// <summary>
/// int _mm256_testc_si256 (__m256i a, __m256i b)
/// int _mm256_testc_ps (__m256 a, __m256 b)
/// int _mm256_testc_pd (__m256d a, __m256d b)
/// </summary>
- public static bool TestC<T>(Vector256<T> left, Vector256<T> right) where T : struct { throw new NotImplementedException(); }
+ public static bool TestC<T>(Vector256<T> left, Vector256<T> right) where T : struct => TestC<T>(left, right);
/// <summary>
/// int _mm_testnzc_ps (__m128 a, __m128 b)
/// </summary>
- public static bool TestNotZAndNotC(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static bool TestNotZAndNotC(Vector128<float> left, Vector128<float> right) => TestNotZAndNotC(left, right);
/// <summary>
/// int _mm_testnzc_pd (__m128d a, __m128d b)
/// </summary>
- public static bool TestNotZAndNotC(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static bool TestNotZAndNotC(Vector128<double> left, Vector128<double> right) => TestNotZAndNotC(left, right);
/// <summary>
/// int _mm256_testnzc_si256 (__m256i a, __m256i b)
/// int _mm256_testnzc_ps (__m256 a, __m256 b)
/// int _mm256_testnzc_pd (__m256d a, __m256d b)
/// </summary>
- public static bool TestNotZAndNotC<T>(Vector256<T> left, Vector256<T> right) where T : struct { throw new NotImplementedException(); }
+ public static bool TestNotZAndNotC<T>(Vector256<T> left, Vector256<T> right) where T : struct => TestNotZAndNotC<T>(left, right);
/// <summary>
/// int _mm_testz_ps (__m128 a, __m128 b)
/// </summary>
- public static bool TestZ(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static bool TestZ(Vector128<float> left, Vector128<float> right) => TestZ(left, right);
/// <summary>
/// int _mm_testz_ps (__m128 a, __m128 b)
/// </summary>
- public static bool TestZ(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static bool TestZ(Vector128<double> left, Vector128<double> right) => TestZ(left, right);
/// <summary>
/// int _mm256_testz_si256 (__m256i a, __m256i b)
/// int _mm256_testz_ps (__m256 a, __m256 b)
/// int _mm256_testz_pd (__m256d a, __m256d b)
/// </summary>
- public static bool TestZ<T>(Vector256<T> left, Vector256<T> right) where T : struct { throw new NotImplementedException(); }
+ public static bool TestZ<T>(Vector256<T> left, Vector256<T> right) where T : struct => TestZ<T>(left, right);
/// <summary>
/// __m256 _mm256_unpackhi_ps (__m256 a, __m256 b)
/// </summary>
- public static Vector256<float> UnpackHigh(Vector256<float> left, Vector256<float> right) { throw new NotImplementedException(); }
+ public static Vector256<float> UnpackHigh(Vector256<float> left, Vector256<float> right) => UnpackHigh(left, right);
/// <summary>
/// __m256d _mm256_unpackhi_pd (__m256d a, __m256d b)
/// </summary>
- public static Vector256<double> UnpackHigh(Vector256<double> left, Vector256<double> right) { throw new NotImplementedException(); }
+ public static Vector256<double> UnpackHigh(Vector256<double> left, Vector256<double> right) => UnpackHigh(left, right);
/// <summary>
/// __m256 _mm256_unpacklo_ps (__m256 a, __m256 b)
/// </summary>
- public static Vector256<float> UnpackLow(Vector256<float> left, Vector256<float> right) { throw new NotImplementedException(); }
+ public static Vector256<float> UnpackLow(Vector256<float> left, Vector256<float> right) => UnpackLow(left, right);
/// <summary>
/// __m256d _mm256_unpacklo_pd (__m256d a, __m256d b)
/// </summary>
- public static Vector256<double> UnpackLow(Vector256<double> left, Vector256<double> right) { throw new NotImplementedException(); }
+ public static Vector256<double> UnpackLow(Vector256<double> left, Vector256<double> right) => UnpackLow(left, right);
/// <summary>
/// __m256 _mm256_xor_ps (__m256 a, __m256 b)
/// </summary>
- public static Vector256<float> Xor(Vector256<float> left, Vector256<float> right) { throw new NotImplementedException(); }
+ public static Vector256<float> Xor(Vector256<float> left, Vector256<float> right) => Xor(left, right);
/// <summary>
/// __m256d _mm256_xor_pd (__m256d a, __m256d b)
/// </summary>
- public static Vector256<double> Xor(Vector256<double> left, Vector256<double> right) { throw new NotImplementedException(); }
+ public static Vector256<double> Xor(Vector256<double> left, Vector256<double> right) => Xor(left, right);
/// <summary>
/// void _mm256_zeroall (void)
/// </summary>
- public static void ZeroAll() { throw new NotImplementedException(); }
+ public static void ZeroAll() => ZeroAll();
/// <summary>
/// void _mm256_zeroupper (void)
/// </summary>
- public static void ZeroUpper() { throw new NotImplementedException(); }
+ public static void ZeroUpper() => ZeroUpper();
/// <summary>
/// __m256d _mm256_zextpd128_pd256 (__m128d a)
/// __m256 _mm256_zextps128_ps256 (__m128 a)
/// __m256i _mm256_zextsi128_si256 (__m128i a)
/// </summary>
- public static Vector256<T> ZeroExtendToVector256<T>(Vector128<T> value) where T : struct { throw new NotImplementedException(); }
+ public static Vector256<T> ZeroExtendToVector256<T>(Vector128<T> value) where T : struct => ZeroExtendToVector256<T>(value);
}
}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Avx2.PlatformNotSupported.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Avx2.PlatformNotSupported.cs
new file mode 100644
index 0000000000..97e1074ef6
--- /dev/null
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Avx2.PlatformNotSupported.cs
@@ -0,0 +1,1362 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.Intrinsics;
+
+namespace System.Runtime.Intrinsics.X86
+{
+ /// <summary>
+ /// This class provides access to Intel AVX2 hardware instructions via intrinsics
+ /// </summary>
+ [CLSCompliant(false)]
+ public static class Avx2
+ {
+ public static bool IsSupported { get { return false; } }
+
+ /// <summary>
+ /// __m256i _mm256_abs_epi8 (__m256i a)
+ /// </summary>
+ public static Vector256<byte> Abs(Vector256<sbyte> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_abs_epi16 (__m256i a)
+ /// </summary>
+ public static Vector256<ushort> Abs(Vector256<short> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_abs_epi32 (__m256i a)
+ /// </summary>
+ public static Vector256<uint> Abs(Vector256<int> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_add_epi8 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<sbyte> Add(Vector256<sbyte> left, Vector256<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_add_epi8 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<byte> Add(Vector256<byte> left, Vector256<byte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_add_epi16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<short> Add(Vector256<short> left, Vector256<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_add_epi16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<ushort> Add(Vector256<ushort> left, Vector256<ushort> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_add_epi32 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<int> Add(Vector256<int> left, Vector256<int> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_add_epi32 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<uint> Add(Vector256<uint> left, Vector256<uint> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_add_epi64 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<long> Add(Vector256<long> left, Vector256<long> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_add_epi64 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<ulong> Add(Vector256<ulong> left, Vector256<ulong> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_adds_epi8 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<sbyte> AddSaturate(Vector256<sbyte> left, Vector256<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_adds_epu8 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<byte> AddSaturate(Vector256<byte> left, Vector256<byte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_adds_epi16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<short> AddSaturate(Vector256<short> left, Vector256<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_adds_epu16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<ushort> AddSaturate(Vector256<ushort> left, Vector256<ushort> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_alignr_epi8 (__m256i a, __m256i b, const int count)
+ /// </summary>
+ public static Vector256<sbyte> AlignRight(Vector256<sbyte> left, Vector256<sbyte> right, byte mask) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_and_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<sbyte> And(Vector256<sbyte> left, Vector256<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_and_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<byte> And(Vector256<byte> left, Vector256<byte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_and_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<short> And(Vector256<short> left, Vector256<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_and_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<ushort> And(Vector256<ushort> left, Vector256<ushort> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_and_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<int> And(Vector256<int> left, Vector256<int> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_and_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<uint> And(Vector256<uint> left, Vector256<uint> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_and_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<long> And(Vector256<long> left, Vector256<long> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_and_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<ulong> And(Vector256<ulong> left, Vector256<ulong> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_andnot_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<sbyte> AndNot(Vector256<sbyte> left, Vector256<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_andnot_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<byte> AndNot(Vector256<byte> left, Vector256<byte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_andnot_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<short> AndNot(Vector256<short> left, Vector256<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_andnot_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<ushort> AndNot(Vector256<ushort> left, Vector256<ushort> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_andnot_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<int> AndNot(Vector256<int> left, Vector256<int> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_andnot_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<uint> AndNot(Vector256<uint> left, Vector256<uint> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_andnot_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<long> AndNot(Vector256<long> left, Vector256<long> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_andnot_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<ulong> AndNot(Vector256<ulong> left, Vector256<ulong> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_avg_epu8 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<byte> Average(Vector256<byte> left, Vector256<byte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_avg_epu16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<ushort> Average(Vector256<ushort> left, Vector256<ushort> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_blend_epi32 (__m128i a, __m128i b, const int imm8)
+ /// </summary>
+ public static Vector128<int> Blend(Vector128<int> left, Vector128<int> right, byte control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_blend_epi32 (__m128i a, __m128i b, const int imm8)
+ /// </summary>
+ public static Vector128<uint> Blend(Vector128<uint> left, Vector128<uint> right, byte control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_blend_epi16 (__m256i a, __m256i b, const int imm8)
+ /// </summary>
+ public static Vector256<short> Blend(Vector256<short> left, Vector256<short> right, byte control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_blend_epi16 (__m256i a, __m256i b, const int imm8)
+ /// </summary>
+ public static Vector256<ushort> Blend(Vector256<ushort> left, Vector256<ushort> right, byte control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_blend_epi32 (__m256i a, __m256i b, const int imm8)
+ /// </summary>
+ public static Vector256<int> Blend(Vector256<int> left, Vector256<int> right, byte control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_blend_epi32 (__m256i a, __m256i b, const int imm8)
+ /// </summary>
+ public static Vector256<uint> Blend(Vector256<uint> left, Vector256<uint> right, byte control) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_blendv_epi8 (__m256i a, __m256i b, __m256i mask)
+ /// </summary>
+ public static Vector256<sbyte> BlendVariable(Vector256<sbyte> left, Vector256<sbyte> right, Vector256<sbyte> mask) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_blendv_epi8 (__m256i a, __m256i b, __m256i mask)
+ /// </summary>
+ public static Vector256<byte> BlendVariable(Vector256<byte> left, Vector256<byte> right, Vector256<byte> mask) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_broadcastb_epi8 (__m128i a)
+ /// __m128i _mm_broadcastw_epi16 (__m128i a)
+ /// __m128i _mm_broadcastd_epi32 (__m128i a)
+ /// __m128i _mm_broadcastq_epi64 (__m128i a)
+ /// __m128 _mm_broadcastss_ps (__m128 a)
+ /// __m128d _mm_broadcastsd_pd (__m128d a)
+ /// </summary>
+ public static Vector128<T> BroadcastElementToVector128<T>(Vector128<T> value) where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_broadcastb_epi8 (__m128i a)
+ /// __m256i _mm256_broadcastw_epi16 (__m128i a)
+ /// __m256i _mm256_broadcastd_epi32 (__m128i a)
+ /// __m256i _mm256_broadcastq_epi64 (__m128i a)
+ /// __m256 _mm256_broadcastss_ps (__m128 a)
+ /// __m256d _mm256_broadcastsd_pd (__m128d a)
+ /// </summary>
+ public static Vector256<T> BroadcastElementToVector256<T>(Vector128<T> value) where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_broadcastsi128_si256 (__m128i a)
+ /// </summary>
+ public static unsafe Vector256<sbyte> BroadcastVector128ToVector256(sbyte* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_broadcastsi128_si256 (__m128i a)
+ /// </summary>
+ public static unsafe Vector256<byte> BroadcastVector128ToVector256(byte* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_broadcastsi128_si256 (__m128i a)
+ /// </summary>
+ public static unsafe Vector256<short> BroadcastVector128ToVector256(short* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_broadcastsi128_si256 (__m128i a)
+ /// </summary>
+ public static unsafe Vector256<ushort> BroadcastVector128ToVector256(ushort* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_broadcastsi128_si256 (__m128i a)
+ /// </summary>
+ public static unsafe Vector256<int> BroadcastVector128ToVector256(int* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_broadcastsi128_si256 (__m128i a)
+ /// </summary>
+ public static unsafe Vector256<uint> BroadcastVector128ToVector256(uint* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_broadcastsi128_si256 (__m128i a)
+ /// </summary>
+ public static unsafe Vector256<long> BroadcastVector128ToVector256(long* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_broadcastsi128_si256 (__m128i a)
+ /// </summary>
+ public static unsafe Vector256<ulong> BroadcastVector128ToVector256(ulong* address) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_cmpeq_epi8 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<sbyte> CompareEqual(Vector256<sbyte> left, Vector256<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_cmpeq_epi8 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<byte> CompareEqual(Vector256<byte> left, Vector256<byte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_cmpeq_epi16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<short> CompareEqual(Vector256<short> left, Vector256<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_cmpeq_epi16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<ushort> CompareEqual(Vector256<ushort> left, Vector256<ushort> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_cmpeq_epi32 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<int> CompareEqual(Vector256<int> left, Vector256<int> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_cmpeq_epi32 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<uint> CompareEqual(Vector256<uint> left, Vector256<uint> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_cmpeq_epi64 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<long> CompareEqual(Vector256<long> left, Vector256<long> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_cmpeq_epi64 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<ulong> CompareEqual(Vector256<ulong> left, Vector256<ulong> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_cmpgt_epi8 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<sbyte> CompareGreaterThan(Vector256<sbyte> left, Vector256<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_cmpgt_epi16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<short> CompareGreaterThan(Vector256<short> left, Vector256<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_cmpgt_epi32 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<int> CompareGreaterThan(Vector256<int> left, Vector256<int> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_cmpgt_epi64 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<long> CompareGreaterThan(Vector256<long> left, Vector256<long> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_cvtepi8_epi16 (__m128i a)
+ /// </summary>
+ public static Vector256<short> ConvertToVector256Short(Vector128<sbyte> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_cvtepu8_epi16 (__m128i a)
+ /// </summary>
+ public static Vector256<ushort> ConvertToVector256UShort(Vector128<byte> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_cvtepi8_epi32 (__m128i a)
+ /// </summary>
+ public static Vector256<int> ConvertToVector256Int(Vector128<sbyte> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_cvtepi16_epi32 (__m128i a)
+ /// </summary>
+ public static Vector256<int> ConvertToVector256Int(Vector128<short> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_cvtepu8_epi32 (__m128i a)
+ /// </summary>
+ public static Vector256<uint> ConvertToVector256UInt(Vector128<byte> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_cvtepu16_epi32 (__m128i a)
+ /// </summary>
+ public static Vector256<uint> ConvertToVector256UInt(Vector128<ushort> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_cvtepi8_epi64 (__m128i a)
+ /// </summary>
+ public static Vector256<long> ConvertToVector256Long(Vector128<sbyte> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_cvtepi16_epi64 (__m128i a)
+ /// </summary>
+ public static Vector256<long> ConvertToVector256Long(Vector128<short> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_cvtepi32_epi64 (__m128i a)
+ /// </summary>
+ public static Vector256<long> ConvertToVector256Long(Vector128<int> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_cvtepu8_epi64 (__m128i a)
+ /// </summary>
+ public static Vector256<ulong> ConvertToVector256ULong(Vector128<byte> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_cvtepu16_epi64 (__m128i a)
+ /// </summary>
+ public static Vector256<ulong> ConvertToVector256ULong(Vector128<ushort> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_cvtepu32_epi64 (__m128i a)
+ /// </summary>
+ public static Vector256<ulong> ConvertToVector256ULong(Vector128<uint> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector128<sbyte> ExtractVector128(Vector256<sbyte> value, byte index) { throw new PlatformNotSupportedException(); }
+ // <summary>
+ /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
+ /// </summary>
+ public static unsafe void ExtractVector128(sbyte* address, Vector256<sbyte> value, byte index) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector128<byte> ExtractVector128(Vector256<byte> value, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
+ /// </summary>
+ public static unsafe void ExtractVector128(byte* address, Vector256<byte> value, byte index) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector128<short> ExtractVector128(Vector256<short> value, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
+ /// </summary>
+ public static unsafe void ExtractVector128(short* address, Vector256<short> value, byte index) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector128<ushort> ExtractVector128(Vector256<ushort> value, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
+ /// </summary>
+ public static unsafe void ExtractVector128(ushort* address, Vector256<ushort> value, byte index) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector128<int> ExtractVector128(Vector256<int> value, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
+ /// </summary>
+ public static unsafe void ExtractVector128(int* address, Vector256<int> value, byte index) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector128<uint> ExtractVector128(Vector256<uint> value, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
+ /// </summary>
+ public static unsafe void ExtractVector128(uint* address, Vector256<uint> value, byte index) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector128<long> ExtractVector128(Vector256<long> value, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
+ /// </summary>
+ public static unsafe void ExtractVector128(long* address, Vector256<long> value, byte index) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector128<ulong> ExtractVector128(Vector256<ulong> value, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
+ /// </summary>
+ public static unsafe void ExtractVector128(ulong* address, Vector256<ulong> value, byte index) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_i32gather_epi32 (int const* base_addr, __m128i vindex, const int scale)
+ /// </summary>
+ public static unsafe Vector128<int> GatherVector128(int* baseAddress, Vector128<int> index, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_i32gather_epi32 (int const* base_addr, __m128i vindex, const int scale)
+ /// </summary>
+ public static unsafe Vector128<uint> GatherVector128(uint* baseAddress, Vector128<int> index, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_i32gather_epi64 (__int64 const* base_addr, __m128i vindex, const int scale)
+ /// </summary>
+ public static unsafe Vector128<long> GatherVector128(long* baseAddress, Vector128<int> index, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_i32gather_epi64 (__int64 const* base_addr, __m128i vindex, const int scale)
+ /// </summary>
+ public static unsafe Vector128<ulong> GatherVector128(ulong* baseAddress, Vector128<int> index, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128 _mm_i32gather_ps (float const* base_addr, __m128i vindex, const int scale)
+ /// </summary>
+ public static unsafe Vector128<float> GatherVector128(float* baseAddress, Vector128<int> index, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_i32gather_pd (double const* base_addr, __m128i vindex, const int scale)
+ /// </summary>
+ public static unsafe Vector128<double> GatherVector128(double* baseAddress, Vector128<int> index, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_i64gather_epi32 (int const* base_addr, __m128i vindex, const int scale)
+ /// </summary>
+ public static unsafe Vector128<int> GatherVector128(int* baseAddress, Vector128<long> index, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_i64gather_epi32 (int const* base_addr, __m128i vindex, const int scale)
+ /// </summary>
+ public static unsafe Vector128<uint> GatherVector128(uint* baseAddress, Vector128<long> index, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_i64gather_epi64 (__int64 const* base_addr, __m128i vindex, const int scale)
+ /// </summary>
+ public static unsafe Vector128<long> GatherVector128(long* baseAddress, Vector128<long> index, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_i64gather_epi64 (__int64 const* base_addr, __m128i vindex, const int scale)
+ /// </summary>
+ public static unsafe Vector128<ulong> GatherVector128(ulong* baseAddress, Vector128<long> index, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128 _mm_i64gather_ps (float const* base_addr, __m128i vindex, const int scale)
+ /// </summary>
+ public static unsafe Vector128<float> GatherVector128(float* baseAddress, Vector128<long> index, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_i64gather_pd (double const* base_addr, __m128i vindex, const int scale)
+ /// </summary>
+ public static unsafe Vector128<double> GatherVector128(double* baseAddress, Vector128<long> index, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_i32gather_epi32 (int const* base_addr, __m256i vindex, const int scale)
+ /// </summary>
+ public static unsafe Vector256<int> GatherVector256(int* baseAddress, Vector256<int> index, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_i32gather_epi32 (int const* base_addr, __m256i vindex, const int scale)
+ /// </summary>
+ public static unsafe Vector256<uint> GatherVector256(uint* baseAddress, Vector256<int> index, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_i32gather_epi64 (__int64 const* base_addr, __m128i vindex, const int scale)
+ /// </summary>
+ public static unsafe Vector256<long> GatherVector256(long* baseAddress, Vector128<int> index, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_i32gather_epi64 (__int64 const* base_addr, __m128i vindex, const int scale)
+ /// </summary>
+ public static unsafe Vector256<ulong> GatherVector256(ulong* baseAddress, Vector128<int> index, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256 _mm256_i32gather_ps (float const* base_addr, __m256i vindex, const int scale)
+ /// </summary>
+ public static unsafe Vector256<float> GatherVector256(float* baseAddress, Vector256<int> index, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_i32gather_pd (double const* base_addr, __m128i vindex, const int scale)
+ /// </summary>
+ public static unsafe Vector256<double> GatherVector256(double* baseAddress, Vector128<int> index, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm256_i64gather_epi32 (int const* base_addr, __m256i vindex, const int scale)
+ /// </summary>
+ public static unsafe Vector128<int> GatherVector128(int* baseAddress, Vector256<long> index, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm256_i64gather_epi32 (int const* base_addr, __m256i vindex, const int scale)
+ /// </summary>
+ public static unsafe Vector128<uint> GatherVector128(uint* baseAddress, Vector256<long> index, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_i64gather_epi64 (__int64 const* base_addr, __m256i vindex, const int scale)
+ /// </summary>
+ public static unsafe Vector256<long> GatherVector256(long* baseAddress, Vector256<long> index, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_i64gather_epi64 (__int64 const* base_addr, __m256i vindex, const int scale)
+ /// </summary>
+ public static unsafe Vector256<ulong> GatherVector256(ulong* baseAddress, Vector256<long> index, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128 _mm256_i64gather_ps (float const* base_addr, __m256i vindex, const int scale)
+ /// </summary>
+ public static unsafe Vector128<float> GatherVector128(float* baseAddress, Vector256<long> index, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_i64gather_pd (double const* base_addr, __m256i vindex, const int scale)
+ /// </summary>
+ public static unsafe Vector256<double> GatherVector256(double* baseAddress, Vector256<long> index, byte scale) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_mask_i32gather_epi32 (__m128i src, int const* base_addr, __m128i vindex, __m128i mask, const int scale)
+ /// </summary>
+ public static unsafe Vector128<int> GatherMaskVector128(Vector128<int> source, int* baseAddress, Vector128<int> index, Vector128<int> mask, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_mask_i32gather_epi32 (__m128i src, int const* base_addr, __m128i vindex, __m128i mask, const int scale)
+ /// </summary>
+ public static unsafe Vector128<uint> GatherMaskVector128(Vector128<uint> source, uint* baseAddress, Vector128<int> index, Vector128<uint> mask, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_mask_i32gather_epi64 (__m128i src, __int64 const* base_addr, __m128i vindex, __m128i mask, const int scale)
+ /// </summary>
+ public static unsafe Vector128<long> GatherMaskVector128(Vector128<long> source, long* baseAddress, Vector128<int> index, Vector128<long> mask, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_mask_i32gather_epi64 (__m128i src, __int64 const* base_addr, __m128i vindex, __m128i mask, const int scale)
+ /// </summary>
+ public static unsafe Vector128<ulong> GatherMaskVector128(Vector128<ulong> source, ulong* baseAddress, Vector128<int> index, Vector128<ulong> mask, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128 _mm_mask_i32gather_ps (__m128 src, float const* base_addr, __m128i vindex, __m128 mask, const int scale)
+ /// </summary>
+ public static unsafe Vector128<float> GatherMaskVector128(Vector128<float> source, float* baseAddress, Vector128<int> index, Vector128<float> mask, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_mask_i32gather_pd (__m128d src, double const* base_addr, __m128i vindex, __m128d mask, const int scale)
+ /// </summary>
+ public static unsafe Vector128<double> GatherMaskVector128(Vector128<double> source, double* baseAddress, Vector128<int> index, Vector128<double> mask, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_mask_i64gather_epi32 (__m128i src, int const* base_addr, __m128i vindex, __m128i mask, const int scale)
+ /// </summary>
+ public static unsafe Vector128<int> GatherMaskVector128(Vector128<int> source, int* baseAddress, Vector128<long> index, Vector128<int> mask, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_mask_i64gather_epi32 (__m128i src, int const* base_addr, __m128i vindex, __m128i mask, const int scale)
+ /// </summary>
+ public static unsafe Vector128<uint> GatherMaskVector128(Vector128<uint> source, uint* baseAddress, Vector128<long> index, Vector128<uint> mask, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_mask_i64gather_epi64 (__m128i src, __int64 const* base_addr, __m128i vindex, __m128i mask, const int scale)
+ /// </summary>
+ public static unsafe Vector128<long> GatherMaskVector128(Vector128<long> source, long* baseAddress, Vector128<long> index, Vector128<long> mask, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_mask_i64gather_epi64 (__m128i src, __int64 const* base_addr, __m128i vindex, __m128i mask, const int scale)
+ /// </summary>
+ public static unsafe Vector128<ulong> GatherMaskVector128(Vector128<ulong> source, ulong* baseAddress, Vector128<long> index, Vector128<ulong> mask, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128 _mm_mask_i64gather_ps (__m128 src, float const* base_addr, __m128i vindex, __m128 mask, const int scale)
+ /// </summary>
+ public static unsafe Vector128<float> GatherMaskVector128(Vector128<float> source, float* baseAddress, Vector128<long> index, Vector128<float> mask, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_mask_i64gather_pd (__m128d src, double const* base_addr, __m128i vindex, __m128d mask, const int scale)
+ /// </summary>
+ public static unsafe Vector128<double> GatherMaskVector128(Vector128<double> source, double* baseAddress, Vector128<long> index, Vector128<double> mask, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_mask_i32gather_epi32 (__m256i src, int const* base_addr, __m256i vindex, __m256i mask, const int scale)
+ /// </summary>
+ public static unsafe Vector256<int> GatherMaskVector256(Vector256<int> source, int* baseAddress, Vector256<int> index, Vector256<int> mask, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_mask_i32gather_epi32 (__m256i src, int const* base_addr, __m256i vindex, __m256i mask, const int scale)
+ /// </summary>
+ public static unsafe Vector256<uint> GatherMaskVector256(Vector256<uint> source, uint* baseAddress, Vector256<int> index, Vector256<uint> mask, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_mask_i32gather_epi64 (__m256i src, __int64 const* base_addr, __m128i vindex, __m256i mask, const int scale)
+ /// </summary>
+ public static unsafe Vector256<long> GatherMaskVector256(Vector256<long> source, long* baseAddress, Vector128<int> index, Vector256<long> mask, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_mask_i32gather_epi64 (__m256i src, __int64 const* base_addr, __m128i vindex, __m256i mask, const int scale)
+ /// </summary>
+ public static unsafe Vector256<ulong> GatherMaskVector256(Vector256<ulong> source, ulong* baseAddress, Vector128<int> index, Vector256<ulong> mask, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256 _mm256_mask_i32gather_ps (__m256 src, float const* base_addr, __m256i vindex, __m256 mask, const int scale)
+ /// </summary>
+ public static unsafe Vector256<float> GatherMaskVector256(Vector256<float> source, float* baseAddress, Vector256<int> index, Vector256<float> mask, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_mask_i32gather_pd (__m256d src, double const* base_addr, __m128i vindex, __m256d mask, const int scale)
+ /// </summary>
+ public static unsafe Vector256<double> GatherMaskVector256(Vector256<double> source, double* baseAddress, Vector128<int> index, Vector256<double> mask, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm256_mask_i64gather_epi32 (__m128i src, int const* base_addr, __m256i vindex, __m128i mask, const int scale)
+ /// </summary>
+ public static unsafe Vector128<int> GatherMaskVector128(Vector128<int> source, int* baseAddress, Vector256<long> index, Vector128<int> mask, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm256_mask_i64gather_epi32 (__m128i src, int const* base_addr, __m256i vindex, __m128i mask, const int scale)
+ /// </summary>
+ public static unsafe Vector128<uint> GatherMaskVector128(Vector128<uint> source, uint* baseAddress, Vector256<long> index, Vector128<uint> mask, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_mask_i64gather_epi64 (__m256i src, __int64 const* base_addr, __m256i vindex, __m256i mask, const int scale)
+ /// </summary>
+ public static unsafe Vector256<long> GatherMaskVector256(Vector256<long> source, long* baseAddress, Vector256<long> index, Vector256<long> mask, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_mask_i64gather_epi64 (__m256i src, __int64 const* base_addr, __m256i vindex, __m256i mask, const int scale)
+ /// </summary>
+ public static unsafe Vector256<ulong> GatherMaskVector256(Vector256<ulong> source, ulong* baseAddress, Vector256<long> index, Vector256<ulong> mask, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128 _mm256_mask_i64gather_ps (__m128 src, float const* base_addr, __m256i vindex, __m128 mask, const int scale)
+ /// </summary>
+ public static unsafe Vector128<float> GatherMaskVector128(Vector128<float> source, float* baseAddress, Vector256<long> index, Vector128<float> mask, byte scale) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_mask_i64gather_pd (__m256d src, double const* base_addr, __m256i vindex, __m256d mask, const int scale)
+ /// </summary>
+ public static unsafe Vector256<double> GatherMaskVector256(Vector256<double> source, double* baseAddress, Vector256<long> index, Vector256<double> mask, byte scale) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_hadd_epi16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<short> HorizontalAdd(Vector256<short> left, Vector256<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_hadd_epi32 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<int> HorizontalAdd(Vector256<int> left, Vector256<int> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_hadds_epi16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<short> HorizontalAddSaturate(Vector256<short> left, Vector256<short> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_hsub_epi16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<short> HorizontalSubtract(Vector256<short> left, Vector256<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_hsub_epi32 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<int> HorizontalSubtract(Vector256<int> left, Vector256<int> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_hsubs_epi16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<short> HorizontalSubtractSaturate(Vector256<short> left, Vector256<short> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
+ /// </summary>
+ public static Vector256<sbyte> Insert(Vector256<sbyte> value, Vector128<sbyte> data, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
+ /// </summary>
+ public static unsafe Vector256<sbyte> Insert(Vector256<sbyte> value, sbyte* address, byte index) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
+ /// </summary>
+ public static Vector256<byte> Insert(Vector256<byte> value, Vector128<byte> data, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
+ /// </summary>
+ public static unsafe Vector256<byte> Insert(Vector256<byte> value, byte* address, byte index) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
+ /// </summary>
+ public static Vector256<short> Insert(Vector256<short> value, Vector128<short> data, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
+ /// </summary>
+ public static unsafe Vector256<short> Insert(Vector256<short> value, short* address, byte index) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
+ /// </summary>
+ public static Vector256<ushort> Insert(Vector256<ushort> value, Vector128<ushort> data, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
+ /// </summary>
+ public static unsafe Vector256<ushort> Insert(Vector256<ushort> value, ushort* address, byte index) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
+ /// </summary>
+ public static Vector256<int> Insert(Vector256<int> value, Vector128<int> data, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
+ /// </summary>
+ public static unsafe Vector256<int> Insert(Vector256<int> value, int* address, byte index) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
+ /// </summary>
+ public static Vector256<uint> Insert(Vector256<uint> value, Vector128<uint> data, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
+ /// </summary>
+ public static unsafe Vector256<uint> Insert(Vector256<uint> value, uint* address, byte index) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
+ /// </summary>
+ public static Vector256<long> Insert(Vector256<long> value, Vector128<long> data, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
+ /// </summary>
+ public static unsafe Vector256<long> Insert(Vector256<long> value, long* address, byte index) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
+ /// </summary>
+ public static Vector256<ulong> Insert(Vector256<ulong> value, Vector128<ulong> data, byte index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
+ /// </summary>
+ public static unsafe Vector256<ulong> Insert(Vector256<ulong> value, ulong* address, byte index) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_maskload_epi32 (int const* mem_addr, __m128i mask)
+ /// </summary>
+ public static unsafe Vector128<int> MaskLoad(int* address, Vector128<int> mask) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_maskload_epi32 (int const* mem_addr, __m128i mask)
+ /// </summary>
+ public static unsafe Vector128<uint> MaskLoad(uint* address, Vector128<uint> mask) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_maskload_epi64 (__int64 const* mem_addr, __m128i mask)
+ /// </summary>
+ public static unsafe Vector128<long> MaskLoad(long* address, Vector128<long> mask) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_maskload_epi64 (__int64 const* mem_addr, __m128i mask)
+ /// </summary>
+ public static unsafe Vector128<ulong> MaskLoad(ulong* address, Vector128<ulong> mask) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_maskload_epi32 (int const* mem_addr, __m256i mask)
+ /// </summary>
+ public static unsafe Vector256<int> MaskLoad(int* address, Vector256<int> mask) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_maskload_epi32 (int const* mem_addr, __m256i mask)
+ /// </summary>
+ public static unsafe Vector256<uint> MaskLoad(uint* address, Vector256<uint> mask) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_maskload_epi64 (__int64 const* mem_addr, __m256i mask)
+ /// </summary>
+ public static unsafe Vector256<long> MaskLoad(long* address, Vector256<long> mask) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_maskload_epi64 (__int64 const* mem_addr, __m256i mask)
+ /// </summary>
+ public static unsafe Vector256<ulong> MaskLoad(ulong* address, Vector256<ulong> mask) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// void _mm_maskstore_epi32 (int* mem_addr, __m128i mask, __m128i a)
+ /// </summary>
+ public static unsafe void MaskStore(int* address, Vector128<int> mask, Vector128<int> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_maskstore_epi32 (int* mem_addr, __m128i mask, __m128i a)
+ /// </summary>
+ public static unsafe void MaskStore(uint* address, Vector128<uint> mask, Vector128<uint> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_maskstore_epi64 (__int64* mem_addr, __m128i mask, __m128i a)
+ /// </summary>
+ public static unsafe void MaskStore(long* address, Vector128<long> mask, Vector128<long> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_maskstore_epi64 (__int64* mem_addr, __m128i mask, __m128i a)
+ /// </summary>
+ public static unsafe void MaskStore(ulong* address, Vector128<ulong> mask, Vector128<ulong> source) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// void _mm256_maskstore_epi32 (int* mem_addr, __m256i mask, __m256i a)
+ /// </summary>
+ public static unsafe void MaskStore(int* address, Vector256<int> mask, Vector256<int> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_maskstore_epi32 (int* mem_addr, __m256i mask, __m256i a)
+ /// </summary>
+ public static unsafe void MaskStore(uint* address, Vector256<uint> mask, Vector256<uint> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_maskstore_epi64 (__int64* mem_addr, __m256i mask, __m256i a)
+ /// </summary>
+ public static unsafe void MaskStore(long* address, Vector256<long> mask, Vector256<long> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm256_maskstore_epi64 (__int64* mem_addr, __m256i mask, __m256i a)
+ /// </summary>
+ public static unsafe void MaskStore(ulong* address, Vector256<ulong> mask, Vector256<ulong> source) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_madd_epi16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<int> MultiplyAddAdjacent(Vector256<short> left, Vector256<short> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_maddubs_epi16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<short> MultiplyAddAdjacent(Vector256<byte> left, Vector256<sbyte> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_max_epi8 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<sbyte> Max(Vector256<sbyte> left, Vector256<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_max_epu8 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<byte> Max(Vector256<byte> left, Vector256<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_max_epi16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<short> Max(Vector256<short> left, Vector256<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_max_epu16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<ushort> Max(Vector256<ushort> left, Vector256<ushort> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_max_epi32 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<int> Max(Vector256<int> left, Vector256<int> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_max_epu32 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<uint> Max(Vector256<uint> left, Vector256<uint> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_min_epi8 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<sbyte> Min(Vector256<sbyte> left, Vector256<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_min_epu8 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<byte> Min(Vector256<byte> left, Vector256<byte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_min_epi16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<short> Min(Vector256<short> left, Vector256<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_min_epu16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<ushort> Min(Vector256<ushort> left, Vector256<ushort> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_min_epi32 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<int> Min(Vector256<int> left, Vector256<int> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_min_epu32 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<uint> Min(Vector256<uint> left, Vector256<uint> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm256_movemask_epi8 (__m256i a)
+ /// </summary>
+ public static int MoveMask(Vector256<sbyte> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// int _mm256_movemask_epi8 (__m256i a)
+ /// </summary>
+ public static int MoveMask(Vector256<byte> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_mpsadbw_epu8 (__m256i a, __m256i b, const int imm8)
+ /// </summary>
+ public static Vector256<ushort> MultipleSumAbsoluteDifferences(Vector256<byte> left, Vector256<byte> right, byte mask) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_mul_epi32 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<long> Multiply(Vector256<int> left, Vector256<int> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_mul_epu32 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<ulong> Multiply(Vector256<uint> left, Vector256<uint> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_mulhi_epi16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<short> MultiplyHigh(Vector256<short> left, Vector256<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_mulhi_epu16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<ushort> MultiplyHigh(Vector256<ushort> left, Vector256<ushort> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_mulhrs_epi16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<short> MultiplyHighRoundScale(Vector256<short> left, Vector256<short> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_mullo_epi16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<short> MultiplyLow(Vector256<short> left, Vector256<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_mullo_epu16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<int> MultiplyLow(Vector256<int> left, Vector256<int> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_or_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<sbyte> Or(Vector256<sbyte> left, Vector256<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_or_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<byte> Or(Vector256<byte> left, Vector256<byte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_or_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<short> Or(Vector256<short> left, Vector256<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_or_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<ushort> Or(Vector256<ushort> left, Vector256<ushort> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_or_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<int> Or(Vector256<int> left, Vector256<int> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_or_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<uint> Or(Vector256<uint> left, Vector256<uint> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_or_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<long> Or(Vector256<long> left, Vector256<long> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_or_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<ulong> Or(Vector256<ulong> left, Vector256<ulong> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_packs_epi16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<sbyte> PackSignedSaturate(Vector256<short> left, Vector256<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_packs_epi32 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<short> PackSignedSaturate(Vector256<int> left, Vector256<int> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_packus_epi16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<byte> PackUnsignedSaturate(Vector256<short> left, Vector256<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_packus_epi32 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<ushort> PackUnsignedSaturate(Vector256<int> left, Vector256<int> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_permute2x128_si256 (__m256i a, __m256i b, const int imm8)
+ /// </summary>
+ public static Vector256<sbyte> Permute2x128(Vector256<sbyte> left, Vector256<sbyte> right, byte control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_permute2x128_si256 (__m256i a, __m256i b, const int imm8)
+ /// </summary>
+ public static Vector256<byte> Permute2x128(Vector256<byte> left, Vector256<byte> right, byte control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_permute2x128_si256 (__m256i a, __m256i b, const int imm8)
+ /// </summary>
+ public static Vector256<short> Permute2x128(Vector256<short> left, Vector256<short> right, byte control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_permute2x128_si256 (__m256i a, __m256i b, const int imm8)
+ /// </summary>
+ public static Vector256<ushort> Permute2x128(Vector256<ushort> left, Vector256<ushort> right, byte control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_permute2x128_si256 (__m256i a, __m256i b, const int imm8)
+ /// </summary>
+ public static Vector256<int> Permute2x128(Vector256<int> left, Vector256<int> right, byte control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_permute2x128_si256 (__m256i a, __m256i b, const int imm8)
+ /// </summary>
+ public static Vector256<uint> Permute2x128(Vector256<uint> left, Vector256<uint> right, byte control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_permute2x128_si256 (__m256i a, __m256i b, const int imm8)
+ /// </summary>
+ public static Vector256<long> Permute2x128(Vector256<long> left, Vector256<long> right, byte control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_permute2x128_si256 (__m256i a, __m256i b, const int imm8)
+ /// </summary>
+ public static Vector256<ulong> Permute2x128(Vector256<ulong> left, Vector256<ulong> right, byte control) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_permute4x64_epi64 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector256<long> Permute4x64(Vector256<long> value, byte control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_permute4x64_epi64 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector256<ulong> Permute4x64(Vector256<ulong> value, byte control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_permute4x64_pd (__m256d a, const int imm8)
+ /// </summary>
+ public static Vector256<double> Permute4x64(Vector256<double> value, byte control) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_permutevar8x32_epi32 (__m256i a, __m256i idx)
+ /// </summary>
+ public static Vector256<int> PermuteVar8x32(Vector256<int> left, Vector256<int> mask) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_permutevar8x32_epi32 (__m256i a, __m256i idx)
+ /// </summary>
+ public static Vector256<uint> PermuteVar8x32(Vector256<uint> left, Vector256<uint> mask) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256 _mm256_permutevar8x32_ps (__m256 a, __m256i idx)
+ /// </summary>
+ public static Vector256<float> PermuteVar8x32(Vector256<float> left, Vector256<float> mask) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_slli_epi16 (__m256i a, int imm8)
+ /// </summary>
+ public static Vector256<short> ShiftLeftLogical(Vector256<short> value, byte count) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_slli_epi16 (__m256i a, int imm8)
+ /// </summary>
+ public static Vector256<ushort> ShiftLeftLogical(Vector256<ushort> value, byte count) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_slli_epi32 (__m256i a, int imm8)
+ /// </summary>
+ public static Vector256<int> ShiftLeftLogical(Vector256<int> value, byte count) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_slli_epi32 (__m256i a, int imm8)
+ /// </summary>
+ public static Vector256<uint> ShiftLeftLogical(Vector256<uint> value, byte count) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_slli_epi64 (__m256i a, int imm8)
+ /// </summary>
+ public static Vector256<long> ShiftLeftLogical(Vector256<long> value, byte count) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_slli_epi64 (__m256i a, int imm8)
+ /// </summary>
+ public static Vector256<ulong> ShiftLeftLogical(Vector256<ulong> value, byte count) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_bslli_epi128 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector256<sbyte> ShiftLeftLogical128BitLane(Vector256<sbyte> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_bslli_epi128 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector256<byte> ShiftLeftLogical128BitLane(Vector256<byte> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_bslli_epi128 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector256<short> ShiftLeftLogical128BitLane(Vector256<short> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_bslli_epi128 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector256<ushort> ShiftLeftLogical128BitLane(Vector256<ushort> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_bslli_epi128 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector256<int> ShiftLeftLogical128BitLane(Vector256<int> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_bslli_epi128 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector256<uint> ShiftLeftLogical128BitLane(Vector256<uint> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_bslli_epi128 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector256<long> ShiftLeftLogical128BitLane(Vector256<long> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_bslli_epi128 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector256<ulong> ShiftLeftLogical128BitLane(Vector256<ulong> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_sllv_epi32 (__m256i a, __m256i count)
+ /// </summary>
+ public static Vector256<int> ShiftLeftLogicalVariable(Vector256<int> value, Vector256<uint> count) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_sllv_epi32 (__m256i a, __m256i count)
+ /// </summary>
+ public static Vector256<uint> ShiftLeftLogicalVariable(Vector256<uint> value, Vector256<uint> count) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_sllv_epi64 (__m256i a, __m256i count)
+ /// </summary>
+ public static Vector256<long> ShiftLeftLogicalVariable(Vector256<long> value, Vector256<ulong> count) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_sllv_epi64 (__m256i a, __m256i count)
+ /// </summary>
+ public static Vector256<ulong> ShiftLeftLogicalVariable(Vector256<ulong> value, Vector256<ulong> count) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_srai_epi16 (__m256i a, int imm8)
+ /// </summary>
+ public static Vector256<short> ShiftRightArithmetic(Vector256<short> value, byte count) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_srai_epi32 (__m256i a, int imm8)
+ /// </summary>
+ public static Vector256<int> ShiftRightArithmetic(Vector256<int> value, byte count) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_srav_epi32 (__m256i a, __m256i count)
+ /// </summary>
+ public static Vector256<int> ShiftRightArithmeticVariable(Vector256<int> value, Vector256<uint> count) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_srli_epi16 (__m256i a, int imm8)
+ /// </summary>
+ public static Vector256<short> ShiftRightLogical(Vector256<short> value, byte count) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_srli_epi16 (__m256i a, int imm8)
+ /// </summary>
+ public static Vector256<ushort> ShiftRightLogical(Vector256<ushort> value, byte count) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_srli_epi32 (__m256i a, int imm8)
+ /// </summary>
+ public static Vector256<int> ShiftRightLogical(Vector256<int> value, byte count) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_srli_epi32 (__m256i a, int imm8)
+ /// </summary>
+ public static Vector256<uint> ShiftRightLogical(Vector256<uint> value, byte count) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_srli_epi64 (__m256i a, int imm8)
+ /// </summary>
+ public static Vector256<long> ShiftRightLogical(Vector256<long> value, byte count) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_srli_epi64 (__m256i a, int imm8)
+ /// </summary>
+ public static Vector256<ulong> ShiftRightLogical(Vector256<ulong> value, byte count) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_bsrli_epi128 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector256<sbyte> ShiftRightLogical128BitLane(Vector256<sbyte> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_bsrli_epi128 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector256<byte> ShiftRightLogical128BitLane(Vector256<byte> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_bsrli_epi128 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector256<short> ShiftRightLogical128BitLane(Vector256<short> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_bsrli_epi128 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector256<ushort> ShiftRightLogical128BitLane(Vector256<ushort> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_bsrli_epi128 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector256<int> ShiftRightLogical128BitLane(Vector256<int> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_bsrli_epi128 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector256<uint> ShiftRightLogical128BitLane(Vector256<uint> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_bsrli_epi128 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector256<long> ShiftRightLogical128BitLane(Vector256<long> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_bsrli_epi128 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector256<ulong> ShiftRightLogical128BitLane(Vector256<ulong> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_srlv_epi32 (__m256i a, __m256i count)
+ /// </summary>
+ public static Vector256<int> ShiftRightLogicalVariable(Vector256<int> value, Vector256<uint> count) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_srlv_epi32 (__m256i a, __m256i count)
+ /// </summary>
+ public static Vector256<uint> ShiftRightLogicalVariable(Vector256<uint> value, Vector256<uint> count) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_srlv_epi64 (__m256i a, __m256i count)
+ /// </summary>
+ public static Vector256<long> ShiftRightLogicalVariable(Vector256<long> value, Vector256<ulong> count) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_srlv_epi64 (__m256i a, __m256i count)
+ /// </summary>
+ public static Vector256<ulong> ShiftRightLogicalVariable(Vector256<ulong> value, Vector256<ulong> count) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_shuffle_epi8 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<sbyte> Shuffle(Vector256<sbyte> value, Vector256<sbyte> mask) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_shuffle_epi8 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<byte> Shuffle(Vector256<byte> value, Vector256<byte> mask) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_shuffle_epi32 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector256<int> Shuffle(Vector256<int> value, byte control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_shuffle_epi32 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector256<uint> Shuffle(Vector256<uint> value, byte control) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_shufflehi_epi16 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector256<short> ShuffleHigh(Vector256<short> value, byte control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_shufflehi_epi16 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector256<ushort> ShuffleHigh(Vector256<ushort> value, byte control) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_shufflelo_epi16 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector256<short> ShuffleLow(Vector256<short> value, byte control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_shufflelo_epi16 (__m256i a, const int imm8)
+ /// </summary>
+ public static Vector256<ushort> ShuffleLow(Vector256<ushort> value, byte control) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_sign_epi8 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<sbyte> Sign(Vector256<sbyte> left, Vector256<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_sign_epi16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<short> Sign(Vector256<short> left, Vector256<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_sign_epi32 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<int> Sign(Vector256<int> left, Vector256<int> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_sub_epi8 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<sbyte> Subtract(Vector256<sbyte> left, Vector256<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_sub_epi8 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<byte> Subtract(Vector256<byte> left, Vector256<byte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_sub_epi16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<short> Subtract(Vector256<short> left, Vector256<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_sub_epi16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<ushort> Subtract(Vector256<ushort> left, Vector256<ushort> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_sub_epi32 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<int> Subtract(Vector256<int> left, Vector256<int> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_sub_epi32 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<uint> Subtract(Vector256<uint> left, Vector256<uint> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_sub_epi64 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<long> Subtract(Vector256<long> left, Vector256<long> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_sub_epi64 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<ulong> Subtract(Vector256<ulong> left, Vector256<ulong> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_subs_epi8 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<sbyte> SubtractSaturate(Vector256<sbyte> left, Vector256<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_subs_epi16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<short> SubtractSaturate(Vector256<short> left, Vector256<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_subs_epu8 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<byte> SubtractSaturate(Vector256<byte> left, Vector256<byte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_subs_epu16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<ushort> SubtractSaturate(Vector256<ushort> left, Vector256<ushort> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_sad_epu8 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<ulong> SumAbsoluteDifferences(Vector256<byte> left, Vector256<byte> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_unpackhi_epi8 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<sbyte> UnpackHigh(Vector256<sbyte> left, Vector256<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_unpackhi_epi8 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<byte> UnpackHigh(Vector256<byte> left, Vector256<byte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_unpackhi_epi16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<short> UnpackHigh(Vector256<short> left, Vector256<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_unpackhi_epi16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<ushort> UnpackHigh(Vector256<ushort> left, Vector256<ushort> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_unpackhi_epi32 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<int> UnpackHigh(Vector256<int> left, Vector256<int> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_unpackhi_epi32 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<uint> UnpackHigh(Vector256<uint> left, Vector256<uint> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_unpackhi_epi64 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<long> UnpackHigh(Vector256<long> left, Vector256<long> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_unpackhi_epi64 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<ulong> UnpackHigh(Vector256<ulong> left, Vector256<ulong> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_unpacklo_epi8 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<sbyte> UnpackLow(Vector256<sbyte> left, Vector256<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_unpacklo_epi8 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<byte> UnpackLow(Vector256<byte> left, Vector256<byte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_unpacklo_epi16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<short> UnpackLow(Vector256<short> left, Vector256<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_unpacklo_epi16 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<ushort> UnpackLow(Vector256<ushort> left, Vector256<ushort> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_unpacklo_epi32 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<int> UnpackLow(Vector256<int> left, Vector256<int> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_unpacklo_epi32 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<uint> UnpackLow(Vector256<uint> left, Vector256<uint> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_unpacklo_epi64 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<long> UnpackLow(Vector256<long> left, Vector256<long> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_unpacklo_epi64 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<ulong> UnpackLow(Vector256<ulong> left, Vector256<ulong> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m256i _mm256_xor_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<sbyte> Xor(Vector256<sbyte> left, Vector256<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_xor_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<byte> Xor(Vector256<byte> left, Vector256<byte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_xor_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<short> Xor(Vector256<short> left, Vector256<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_xor_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<ushort> Xor(Vector256<ushort> left, Vector256<ushort> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_xor_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<int> Xor(Vector256<int> left, Vector256<int> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_xor_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<uint> Xor(Vector256<uint> left, Vector256<uint> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_xor_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<long> Xor(Vector256<long> left, Vector256<long> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256i _mm256_xor_si256 (__m256i a, __m256i b)
+ /// </summary>
+ public static Vector256<ulong> Xor(Vector256<ulong> left, Vector256<ulong> right) { throw new PlatformNotSupportedException(); }
+ }
+}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Avx2.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Avx2.cs
index cd652c26e2..f8ee1fdcb4 100644
--- a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Avx2.cs
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Avx2.cs
@@ -13,184 +13,184 @@ namespace System.Runtime.Intrinsics.X86
[CLSCompliant(false)]
public static class Avx2
{
- public static bool IsSupported { get { return false; } }
+ public static bool IsSupported { get => IsSupported; }
/// <summary>
/// __m256i _mm256_abs_epi8 (__m256i a)
/// </summary>
- public static Vector256<byte> Abs(Vector256<sbyte> value) { throw new NotImplementedException(); }
+ public static Vector256<byte> Abs(Vector256<sbyte> value) => Abs(value);
/// <summary>
/// __m256i _mm256_abs_epi16 (__m256i a)
/// </summary>
- public static Vector256<ushort> Abs(Vector256<short> value) { throw new NotImplementedException(); }
+ public static Vector256<ushort> Abs(Vector256<short> value) => Abs(value);
/// <summary>
/// __m256i _mm256_abs_epi32 (__m256i a)
/// </summary>
- public static Vector256<uint> Abs(Vector256<int> value) { throw new NotImplementedException(); }
+ public static Vector256<uint> Abs(Vector256<int> value) => Abs(value);
/// <summary>
/// __m256i _mm256_add_epi8 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<sbyte> Add(Vector256<sbyte> left, Vector256<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector256<sbyte> Add(Vector256<sbyte> left, Vector256<sbyte> right) => Add(left, right);
/// <summary>
/// __m256i _mm256_add_epi8 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<byte> Add(Vector256<byte> left, Vector256<byte> right) { throw new NotImplementedException(); }
+ public static Vector256<byte> Add(Vector256<byte> left, Vector256<byte> right) => Add(left, right);
/// <summary>
/// __m256i _mm256_add_epi16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<short> Add(Vector256<short> left, Vector256<short> right) { throw new NotImplementedException(); }
+ public static Vector256<short> Add(Vector256<short> left, Vector256<short> right) => Add(left, right);
/// <summary>
/// __m256i _mm256_add_epi16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<ushort> Add(Vector256<ushort> left, Vector256<ushort> right) { throw new NotImplementedException(); }
+ public static Vector256<ushort> Add(Vector256<ushort> left, Vector256<ushort> right) => Add(left, right);
/// <summary>
/// __m256i _mm256_add_epi32 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<int> Add(Vector256<int> left, Vector256<int> right) { throw new NotImplementedException(); }
+ public static Vector256<int> Add(Vector256<int> left, Vector256<int> right) => Add(left, right);
/// <summary>
/// __m256i _mm256_add_epi32 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<uint> Add(Vector256<uint> left, Vector256<uint> right) { throw new NotImplementedException(); }
+ public static Vector256<uint> Add(Vector256<uint> left, Vector256<uint> right) => Add(left, right);
/// <summary>
/// __m256i _mm256_add_epi64 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<long> Add(Vector256<long> left, Vector256<long> right) { throw new NotImplementedException(); }
+ public static Vector256<long> Add(Vector256<long> left, Vector256<long> right) => Add(left, right);
/// <summary>
/// __m256i _mm256_add_epi64 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<ulong> Add(Vector256<ulong> left, Vector256<ulong> right) { throw new NotImplementedException(); }
+ public static Vector256<ulong> Add(Vector256<ulong> left, Vector256<ulong> right) => Add(left, right);
/// <summary>
/// __m256i _mm256_adds_epi8 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<sbyte> AddSaturate(Vector256<sbyte> left, Vector256<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector256<sbyte> AddSaturate(Vector256<sbyte> left, Vector256<sbyte> right) => AddSaturate(left, right);
/// <summary>
/// __m256i _mm256_adds_epu8 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<byte> AddSaturate(Vector256<byte> left, Vector256<byte> right) { throw new NotImplementedException(); }
+ public static Vector256<byte> AddSaturate(Vector256<byte> left, Vector256<byte> right) => AddSaturate(left, right);
/// <summary>
/// __m256i _mm256_adds_epi16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<short> AddSaturate(Vector256<short> left, Vector256<short> right) { throw new NotImplementedException(); }
+ public static Vector256<short> AddSaturate(Vector256<short> left, Vector256<short> right) => AddSaturate(left, right);
/// <summary>
/// __m256i _mm256_adds_epu16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<ushort> AddSaturate(Vector256<ushort> left, Vector256<ushort> right) { throw new NotImplementedException(); }
+ public static Vector256<ushort> AddSaturate(Vector256<ushort> left, Vector256<ushort> right) => AddSaturate(left, right);
/// <summary>
/// __m256i _mm256_alignr_epi8 (__m256i a, __m256i b, const int count)
/// </summary>
- public static Vector256<sbyte> AlignRight(Vector256<sbyte> left, Vector256<sbyte> right, byte mask) { throw new NotImplementedException(); }
+ public static Vector256<sbyte> AlignRight(Vector256<sbyte> left, Vector256<sbyte> right, byte mask) => AlignRight(left, right, mask);
/// <summary>
/// __m256i _mm256_and_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<sbyte> And(Vector256<sbyte> left, Vector256<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector256<sbyte> And(Vector256<sbyte> left, Vector256<sbyte> right) => And(left, right);
/// <summary>
/// __m256i _mm256_and_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<byte> And(Vector256<byte> left, Vector256<byte> right) { throw new NotImplementedException(); }
+ public static Vector256<byte> And(Vector256<byte> left, Vector256<byte> right) => And(left, right);
/// <summary>
/// __m256i _mm256_and_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<short> And(Vector256<short> left, Vector256<short> right) { throw new NotImplementedException(); }
+ public static Vector256<short> And(Vector256<short> left, Vector256<short> right) => And(left, right);
/// <summary>
/// __m256i _mm256_and_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<ushort> And(Vector256<ushort> left, Vector256<ushort> right) { throw new NotImplementedException(); }
+ public static Vector256<ushort> And(Vector256<ushort> left, Vector256<ushort> right) => And(left, right);
/// <summary>
/// __m256i _mm256_and_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<int> And(Vector256<int> left, Vector256<int> right) { throw new NotImplementedException(); }
+ public static Vector256<int> And(Vector256<int> left, Vector256<int> right) => And(left, right);
/// <summary>
/// __m256i _mm256_and_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<uint> And(Vector256<uint> left, Vector256<uint> right) { throw new NotImplementedException(); }
+ public static Vector256<uint> And(Vector256<uint> left, Vector256<uint> right) => And(left, right);
/// <summary>
/// __m256i _mm256_and_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<long> And(Vector256<long> left, Vector256<long> right) { throw new NotImplementedException(); }
+ public static Vector256<long> And(Vector256<long> left, Vector256<long> right) => And(left, right);
/// <summary>
/// __m256i _mm256_and_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<ulong> And(Vector256<ulong> left, Vector256<ulong> right) { throw new NotImplementedException(); }
+ public static Vector256<ulong> And(Vector256<ulong> left, Vector256<ulong> right) => And(left, right);
/// <summary>
/// __m256i _mm256_andnot_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<sbyte> AndNot(Vector256<sbyte> left, Vector256<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector256<sbyte> AndNot(Vector256<sbyte> left, Vector256<sbyte> right) => AndNot(left, right);
/// <summary>
/// __m256i _mm256_andnot_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<byte> AndNot(Vector256<byte> left, Vector256<byte> right) { throw new NotImplementedException(); }
+ public static Vector256<byte> AndNot(Vector256<byte> left, Vector256<byte> right) => AndNot(left, right);
/// <summary>
/// __m256i _mm256_andnot_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<short> AndNot(Vector256<short> left, Vector256<short> right) { throw new NotImplementedException(); }
+ public static Vector256<short> AndNot(Vector256<short> left, Vector256<short> right) => AndNot(left, right);
/// <summary>
/// __m256i _mm256_andnot_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<ushort> AndNot(Vector256<ushort> left, Vector256<ushort> right) { throw new NotImplementedException(); }
+ public static Vector256<ushort> AndNot(Vector256<ushort> left, Vector256<ushort> right) => AndNot(left, right);
/// <summary>
/// __m256i _mm256_andnot_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<int> AndNot(Vector256<int> left, Vector256<int> right) { throw new NotImplementedException(); }
+ public static Vector256<int> AndNot(Vector256<int> left, Vector256<int> right) => AndNot(left, right);
/// <summary>
/// __m256i _mm256_andnot_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<uint> AndNot(Vector256<uint> left, Vector256<uint> right) { throw new NotImplementedException(); }
+ public static Vector256<uint> AndNot(Vector256<uint> left, Vector256<uint> right) => AndNot(left, right);
/// <summary>
/// __m256i _mm256_andnot_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<long> AndNot(Vector256<long> left, Vector256<long> right) { throw new NotImplementedException(); }
+ public static Vector256<long> AndNot(Vector256<long> left, Vector256<long> right) => AndNot(left, right);
/// <summary>
/// __m256i _mm256_andnot_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<ulong> AndNot(Vector256<ulong> left, Vector256<ulong> right) { throw new NotImplementedException(); }
+ public static Vector256<ulong> AndNot(Vector256<ulong> left, Vector256<ulong> right) => AndNot(left, right);
/// <summary>
/// __m256i _mm256_avg_epu8 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<byte> Average(Vector256<byte> left, Vector256<byte> right) { throw new NotImplementedException(); }
+ public static Vector256<byte> Average(Vector256<byte> left, Vector256<byte> right) => Average(left, right);
/// <summary>
/// __m256i _mm256_avg_epu16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<ushort> Average(Vector256<ushort> left, Vector256<ushort> right) { throw new NotImplementedException(); }
+ public static Vector256<ushort> Average(Vector256<ushort> left, Vector256<ushort> right) => Average(left, right);
/// <summary>
/// __m128i _mm_blend_epi32 (__m128i a, __m128i b, const int imm8)
/// </summary>
- public static Vector128<int> Blend(Vector128<int> left, Vector128<int> right, byte control) { throw new NotImplementedException(); }
+ public static Vector128<int> Blend(Vector128<int> left, Vector128<int> right, byte control) => Blend(left, right, control);
/// <summary>
/// __m128i _mm_blend_epi32 (__m128i a, __m128i b, const int imm8)
/// </summary>
- public static Vector128<uint> Blend(Vector128<uint> left, Vector128<uint> right, byte control) { throw new NotImplementedException(); }
+ public static Vector128<uint> Blend(Vector128<uint> left, Vector128<uint> right, byte control) => Blend(left, right, control);
/// <summary>
/// __m256i _mm256_blend_epi16 (__m256i a, __m256i b, const int imm8)
/// </summary>
- public static Vector256<short> Blend(Vector256<short> left, Vector256<short> right, byte control) { throw new NotImplementedException(); }
+ public static Vector256<short> Blend(Vector256<short> left, Vector256<short> right, byte control) => Blend(left, right, control);
/// <summary>
/// __m256i _mm256_blend_epi16 (__m256i a, __m256i b, const int imm8)
/// </summary>
- public static Vector256<ushort> Blend(Vector256<ushort> left, Vector256<ushort> right, byte control) { throw new NotImplementedException(); }
+ public static Vector256<ushort> Blend(Vector256<ushort> left, Vector256<ushort> right, byte control) => Blend(left, right, control);
/// <summary>
/// __m256i _mm256_blend_epi32 (__m256i a, __m256i b, const int imm8)
/// </summary>
- public static Vector256<int> Blend(Vector256<int> left, Vector256<int> right, byte control) { throw new NotImplementedException(); }
+ public static Vector256<int> Blend(Vector256<int> left, Vector256<int> right, byte control) => Blend(left, right, control);
/// <summary>
/// __m256i _mm256_blend_epi32 (__m256i a, __m256i b, const int imm8)
/// </summary>
- public static Vector256<uint> Blend(Vector256<uint> left, Vector256<uint> right, byte control) { throw new NotImplementedException(); }
+ public static Vector256<uint> Blend(Vector256<uint> left, Vector256<uint> right, byte control) => Blend(left, right, control);
/// <summary>
/// __m256i _mm256_blendv_epi8 (__m256i a, __m256i b, __m256i mask)
/// </summary>
- public static Vector256<sbyte> BlendVariable(Vector256<sbyte> left, Vector256<sbyte> right, Vector256<sbyte> mask) { throw new NotImplementedException(); }
+ public static Vector256<sbyte> BlendVariable(Vector256<sbyte> left, Vector256<sbyte> right, Vector256<sbyte> mask) => BlendVariable(left, right, mask);
/// <summary>
/// __m256i _mm256_blendv_epi8 (__m256i a, __m256i b, __m256i mask)
/// </summary>
- public static Vector256<byte> BlendVariable(Vector256<byte> left, Vector256<byte> right, Vector256<byte> mask) { throw new NotImplementedException(); }
+ public static Vector256<byte> BlendVariable(Vector256<byte> left, Vector256<byte> right, Vector256<byte> mask) => BlendVariable(left, right, mask);
/// <summary>
/// __m128i _mm_broadcastb_epi8 (__m128i a)
@@ -200,7 +200,7 @@ namespace System.Runtime.Intrinsics.X86
/// __m128 _mm_broadcastss_ps (__m128 a)
/// __m128d _mm_broadcastsd_pd (__m128d a)
/// </summary>
- public static Vector128<T> BroadcastElementToVector128<T>(Vector128<T> value) where T : struct { throw new NotImplementedException(); }
+ public static Vector128<T> BroadcastElementToVector128<T>(Vector128<T> value) where T : struct => BroadcastElementToVector128<T>(value);
/// <summary>
/// __m256i _mm256_broadcastb_epi8 (__m128i a)
@@ -210,1153 +210,1153 @@ namespace System.Runtime.Intrinsics.X86
/// __m256 _mm256_broadcastss_ps (__m128 a)
/// __m256d _mm256_broadcastsd_pd (__m128d a)
/// </summary>
- public static Vector256<T> BroadcastElementToVector256<T>(Vector128<T> value) where T : struct { throw new NotImplementedException(); }
+ public static Vector256<T> BroadcastElementToVector256<T>(Vector128<T> value) where T : struct => BroadcastElementToVector256<T>(value);
/// <summary>
/// __m256i _mm256_broadcastsi128_si256 (__m128i a)
/// </summary>
- public static unsafe Vector256<sbyte> BroadcastVector128ToVector256(sbyte* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<sbyte> BroadcastVector128ToVector256(sbyte* address) => BroadcastVector128ToVector256(address);
/// <summary>
/// __m256i _mm256_broadcastsi128_si256 (__m128i a)
/// </summary>
- public static unsafe Vector256<byte> BroadcastVector128ToVector256(byte* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<byte> BroadcastVector128ToVector256(byte* address) => BroadcastVector128ToVector256(address);
/// <summary>
/// __m256i _mm256_broadcastsi128_si256 (__m128i a)
/// </summary>
- public static unsafe Vector256<short> BroadcastVector128ToVector256(short* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<short> BroadcastVector128ToVector256(short* address) => BroadcastVector128ToVector256(address);
/// <summary>
/// __m256i _mm256_broadcastsi128_si256 (__m128i a)
/// </summary>
- public static unsafe Vector256<ushort> BroadcastVector128ToVector256(ushort* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<ushort> BroadcastVector128ToVector256(ushort* address) => BroadcastVector128ToVector256(address);
/// <summary>
/// __m256i _mm256_broadcastsi128_si256 (__m128i a)
/// </summary>
- public static unsafe Vector256<int> BroadcastVector128ToVector256(int* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<int> BroadcastVector128ToVector256(int* address) => BroadcastVector128ToVector256(address);
/// <summary>
/// __m256i _mm256_broadcastsi128_si256 (__m128i a)
/// </summary>
- public static unsafe Vector256<uint> BroadcastVector128ToVector256(uint* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<uint> BroadcastVector128ToVector256(uint* address) => BroadcastVector128ToVector256(address);
/// <summary>
/// __m256i _mm256_broadcastsi128_si256 (__m128i a)
/// </summary>
- public static unsafe Vector256<long> BroadcastVector128ToVector256(long* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<long> BroadcastVector128ToVector256(long* address) => BroadcastVector128ToVector256(address);
/// <summary>
/// __m256i _mm256_broadcastsi128_si256 (__m128i a)
/// </summary>
- public static unsafe Vector256<ulong> BroadcastVector128ToVector256(ulong* address) { throw new NotImplementedException(); }
+ public static unsafe Vector256<ulong> BroadcastVector128ToVector256(ulong* address) => BroadcastVector128ToVector256(address);
/// <summary>
/// __m256i _mm256_cmpeq_epi8 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<sbyte> CompareEqual(Vector256<sbyte> left, Vector256<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector256<sbyte> CompareEqual(Vector256<sbyte> left, Vector256<sbyte> right) => CompareEqual(left, right);
/// <summary>
/// __m256i _mm256_cmpeq_epi8 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<byte> CompareEqual(Vector256<byte> left, Vector256<byte> right) { throw new NotImplementedException(); }
+ public static Vector256<byte> CompareEqual(Vector256<byte> left, Vector256<byte> right) => CompareEqual(left, right);
/// <summary>
/// __m256i _mm256_cmpeq_epi16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<short> CompareEqual(Vector256<short> left, Vector256<short> right) { throw new NotImplementedException(); }
+ public static Vector256<short> CompareEqual(Vector256<short> left, Vector256<short> right) => CompareEqual(left, right);
/// <summary>
/// __m256i _mm256_cmpeq_epi16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<ushort> CompareEqual(Vector256<ushort> left, Vector256<ushort> right) { throw new NotImplementedException(); }
+ public static Vector256<ushort> CompareEqual(Vector256<ushort> left, Vector256<ushort> right) => CompareEqual(left, right);
/// <summary>
/// __m256i _mm256_cmpeq_epi32 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<int> CompareEqual(Vector256<int> left, Vector256<int> right) { throw new NotImplementedException(); }
+ public static Vector256<int> CompareEqual(Vector256<int> left, Vector256<int> right) => CompareEqual(left, right);
/// <summary>
/// __m256i _mm256_cmpeq_epi32 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<uint> CompareEqual(Vector256<uint> left, Vector256<uint> right) { throw new NotImplementedException(); }
+ public static Vector256<uint> CompareEqual(Vector256<uint> left, Vector256<uint> right) => CompareEqual(left, right);
/// <summary>
/// __m256i _mm256_cmpeq_epi64 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<long> CompareEqual(Vector256<long> left, Vector256<long> right) { throw new NotImplementedException(); }
+ public static Vector256<long> CompareEqual(Vector256<long> left, Vector256<long> right) => CompareEqual(left, right);
/// <summary>
/// __m256i _mm256_cmpeq_epi64 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<ulong> CompareEqual(Vector256<ulong> left, Vector256<ulong> right) { throw new NotImplementedException(); }
+ public static Vector256<ulong> CompareEqual(Vector256<ulong> left, Vector256<ulong> right) => CompareEqual(left, right);
/// <summary>
/// __m256i _mm256_cmpgt_epi8 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<sbyte> CompareGreaterThan(Vector256<sbyte> left, Vector256<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector256<sbyte> CompareGreaterThan(Vector256<sbyte> left, Vector256<sbyte> right) => CompareGreaterThan(left, right);
/// <summary>
/// __m256i _mm256_cmpgt_epi16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<short> CompareGreaterThan(Vector256<short> left, Vector256<short> right) { throw new NotImplementedException(); }
+ public static Vector256<short> CompareGreaterThan(Vector256<short> left, Vector256<short> right) => CompareGreaterThan(left, right);
/// <summary>
/// __m256i _mm256_cmpgt_epi32 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<int> CompareGreaterThan(Vector256<int> left, Vector256<int> right) { throw new NotImplementedException(); }
+ public static Vector256<int> CompareGreaterThan(Vector256<int> left, Vector256<int> right) => CompareGreaterThan(left, right);
/// <summary>
/// __m256i _mm256_cmpgt_epi64 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<long> CompareGreaterThan(Vector256<long> left, Vector256<long> right) { throw new NotImplementedException(); }
+ public static Vector256<long> CompareGreaterThan(Vector256<long> left, Vector256<long> right) => CompareGreaterThan(left, right);
/// <summary>
/// __m256i _mm256_cvtepi8_epi16 (__m128i a)
/// </summary>
- public static Vector256<short> ConvertToVector256Short(Vector128<sbyte> value) { throw new NotImplementedException(); }
+ public static Vector256<short> ConvertToVector256Short(Vector128<sbyte> value) => ConvertToVector256Short(value);
/// <summary>
/// __m256i _mm256_cvtepu8_epi16 (__m128i a)
/// </summary>
- public static Vector256<ushort> ConvertToVector256UShort(Vector128<byte> value) { throw new NotImplementedException(); }
+ public static Vector256<ushort> ConvertToVector256UShort(Vector128<byte> value) => ConvertToVector256UShort(value);
/// <summary>
/// __m256i _mm256_cvtepi8_epi32 (__m128i a)
/// </summary>
- public static Vector256<int> ConvertToVector256Int(Vector128<sbyte> value) { throw new NotImplementedException(); }
+ public static Vector256<int> ConvertToVector256Int(Vector128<sbyte> value) => ConvertToVector256Int(value);
/// <summary>
/// __m256i _mm256_cvtepi16_epi32 (__m128i a)
/// </summary>
- public static Vector256<int> ConvertToVector256Int(Vector128<short> value) { throw new NotImplementedException(); }
+ public static Vector256<int> ConvertToVector256Int(Vector128<short> value) => ConvertToVector256Int(value);
/// <summary>
/// __m256i _mm256_cvtepu8_epi32 (__m128i a)
/// </summary>
- public static Vector256<uint> ConvertToVector256UInt(Vector128<byte> value) { throw new NotImplementedException(); }
+ public static Vector256<uint> ConvertToVector256UInt(Vector128<byte> value) => ConvertToVector256UInt(value);
/// <summary>
/// __m256i _mm256_cvtepu16_epi32 (__m128i a)
/// </summary>
- public static Vector256<uint> ConvertToVector256UInt(Vector128<ushort> value) { throw new NotImplementedException(); }
+ public static Vector256<uint> ConvertToVector256UInt(Vector128<ushort> value) => ConvertToVector256UInt(value);
/// <summary>
/// __m256i _mm256_cvtepi8_epi64 (__m128i a)
/// </summary>
- public static Vector256<long> ConvertToVector256Long(Vector128<sbyte> value) { throw new NotImplementedException(); }
+ public static Vector256<long> ConvertToVector256Long(Vector128<sbyte> value) => ConvertToVector256Long(value);
/// <summary>
/// __m256i _mm256_cvtepi16_epi64 (__m128i a)
/// </summary>
- public static Vector256<long> ConvertToVector256Long(Vector128<short> value) { throw new NotImplementedException(); }
+ public static Vector256<long> ConvertToVector256Long(Vector128<short> value) => ConvertToVector256Long(value);
/// <summary>
/// __m256i _mm256_cvtepi32_epi64 (__m128i a)
/// </summary>
- public static Vector256<long> ConvertToVector256Long(Vector128<int> value) { throw new NotImplementedException(); }
+ public static Vector256<long> ConvertToVector256Long(Vector128<int> value) => ConvertToVector256Long(value);
/// <summary>
/// __m256i _mm256_cvtepu8_epi64 (__m128i a)
/// </summary>
- public static Vector256<ulong> ConvertToVector256ULong(Vector128<byte> value) { throw new NotImplementedException(); }
+ public static Vector256<ulong> ConvertToVector256ULong(Vector128<byte> value) => ConvertToVector256ULong(value);
/// <summary>
/// __m256i _mm256_cvtepu16_epi64 (__m128i a)
/// </summary>
- public static Vector256<ulong> ConvertToVector256ULong(Vector128<ushort> value) { throw new NotImplementedException(); }
+ public static Vector256<ulong> ConvertToVector256ULong(Vector128<ushort> value) => ConvertToVector256ULong(value);
/// <summary>
/// __m256i _mm256_cvtepu32_epi64 (__m128i a)
/// </summary>
- public static Vector256<ulong> ConvertToVector256ULong(Vector128<uint> value) { throw new NotImplementedException(); }
+ public static Vector256<ulong> ConvertToVector256ULong(Vector128<uint> value) => ConvertToVector256ULong(value);
/// <summary>
/// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
/// </summary>
- public static Vector128<sbyte> ExtractVector128(Vector256<sbyte> value, byte index) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> ExtractVector128(Vector256<sbyte> value, byte index) => ExtractVector128(value, index);
// <summary>
/// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
/// </summary>
- public static unsafe void ExtractVector128(sbyte* address, Vector256<sbyte> value, byte index) { throw new NotImplementedException(); }
+ public static unsafe void ExtractVector128(sbyte* address, Vector256<sbyte> value, byte index) => ExtractVector128(address, value, index);
/// <summary>
/// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
/// </summary>
- public static Vector128<byte> ExtractVector128(Vector256<byte> value, byte index) { throw new NotImplementedException(); }
+ public static Vector128<byte> ExtractVector128(Vector256<byte> value, byte index) => ExtractVector128(value, index);
/// <summary>
/// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
/// </summary>
- public static unsafe void ExtractVector128(byte* address, Vector256<byte> value, byte index) { throw new NotImplementedException(); }
+ public static unsafe void ExtractVector128(byte* address, Vector256<byte> value, byte index) => ExtractVector128(address, value, index);
/// <summary>
/// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
/// </summary>
- public static Vector128<short> ExtractVector128(Vector256<short> value, byte index) { throw new NotImplementedException(); }
+ public static Vector128<short> ExtractVector128(Vector256<short> value, byte index) => ExtractVector128(value, index);
/// <summary>
/// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
/// </summary>
- public static unsafe void ExtractVector128(short* address, Vector256<short> value, byte index) { throw new NotImplementedException(); }
+ public static unsafe void ExtractVector128(short* address, Vector256<short> value, byte index) => ExtractVector128(address, value, index);
/// <summary>
/// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
/// </summary>
- public static Vector128<ushort> ExtractVector128(Vector256<ushort> value, byte index) { throw new NotImplementedException(); }
+ public static Vector128<ushort> ExtractVector128(Vector256<ushort> value, byte index) => ExtractVector128(value, index);
/// <summary>
/// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
/// </summary>
- public static unsafe void ExtractVector128(ushort* address, Vector256<ushort> value, byte index) { throw new NotImplementedException(); }
+ public static unsafe void ExtractVector128(ushort* address, Vector256<ushort> value, byte index) => ExtractVector128(address, value, index);
/// <summary>
/// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
/// </summary>
- public static Vector128<int> ExtractVector128(Vector256<int> value, byte index) { throw new NotImplementedException(); }
+ public static Vector128<int> ExtractVector128(Vector256<int> value, byte index) => ExtractVector128(value, index);
/// <summary>
/// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
/// </summary>
- public static unsafe void ExtractVector128(int* address, Vector256<int> value, byte index) { throw new NotImplementedException(); }
+ public static unsafe void ExtractVector128(int* address, Vector256<int> value, byte index) => ExtractVector128(address, value, index);
/// <summary>
/// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
/// </summary>
- public static Vector128<uint> ExtractVector128(Vector256<uint> value, byte index) { throw new NotImplementedException(); }
+ public static Vector128<uint> ExtractVector128(Vector256<uint> value, byte index) => ExtractVector128(value, index);
/// <summary>
/// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
/// </summary>
- public static unsafe void ExtractVector128(uint* address, Vector256<uint> value, byte index) { throw new NotImplementedException(); }
+ public static unsafe void ExtractVector128(uint* address, Vector256<uint> value, byte index) => ExtractVector128(address, value, index);
/// <summary>
/// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
/// </summary>
- public static Vector128<long> ExtractVector128(Vector256<long> value, byte index) { throw new NotImplementedException(); }
+ public static Vector128<long> ExtractVector128(Vector256<long> value, byte index) => ExtractVector128(value, index);
/// <summary>
/// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
/// </summary>
- public static unsafe void ExtractVector128(long* address, Vector256<long> value, byte index) { throw new NotImplementedException(); }
+ public static unsafe void ExtractVector128(long* address, Vector256<long> value, byte index) => ExtractVector128(address, value, index);
/// <summary>
/// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
/// </summary>
- public static Vector128<ulong> ExtractVector128(Vector256<ulong> value, byte index) { throw new NotImplementedException(); }
+ public static Vector128<ulong> ExtractVector128(Vector256<ulong> value, byte index) => ExtractVector128(value, index);
/// <summary>
/// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8)
/// </summary>
- public static unsafe void ExtractVector128(ulong* address, Vector256<ulong> value, byte index) { throw new NotImplementedException(); }
+ public static unsafe void ExtractVector128(ulong* address, Vector256<ulong> value, byte index) => ExtractVector128(address, value, index);
/// <summary>
/// __m128i _mm_i32gather_epi32 (int const* base_addr, __m128i vindex, const int scale)
/// </summary>
- public static unsafe Vector128<int> GatherVector128(int* baseAddress, Vector128<int> index, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<int> GatherVector128(int* baseAddress, Vector128<int> index, byte scale) => GatherVector128(baseAddress, index, scale);
/// <summary>
/// __m128i _mm_i32gather_epi32 (int const* base_addr, __m128i vindex, const int scale)
/// </summary>
- public static unsafe Vector128<uint> GatherVector128(uint* baseAddress, Vector128<int> index, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<uint> GatherVector128(uint* baseAddress, Vector128<int> index, byte scale) => GatherVector128(baseAddress, index, scale);
/// <summary>
/// __m128i _mm_i32gather_epi64 (__int64 const* base_addr, __m128i vindex, const int scale)
/// </summary>
- public static unsafe Vector128<long> GatherVector128(long* baseAddress, Vector128<int> index, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<long> GatherVector128(long* baseAddress, Vector128<int> index, byte scale) => GatherVector128(baseAddress, index, scale);
/// <summary>
/// __m128i _mm_i32gather_epi64 (__int64 const* base_addr, __m128i vindex, const int scale)
/// </summary>
- public static unsafe Vector128<ulong> GatherVector128(ulong* baseAddress, Vector128<int> index, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<ulong> GatherVector128(ulong* baseAddress, Vector128<int> index, byte scale) => GatherVector128(baseAddress, index, scale);
/// <summary>
/// __m128 _mm_i32gather_ps (float const* base_addr, __m128i vindex, const int scale)
/// </summary>
- public static unsafe Vector128<float> GatherVector128(float* baseAddress, Vector128<int> index, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<float> GatherVector128(float* baseAddress, Vector128<int> index, byte scale) => GatherVector128(baseAddress, index, scale);
/// <summary>
/// __m128d _mm_i32gather_pd (double const* base_addr, __m128i vindex, const int scale)
/// </summary>
- public static unsafe Vector128<double> GatherVector128(double* baseAddress, Vector128<int> index, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<double> GatherVector128(double* baseAddress, Vector128<int> index, byte scale) => GatherVector128(baseAddress, index, scale);
/// <summary>
/// __m128i _mm_i64gather_epi32 (int const* base_addr, __m128i vindex, const int scale)
/// </summary>
- public static unsafe Vector128<int> GatherVector128(int* baseAddress, Vector128<long> index, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<int> GatherVector128(int* baseAddress, Vector128<long> index, byte scale) => GatherVector128(baseAddress, index, scale);
/// <summary>
/// __m128i _mm_i64gather_epi32 (int const* base_addr, __m128i vindex, const int scale)
/// </summary>
- public static unsafe Vector128<uint> GatherVector128(uint* baseAddress, Vector128<long> index, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<uint> GatherVector128(uint* baseAddress, Vector128<long> index, byte scale) => GatherVector128(baseAddress, index, scale);
/// <summary>
/// __m128i _mm_i64gather_epi64 (__int64 const* base_addr, __m128i vindex, const int scale)
/// </summary>
- public static unsafe Vector128<long> GatherVector128(long* baseAddress, Vector128<long> index, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<long> GatherVector128(long* baseAddress, Vector128<long> index, byte scale) => GatherVector128(baseAddress, index, scale);
/// <summary>
/// __m128i _mm_i64gather_epi64 (__int64 const* base_addr, __m128i vindex, const int scale)
/// </summary>
- public static unsafe Vector128<ulong> GatherVector128(ulong* baseAddress, Vector128<long> index, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<ulong> GatherVector128(ulong* baseAddress, Vector128<long> index, byte scale) => GatherVector128(baseAddress, index, scale);
/// <summary>
/// __m128 _mm_i64gather_ps (float const* base_addr, __m128i vindex, const int scale)
/// </summary>
- public static unsafe Vector128<float> GatherVector128(float* baseAddress, Vector128<long> index, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<float> GatherVector128(float* baseAddress, Vector128<long> index, byte scale) => GatherVector128(baseAddress, index, scale);
/// <summary>
/// __m128d _mm_i64gather_pd (double const* base_addr, __m128i vindex, const int scale)
/// </summary>
- public static unsafe Vector128<double> GatherVector128(double* baseAddress, Vector128<long> index, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<double> GatherVector128(double* baseAddress, Vector128<long> index, byte scale) => GatherVector128(baseAddress, index, scale);
/// <summary>
/// __m256i _mm256_i32gather_epi32 (int const* base_addr, __m256i vindex, const int scale)
/// </summary>
- public static unsafe Vector256<int> GatherVector256(int* baseAddress, Vector256<int> index, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector256<int> GatherVector256(int* baseAddress, Vector256<int> index, byte scale) => GatherVector256(baseAddress, index, scale);
/// <summary>
/// __m256i _mm256_i32gather_epi32 (int const* base_addr, __m256i vindex, const int scale)
/// </summary>
- public static unsafe Vector256<uint> GatherVector256(uint* baseAddress, Vector256<int> index, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector256<uint> GatherVector256(uint* baseAddress, Vector256<int> index, byte scale) => GatherVector256(baseAddress, index, scale);
/// <summary>
/// __m256i _mm256_i32gather_epi64 (__int64 const* base_addr, __m128i vindex, const int scale)
/// </summary>
- public static unsafe Vector256<long> GatherVector256(long* baseAddress, Vector128<int> index, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector256<long> GatherVector256(long* baseAddress, Vector128<int> index, byte scale) => GatherVector256(baseAddress, index, scale);
/// <summary>
/// __m256i _mm256_i32gather_epi64 (__int64 const* base_addr, __m128i vindex, const int scale)
/// </summary>
- public static unsafe Vector256<ulong> GatherVector256(ulong* baseAddress, Vector128<int> index, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector256<ulong> GatherVector256(ulong* baseAddress, Vector128<int> index, byte scale) => GatherVector256(baseAddress, index, scale);
/// <summary>
/// __m256 _mm256_i32gather_ps (float const* base_addr, __m256i vindex, const int scale)
/// </summary>
- public static unsafe Vector256<float> GatherVector256(float* baseAddress, Vector256<int> index, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector256<float> GatherVector256(float* baseAddress, Vector256<int> index, byte scale) => GatherVector256(baseAddress, index, scale);
/// <summary>
/// __m256d _mm256_i32gather_pd (double const* base_addr, __m128i vindex, const int scale)
/// </summary>
- public static unsafe Vector256<double> GatherVector256(double* baseAddress, Vector128<int> index, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector256<double> GatherVector256(double* baseAddress, Vector128<int> index, byte scale) => GatherVector256(baseAddress, index, scale);
/// <summary>
/// __m128i _mm256_i64gather_epi32 (int const* base_addr, __m256i vindex, const int scale)
/// </summary>
- public static unsafe Vector128<int> GatherVector128(int* baseAddress, Vector256<long> index, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<int> GatherVector128(int* baseAddress, Vector256<long> index, byte scale) => GatherVector128(baseAddress, index, scale);
/// <summary>
/// __m128i _mm256_i64gather_epi32 (int const* base_addr, __m256i vindex, const int scale)
/// </summary>
- public static unsafe Vector128<uint> GatherVector128(uint* baseAddress, Vector256<long> index, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<uint> GatherVector128(uint* baseAddress, Vector256<long> index, byte scale) => GatherVector128(baseAddress, index, scale);
/// <summary>
/// __m256i _mm256_i64gather_epi64 (__int64 const* base_addr, __m256i vindex, const int scale)
/// </summary>
- public static unsafe Vector256<long> GatherVector256(long* baseAddress, Vector256<long> index, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector256<long> GatherVector256(long* baseAddress, Vector256<long> index, byte scale) => GatherVector256(baseAddress, index, scale);
/// <summary>
/// __m256i _mm256_i64gather_epi64 (__int64 const* base_addr, __m256i vindex, const int scale)
/// </summary>
- public static unsafe Vector256<ulong> GatherVector256(ulong* baseAddress, Vector256<long> index, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector256<ulong> GatherVector256(ulong* baseAddress, Vector256<long> index, byte scale) => GatherVector256(baseAddress, index, scale);
/// <summary>
/// __m128 _mm256_i64gather_ps (float const* base_addr, __m256i vindex, const int scale)
/// </summary>
- public static unsafe Vector128<float> GatherVector128(float* baseAddress, Vector256<long> index, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<float> GatherVector128(float* baseAddress, Vector256<long> index, byte scale) => GatherVector128(baseAddress, index, scale);
/// <summary>
/// __m256d _mm256_i64gather_pd (double const* base_addr, __m256i vindex, const int scale)
/// </summary>
- public static unsafe Vector256<double> GatherVector256(double* baseAddress, Vector256<long> index, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector256<double> GatherVector256(double* baseAddress, Vector256<long> index, byte scale) => GatherVector256(baseAddress, index, scale);
/// <summary>
/// __m128i _mm_mask_i32gather_epi32 (__m128i src, int const* base_addr, __m128i vindex, __m128i mask, const int scale)
/// </summary>
- public static unsafe Vector128<int> GatherMaskVector128(Vector128<int> source, int* baseAddress, Vector128<int> index, Vector128<int> mask, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<int> GatherMaskVector128(Vector128<int> source, int* baseAddress, Vector128<int> index, Vector128<int> mask, byte scale) => GatherMaskVector128(source, baseAddress, index, mask, scale);
/// <summary>
/// __m128i _mm_mask_i32gather_epi32 (__m128i src, int const* base_addr, __m128i vindex, __m128i mask, const int scale)
/// </summary>
- public static unsafe Vector128<uint> GatherMaskVector128(Vector128<uint> source, uint* baseAddress, Vector128<int> index, Vector128<uint> mask, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<uint> GatherMaskVector128(Vector128<uint> source, uint* baseAddress, Vector128<int> index, Vector128<uint> mask, byte scale) => GatherMaskVector128(source, baseAddress, index, mask, scale);
/// <summary>
/// __m128i _mm_mask_i32gather_epi64 (__m128i src, __int64 const* base_addr, __m128i vindex, __m128i mask, const int scale)
/// </summary>
- public static unsafe Vector128<long> GatherMaskVector128(Vector128<long> source, long* baseAddress, Vector128<int> index, Vector128<long> mask, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<long> GatherMaskVector128(Vector128<long> source, long* baseAddress, Vector128<int> index, Vector128<long> mask, byte scale) => GatherMaskVector128(source, baseAddress, index, mask, scale);
/// <summary>
/// __m128i _mm_mask_i32gather_epi64 (__m128i src, __int64 const* base_addr, __m128i vindex, __m128i mask, const int scale)
/// </summary>
- public static unsafe Vector128<ulong> GatherMaskVector128(Vector128<ulong> source, ulong* baseAddress, Vector128<int> index, Vector128<ulong> mask, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<ulong> GatherMaskVector128(Vector128<ulong> source, ulong* baseAddress, Vector128<int> index, Vector128<ulong> mask, byte scale) => GatherMaskVector128(source, baseAddress, index, mask, scale);
/// <summary>
/// __m128 _mm_mask_i32gather_ps (__m128 src, float const* base_addr, __m128i vindex, __m128 mask, const int scale)
/// </summary>
- public static unsafe Vector128<float> GatherMaskVector128(Vector128<float> source, float* baseAddress, Vector128<int> index, Vector128<float> mask, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<float> GatherMaskVector128(Vector128<float> source, float* baseAddress, Vector128<int> index, Vector128<float> mask, byte scale) => GatherMaskVector128(source, baseAddress, index, mask, scale);
/// <summary>
/// __m128d _mm_mask_i32gather_pd (__m128d src, double const* base_addr, __m128i vindex, __m128d mask, const int scale)
/// </summary>
- public static unsafe Vector128<double> GatherMaskVector128(Vector128<double> source, double* baseAddress, Vector128<int> index, Vector128<double> mask, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<double> GatherMaskVector128(Vector128<double> source, double* baseAddress, Vector128<int> index, Vector128<double> mask, byte scale) => GatherMaskVector128(source, baseAddress, index, mask, scale);
/// <summary>
/// __m128i _mm_mask_i64gather_epi32 (__m128i src, int const* base_addr, __m128i vindex, __m128i mask, const int scale)
/// </summary>
- public static unsafe Vector128<int> GatherMaskVector128(Vector128<int> source, int* baseAddress, Vector128<long> index, Vector128<int> mask, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<int> GatherMaskVector128(Vector128<int> source, int* baseAddress, Vector128<long> index, Vector128<int> mask, byte scale) => GatherMaskVector128(source, baseAddress, index, mask, scale);
/// <summary>
/// __m128i _mm_mask_i64gather_epi32 (__m128i src, int const* base_addr, __m128i vindex, __m128i mask, const int scale)
/// </summary>
- public static unsafe Vector128<uint> GatherMaskVector128(Vector128<uint> source, uint* baseAddress, Vector128<long> index, Vector128<uint> mask, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<uint> GatherMaskVector128(Vector128<uint> source, uint* baseAddress, Vector128<long> index, Vector128<uint> mask, byte scale) => GatherMaskVector128(source, baseAddress, index, mask, scale);
/// <summary>
/// __m128i _mm_mask_i64gather_epi64 (__m128i src, __int64 const* base_addr, __m128i vindex, __m128i mask, const int scale)
/// </summary>
- public static unsafe Vector128<long> GatherMaskVector128(Vector128<long> source, long* baseAddress, Vector128<long> index, Vector128<long> mask, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<long> GatherMaskVector128(Vector128<long> source, long* baseAddress, Vector128<long> index, Vector128<long> mask, byte scale) => GatherMaskVector128(source, baseAddress, index, mask, scale);
/// <summary>
/// __m128i _mm_mask_i64gather_epi64 (__m128i src, __int64 const* base_addr, __m128i vindex, __m128i mask, const int scale)
/// </summary>
- public static unsafe Vector128<ulong> GatherMaskVector128(Vector128<ulong> source, ulong* baseAddress, Vector128<long> index, Vector128<ulong> mask, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<ulong> GatherMaskVector128(Vector128<ulong> source, ulong* baseAddress, Vector128<long> index, Vector128<ulong> mask, byte scale) => GatherMaskVector128(source, baseAddress, index, mask, scale);
/// <summary>
/// __m128 _mm_mask_i64gather_ps (__m128 src, float const* base_addr, __m128i vindex, __m128 mask, const int scale)
/// </summary>
- public static unsafe Vector128<float> GatherMaskVector128(Vector128<float> source, float* baseAddress, Vector128<long> index, Vector128<float> mask, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<float> GatherMaskVector128(Vector128<float> source, float* baseAddress, Vector128<long> index, Vector128<float> mask, byte scale) => GatherMaskVector128(source, baseAddress, index, mask, scale);
/// <summary>
/// __m128d _mm_mask_i64gather_pd (__m128d src, double const* base_addr, __m128i vindex, __m128d mask, const int scale)
/// </summary>
- public static unsafe Vector128<double> GatherMaskVector128(Vector128<double> source, double* baseAddress, Vector128<long> index, Vector128<double> mask, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<double> GatherMaskVector128(Vector128<double> source, double* baseAddress, Vector128<long> index, Vector128<double> mask, byte scale) => GatherMaskVector128(source, baseAddress, index, mask, scale);
/// <summary>
/// __m256i _mm256_mask_i32gather_epi32 (__m256i src, int const* base_addr, __m256i vindex, __m256i mask, const int scale)
/// </summary>
- public static unsafe Vector256<int> GatherMaskVector256(Vector256<int> source, int* baseAddress, Vector256<int> index, Vector256<int> mask, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector256<int> GatherMaskVector256(Vector256<int> source, int* baseAddress, Vector256<int> index, Vector256<int> mask, byte scale) => GatherMaskVector256(source, baseAddress, index, mask, scale);
/// <summary>
/// __m256i _mm256_mask_i32gather_epi32 (__m256i src, int const* base_addr, __m256i vindex, __m256i mask, const int scale)
/// </summary>
- public static unsafe Vector256<uint> GatherMaskVector256(Vector256<uint> source, uint* baseAddress, Vector256<int> index, Vector256<uint> mask, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector256<uint> GatherMaskVector256(Vector256<uint> source, uint* baseAddress, Vector256<int> index, Vector256<uint> mask, byte scale) => GatherMaskVector256(source, baseAddress, index, mask, scale);
/// <summary>
/// __m256i _mm256_mask_i32gather_epi64 (__m256i src, __int64 const* base_addr, __m128i vindex, __m256i mask, const int scale)
/// </summary>
- public static unsafe Vector256<long> GatherMaskVector256(Vector256<long> source, long* baseAddress, Vector128<int> index, Vector256<long> mask, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector256<long> GatherMaskVector256(Vector256<long> source, long* baseAddress, Vector128<int> index, Vector256<long> mask, byte scale) => GatherMaskVector256(source, baseAddress, index, mask, scale);
/// <summary>
/// __m256i _mm256_mask_i32gather_epi64 (__m256i src, __int64 const* base_addr, __m128i vindex, __m256i mask, const int scale)
/// </summary>
- public static unsafe Vector256<ulong> GatherMaskVector256(Vector256<ulong> source, ulong* baseAddress, Vector128<int> index, Vector256<ulong> mask, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector256<ulong> GatherMaskVector256(Vector256<ulong> source, ulong* baseAddress, Vector128<int> index, Vector256<ulong> mask, byte scale) => GatherMaskVector256(source, baseAddress, index, mask, scale);
/// <summary>
/// __m256 _mm256_mask_i32gather_ps (__m256 src, float const* base_addr, __m256i vindex, __m256 mask, const int scale)
/// </summary>
- public static unsafe Vector256<float> GatherMaskVector256(Vector256<float> source, float* baseAddress, Vector256<int> index, Vector256<float> mask, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector256<float> GatherMaskVector256(Vector256<float> source, float* baseAddress, Vector256<int> index, Vector256<float> mask, byte scale) => GatherMaskVector256(source, baseAddress, index, mask, scale);
/// <summary>
/// __m256d _mm256_mask_i32gather_pd (__m256d src, double const* base_addr, __m128i vindex, __m256d mask, const int scale)
/// </summary>
- public static unsafe Vector256<double> GatherMaskVector256(Vector256<double> source, double* baseAddress, Vector128<int> index, Vector256<double> mask, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector256<double> GatherMaskVector256(Vector256<double> source, double* baseAddress, Vector128<int> index, Vector256<double> mask, byte scale) => GatherMaskVector256(source, baseAddress, index, mask, scale);
/// <summary>
/// __m128i _mm256_mask_i64gather_epi32 (__m128i src, int const* base_addr, __m256i vindex, __m128i mask, const int scale)
/// </summary>
- public static unsafe Vector128<int> GatherMaskVector128(Vector128<int> source, int* baseAddress, Vector256<long> index, Vector128<int> mask, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<int> GatherMaskVector128(Vector128<int> source, int* baseAddress, Vector256<long> index, Vector128<int> mask, byte scale) => GatherMaskVector128(source, baseAddress, index, mask, scale);
/// <summary>
/// __m128i _mm256_mask_i64gather_epi32 (__m128i src, int const* base_addr, __m256i vindex, __m128i mask, const int scale)
/// </summary>
- public static unsafe Vector128<uint> GatherMaskVector128(Vector128<uint> source, uint* baseAddress, Vector256<long> index, Vector128<uint> mask, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<uint> GatherMaskVector128(Vector128<uint> source, uint* baseAddress, Vector256<long> index, Vector128<uint> mask, byte scale) => GatherMaskVector128(source, baseAddress, index, mask, scale);
/// <summary>
/// __m256i _mm256_mask_i64gather_epi64 (__m256i src, __int64 const* base_addr, __m256i vindex, __m256i mask, const int scale)
/// </summary>
- public static unsafe Vector256<long> GatherMaskVector256(Vector256<long> source, long* baseAddress, Vector256<long> index, Vector256<long> mask, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector256<long> GatherMaskVector256(Vector256<long> source, long* baseAddress, Vector256<long> index, Vector256<long> mask, byte scale) => GatherMaskVector256(source, baseAddress, index, mask, scale);
/// <summary>
/// __m256i _mm256_mask_i64gather_epi64 (__m256i src, __int64 const* base_addr, __m256i vindex, __m256i mask, const int scale)
/// </summary>
- public static unsafe Vector256<ulong> GatherMaskVector256(Vector256<ulong> source, ulong* baseAddress, Vector256<long> index, Vector256<ulong> mask, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector256<ulong> GatherMaskVector256(Vector256<ulong> source, ulong* baseAddress, Vector256<long> index, Vector256<ulong> mask, byte scale) => GatherMaskVector256(source, baseAddress, index, mask, scale);
/// <summary>
/// __m128 _mm256_mask_i64gather_ps (__m128 src, float const* base_addr, __m256i vindex, __m128 mask, const int scale)
/// </summary>
- public static unsafe Vector128<float> GatherMaskVector128(Vector128<float> source, float* baseAddress, Vector256<long> index, Vector128<float> mask, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector128<float> GatherMaskVector128(Vector128<float> source, float* baseAddress, Vector256<long> index, Vector128<float> mask, byte scale) => GatherMaskVector128(source, baseAddress, index, mask, scale);
/// <summary>
/// __m256d _mm256_mask_i64gather_pd (__m256d src, double const* base_addr, __m256i vindex, __m256d mask, const int scale)
/// </summary>
- public static unsafe Vector256<double> GatherMaskVector256(Vector256<double> source, double* baseAddress, Vector256<long> index, Vector256<double> mask, byte scale) { throw new NotImplementedException(); }
+ public static unsafe Vector256<double> GatherMaskVector256(Vector256<double> source, double* baseAddress, Vector256<long> index, Vector256<double> mask, byte scale) => GatherMaskVector256(source, baseAddress, index, mask, scale);
/// <summary>
/// __m256i _mm256_hadd_epi16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<short> HorizontalAdd(Vector256<short> left, Vector256<short> right) { throw new NotImplementedException(); }
+ public static Vector256<short> HorizontalAdd(Vector256<short> left, Vector256<short> right) => HorizontalAdd(left, right);
/// <summary>
/// __m256i _mm256_hadd_epi32 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<int> HorizontalAdd(Vector256<int> left, Vector256<int> right) { throw new NotImplementedException(); }
+ public static Vector256<int> HorizontalAdd(Vector256<int> left, Vector256<int> right) => HorizontalAdd(left, right);
/// <summary>
/// __m256i _mm256_hadds_epi16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<short> HorizontalAddSaturate(Vector256<short> left, Vector256<short> right) { throw new NotImplementedException(); }
+ public static Vector256<short> HorizontalAddSaturate(Vector256<short> left, Vector256<short> right) => HorizontalAddSaturate(left, right);
/// <summary>
/// __m256i _mm256_hsub_epi16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<short> HorizontalSubtract(Vector256<short> left, Vector256<short> right) { throw new NotImplementedException(); }
+ public static Vector256<short> HorizontalSubtract(Vector256<short> left, Vector256<short> right) => HorizontalSubtract(left, right);
/// <summary>
/// __m256i _mm256_hsub_epi32 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<int> HorizontalSubtract(Vector256<int> left, Vector256<int> right) { throw new NotImplementedException(); }
+ public static Vector256<int> HorizontalSubtract(Vector256<int> left, Vector256<int> right) => HorizontalSubtract(left, right);
/// <summary>
/// __m256i _mm256_hsubs_epi16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<short> HorizontalSubtractSaturate(Vector256<short> left, Vector256<short> right) { throw new NotImplementedException(); }
+ public static Vector256<short> HorizontalSubtractSaturate(Vector256<short> left, Vector256<short> right) => HorizontalSubtractSaturate(left, right);
/// <summary>
/// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
/// </summary>
- public static Vector256<sbyte> Insert(Vector256<sbyte> value, Vector128<sbyte> data, byte index) { throw new NotImplementedException(); }
+ public static Vector256<sbyte> Insert(Vector256<sbyte> value, Vector128<sbyte> data, byte index) => Insert(value, data, index);
/// <summary>
/// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
/// </summary>
- public static unsafe Vector256<sbyte> Insert(Vector256<sbyte> value, sbyte* address, byte index) { throw new NotImplementedException(); }
+ public static unsafe Vector256<sbyte> Insert(Vector256<sbyte> value, sbyte* address, byte index) => Insert(value, address, index);
/// <summary>
/// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
/// </summary>
- public static Vector256<byte> Insert(Vector256<byte> value, Vector128<byte> data, byte index) { throw new NotImplementedException(); }
+ public static Vector256<byte> Insert(Vector256<byte> value, Vector128<byte> data, byte index) => Insert(value, data, index);
/// <summary>
/// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
/// </summary>
- public static unsafe Vector256<byte> Insert(Vector256<byte> value, byte* address, byte index) { throw new NotImplementedException(); }
+ public static unsafe Vector256<byte> Insert(Vector256<byte> value, byte* address, byte index) => Insert(value, address, index);
/// <summary>
/// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
/// </summary>
- public static Vector256<short> Insert(Vector256<short> value, Vector128<short> data, byte index) { throw new NotImplementedException(); }
+ public static Vector256<short> Insert(Vector256<short> value, Vector128<short> data, byte index) => Insert(value, data, index);
/// <summary>
/// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
/// </summary>
- public static unsafe Vector256<short> Insert(Vector256<short> value, short* address, byte index) { throw new NotImplementedException(); }
+ public static unsafe Vector256<short> Insert(Vector256<short> value, short* address, byte index) => Insert(value, address, index);
/// <summary>
/// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
/// </summary>
- public static Vector256<ushort> Insert(Vector256<ushort> value, Vector128<ushort> data, byte index) { throw new NotImplementedException(); }
+ public static Vector256<ushort> Insert(Vector256<ushort> value, Vector128<ushort> data, byte index) => Insert(value, data, index);
/// <summary>
/// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
/// </summary>
- public static unsafe Vector256<ushort> Insert(Vector256<ushort> value, ushort* address, byte index) { throw new NotImplementedException(); }
+ public static unsafe Vector256<ushort> Insert(Vector256<ushort> value, ushort* address, byte index) => Insert(value, address, index);
/// <summary>
/// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
/// </summary>
- public static Vector256<int> Insert(Vector256<int> value, Vector128<int> data, byte index) { throw new NotImplementedException(); }
+ public static Vector256<int> Insert(Vector256<int> value, Vector128<int> data, byte index) => Insert(value, data, index);
/// <summary>
/// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
/// </summary>
- public static unsafe Vector256<int> Insert(Vector256<int> value, int* address, byte index) { throw new NotImplementedException(); }
+ public static unsafe Vector256<int> Insert(Vector256<int> value, int* address, byte index) => Insert(value, address, index);
/// <summary>
/// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
/// </summary>
- public static Vector256<uint> Insert(Vector256<uint> value, Vector128<uint> data, byte index) { throw new NotImplementedException(); }
+ public static Vector256<uint> Insert(Vector256<uint> value, Vector128<uint> data, byte index) => Insert(value, data, index);
/// <summary>
/// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
/// </summary>
- public static unsafe Vector256<uint> Insert(Vector256<uint> value, uint* address, byte index) { throw new NotImplementedException(); }
+ public static unsafe Vector256<uint> Insert(Vector256<uint> value, uint* address, byte index) => Insert(value, address, index);
/// <summary>
/// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
/// </summary>
- public static Vector256<long> Insert(Vector256<long> value, Vector128<long> data, byte index) { throw new NotImplementedException(); }
+ public static Vector256<long> Insert(Vector256<long> value, Vector128<long> data, byte index) => Insert(value, data, index);
/// <summary>
/// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
/// </summary>
- public static unsafe Vector256<long> Insert(Vector256<long> value, long* address, byte index) { throw new NotImplementedException(); }
+ public static unsafe Vector256<long> Insert(Vector256<long> value, long* address, byte index) => Insert(value, address, index);
/// <summary>
/// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
/// </summary>
- public static Vector256<ulong> Insert(Vector256<ulong> value, Vector128<ulong> data, byte index) { throw new NotImplementedException(); }
+ public static Vector256<ulong> Insert(Vector256<ulong> value, Vector128<ulong> data, byte index) => Insert(value, data, index);
/// <summary>
/// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8)
/// </summary>
- public static unsafe Vector256<ulong> Insert(Vector256<ulong> value, ulong* address, byte index) { throw new NotImplementedException(); }
+ public static unsafe Vector256<ulong> Insert(Vector256<ulong> value, ulong* address, byte index) => Insert(value, address, index);
/// <summary>
/// __m128i _mm_maskload_epi32 (int const* mem_addr, __m128i mask)
/// </summary>
- public static unsafe Vector128<int> MaskLoad(int* address, Vector128<int> mask) { throw new NotImplementedException(); }
+ public static unsafe Vector128<int> MaskLoad(int* address, Vector128<int> mask) => MaskLoad(address, mask);
/// <summary>
/// __m128i _mm_maskload_epi32 (int const* mem_addr, __m128i mask)
/// </summary>
- public static unsafe Vector128<uint> MaskLoad(uint* address, Vector128<uint> mask) { throw new NotImplementedException(); }
+ public static unsafe Vector128<uint> MaskLoad(uint* address, Vector128<uint> mask) => MaskLoad(address, mask);
/// <summary>
/// __m128i _mm_maskload_epi64 (__int64 const* mem_addr, __m128i mask)
/// </summary>
- public static unsafe Vector128<long> MaskLoad(long* address, Vector128<long> mask) { throw new NotImplementedException(); }
+ public static unsafe Vector128<long> MaskLoad(long* address, Vector128<long> mask) => MaskLoad(address, mask);
/// <summary>
/// __m128i _mm_maskload_epi64 (__int64 const* mem_addr, __m128i mask)
/// </summary>
- public static unsafe Vector128<ulong> MaskLoad(ulong* address, Vector128<ulong> mask) { throw new NotImplementedException(); }
+ public static unsafe Vector128<ulong> MaskLoad(ulong* address, Vector128<ulong> mask) => MaskLoad(address, mask);
/// <summary>
/// __m256i _mm256_maskload_epi32 (int const* mem_addr, __m256i mask)
/// </summary>
- public static unsafe Vector256<int> MaskLoad(int* address, Vector256<int> mask) { throw new NotImplementedException(); }
+ public static unsafe Vector256<int> MaskLoad(int* address, Vector256<int> mask) => MaskLoad(address, mask);
/// <summary>
/// __m256i _mm256_maskload_epi32 (int const* mem_addr, __m256i mask)
/// </summary>
- public static unsafe Vector256<uint> MaskLoad(uint* address, Vector256<uint> mask) { throw new NotImplementedException(); }
+ public static unsafe Vector256<uint> MaskLoad(uint* address, Vector256<uint> mask) => MaskLoad(address, mask);
/// <summary>
/// __m256i _mm256_maskload_epi64 (__int64 const* mem_addr, __m256i mask)
/// </summary>
- public static unsafe Vector256<long> MaskLoad(long* address, Vector256<long> mask) { throw new NotImplementedException(); }
+ public static unsafe Vector256<long> MaskLoad(long* address, Vector256<long> mask) => MaskLoad(address, mask);
/// <summary>
/// __m256i _mm256_maskload_epi64 (__int64 const* mem_addr, __m256i mask)
/// </summary>
- public static unsafe Vector256<ulong> MaskLoad(ulong* address, Vector256<ulong> mask) { throw new NotImplementedException(); }
+ public static unsafe Vector256<ulong> MaskLoad(ulong* address, Vector256<ulong> mask) => MaskLoad(address, mask);
/// <summary>
/// void _mm_maskstore_epi32 (int* mem_addr, __m128i mask, __m128i a)
/// </summary>
- public static unsafe void MaskStore(int* address, Vector128<int> mask, Vector128<int> source) { throw new NotImplementedException(); }
+ public static unsafe void MaskStore(int* address, Vector128<int> mask, Vector128<int> source) => MaskStore(address, mask, source);
/// <summary>
/// void _mm_maskstore_epi32 (int* mem_addr, __m128i mask, __m128i a)
/// </summary>
- public static unsafe void MaskStore(uint* address, Vector128<uint> mask, Vector128<uint> source) { throw new NotImplementedException(); }
+ public static unsafe void MaskStore(uint* address, Vector128<uint> mask, Vector128<uint> source) => MaskStore(address, mask, source);
/// <summary>
/// void _mm_maskstore_epi64 (__int64* mem_addr, __m128i mask, __m128i a)
/// </summary>
- public static unsafe void MaskStore(long* address, Vector128<long> mask, Vector128<long> source) { throw new NotImplementedException(); }
+ public static unsafe void MaskStore(long* address, Vector128<long> mask, Vector128<long> source) => MaskStore(address, mask, source);
/// <summary>
/// void _mm_maskstore_epi64 (__int64* mem_addr, __m128i mask, __m128i a)
/// </summary>
- public static unsafe void MaskStore(ulong* address, Vector128<ulong> mask, Vector128<ulong> source) { throw new NotImplementedException(); }
+ public static unsafe void MaskStore(ulong* address, Vector128<ulong> mask, Vector128<ulong> source) => MaskStore(address, mask, source);
/// <summary>
/// void _mm256_maskstore_epi32 (int* mem_addr, __m256i mask, __m256i a)
/// </summary>
- public static unsafe void MaskStore(int* address, Vector256<int> mask, Vector256<int> source) { throw new NotImplementedException(); }
+ public static unsafe void MaskStore(int* address, Vector256<int> mask, Vector256<int> source) => MaskStore(address, mask, source);
/// <summary>
/// void _mm256_maskstore_epi32 (int* mem_addr, __m256i mask, __m256i a)
/// </summary>
- public static unsafe void MaskStore(uint* address, Vector256<uint> mask, Vector256<uint> source) { throw new NotImplementedException(); }
+ public static unsafe void MaskStore(uint* address, Vector256<uint> mask, Vector256<uint> source) => MaskStore(address, mask, source);
/// <summary>
/// void _mm256_maskstore_epi64 (__int64* mem_addr, __m256i mask, __m256i a)
/// </summary>
- public static unsafe void MaskStore(long* address, Vector256<long> mask, Vector256<long> source) { throw new NotImplementedException(); }
+ public static unsafe void MaskStore(long* address, Vector256<long> mask, Vector256<long> source) => MaskStore(address, mask, source);
/// <summary>
/// void _mm256_maskstore_epi64 (__int64* mem_addr, __m256i mask, __m256i a)
/// </summary>
- public static unsafe void MaskStore(ulong* address, Vector256<ulong> mask, Vector256<ulong> source) { throw new NotImplementedException(); }
+ public static unsafe void MaskStore(ulong* address, Vector256<ulong> mask, Vector256<ulong> source) => MaskStore(address, mask, source);
/// <summary>
/// __m256i _mm256_madd_epi16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<int> MultiplyAddAdjacent(Vector256<short> left, Vector256<short> right) { throw new NotImplementedException(); }
+ public static Vector256<int> MultiplyAddAdjacent(Vector256<short> left, Vector256<short> right) => MultiplyAddAdjacent(left, right);
/// <summary>
/// __m256i _mm256_maddubs_epi16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<short> MultiplyAddAdjacent(Vector256<byte> left, Vector256<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector256<short> MultiplyAddAdjacent(Vector256<byte> left, Vector256<sbyte> right) => MultiplyAddAdjacent(left, right);
/// <summary>
/// __m256i _mm256_max_epi8 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<sbyte> Max(Vector256<sbyte> left, Vector256<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector256<sbyte> Max(Vector256<sbyte> left, Vector256<sbyte> right) => Max(left, right);
/// <summary>
/// __m256i _mm256_max_epu8 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<byte> Max(Vector256<byte> left, Vector256<short> right) { throw new NotImplementedException(); }
+ public static Vector256<byte> Max(Vector256<byte> left, Vector256<short> right) => Max(left, right);
/// <summary>
/// __m256i _mm256_max_epi16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<short> Max(Vector256<short> left, Vector256<short> right) { throw new NotImplementedException(); }
+ public static Vector256<short> Max(Vector256<short> left, Vector256<short> right) => Max(left, right);
/// <summary>
/// __m256i _mm256_max_epu16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<ushort> Max(Vector256<ushort> left, Vector256<ushort> right) { throw new NotImplementedException(); }
+ public static Vector256<ushort> Max(Vector256<ushort> left, Vector256<ushort> right) => Max(left, right);
/// <summary>
/// __m256i _mm256_max_epi32 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<int> Max(Vector256<int> left, Vector256<int> right) { throw new NotImplementedException(); }
+ public static Vector256<int> Max(Vector256<int> left, Vector256<int> right) => Max(left, right);
/// <summary>
/// __m256i _mm256_max_epu32 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<uint> Max(Vector256<uint> left, Vector256<uint> right) { throw new NotImplementedException(); }
+ public static Vector256<uint> Max(Vector256<uint> left, Vector256<uint> right) => Max(left, right);
/// <summary>
/// __m256i _mm256_min_epi8 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<sbyte> Min(Vector256<sbyte> left, Vector256<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector256<sbyte> Min(Vector256<sbyte> left, Vector256<sbyte> right) => Min(left, right);
/// <summary>
/// __m256i _mm256_min_epu8 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<byte> Min(Vector256<byte> left, Vector256<byte> right) { throw new NotImplementedException(); }
+ public static Vector256<byte> Min(Vector256<byte> left, Vector256<byte> right) => Min(left, right);
/// <summary>
/// __m256i _mm256_min_epi16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<short> Min(Vector256<short> left, Vector256<short> right) { throw new NotImplementedException(); }
+ public static Vector256<short> Min(Vector256<short> left, Vector256<short> right) => Min(left, right);
/// <summary>
/// __m256i _mm256_min_epu16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<ushort> Min(Vector256<ushort> left, Vector256<ushort> right) { throw new NotImplementedException(); }
+ public static Vector256<ushort> Min(Vector256<ushort> left, Vector256<ushort> right) => Min(left, right);
/// <summary>
/// __m256i _mm256_min_epi32 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<int> Min(Vector256<int> left, Vector256<int> right) { throw new NotImplementedException(); }
+ public static Vector256<int> Min(Vector256<int> left, Vector256<int> right) => Min(left, right);
/// <summary>
/// __m256i _mm256_min_epu32 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<uint> Min(Vector256<uint> left, Vector256<uint> right) { throw new NotImplementedException(); }
+ public static Vector256<uint> Min(Vector256<uint> left, Vector256<uint> right) => Min(left, right);
/// <summary>
/// int _mm256_movemask_epi8 (__m256i a)
/// </summary>
- public static int MoveMask(Vector256<sbyte> value) { throw new NotImplementedException(); }
+ public static int MoveMask(Vector256<sbyte> value) => MoveMask(value);
/// <summary>
/// int _mm256_movemask_epi8 (__m256i a)
/// </summary>
- public static int MoveMask(Vector256<byte> value) { throw new NotImplementedException(); }
+ public static int MoveMask(Vector256<byte> value) => MoveMask(value);
/// <summary>
/// __m256i _mm256_mpsadbw_epu8 (__m256i a, __m256i b, const int imm8)
/// </summary>
- public static Vector256<ushort> MultipleSumAbsoluteDifferences(Vector256<byte> left, Vector256<byte> right, byte mask) { throw new NotImplementedException(); }
+ public static Vector256<ushort> MultipleSumAbsoluteDifferences(Vector256<byte> left, Vector256<byte> right, byte mask) => MultipleSumAbsoluteDifferences(left, right, mask);
/// <summary>
/// __m256i _mm256_mul_epi32 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<long> Multiply(Vector256<int> left, Vector256<int> right) { throw new NotImplementedException(); }
+ public static Vector256<long> Multiply(Vector256<int> left, Vector256<int> right) => Multiply(left, right);
/// <summary>
/// __m256i _mm256_mul_epu32 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<ulong> Multiply(Vector256<uint> left, Vector256<uint> right) { throw new NotImplementedException(); }
+ public static Vector256<ulong> Multiply(Vector256<uint> left, Vector256<uint> right) => Multiply(left, right);
/// <summary>
/// __m256i _mm256_mulhi_epi16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<short> MultiplyHigh(Vector256<short> left, Vector256<short> right) { throw new NotImplementedException(); }
+ public static Vector256<short> MultiplyHigh(Vector256<short> left, Vector256<short> right) => MultiplyHigh(left, right);
/// <summary>
/// __m256i _mm256_mulhi_epu16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<ushort> MultiplyHigh(Vector256<ushort> left, Vector256<ushort> right) { throw new NotImplementedException(); }
+ public static Vector256<ushort> MultiplyHigh(Vector256<ushort> left, Vector256<ushort> right) => MultiplyHigh(left, right);
/// <summary>
/// __m256i _mm256_mulhrs_epi16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<short> MultiplyHighRoundScale(Vector256<short> left, Vector256<short> right) { throw new NotImplementedException(); }
+ public static Vector256<short> MultiplyHighRoundScale(Vector256<short> left, Vector256<short> right) => MultiplyHighRoundScale(left, right);
/// <summary>
/// __m256i _mm256_mullo_epi16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<short> MultiplyLow(Vector256<short> left, Vector256<short> right) { throw new NotImplementedException(); }
+ public static Vector256<short> MultiplyLow(Vector256<short> left, Vector256<short> right) => MultiplyLow(left, right);
/// <summary>
/// __m256i _mm256_mullo_epu16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<int> MultiplyLow(Vector256<int> left, Vector256<int> right) { throw new NotImplementedException(); }
+ public static Vector256<int> MultiplyLow(Vector256<int> left, Vector256<int> right) => MultiplyLow(left, right);
/// <summary>
/// __m256i _mm256_or_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<sbyte> Or(Vector256<sbyte> left, Vector256<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector256<sbyte> Or(Vector256<sbyte> left, Vector256<sbyte> right) => Or(left, right);
/// <summary>
/// __m256i _mm256_or_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<byte> Or(Vector256<byte> left, Vector256<byte> right) { throw new NotImplementedException(); }
+ public static Vector256<byte> Or(Vector256<byte> left, Vector256<byte> right) => Or(left, right);
/// <summary>
/// __m256i _mm256_or_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<short> Or(Vector256<short> left, Vector256<short> right) { throw new NotImplementedException(); }
+ public static Vector256<short> Or(Vector256<short> left, Vector256<short> right) => Or(left, right);
/// <summary>
/// __m256i _mm256_or_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<ushort> Or(Vector256<ushort> left, Vector256<ushort> right) { throw new NotImplementedException(); }
+ public static Vector256<ushort> Or(Vector256<ushort> left, Vector256<ushort> right) => Or(left, right);
/// <summary>
/// __m256i _mm256_or_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<int> Or(Vector256<int> left, Vector256<int> right) { throw new NotImplementedException(); }
+ public static Vector256<int> Or(Vector256<int> left, Vector256<int> right) => Or(left, right);
/// <summary>
/// __m256i _mm256_or_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<uint> Or(Vector256<uint> left, Vector256<uint> right) { throw new NotImplementedException(); }
+ public static Vector256<uint> Or(Vector256<uint> left, Vector256<uint> right) => Or(left, right);
/// <summary>
/// __m256i _mm256_or_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<long> Or(Vector256<long> left, Vector256<long> right) { throw new NotImplementedException(); }
+ public static Vector256<long> Or(Vector256<long> left, Vector256<long> right) => Or(left, right);
/// <summary>
/// __m256i _mm256_or_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<ulong> Or(Vector256<ulong> left, Vector256<ulong> right) { throw new NotImplementedException(); }
+ public static Vector256<ulong> Or(Vector256<ulong> left, Vector256<ulong> right) => Or(left, right);
/// <summary>
/// __m256i _mm256_packs_epi16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<sbyte> PackSignedSaturate(Vector256<short> left, Vector256<short> right) { throw new NotImplementedException(); }
+ public static Vector256<sbyte> PackSignedSaturate(Vector256<short> left, Vector256<short> right) => PackSignedSaturate(left, right);
/// <summary>
/// __m256i _mm256_packs_epi32 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<short> PackSignedSaturate(Vector256<int> left, Vector256<int> right) { throw new NotImplementedException(); }
+ public static Vector256<short> PackSignedSaturate(Vector256<int> left, Vector256<int> right) => PackSignedSaturate(left, right);
/// <summary>
/// __m256i _mm256_packus_epi16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<byte> PackUnsignedSaturate(Vector256<short> left, Vector256<short> right) { throw new NotImplementedException(); }
+ public static Vector256<byte> PackUnsignedSaturate(Vector256<short> left, Vector256<short> right) => PackUnsignedSaturate(left, right);
/// <summary>
/// __m256i _mm256_packus_epi32 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<ushort> PackUnsignedSaturate(Vector256<int> left, Vector256<int> right) { throw new NotImplementedException(); }
+ public static Vector256<ushort> PackUnsignedSaturate(Vector256<int> left, Vector256<int> right) => PackUnsignedSaturate(left, right);
/// <summary>
/// __m256i _mm256_permute2x128_si256 (__m256i a, __m256i b, const int imm8)
/// </summary>
- public static Vector256<sbyte> Permute2x128(Vector256<sbyte> left, Vector256<sbyte> right, byte control) { throw new NotImplementedException(); }
+ public static Vector256<sbyte> Permute2x128(Vector256<sbyte> left, Vector256<sbyte> right, byte control) => Permute2x128(left, right, control);
/// <summary>
/// __m256i _mm256_permute2x128_si256 (__m256i a, __m256i b, const int imm8)
/// </summary>
- public static Vector256<byte> Permute2x128(Vector256<byte> left, Vector256<byte> right, byte control) { throw new NotImplementedException(); }
+ public static Vector256<byte> Permute2x128(Vector256<byte> left, Vector256<byte> right, byte control) => Permute2x128(left, right, control);
/// <summary>
/// __m256i _mm256_permute2x128_si256 (__m256i a, __m256i b, const int imm8)
/// </summary>
- public static Vector256<short> Permute2x128(Vector256<short> left, Vector256<short> right, byte control) { throw new NotImplementedException(); }
+ public static Vector256<short> Permute2x128(Vector256<short> left, Vector256<short> right, byte control) => Permute2x128(left, right, control);
/// <summary>
/// __m256i _mm256_permute2x128_si256 (__m256i a, __m256i b, const int imm8)
/// </summary>
- public static Vector256<ushort> Permute2x128(Vector256<ushort> left, Vector256<ushort> right, byte control) { throw new NotImplementedException(); }
+ public static Vector256<ushort> Permute2x128(Vector256<ushort> left, Vector256<ushort> right, byte control) => Permute2x128(left, right, control);
/// <summary>
/// __m256i _mm256_permute2x128_si256 (__m256i a, __m256i b, const int imm8)
/// </summary>
- public static Vector256<int> Permute2x128(Vector256<int> left, Vector256<int> right, byte control) { throw new NotImplementedException(); }
+ public static Vector256<int> Permute2x128(Vector256<int> left, Vector256<int> right, byte control) => Permute2x128(left, right, control);
/// <summary>
/// __m256i _mm256_permute2x128_si256 (__m256i a, __m256i b, const int imm8)
/// </summary>
- public static Vector256<uint> Permute2x128(Vector256<uint> left, Vector256<uint> right, byte control) { throw new NotImplementedException(); }
+ public static Vector256<uint> Permute2x128(Vector256<uint> left, Vector256<uint> right, byte control) => Permute2x128(left, right, control);
/// <summary>
/// __m256i _mm256_permute2x128_si256 (__m256i a, __m256i b, const int imm8)
/// </summary>
- public static Vector256<long> Permute2x128(Vector256<long> left, Vector256<long> right, byte control) { throw new NotImplementedException(); }
+ public static Vector256<long> Permute2x128(Vector256<long> left, Vector256<long> right, byte control) => Permute2x128(left, right, control);
/// <summary>
/// __m256i _mm256_permute2x128_si256 (__m256i a, __m256i b, const int imm8)
/// </summary>
- public static Vector256<ulong> Permute2x128(Vector256<ulong> left, Vector256<ulong> right, byte control) { throw new NotImplementedException(); }
+ public static Vector256<ulong> Permute2x128(Vector256<ulong> left, Vector256<ulong> right, byte control) => Permute2x128(left, right, control);
/// <summary>
/// __m256i _mm256_permute4x64_epi64 (__m256i a, const int imm8)
/// </summary>
- public static Vector256<long> Permute4x64(Vector256<long> value, byte control) { throw new NotImplementedException(); }
+ public static Vector256<long> Permute4x64(Vector256<long> value, byte control) => Permute4x64(value, control);
/// <summary>
/// __m256i _mm256_permute4x64_epi64 (__m256i a, const int imm8)
/// </summary>
- public static Vector256<ulong> Permute4x64(Vector256<ulong> value, byte control) { throw new NotImplementedException(); }
+ public static Vector256<ulong> Permute4x64(Vector256<ulong> value, byte control) => Permute4x64(value, control);
/// <summary>
/// __m256d _mm256_permute4x64_pd (__m256d a, const int imm8)
/// </summary>
- public static Vector256<double> Permute4x64(Vector256<double> value, byte control) { throw new NotImplementedException(); }
+ public static Vector256<double> Permute4x64(Vector256<double> value, byte control) => Permute4x64(value, control);
/// <summary>
/// __m256i _mm256_permutevar8x32_epi32 (__m256i a, __m256i idx)
/// </summary>
- public static Vector256<int> PermuteVar8x32(Vector256<int> left, Vector256<int> mask) { throw new NotImplementedException(); }
+ public static Vector256<int> PermuteVar8x32(Vector256<int> left, Vector256<int> mask) => PermuteVar8x32(left, mask);
/// <summary>
/// __m256i _mm256_permutevar8x32_epi32 (__m256i a, __m256i idx)
/// </summary>
- public static Vector256<uint> PermuteVar8x32(Vector256<uint> left, Vector256<uint> mask) { throw new NotImplementedException(); }
+ public static Vector256<uint> PermuteVar8x32(Vector256<uint> left, Vector256<uint> mask) => PermuteVar8x32(left, mask);
/// <summary>
/// __m256 _mm256_permutevar8x32_ps (__m256 a, __m256i idx)
/// </summary>
- public static Vector256<float> PermuteVar8x32(Vector256<float> left, Vector256<float> mask) { throw new NotImplementedException(); }
+ public static Vector256<float> PermuteVar8x32(Vector256<float> left, Vector256<float> mask) => PermuteVar8x32(left, mask);
/// <summary>
/// __m256i _mm256_slli_epi16 (__m256i a, int imm8)
/// </summary>
- public static Vector256<short> ShiftLeftLogical(Vector256<short> value, byte count) { throw new NotImplementedException(); }
+ public static Vector256<short> ShiftLeftLogical(Vector256<short> value, byte count) => ShiftLeftLogical(value, count);
/// <summary>
/// __m256i _mm256_slli_epi16 (__m256i a, int imm8)
/// </summary>
- public static Vector256<ushort> ShiftLeftLogical(Vector256<ushort> value, byte count) { throw new NotImplementedException(); }
+ public static Vector256<ushort> ShiftLeftLogical(Vector256<ushort> value, byte count) => ShiftLeftLogical(value, count);
/// <summary>
/// __m256i _mm256_slli_epi32 (__m256i a, int imm8)
/// </summary>
- public static Vector256<int> ShiftLeftLogical(Vector256<int> value, byte count) { throw new NotImplementedException(); }
+ public static Vector256<int> ShiftLeftLogical(Vector256<int> value, byte count) => ShiftLeftLogical(value, count);
/// <summary>
/// __m256i _mm256_slli_epi32 (__m256i a, int imm8)
/// </summary>
- public static Vector256<uint> ShiftLeftLogical(Vector256<uint> value, byte count) { throw new NotImplementedException(); }
+ public static Vector256<uint> ShiftLeftLogical(Vector256<uint> value, byte count) => ShiftLeftLogical(value, count);
/// <summary>
/// __m256i _mm256_slli_epi64 (__m256i a, int imm8)
/// </summary>
- public static Vector256<long> ShiftLeftLogical(Vector256<long> value, byte count) { throw new NotImplementedException(); }
+ public static Vector256<long> ShiftLeftLogical(Vector256<long> value, byte count) => ShiftLeftLogical(value, count);
/// <summary>
/// __m256i _mm256_slli_epi64 (__m256i a, int imm8)
/// </summary>
- public static Vector256<ulong> ShiftLeftLogical(Vector256<ulong> value, byte count) { throw new NotImplementedException(); }
+ public static Vector256<ulong> ShiftLeftLogical(Vector256<ulong> value, byte count) => ShiftLeftLogical(value, count);
/// <summary>
/// __m256i _mm256_bslli_epi128 (__m256i a, const int imm8)
/// </summary>
- public static Vector256<sbyte> ShiftLeftLogical128BitLane(Vector256<sbyte> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector256<sbyte> ShiftLeftLogical128BitLane(Vector256<sbyte> value, byte numBytes) => ShiftLeftLogical128BitLane(value, numBytes);
/// <summary>
/// __m256i _mm256_bslli_epi128 (__m256i a, const int imm8)
/// </summary>
- public static Vector256<byte> ShiftLeftLogical128BitLane(Vector256<byte> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector256<byte> ShiftLeftLogical128BitLane(Vector256<byte> value, byte numBytes) => ShiftLeftLogical128BitLane(value, numBytes);
/// <summary>
/// __m256i _mm256_bslli_epi128 (__m256i a, const int imm8)
/// </summary>
- public static Vector256<short> ShiftLeftLogical128BitLane(Vector256<short> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector256<short> ShiftLeftLogical128BitLane(Vector256<short> value, byte numBytes) => ShiftLeftLogical128BitLane(value, numBytes);
/// <summary>
/// __m256i _mm256_bslli_epi128 (__m256i a, const int imm8)
/// </summary>
- public static Vector256<ushort> ShiftLeftLogical128BitLane(Vector256<ushort> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector256<ushort> ShiftLeftLogical128BitLane(Vector256<ushort> value, byte numBytes) => ShiftLeftLogical128BitLane(value, numBytes);
/// <summary>
/// __m256i _mm256_bslli_epi128 (__m256i a, const int imm8)
/// </summary>
- public static Vector256<int> ShiftLeftLogical128BitLane(Vector256<int> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector256<int> ShiftLeftLogical128BitLane(Vector256<int> value, byte numBytes) => ShiftLeftLogical128BitLane(value, numBytes);
/// <summary>
/// __m256i _mm256_bslli_epi128 (__m256i a, const int imm8)
/// </summary>
- public static Vector256<uint> ShiftLeftLogical128BitLane(Vector256<uint> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector256<uint> ShiftLeftLogical128BitLane(Vector256<uint> value, byte numBytes) => ShiftLeftLogical128BitLane(value, numBytes);
/// <summary>
/// __m256i _mm256_bslli_epi128 (__m256i a, const int imm8)
/// </summary>
- public static Vector256<long> ShiftLeftLogical128BitLane(Vector256<long> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector256<long> ShiftLeftLogical128BitLane(Vector256<long> value, byte numBytes) => ShiftLeftLogical128BitLane(value, numBytes);
/// <summary>
/// __m256i _mm256_bslli_epi128 (__m256i a, const int imm8)
/// </summary>
- public static Vector256<ulong> ShiftLeftLogical128BitLane(Vector256<ulong> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector256<ulong> ShiftLeftLogical128BitLane(Vector256<ulong> value, byte numBytes) => ShiftLeftLogical128BitLane(value, numBytes);
/// <summary>
/// __m256i _mm256_sllv_epi32 (__m256i a, __m256i count)
/// </summary>
- public static Vector256<int> ShiftLeftLogicalVariable(Vector256<int> value, Vector256<uint> count) { throw new NotImplementedException(); }
+ public static Vector256<int> ShiftLeftLogicalVariable(Vector256<int> value, Vector256<uint> count) => ShiftLeftLogicalVariable(value, count);
/// <summary>
/// __m256i _mm256_sllv_epi32 (__m256i a, __m256i count)
/// </summary>
- public static Vector256<uint> ShiftLeftLogicalVariable(Vector256<uint> value, Vector256<uint> count) { throw new NotImplementedException(); }
+ public static Vector256<uint> ShiftLeftLogicalVariable(Vector256<uint> value, Vector256<uint> count) => ShiftLeftLogicalVariable(value, count);
/// <summary>
/// __m256i _mm256_sllv_epi64 (__m256i a, __m256i count)
/// </summary>
- public static Vector256<long> ShiftLeftLogicalVariable(Vector256<long> value, Vector256<ulong> count) { throw new NotImplementedException(); }
+ public static Vector256<long> ShiftLeftLogicalVariable(Vector256<long> value, Vector256<ulong> count) => ShiftLeftLogicalVariable(value, count);
/// <summary>
/// __m256i _mm256_sllv_epi64 (__m256i a, __m256i count)
/// </summary>
- public static Vector256<ulong> ShiftLeftLogicalVariable(Vector256<ulong> value, Vector256<ulong> count) { throw new NotImplementedException(); }
+ public static Vector256<ulong> ShiftLeftLogicalVariable(Vector256<ulong> value, Vector256<ulong> count) => ShiftLeftLogicalVariable(value, count);
/// <summary>
/// __m256i _mm256_srai_epi16 (__m256i a, int imm8)
/// </summary>
- public static Vector256<short> ShiftRightArithmetic(Vector256<short> value, byte count) { throw new NotImplementedException(); }
+ public static Vector256<short> ShiftRightArithmetic(Vector256<short> value, byte count) => ShiftRightArithmetic(value, count);
/// <summary>
/// __m256i _mm256_srai_epi32 (__m256i a, int imm8)
/// </summary>
- public static Vector256<int> ShiftRightArithmetic(Vector256<int> value, byte count) { throw new NotImplementedException(); }
+ public static Vector256<int> ShiftRightArithmetic(Vector256<int> value, byte count) => ShiftRightArithmetic(value, count);
/// <summary>
/// __m256i _mm256_srav_epi32 (__m256i a, __m256i count)
/// </summary>
- public static Vector256<int> ShiftRightArithmeticVariable(Vector256<int> value, Vector256<uint> count) { throw new NotImplementedException(); }
+ public static Vector256<int> ShiftRightArithmeticVariable(Vector256<int> value, Vector256<uint> count) => ShiftRightArithmeticVariable(value, count);
/// <summary>
/// __m256i _mm256_srli_epi16 (__m256i a, int imm8)
/// </summary>
- public static Vector256<short> ShiftRightLogical(Vector256<short> value, byte count) { throw new NotImplementedException(); }
+ public static Vector256<short> ShiftRightLogical(Vector256<short> value, byte count) => ShiftRightLogical(value, count);
/// <summary>
/// __m256i _mm256_srli_epi16 (__m256i a, int imm8)
/// </summary>
- public static Vector256<ushort> ShiftRightLogical(Vector256<ushort> value, byte count) { throw new NotImplementedException(); }
+ public static Vector256<ushort> ShiftRightLogical(Vector256<ushort> value, byte count) => ShiftRightLogical(value, count);
/// <summary>
/// __m256i _mm256_srli_epi32 (__m256i a, int imm8)
/// </summary>
- public static Vector256<int> ShiftRightLogical(Vector256<int> value, byte count) { throw new NotImplementedException(); }
+ public static Vector256<int> ShiftRightLogical(Vector256<int> value, byte count) => ShiftRightLogical(value, count);
/// <summary>
/// __m256i _mm256_srli_epi32 (__m256i a, int imm8)
/// </summary>
- public static Vector256<uint> ShiftRightLogical(Vector256<uint> value, byte count) { throw new NotImplementedException(); }
+ public static Vector256<uint> ShiftRightLogical(Vector256<uint> value, byte count) => ShiftRightLogical(value, count);
/// <summary>
/// __m256i _mm256_srli_epi64 (__m256i a, int imm8)
/// </summary>
- public static Vector256<long> ShiftRightLogical(Vector256<long> value, byte count) { throw new NotImplementedException(); }
+ public static Vector256<long> ShiftRightLogical(Vector256<long> value, byte count) => ShiftRightLogical(value, count);
/// <summary>
/// __m256i _mm256_srli_epi64 (__m256i a, int imm8)
/// </summary>
- public static Vector256<ulong> ShiftRightLogical(Vector256<ulong> value, byte count) { throw new NotImplementedException(); }
+ public static Vector256<ulong> ShiftRightLogical(Vector256<ulong> value, byte count) => ShiftRightLogical(value, count);
/// <summary>
/// __m256i _mm256_bsrli_epi128 (__m256i a, const int imm8)
/// </summary>
- public static Vector256<sbyte> ShiftRightLogical128BitLane(Vector256<sbyte> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector256<sbyte> ShiftRightLogical128BitLane(Vector256<sbyte> value, byte numBytes) => ShiftRightLogical128BitLane(value, numBytes);
/// <summary>
/// __m256i _mm256_bsrli_epi128 (__m256i a, const int imm8)
/// </summary>
- public static Vector256<byte> ShiftRightLogical128BitLane(Vector256<byte> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector256<byte> ShiftRightLogical128BitLane(Vector256<byte> value, byte numBytes) => ShiftRightLogical128BitLane(value, numBytes);
/// <summary>
/// __m256i _mm256_bsrli_epi128 (__m256i a, const int imm8)
/// </summary>
- public static Vector256<short> ShiftRightLogical128BitLane(Vector256<short> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector256<short> ShiftRightLogical128BitLane(Vector256<short> value, byte numBytes) => ShiftRightLogical128BitLane(value, numBytes);
/// <summary>
/// __m256i _mm256_bsrli_epi128 (__m256i a, const int imm8)
/// </summary>
- public static Vector256<ushort> ShiftRightLogical128BitLane(Vector256<ushort> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector256<ushort> ShiftRightLogical128BitLane(Vector256<ushort> value, byte numBytes) => ShiftRightLogical128BitLane(value, numBytes);
/// <summary>
/// __m256i _mm256_bsrli_epi128 (__m256i a, const int imm8)
/// </summary>
- public static Vector256<int> ShiftRightLogical128BitLane(Vector256<int> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector256<int> ShiftRightLogical128BitLane(Vector256<int> value, byte numBytes) => ShiftRightLogical128BitLane(value, numBytes);
/// <summary>
/// __m256i _mm256_bsrli_epi128 (__m256i a, const int imm8)
/// </summary>
- public static Vector256<uint> ShiftRightLogical128BitLane(Vector256<uint> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector256<uint> ShiftRightLogical128BitLane(Vector256<uint> value, byte numBytes) => ShiftRightLogical128BitLane(value, numBytes);
/// <summary>
/// __m256i _mm256_bsrli_epi128 (__m256i a, const int imm8)
/// </summary>
- public static Vector256<long> ShiftRightLogical128BitLane(Vector256<long> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector256<long> ShiftRightLogical128BitLane(Vector256<long> value, byte numBytes) => ShiftRightLogical128BitLane(value, numBytes);
/// <summary>
/// __m256i _mm256_bsrli_epi128 (__m256i a, const int imm8)
/// </summary>
- public static Vector256<ulong> ShiftRightLogical128BitLane(Vector256<ulong> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector256<ulong> ShiftRightLogical128BitLane(Vector256<ulong> value, byte numBytes) => ShiftRightLogical128BitLane(value, numBytes);
/// <summary>
/// __m256i _mm256_srlv_epi32 (__m256i a, __m256i count)
/// </summary>
- public static Vector256<int> ShiftRightLogicalVariable(Vector256<int> value, Vector256<uint> count) { throw new NotImplementedException(); }
+ public static Vector256<int> ShiftRightLogicalVariable(Vector256<int> value, Vector256<uint> count) => ShiftRightLogicalVariable(value, count);
/// <summary>
/// __m256i _mm256_srlv_epi32 (__m256i a, __m256i count)
/// </summary>
- public static Vector256<uint> ShiftRightLogicalVariable(Vector256<uint> value, Vector256<uint> count) { throw new NotImplementedException(); }
+ public static Vector256<uint> ShiftRightLogicalVariable(Vector256<uint> value, Vector256<uint> count) => ShiftRightLogicalVariable(value, count);
/// <summary>
/// __m256i _mm256_srlv_epi64 (__m256i a, __m256i count)
/// </summary>
- public static Vector256<long> ShiftRightLogicalVariable(Vector256<long> value, Vector256<ulong> count) { throw new NotImplementedException(); }
+ public static Vector256<long> ShiftRightLogicalVariable(Vector256<long> value, Vector256<ulong> count) => ShiftRightLogicalVariable(value, count);
/// <summary>
/// __m256i _mm256_srlv_epi64 (__m256i a, __m256i count)
/// </summary>
- public static Vector256<ulong> ShiftRightLogicalVariable(Vector256<ulong> value, Vector256<ulong> count) { throw new NotImplementedException(); }
+ public static Vector256<ulong> ShiftRightLogicalVariable(Vector256<ulong> value, Vector256<ulong> count) => ShiftRightLogicalVariable(value, count);
/// <summary>
/// __m256i _mm256_shuffle_epi8 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<sbyte> Shuffle(Vector256<sbyte> value, Vector256<sbyte> mask) { throw new NotImplementedException(); }
+ public static Vector256<sbyte> Shuffle(Vector256<sbyte> value, Vector256<sbyte> mask) => Shuffle(value, mask);
/// <summary>
/// __m256i _mm256_shuffle_epi8 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<byte> Shuffle(Vector256<byte> value, Vector256<byte> mask) { throw new NotImplementedException(); }
+ public static Vector256<byte> Shuffle(Vector256<byte> value, Vector256<byte> mask) => Shuffle(value, mask);
/// <summary>
/// __m256i _mm256_shuffle_epi32 (__m256i a, const int imm8)
/// </summary>
- public static Vector256<int> Shuffle(Vector256<int> value, byte control) { throw new NotImplementedException(); }
+ public static Vector256<int> Shuffle(Vector256<int> value, byte control) => Shuffle(value, control);
/// <summary>
/// __m256i _mm256_shuffle_epi32 (__m256i a, const int imm8)
/// </summary>
- public static Vector256<uint> Shuffle(Vector256<uint> value, byte control) { throw new NotImplementedException(); }
+ public static Vector256<uint> Shuffle(Vector256<uint> value, byte control) => Shuffle(value, control);
/// <summary>
/// __m256i _mm256_shufflehi_epi16 (__m256i a, const int imm8)
/// </summary>
- public static Vector256<short> ShuffleHigh(Vector256<short> value, byte control) { throw new NotImplementedException(); }
+ public static Vector256<short> ShuffleHigh(Vector256<short> value, byte control) => ShuffleHigh(value, control);
/// <summary>
/// __m256i _mm256_shufflehi_epi16 (__m256i a, const int imm8)
/// </summary>
- public static Vector256<ushort> ShuffleHigh(Vector256<ushort> value, byte control) { throw new NotImplementedException(); }
+ public static Vector256<ushort> ShuffleHigh(Vector256<ushort> value, byte control) => ShuffleHigh(value, control);
/// <summary>
/// __m256i _mm256_shufflelo_epi16 (__m256i a, const int imm8)
/// </summary>
- public static Vector256<short> ShuffleLow(Vector256<short> value, byte control) { throw new NotImplementedException(); }
+ public static Vector256<short> ShuffleLow(Vector256<short> value, byte control) => ShuffleLow(value, control);
/// <summary>
/// __m256i _mm256_shufflelo_epi16 (__m256i a, const int imm8)
/// </summary>
- public static Vector256<ushort> ShuffleLow(Vector256<ushort> value, byte control) { throw new NotImplementedException(); }
+ public static Vector256<ushort> ShuffleLow(Vector256<ushort> value, byte control) => ShuffleLow(value, control);
/// <summary>
/// __m256i _mm256_sign_epi8 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<sbyte> Sign(Vector256<sbyte> left, Vector256<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector256<sbyte> Sign(Vector256<sbyte> left, Vector256<sbyte> right) => Sign(left, right);
/// <summary>
/// __m256i _mm256_sign_epi16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<short> Sign(Vector256<short> left, Vector256<short> right) { throw new NotImplementedException(); }
+ public static Vector256<short> Sign(Vector256<short> left, Vector256<short> right) => Sign(left, right);
/// <summary>
/// __m256i _mm256_sign_epi32 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<int> Sign(Vector256<int> left, Vector256<int> right) { throw new NotImplementedException(); }
+ public static Vector256<int> Sign(Vector256<int> left, Vector256<int> right) => Sign(left, right);
/// <summary>
/// __m256i _mm256_sub_epi8 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<sbyte> Subtract(Vector256<sbyte> left, Vector256<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector256<sbyte> Subtract(Vector256<sbyte> left, Vector256<sbyte> right) => Subtract(left, right);
/// <summary>
/// __m256i _mm256_sub_epi8 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<byte> Subtract(Vector256<byte> left, Vector256<byte> right) { throw new NotImplementedException(); }
+ public static Vector256<byte> Subtract(Vector256<byte> left, Vector256<byte> right) => Subtract(left, right);
/// <summary>
/// __m256i _mm256_sub_epi16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<short> Subtract(Vector256<short> left, Vector256<short> right) { throw new NotImplementedException(); }
+ public static Vector256<short> Subtract(Vector256<short> left, Vector256<short> right) => Subtract(left, right);
/// <summary>
/// __m256i _mm256_sub_epi16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<ushort> Subtract(Vector256<ushort> left, Vector256<ushort> right) { throw new NotImplementedException(); }
+ public static Vector256<ushort> Subtract(Vector256<ushort> left, Vector256<ushort> right) => Subtract(left, right);
/// <summary>
/// __m256i _mm256_sub_epi32 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<int> Subtract(Vector256<int> left, Vector256<int> right) { throw new NotImplementedException(); }
+ public static Vector256<int> Subtract(Vector256<int> left, Vector256<int> right) => Subtract(left, right);
/// <summary>
/// __m256i _mm256_sub_epi32 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<uint> Subtract(Vector256<uint> left, Vector256<uint> right) { throw new NotImplementedException(); }
+ public static Vector256<uint> Subtract(Vector256<uint> left, Vector256<uint> right) => Subtract(left, right);
/// <summary>
/// __m256i _mm256_sub_epi64 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<long> Subtract(Vector256<long> left, Vector256<long> right) { throw new NotImplementedException(); }
+ public static Vector256<long> Subtract(Vector256<long> left, Vector256<long> right) => Subtract(left, right);
/// <summary>
/// __m256i _mm256_sub_epi64 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<ulong> Subtract(Vector256<ulong> left, Vector256<ulong> right) { throw new NotImplementedException(); }
+ public static Vector256<ulong> Subtract(Vector256<ulong> left, Vector256<ulong> right) => Subtract(left, right);
/// <summary>
/// __m256i _mm256_subs_epi8 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<sbyte> SubtractSaturate(Vector256<sbyte> left, Vector256<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector256<sbyte> SubtractSaturate(Vector256<sbyte> left, Vector256<sbyte> right) => SubtractSaturate(left, right);
/// <summary>
/// __m256i _mm256_subs_epi16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<short> SubtractSaturate(Vector256<short> left, Vector256<short> right) { throw new NotImplementedException(); }
+ public static Vector256<short> SubtractSaturate(Vector256<short> left, Vector256<short> right) => SubtractSaturate(left, right);
/// <summary>
/// __m256i _mm256_subs_epu8 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<byte> SubtractSaturate(Vector256<byte> left, Vector256<byte> right) { throw new NotImplementedException(); }
+ public static Vector256<byte> SubtractSaturate(Vector256<byte> left, Vector256<byte> right) => SubtractSaturate(left, right);
/// <summary>
/// __m256i _mm256_subs_epu16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<ushort> SubtractSaturate(Vector256<ushort> left, Vector256<ushort> right) { throw new NotImplementedException(); }
+ public static Vector256<ushort> SubtractSaturate(Vector256<ushort> left, Vector256<ushort> right) => SubtractSaturate(left, right);
/// <summary>
/// __m256i _mm256_sad_epu8 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<ulong> SumAbsoluteDifferences(Vector256<byte> left, Vector256<byte> right) { throw new NotImplementedException(); }
+ public static Vector256<ulong> SumAbsoluteDifferences(Vector256<byte> left, Vector256<byte> right) => SumAbsoluteDifferences(left, right);
/// <summary>
/// __m256i _mm256_unpackhi_epi8 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<sbyte> UnpackHigh(Vector256<sbyte> left, Vector256<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector256<sbyte> UnpackHigh(Vector256<sbyte> left, Vector256<sbyte> right) => UnpackHigh(left, right);
/// <summary>
/// __m256i _mm256_unpackhi_epi8 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<byte> UnpackHigh(Vector256<byte> left, Vector256<byte> right) { throw new NotImplementedException(); }
+ public static Vector256<byte> UnpackHigh(Vector256<byte> left, Vector256<byte> right) => UnpackHigh(left, right);
/// <summary>
/// __m256i _mm256_unpackhi_epi16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<short> UnpackHigh(Vector256<short> left, Vector256<short> right) { throw new NotImplementedException(); }
+ public static Vector256<short> UnpackHigh(Vector256<short> left, Vector256<short> right) => UnpackHigh(left, right);
/// <summary>
/// __m256i _mm256_unpackhi_epi16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<ushort> UnpackHigh(Vector256<ushort> left, Vector256<ushort> right) { throw new NotImplementedException(); }
+ public static Vector256<ushort> UnpackHigh(Vector256<ushort> left, Vector256<ushort> right) => UnpackHigh(left, right);
/// <summary>
/// __m256i _mm256_unpackhi_epi32 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<int> UnpackHigh(Vector256<int> left, Vector256<int> right) { throw new NotImplementedException(); }
+ public static Vector256<int> UnpackHigh(Vector256<int> left, Vector256<int> right) => UnpackHigh(left, right);
/// <summary>
/// __m256i _mm256_unpackhi_epi32 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<uint> UnpackHigh(Vector256<uint> left, Vector256<uint> right) { throw new NotImplementedException(); }
+ public static Vector256<uint> UnpackHigh(Vector256<uint> left, Vector256<uint> right) => UnpackHigh(left, right);
/// <summary>
/// __m256i _mm256_unpackhi_epi64 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<long> UnpackHigh(Vector256<long> left, Vector256<long> right) { throw new NotImplementedException(); }
+ public static Vector256<long> UnpackHigh(Vector256<long> left, Vector256<long> right) => UnpackHigh(left, right);
/// <summary>
/// __m256i _mm256_unpackhi_epi64 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<ulong> UnpackHigh(Vector256<ulong> left, Vector256<ulong> right) { throw new NotImplementedException(); }
+ public static Vector256<ulong> UnpackHigh(Vector256<ulong> left, Vector256<ulong> right) => UnpackHigh(left, right);
/// <summary>
/// __m256i _mm256_unpacklo_epi8 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<sbyte> UnpackLow(Vector256<sbyte> left, Vector256<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector256<sbyte> UnpackLow(Vector256<sbyte> left, Vector256<sbyte> right) => UnpackLow(left, right);
/// <summary>
/// __m256i _mm256_unpacklo_epi8 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<byte> UnpackLow(Vector256<byte> left, Vector256<byte> right) { throw new NotImplementedException(); }
+ public static Vector256<byte> UnpackLow(Vector256<byte> left, Vector256<byte> right) => UnpackLow(left, right);
/// <summary>
/// __m256i _mm256_unpacklo_epi16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<short> UnpackLow(Vector256<short> left, Vector256<short> right) { throw new NotImplementedException(); }
+ public static Vector256<short> UnpackLow(Vector256<short> left, Vector256<short> right) => UnpackLow(left, right);
/// <summary>
/// __m256i _mm256_unpacklo_epi16 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<ushort> UnpackLow(Vector256<ushort> left, Vector256<ushort> right) { throw new NotImplementedException(); }
+ public static Vector256<ushort> UnpackLow(Vector256<ushort> left, Vector256<ushort> right) => UnpackLow(left, right);
/// <summary>
/// __m256i _mm256_unpacklo_epi32 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<int> UnpackLow(Vector256<int> left, Vector256<int> right) { throw new NotImplementedException(); }
+ public static Vector256<int> UnpackLow(Vector256<int> left, Vector256<int> right) => UnpackLow(left, right);
/// <summary>
/// __m256i _mm256_unpacklo_epi32 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<uint> UnpackLow(Vector256<uint> left, Vector256<uint> right) { throw new NotImplementedException(); }
+ public static Vector256<uint> UnpackLow(Vector256<uint> left, Vector256<uint> right) => UnpackLow(left, right);
/// <summary>
/// __m256i _mm256_unpacklo_epi64 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<long> UnpackLow(Vector256<long> left, Vector256<long> right) { throw new NotImplementedException(); }
+ public static Vector256<long> UnpackLow(Vector256<long> left, Vector256<long> right) => UnpackLow(left, right);
/// <summary>
/// __m256i _mm256_unpacklo_epi64 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<ulong> UnpackLow(Vector256<ulong> left, Vector256<ulong> right) { throw new NotImplementedException(); }
+ public static Vector256<ulong> UnpackLow(Vector256<ulong> left, Vector256<ulong> right) => UnpackLow(left, right);
/// <summary>
/// __m256i _mm256_xor_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<sbyte> Xor(Vector256<sbyte> left, Vector256<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector256<sbyte> Xor(Vector256<sbyte> left, Vector256<sbyte> right) => Xor(left, right);
/// <summary>
/// __m256i _mm256_xor_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<byte> Xor(Vector256<byte> left, Vector256<byte> right) { throw new NotImplementedException(); }
+ public static Vector256<byte> Xor(Vector256<byte> left, Vector256<byte> right) => Xor(left, right);
/// <summary>
/// __m256i _mm256_xor_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<short> Xor(Vector256<short> left, Vector256<short> right) { throw new NotImplementedException(); }
+ public static Vector256<short> Xor(Vector256<short> left, Vector256<short> right) => Xor(left, right);
/// <summary>
/// __m256i _mm256_xor_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<ushort> Xor(Vector256<ushort> left, Vector256<ushort> right) { throw new NotImplementedException(); }
+ public static Vector256<ushort> Xor(Vector256<ushort> left, Vector256<ushort> right) => Xor(left, right);
/// <summary>
/// __m256i _mm256_xor_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<int> Xor(Vector256<int> left, Vector256<int> right) { throw new NotImplementedException(); }
+ public static Vector256<int> Xor(Vector256<int> left, Vector256<int> right) => Xor(left, right);
/// <summary>
/// __m256i _mm256_xor_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<uint> Xor(Vector256<uint> left, Vector256<uint> right) { throw new NotImplementedException(); }
+ public static Vector256<uint> Xor(Vector256<uint> left, Vector256<uint> right) => Xor(left, right);
/// <summary>
/// __m256i _mm256_xor_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<long> Xor(Vector256<long> left, Vector256<long> right) { throw new NotImplementedException(); }
+ public static Vector256<long> Xor(Vector256<long> left, Vector256<long> right) => Xor(left, right);
/// <summary>
/// __m256i _mm256_xor_si256 (__m256i a, __m256i b)
/// </summary>
- public static Vector256<ulong> Xor(Vector256<ulong> left, Vector256<ulong> right) { throw new NotImplementedException(); }
+ public static Vector256<ulong> Xor(Vector256<ulong> left, Vector256<ulong> right) => Xor(left, right);
}
}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Bmi1.PlatformNotSupported.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Bmi1.PlatformNotSupported.cs
new file mode 100644
index 0000000000..eb2e30a2c1
--- /dev/null
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Bmi1.PlatformNotSupported.cs
@@ -0,0 +1,80 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.Intrinsics;
+
+namespace System.Runtime.Intrinsics.X86
+{
+ /// <summary>
+ /// This class provides access to Intel BMI1 hardware instructions via intrinsics
+ /// </summary>
+ [CLSCompliant(false)]
+ public static class Bmi1
+ {
+ public static bool IsSupported { get { return false; } }
+
+ /// <summary>
+ /// unsigned int _andn_u32 (unsigned int a, unsigned int b)
+ /// </summary>
+ public static uint AndNot(uint left, uint right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// unsigned __int64 _andn_u64 (unsigned __int64 a, unsigned __int64 b)
+ /// </summary>
+ public static ulong AndNot(ulong left, ulong right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// unsigned int _bextr_u32 (unsigned int a, unsigned int start, unsigned int len)
+ /// </summary>
+ public static uint BitFieldExtract(uint value, uint start, uint length) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// unsigned __int64 _bextr_u64 (unsigned __int64 a, unsigned int start, unsigned int len)
+ /// </summary>
+ public static ulong BitFieldExtract(ulong value, ulong start, ulong length) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// unsigned int _bextr2_u32 (unsigned int a, unsigned int control)
+ /// </summary>
+ public static uint BitFieldExtract(uint value, uint control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// unsigned __int64 _bextr2_u64 (unsigned __int64 a, unsigned __int64 control)
+ /// </summary>
+ public static ulong BitFieldExtract(ulong value, ulong control) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// unsigned int _blsi_u32 (unsigned int a)
+ /// </summary>
+ public static uint ExtractLowestSetBit(uint value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// unsigned __int64 _blsi_u64 (unsigned __int64 a)
+ /// </summary>
+ public static ulong ExtractLowestSetBit(ulong value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// unsigned int _blsmsk_u32 (unsigned int a)
+ /// </summary>
+ public static uint GetMaskUptoLowestSetBit(uint value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// unsigned __int64 _blsmsk_u64 (unsigned __int64 a)
+ /// </summary>
+ public static ulong GetMaskUptoLowestSetBit(ulong value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// unsigned int _blsr_u32 (unsigned int a)
+ /// </summary>
+ public static uint ResetLowestSetBit(uint value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// unsigned __int64 _blsr_u64 (unsigned __int64 a)
+ /// </summary>
+ public static ulong ResetLowestSetBit(ulong value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_tzcnt_32 (unsigned int a)
+ /// </summary>
+ public static uint TrailingZeroCount(uint value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __int64 _mm_tzcnt_64 (unsigned __int64 a)
+ /// </summary>
+ public static ulong TrailingZeroCount(ulong value) { throw new PlatformNotSupportedException(); }
+ }
+}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Bmi1.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Bmi1.cs
index a2bfcffedc..628c83b6cd 100644
--- a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Bmi1.cs
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Bmi1.cs
@@ -13,68 +13,68 @@ namespace System.Runtime.Intrinsics.X86
[CLSCompliant(false)]
public static class Bmi1
{
- public static bool IsSupported { get { return false; } }
+ public static bool IsSupported { get => IsSupported; }
/// <summary>
/// unsigned int _andn_u32 (unsigned int a, unsigned int b)
/// </summary>
- public static uint AndNot(uint left, uint right) { throw new NotImplementedException(); }
+ public static uint AndNot(uint left, uint right) => AndNot(left, right);
/// <summary>
/// unsigned __int64 _andn_u64 (unsigned __int64 a, unsigned __int64 b)
/// </summary>
- public static ulong AndNot(ulong left, ulong right) { throw new NotImplementedException(); }
+ public static ulong AndNot(ulong left, ulong right) => AndNot(left, right);
/// <summary>
/// unsigned int _bextr_u32 (unsigned int a, unsigned int start, unsigned int len)
/// </summary>
- public static uint BitFieldExtract(uint value, uint start, uint length) { throw new NotImplementedException(); }
+ public static uint BitFieldExtract(uint value, uint start, uint length) => BitFieldExtract(value, start, length);
/// <summary>
/// unsigned __int64 _bextr_u64 (unsigned __int64 a, unsigned int start, unsigned int len)
/// </summary>
- public static ulong BitFieldExtract(ulong value, ulong start, ulong length) { throw new NotImplementedException(); }
+ public static ulong BitFieldExtract(ulong value, ulong start, ulong length) => BitFieldExtract(value, start, length);
/// <summary>
/// unsigned int _bextr2_u32 (unsigned int a, unsigned int control)
/// </summary>
- public static uint BitFieldExtract(uint value, uint control) { throw new NotImplementedException(); }
+ public static uint BitFieldExtract(uint value, uint control) => BitFieldExtract(value, control);
/// <summary>
/// unsigned __int64 _bextr2_u64 (unsigned __int64 a, unsigned __int64 control)
/// </summary>
- public static ulong BitFieldExtract(ulong value, ulong control) { throw new NotImplementedException(); }
+ public static ulong BitFieldExtract(ulong value, ulong control) => BitFieldExtract(value, control);
/// <summary>
/// unsigned int _blsi_u32 (unsigned int a)
/// </summary>
- public static uint ExtractLowestSetBit(uint value) { throw new NotImplementedException(); }
+ public static uint ExtractLowestSetBit(uint value) => ExtractLowestSetBit(value);
/// <summary>
/// unsigned __int64 _blsi_u64 (unsigned __int64 a)
/// </summary>
- public static ulong ExtractLowestSetBit(ulong value) { throw new NotImplementedException(); }
+ public static ulong ExtractLowestSetBit(ulong value) => ExtractLowestSetBit(value);
/// <summary>
/// unsigned int _blsmsk_u32 (unsigned int a)
/// </summary>
- public static uint GetMaskUptoLowestSetBit(uint value) { throw new NotImplementedException(); }
+ public static uint GetMaskUptoLowestSetBit(uint value) => GetMaskUptoLowestSetBit(value);
/// <summary>
/// unsigned __int64 _blsmsk_u64 (unsigned __int64 a)
/// </summary>
- public static ulong GetMaskUptoLowestSetBit(ulong value) { throw new NotImplementedException(); }
+ public static ulong GetMaskUptoLowestSetBit(ulong value) => GetMaskUptoLowestSetBit(value);
/// <summary>
/// unsigned int _blsr_u32 (unsigned int a)
/// </summary>
- public static uint ResetLowestSetBit(uint value) { throw new NotImplementedException(); }
+ public static uint ResetLowestSetBit(uint value) => ResetLowestSetBit(value);
/// <summary>
/// unsigned __int64 _blsr_u64 (unsigned __int64 a)
/// </summary>
- public static ulong ResetLowestSetBit(ulong value) { throw new NotImplementedException(); }
+ public static ulong ResetLowestSetBit(ulong value) => ResetLowestSetBit(value);
/// <summary>
/// int _mm_tzcnt_32 (unsigned int a)
/// </summary>
- public static uint TrailingZeroCount(uint value) { throw new NotImplementedException(); }
+ public static uint TrailingZeroCount(uint value) => TrailingZeroCount(value);
/// <summary>
/// __int64 _mm_tzcnt_64 (unsigned __int64 a)
/// </summary>
- public static ulong TrailingZeroCount(ulong value) { throw new NotImplementedException(); }
+ public static ulong TrailingZeroCount(ulong value) => TrailingZeroCount(value);
}
}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Bmi2.PlatformNotSupported.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Bmi2.PlatformNotSupported.cs
new file mode 100644
index 0000000000..510186a2d1
--- /dev/null
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Bmi2.PlatformNotSupported.cs
@@ -0,0 +1,54 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.Intrinsics;
+
+namespace System.Runtime.Intrinsics.X86
+{
+ /// <summary>
+ /// This class provides access to Intel BMI2 hardware instructions via intrinsics
+ /// </summary>
+ [CLSCompliant(false)]
+ public static class Bmi2
+ {
+ public static bool IsSupported { get { return false; } }
+
+ /// <summary>
+ /// unsigned int _bzhi_u32 (unsigned int a, unsigned int index)
+ /// </summary>
+ public static uint ZeroHighBits(uint value, uint index) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// unsigned __int64 _bzhi_u64 (unsigned __int64 a, unsigned int index)
+ /// </summary>
+ public static ulong ZeroHighBits(ulong value, ulong index) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// unsigned int _mulx_u32 (unsigned int a, unsigned int b, unsigned int* hi)
+ /// </summary>
+ public static unsafe uint MultiplyNoFlags(uint left, uint right, uint* high) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// unsigned __int64 _mulx_u64 (unsigned __int64 a, unsigned __int64 b, unsigned __int64* hi)
+ /// </summary>
+ public static unsafe ulong MultiplyNoFlags(ulong left, ulong right, ulong* high) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// unsigned int _pdep_u32 (unsigned int a, unsigned int mask)
+ /// </summary>
+ public static uint ParallelBitDeposit(uint value, uint mask) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// unsigned __int64 _pdep_u64 (unsigned __int64 a, unsigned __int64 mask)
+ /// </summary>
+ public static ulong ParallelBitDeposit(ulong value, ulong mask) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// unsigned int _pext_u32 (unsigned int a, unsigned int mask)
+ /// </summary>
+ public static uint ParallelBitExtract(uint value, uint mask) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// unsigned __int64 _pext_u64 (unsigned __int64 a, unsigned __int64 mask)
+ /// </summary>
+ public static ulong ParallelBitExtract(ulong value, ulong mask) { throw new PlatformNotSupportedException(); }
+ }
+}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Bmi2.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Bmi2.cs
index a9a73de926..c6dfa72f44 100644
--- a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Bmi2.cs
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Bmi2.cs
@@ -13,42 +13,42 @@ namespace System.Runtime.Intrinsics.X86
[CLSCompliant(false)]
public static class Bmi2
{
- public static bool IsSupported { get { return false; } }
+ public static bool IsSupported { get => IsSupported; }
/// <summary>
/// unsigned int _bzhi_u32 (unsigned int a, unsigned int index)
/// </summary>
- public static uint ZeroHighBits(uint value, uint index) { throw new NotImplementedException(); }
+ public static uint ZeroHighBits(uint value, uint index) => ZeroHighBits(value, index);
/// <summary>
/// unsigned __int64 _bzhi_u64 (unsigned __int64 a, unsigned int index)
/// </summary>
- public static ulong ZeroHighBits(ulong value, ulong index) { throw new NotImplementedException(); }
+ public static ulong ZeroHighBits(ulong value, ulong index) => ZeroHighBits(value, index);
/// <summary>
/// unsigned int _mulx_u32 (unsigned int a, unsigned int b, unsigned int* hi)
/// </summary>
- public static unsafe uint MultiplyNoFlags(uint left, uint right, uint* high) { throw new NotImplementedException(); }
+ public static unsafe uint MultiplyNoFlags(uint left, uint right, uint* high) => MultiplyNoFlags(left, right, high);
/// <summary>
/// unsigned __int64 _mulx_u64 (unsigned __int64 a, unsigned __int64 b, unsigned __int64* hi)
/// </summary>
- public static unsafe ulong MultiplyNoFlags(ulong left, ulong right, ulong* high) { throw new NotImplementedException(); }
+ public static unsafe ulong MultiplyNoFlags(ulong left, ulong right, ulong* high) => MultiplyNoFlags(left, right, high);
/// <summary>
/// unsigned int _pdep_u32 (unsigned int a, unsigned int mask)
/// </summary>
- public static uint ParallelBitDeposit(uint value, uint mask) { throw new NotImplementedException(); }
+ public static uint ParallelBitDeposit(uint value, uint mask) => ParallelBitDeposit(value, mask);
/// <summary>
/// unsigned __int64 _pdep_u64 (unsigned __int64 a, unsigned __int64 mask)
/// </summary>
- public static ulong ParallelBitDeposit(ulong value, ulong mask) { throw new NotImplementedException(); }
+ public static ulong ParallelBitDeposit(ulong value, ulong mask) => ParallelBitDeposit(value, mask);
/// <summary>
/// unsigned int _pext_u32 (unsigned int a, unsigned int mask)
/// </summary>
- public static uint ParallelBitExtract(uint value, uint mask) { throw new NotImplementedException(); }
+ public static uint ParallelBitExtract(uint value, uint mask) => ParallelBitExtract(value, mask);
/// <summary>
/// unsigned __int64 _pext_u64 (unsigned __int64 a, unsigned __int64 mask)
/// </summary>
- public static ulong ParallelBitExtract(ulong value, ulong mask) { throw new NotImplementedException(); }
+ public static ulong ParallelBitExtract(ulong value, ulong mask) => ParallelBitExtract(value, mask);
}
}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Fma.PlatformNotSupported.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Fma.PlatformNotSupported.cs
new file mode 100644
index 0000000000..c3adf712f8
--- /dev/null
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Fma.PlatformNotSupported.cs
@@ -0,0 +1,119 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.Intrinsics;
+
+namespace System.Runtime.Intrinsics.X86
+{
+ /// <summary>
+ /// This class provides access to Intel FMA hardware instructions via intrinsics
+ /// </summary>
+ public static class Fma
+ {
+ public static bool IsSupported { get { return false; } }
+
+ /// <summary>
+ /// __m128 _mm_fmadd_ps (__m128 a, __m128 b, __m128 c)
+ /// </summary>
+ public static Vector128<float> MultiplyAdd(Vector128<float> a, Vector128<float> b, Vector128<float> c) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_fmadd_pd (__m128d a, __m128d b, __m128d c)
+ /// </summary>
+ public static Vector128<double> MultiplyAdd(Vector128<double> a, Vector128<double> b, Vector128<double> c) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256 _mm256_fmadd_ps (__m256 a, __m256 b, __m256 c)
+ /// </summary>
+ public static Vector256<float> MultiplyAdd(Vector256<float> a, Vector256<float> b, Vector256<float> c) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_fmadd_pd (__m256d a, __m256d b, __m256d c)
+ /// </summary>
+ public static Vector256<double> MultiplyAdd(Vector256<double> a, Vector256<double> b, Vector256<double> c) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_fmaddsub_ps (__m128 a, __m128 b, __m128 c)
+ /// </summary>
+ public static Vector128<float> MultiplyAddSubtract(Vector128<float> a, Vector128<float> b, Vector128<float> c) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_fmaddsub_pd (__m128d a, __m128d b, __m128d c)
+ /// </summary>
+ public static Vector128<double> MultiplyAddSubtract(Vector128<double> a, Vector128<double> b, Vector128<double> c) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256 _mm256_fmaddsub_ps (__m256 a, __m256 b, __m256 c)
+ /// </summary>
+ public static Vector256<float> MultiplyAddSubtract(Vector256<float> a, Vector256<float> b, Vector256<float> c) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_fmaddsub_pd (__m256d a, __m256d b, __m256d c)
+ /// </summary>
+ public static Vector256<double> MultiplyAddSubtract(Vector256<double> a, Vector256<double> b, Vector256<double> c) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_fmsub_ps (__m128 a, __m128 b, __m128 c)
+ /// </summary>
+ public static Vector128<float> MultiplySubtract(Vector128<float> a, Vector128<float> b, Vector128<float> c) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_fmsub_pd (__m128d a, __m128d b, __m128d c)
+ /// </summary>
+ public static Vector128<double> MultiplySubtract(Vector128<double> a, Vector128<double> b, Vector128<double> c) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256 _mm256_fmsub_ps (__m256 a, __m256 b, __m256 c)
+ /// </summary>
+ public static Vector256<float> MultiplySubtract(Vector256<float> a, Vector256<float> b, Vector256<float> c) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_fmsub_pd (__m256d a, __m256d b, __m256d c)
+ /// </summary>
+ public static Vector256<double> MultiplySubtract(Vector256<double> a, Vector256<double> b, Vector256<double> c) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_fmsubadd_ps (__m128 a, __m128 b, __m128 c)
+ /// </summary>
+ public static Vector128<float> MultiplySubtractAdd(Vector128<float> a, Vector128<float> b, Vector128<float> c) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_fmsubadd_pd (__m128d a, __m128d b, __m128d c)
+ /// </summary>
+ public static Vector128<double> MultiplySubtractAdd(Vector128<double> a, Vector128<double> b, Vector128<double> c) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256 _mm256_fmsubadd_ps (__m256 a, __m256 b, __m256 c)
+ /// </summary>
+ public static Vector256<float> MultiplySubtractAdd(Vector256<float> a, Vector256<float> b, Vector256<float> c) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_fmsubadd_pd (__m256d a, __m256d b, __m256d c)
+ /// </summary>
+ public static Vector256<double> MultiplySubtractAdd(Vector256<double> a, Vector256<double> b, Vector256<double> c) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_fnmadd_ps (__m128 a, __m128 b, __m128 c)
+ /// </summary>
+ public static Vector128<float> MultiplyAddNegated(Vector128<float> a, Vector128<float> b, Vector128<float> c) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_fnmadd_pd (__m128d a, __m128d b, __m128d c)
+ /// </summary>
+ public static Vector128<double> MultiplyAddNegated(Vector128<double> a, Vector128<double> b, Vector128<double> c) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256 _mm256_fnmadd_ps (__m256 a, __m256 b, __m256 c)
+ /// </summary>
+ public static Vector256<float> MultiplyAddNegated(Vector256<float> a, Vector256<float> b, Vector256<float> c) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_fnmadd_pd (__m256d a, __m256d b, __m256d c)
+ /// </summary>
+ public static Vector256<double> MultiplyAddNegated(Vector256<double> a, Vector256<double> b, Vector256<double> c) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_fnmsub_ps (__m128 a, __m128 b, __m128 c)
+ /// </summary>
+ public static Vector128<float> MultiplySubtractNegated(Vector128<float> a, Vector128<float> b, Vector128<float> c) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_fnmsub_pd (__m128d a, __m128d b, __m128d c)
+ /// </summary>
+ public static Vector128<double> MultiplySubtractNegated(Vector128<double> a, Vector128<double> b, Vector128<double> c) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256 _mm256_fnmsub_ps (__m256 a, __m256 b, __m256 c)
+ /// </summary>
+ public static Vector256<float> MultiplySubtractNegated(Vector256<float> a, Vector256<float> b, Vector256<float> c) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m256d _mm256_fnmsub_pd (__m256d a, __m256d b, __m256d c)
+ /// </summary>
+ public static Vector256<double> MultiplySubtractNegated(Vector256<double> a, Vector256<double> b, Vector256<double> c) { throw new PlatformNotSupportedException(); }
+ }
+}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Fma.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Fma.cs
index 84160f293f..f4d053a078 100644
--- a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Fma.cs
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Fma.cs
@@ -12,108 +12,108 @@ namespace System.Runtime.Intrinsics.X86
/// </summary>
public static class Fma
{
- public static bool IsSupported { get { return false; } }
+ public static bool IsSupported { get => IsSupported; }
/// <summary>
/// __m128 _mm_fmadd_ps (__m128 a, __m128 b, __m128 c)
/// </summary>
- public static Vector128<float> MultiplyAdd(Vector128<float> a, Vector128<float> b, Vector128<float> c) { throw new NotImplementedException(); }
+ public static Vector128<float> MultiplyAdd(Vector128<float> a, Vector128<float> b, Vector128<float> c) => MultiplyAdd(a, b, c);
/// <summary>
/// __m128d _mm_fmadd_pd (__m128d a, __m128d b, __m128d c)
/// </summary>
- public static Vector128<double> MultiplyAdd(Vector128<double> a, Vector128<double> b, Vector128<double> c) { throw new NotImplementedException(); }
+ public static Vector128<double> MultiplyAdd(Vector128<double> a, Vector128<double> b, Vector128<double> c) => MultiplyAdd(a, b, c);
/// <summary>
/// __m256 _mm256_fmadd_ps (__m256 a, __m256 b, __m256 c)
/// </summary>
- public static Vector256<float> MultiplyAdd(Vector256<float> a, Vector256<float> b, Vector256<float> c) { throw new NotImplementedException(); }
+ public static Vector256<float> MultiplyAdd(Vector256<float> a, Vector256<float> b, Vector256<float> c) => MultiplyAdd(a, b, c);
/// <summary>
/// __m256d _mm256_fmadd_pd (__m256d a, __m256d b, __m256d c)
/// </summary>
- public static Vector256<double> MultiplyAdd(Vector256<double> a, Vector256<double> b, Vector256<double> c) { throw new NotImplementedException(); }
+ public static Vector256<double> MultiplyAdd(Vector256<double> a, Vector256<double> b, Vector256<double> c) => MultiplyAdd(a, b, c);
/// <summary>
/// __m128 _mm_fmaddsub_ps (__m128 a, __m128 b, __m128 c)
/// </summary>
- public static Vector128<float> MultiplyAddSubtract(Vector128<float> a, Vector128<float> b, Vector128<float> c) { throw new NotImplementedException(); }
+ public static Vector128<float> MultiplyAddSubtract(Vector128<float> a, Vector128<float> b, Vector128<float> c) => MultiplyAddSubtract(a, b, c);
/// <summary>
/// __m128d _mm_fmaddsub_pd (__m128d a, __m128d b, __m128d c)
/// </summary>
- public static Vector128<double> MultiplyAddSubtract(Vector128<double> a, Vector128<double> b, Vector128<double> c) { throw new NotImplementedException(); }
+ public static Vector128<double> MultiplyAddSubtract(Vector128<double> a, Vector128<double> b, Vector128<double> c) => MultiplyAddSubtract(a, b, c);
/// <summary>
/// __m256 _mm256_fmaddsub_ps (__m256 a, __m256 b, __m256 c)
/// </summary>
- public static Vector256<float> MultiplyAddSubtract(Vector256<float> a, Vector256<float> b, Vector256<float> c) { throw new NotImplementedException(); }
+ public static Vector256<float> MultiplyAddSubtract(Vector256<float> a, Vector256<float> b, Vector256<float> c) => MultiplyAddSubtract(a, b, c);
/// <summary>
/// __m256d _mm256_fmaddsub_pd (__m256d a, __m256d b, __m256d c)
/// </summary>
- public static Vector256<double> MultiplyAddSubtract(Vector256<double> a, Vector256<double> b, Vector256<double> c) { throw new NotImplementedException(); }
+ public static Vector256<double> MultiplyAddSubtract(Vector256<double> a, Vector256<double> b, Vector256<double> c) => MultiplyAddSubtract(a, b, c);
/// <summary>
/// __m128 _mm_fmsub_ps (__m128 a, __m128 b, __m128 c)
/// </summary>
- public static Vector128<float> MultiplySubtract(Vector128<float> a, Vector128<float> b, Vector128<float> c) { throw new NotImplementedException(); }
+ public static Vector128<float> MultiplySubtract(Vector128<float> a, Vector128<float> b, Vector128<float> c) => MultiplySubtract(a, b, c);
/// <summary>
/// __m128d _mm_fmsub_pd (__m128d a, __m128d b, __m128d c)
/// </summary>
- public static Vector128<double> MultiplySubtract(Vector128<double> a, Vector128<double> b, Vector128<double> c) { throw new NotImplementedException(); }
+ public static Vector128<double> MultiplySubtract(Vector128<double> a, Vector128<double> b, Vector128<double> c) => MultiplySubtract(a, b, c);
/// <summary>
/// __m256 _mm256_fmsub_ps (__m256 a, __m256 b, __m256 c)
/// </summary>
- public static Vector256<float> MultiplySubtract(Vector256<float> a, Vector256<float> b, Vector256<float> c) { throw new NotImplementedException(); }
+ public static Vector256<float> MultiplySubtract(Vector256<float> a, Vector256<float> b, Vector256<float> c) => MultiplySubtract(a, b, c);
/// <summary>
/// __m256d _mm256_fmsub_pd (__m256d a, __m256d b, __m256d c)
/// </summary>
- public static Vector256<double> MultiplySubtract(Vector256<double> a, Vector256<double> b, Vector256<double> c) { throw new NotImplementedException(); }
+ public static Vector256<double> MultiplySubtract(Vector256<double> a, Vector256<double> b, Vector256<double> c) => MultiplySubtract(a, b, c);
/// <summary>
/// __m128 _mm_fmsubadd_ps (__m128 a, __m128 b, __m128 c)
/// </summary>
- public static Vector128<float> MultiplySubtractAdd(Vector128<float> a, Vector128<float> b, Vector128<float> c) { throw new NotImplementedException(); }
+ public static Vector128<float> MultiplySubtractAdd(Vector128<float> a, Vector128<float> b, Vector128<float> c) => MultiplySubtractAdd(a, b, c);
/// <summary>
/// __m128d _mm_fmsubadd_pd (__m128d a, __m128d b, __m128d c)
/// </summary>
- public static Vector128<double> MultiplySubtractAdd(Vector128<double> a, Vector128<double> b, Vector128<double> c) { throw new NotImplementedException(); }
+ public static Vector128<double> MultiplySubtractAdd(Vector128<double> a, Vector128<double> b, Vector128<double> c) => MultiplySubtractAdd(a, b, c);
/// <summary>
/// __m256 _mm256_fmsubadd_ps (__m256 a, __m256 b, __m256 c)
/// </summary>
- public static Vector256<float> MultiplySubtractAdd(Vector256<float> a, Vector256<float> b, Vector256<float> c) { throw new NotImplementedException(); }
+ public static Vector256<float> MultiplySubtractAdd(Vector256<float> a, Vector256<float> b, Vector256<float> c) => MultiplySubtractAdd(a, b, c);
/// <summary>
/// __m256d _mm256_fmsubadd_pd (__m256d a, __m256d b, __m256d c)
/// </summary>
- public static Vector256<double> MultiplySubtractAdd(Vector256<double> a, Vector256<double> b, Vector256<double> c) { throw new NotImplementedException(); }
+ public static Vector256<double> MultiplySubtractAdd(Vector256<double> a, Vector256<double> b, Vector256<double> c) => MultiplySubtractAdd(a, b, c);
/// <summary>
/// __m128 _mm_fnmadd_ps (__m128 a, __m128 b, __m128 c)
/// </summary>
- public static Vector128<float> MultiplyAddNegated(Vector128<float> a, Vector128<float> b, Vector128<float> c) { throw new NotImplementedException(); }
+ public static Vector128<float> MultiplyAddNegated(Vector128<float> a, Vector128<float> b, Vector128<float> c) => MultiplyAddNegated(a, b, c);
/// <summary>
/// __m128d _mm_fnmadd_pd (__m128d a, __m128d b, __m128d c)
/// </summary>
- public static Vector128<double> MultiplyAddNegated(Vector128<double> a, Vector128<double> b, Vector128<double> c) { throw new NotImplementedException(); }
+ public static Vector128<double> MultiplyAddNegated(Vector128<double> a, Vector128<double> b, Vector128<double> c) => MultiplyAddNegated(a, b, c);
/// <summary>
/// __m256 _mm256_fnmadd_ps (__m256 a, __m256 b, __m256 c)
/// </summary>
- public static Vector256<float> MultiplyAddNegated(Vector256<float> a, Vector256<float> b, Vector256<float> c) { throw new NotImplementedException(); }
+ public static Vector256<float> MultiplyAddNegated(Vector256<float> a, Vector256<float> b, Vector256<float> c) => MultiplyAddNegated(a, b, c);
/// <summary>
/// __m256d _mm256_fnmadd_pd (__m256d a, __m256d b, __m256d c)
/// </summary>
- public static Vector256<double> MultiplyAddNegated(Vector256<double> a, Vector256<double> b, Vector256<double> c) { throw new NotImplementedException(); }
+ public static Vector256<double> MultiplyAddNegated(Vector256<double> a, Vector256<double> b, Vector256<double> c) => MultiplyAddNegated(a, b, c);
/// <summary>
/// __m128 _mm_fnmsub_ps (__m128 a, __m128 b, __m128 c)
/// </summary>
- public static Vector128<float> MultiplySubtractNegated(Vector128<float> a, Vector128<float> b, Vector128<float> c) { throw new NotImplementedException(); }
+ public static Vector128<float> MultiplySubtractNegated(Vector128<float> a, Vector128<float> b, Vector128<float> c) => MultiplySubtractNegated(a, b, c);
/// <summary>
/// __m128d _mm_fnmsub_pd (__m128d a, __m128d b, __m128d c)
/// </summary>
- public static Vector128<double> MultiplySubtractNegated(Vector128<double> a, Vector128<double> b, Vector128<double> c) { throw new NotImplementedException(); }
+ public static Vector128<double> MultiplySubtractNegated(Vector128<double> a, Vector128<double> b, Vector128<double> c) => MultiplySubtractNegated(a, b, c);
/// <summary>
/// __m256 _mm256_fnmsub_ps (__m256 a, __m256 b, __m256 c)
/// </summary>
- public static Vector256<float> MultiplySubtractNegated(Vector256<float> a, Vector256<float> b, Vector256<float> c) { throw new NotImplementedException(); }
+ public static Vector256<float> MultiplySubtractNegated(Vector256<float> a, Vector256<float> b, Vector256<float> c) => MultiplySubtractNegated(a, b, c);
/// <summary>
/// __m256d _mm256_fnmsub_pd (__m256d a, __m256d b, __m256d c)
/// </summary>
- public static Vector256<double> MultiplySubtractNegated(Vector256<double> a, Vector256<double> b, Vector256<double> c) { throw new NotImplementedException(); }
+ public static Vector256<double> MultiplySubtractNegated(Vector256<double> a, Vector256<double> b, Vector256<double> c) => MultiplySubtractNegated(a, b, c);
}
}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Lzcnt.PlatformNotSupported.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Lzcnt.PlatformNotSupported.cs
new file mode 100644
index 0000000000..a305c80649
--- /dev/null
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Lzcnt.PlatformNotSupported.cs
@@ -0,0 +1,26 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+
+namespace System.Runtime.Intrinsics.X86
+{
+ /// <summary>
+ /// This class provides access to Intel LZCNT hardware instructions via intrinsics
+ /// </summary>
+ [CLSCompliant(false)]
+ public static class Lzcnt
+ {
+ public static bool IsSupported { get { return false; } }
+
+ /// <summary>
+ /// unsigned int _lzcnt_u32 (unsigned int a)
+ /// </summary>
+ public static uint LeadingZeroCount(uint value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// unsigned __int64 _lzcnt_u64 (unsigned __int64 a)
+ /// </summary>
+ public static ulong LeadingZeroCount(ulong value) { throw new PlatformNotSupportedException(); }
+ }
+}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Lzcnt.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Lzcnt.cs
index ffc656e43b..17d7716fc0 100644
--- a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Lzcnt.cs
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Lzcnt.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System;
-using System.Runtime.Intrinsics;
namespace System.Runtime.Intrinsics.X86
{
@@ -13,15 +12,15 @@ namespace System.Runtime.Intrinsics.X86
[CLSCompliant(false)]
public static class Lzcnt
{
- public static bool IsSupported { get { return false; } }
+ public static bool IsSupported { get => IsSupported; }
/// <summary>
/// unsigned int _lzcnt_u32 (unsigned int a)
/// </summary>
- public static uint LeadingZeroCount(uint value) { throw new NotImplementedException(); }
+ public static uint LeadingZeroCount(uint value) => LeadingZeroCount(value);
/// <summary>
/// unsigned __int64 _lzcnt_u64 (unsigned __int64 a)
/// </summary>
- public static ulong LeadingZeroCount(ulong value) { throw new NotImplementedException(); }
+ public static ulong LeadingZeroCount(ulong value) => LeadingZeroCount(value);
}
}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Pclmulqdq.PlatformNotSupported.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Pclmulqdq.PlatformNotSupported.cs
new file mode 100644
index 0000000000..d2ee7f0bc6
--- /dev/null
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Pclmulqdq.PlatformNotSupported.cs
@@ -0,0 +1,27 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.Intrinsics;
+
+namespace System.Runtime.Intrinsics.X86
+{
+ /// <summary>
+ /// This class provides access to Intel PCLMULQDQ hardware instructions via intrinsics
+ /// </summary>
+ [CLSCompliant(false)]
+ public static class Pclmulqdq
+ {
+ public static bool IsSupported { get { return false; } }
+
+ /// <summary>
+ /// __m128i _mm_clmulepi64_si128 (__m128i a, __m128i b, const int imm8)
+ /// </summary>
+ public static Vector128<long> CarryLessMultiply(Vector128<long> left, Vector128<long> right, byte control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_clmulepi64_si128 (__m128i a, __m128i b, const int imm8)
+ /// </summary>
+ public static Vector128<ulong> CarryLessMultiply(Vector128<ulong> left, Vector128<ulong> right, byte control) { throw new PlatformNotSupportedException(); }
+ }
+}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Pclmulqdq.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Pclmulqdq.cs
index f8576f89fe..03cb378653 100644
--- a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Pclmulqdq.cs
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Pclmulqdq.cs
@@ -13,15 +13,15 @@ namespace System.Runtime.Intrinsics.X86
[CLSCompliant(false)]
public static class Pclmulqdq
{
- public static bool IsSupported { get { return false; } }
+ public static bool IsSupported { get => IsSupported; }
/// <summary>
/// __m128i _mm_clmulepi64_si128 (__m128i a, __m128i b, const int imm8)
/// </summary>
- public static Vector128<long> CarryLessMultiply(Vector128<long> left, Vector128<long> right, byte control) { throw new NotImplementedException(); }
+ public static Vector128<long> CarryLessMultiply(Vector128<long> left, Vector128<long> right, byte control) => CarryLessMultiply(left, right, control);
/// <summary>
/// __m128i _mm_clmulepi64_si128 (__m128i a, __m128i b, const int imm8)
/// </summary>
- public static Vector128<ulong> CarryLessMultiply(Vector128<ulong> left, Vector128<ulong> right, byte control) { throw new NotImplementedException(); }
+ public static Vector128<ulong> CarryLessMultiply(Vector128<ulong> left, Vector128<ulong> right, byte control) => CarryLessMultiply(left, right, control);
}
}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Popcnt.PlatformNotSupported.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Popcnt.PlatformNotSupported.cs
new file mode 100644
index 0000000000..f02db7a279
--- /dev/null
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Popcnt.PlatformNotSupported.cs
@@ -0,0 +1,26 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+
+namespace System.Runtime.Intrinsics.X86
+{
+ /// <summary>
+ /// This class provides access to Intel POPCNT hardware instructions via intrinsics
+ /// </summary>
+ [CLSCompliant(false)]
+ public static class Popcnt
+ {
+ public static bool IsSupported { get { return false; } }
+
+ /// <summary>
+ /// int _mm_popcnt_u32 (unsigned int a)
+ /// </summary>
+ public static int PopCount(uint value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __int64 _mm_popcnt_u64 (unsigned __int64 a)
+ /// </summary>
+ public static long PopCount(ulong value) { throw new PlatformNotSupportedException(); }
+ }
+}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Popcnt.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Popcnt.cs
index 66f2ab127d..c9e71b3a47 100644
--- a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Popcnt.cs
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Popcnt.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System;
-using System.Runtime.Intrinsics;
namespace System.Runtime.Intrinsics.X86
{
@@ -13,15 +12,15 @@ namespace System.Runtime.Intrinsics.X86
[CLSCompliant(false)]
public static class Popcnt
{
- public static bool IsSupported { get { return false; } }
+ public static bool IsSupported { get => IsSupported; }
/// <summary>
/// int _mm_popcnt_u32 (unsigned int a)
/// </summary>
- public static int PopCount(uint value) { throw new NotImplementedException(); }
+ public static int PopCount(uint value) => PopCount(value);
/// <summary>
/// __int64 _mm_popcnt_u64 (unsigned __int64 a)
/// </summary>
- public static long PopCount(ulong value) { throw new NotImplementedException(); }
+ public static long PopCount(ulong value) => PopCount(value);
}
}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse.PlatformNotSupported.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse.PlatformNotSupported.cs
new file mode 100644
index 0000000000..fa91c5055e
--- /dev/null
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse.PlatformNotSupported.cs
@@ -0,0 +1,218 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.Intrinsics;
+
+namespace System.Runtime.Intrinsics.X86
+{
+ /// <summary>
+ /// This class provides access to Intel SSE hardware instructions via intrinsics
+ /// </summary>
+ [CLSCompliant(false)]
+ public static class Sse
+ {
+ public static bool IsSupported { get { return false; } }
+
+ /// <summary>
+ /// __m128 _mm_add_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static Vector128<float> Add(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_and_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static Vector128<float> And(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_andnot_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static Vector128<float> AndNot(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_cmpeq_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static Vector128<float> CompareEqual(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_cmpgt_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static Vector128<float> CompareGreaterThan(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_cmpge_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static Vector128<float> CompareGreaterThanOrEqual(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_cmplt_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static Vector128<float> CompareLessThan(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_cmple_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static Vector128<float> CompareLessThanOrEqual(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_cmpneq_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static Vector128<float> CompareNotEqual(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_cmpngt_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static Vector128<float> CompareNotGreaterThan(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_cmpnge_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static Vector128<float> CompareNotGreaterThanOrEqual(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_cmpnlt_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static Vector128<float> CompareNotLessThan(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_cmpnle_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static Vector128<float> CompareNotLessThanOrEqual(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_cmpord_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static Vector128<float> CompareOrdered(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_cmpunord_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static Vector128<float> CompareUnordered(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_div_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static Vector128<float> Divide(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_loadu_ps (float const* mem_address)
+ /// </summary>
+ public static unsafe Vector128<float> Load(float* address) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_load_ps (float const* mem_address)
+ /// </summary>
+ public static unsafe Vector128<float> LoadAligned(float* address) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_max_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static Vector128<float> Max(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_min_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static Vector128<float> Min(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_movehl_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static Vector128<float> MoveHighToLow(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_movelh_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static Vector128<float> MoveLowToHigh(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_mul_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static Vector128<float> Multiply(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_or_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static Vector128<float> Or(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_rcp_ps (__m128 a)
+ /// </summary>
+ public static Vector128<float> Reciprocal(Vector128<float> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_rsqrt_ps (__m128 a)
+ /// </summary>
+ public static Vector128<float> ReciprocalSquareRoot(Vector128<float> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_set_ps (float e3, float e2, float e1, float e0)
+ /// </summary>
+ public static Vector128<float> Set(float e3, float e2, float e1, float e0) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_set1_ps (float a)
+ /// </summary>
+ public static Vector128<float> Set1(float value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128d _mm_setzero_ps (void)
+ /// </summary>
+ public static Vector128<float> SetZero() { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_castpd_ps (__m128d a)
+ /// __m128i _mm_castpd_si128 (__m128d a)
+ /// __m128d _mm_castps_pd (__m128 a)
+ /// __m128i _mm_castps_si128 (__m128 a)
+ /// __m128d _mm_castsi128_pd (__m128i a)
+ /// __m128 _mm_castsi128_ps (__m128i a)
+ /// </summary>
+ public static Vector128<U> StaticCast<T, U>(Vector128<T> value) where T : struct where U : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_shuffle_ps (__m128 a, __m128 b, unsigned int control)
+ /// </summary>
+ public static Vector128<float> Shuffle(Vector128<float> left, Vector128<float> right, byte control) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_sqrt_ps (__m128 a)
+ /// </summary>
+ public static Vector128<float> Sqrt(Vector128<float> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// void _mm_store_ps (float* mem_addr, __m128 a)
+ /// </summary>
+ public static unsafe void StoreAligned(float* address, Vector128<float> source) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// void _mm_stream_ps (float* mem_addr, __m128 a)
+ /// </summary>
+ public static unsafe void StoreAlignedNonTemporal(float* address, Vector128<float> source) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// void _mm_storeu_ps (float* mem_addr, __m128 a)
+ /// </summary>
+ public static unsafe void Store(float* address, Vector128<float> source) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128d _mm_sub_ps (__m128d a, __m128d b)
+ /// </summary>
+ public static Vector128<float> Subtract(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_unpackhi_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static Vector128<float> UnpackHigh(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_unpacklo_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static Vector128<float> UnpackLow(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_xor_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static Vector128<float> Xor(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+ }
+}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse.cs
index c85aee3015..bd48cd8e4d 100644
--- a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse.cs
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse.cs
@@ -13,152 +13,152 @@ namespace System.Runtime.Intrinsics.X86
[CLSCompliant(false)]
public static class Sse
{
- public static bool IsSupported { get { return false; } }
+ public static bool IsSupported { get => IsSupported; }
/// <summary>
/// __m128 _mm_add_ps (__m128 a, __m128 b)
/// </summary>
- public static Vector128<float> Add(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> Add(Vector128<float> left, Vector128<float> right) => Add(left, right);
/// <summary>
/// __m128 _mm_and_ps (__m128 a, __m128 b)
/// </summary>
- public static Vector128<float> And(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> And(Vector128<float> left, Vector128<float> right) => And(left, right);
/// <summary>
/// __m128 _mm_andnot_ps (__m128 a, __m128 b)
/// </summary>
- public static Vector128<float> AndNot(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> AndNot(Vector128<float> left, Vector128<float> right) => AndNot(left, right);
/// <summary>
/// __m128 _mm_cmpeq_ps (__m128 a, __m128 b)
/// </summary>
- public static Vector128<float> CompareEqual(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> CompareEqual(Vector128<float> left, Vector128<float> right) => CompareEqual(left, right);
/// <summary>
/// __m128 _mm_cmpgt_ps (__m128 a, __m128 b)
/// </summary>
- public static Vector128<float> CompareGreaterThan(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> CompareGreaterThan(Vector128<float> left, Vector128<float> right) => CompareGreaterThan(left, right);
/// <summary>
/// __m128 _mm_cmpge_ps (__m128 a, __m128 b)
/// </summary>
- public static Vector128<float> CompareGreaterThanOrEqual(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> CompareGreaterThanOrEqual(Vector128<float> left, Vector128<float> right) => CompareGreaterThanOrEqual(left, right);
/// <summary>
/// __m128 _mm_cmplt_ps (__m128 a, __m128 b)
/// </summary>
- public static Vector128<float> CompareLessThan(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> CompareLessThan(Vector128<float> left, Vector128<float> right) => CompareLessThan(left, right);
/// <summary>
/// __m128 _mm_cmple_ps (__m128 a, __m128 b)
/// </summary>
- public static Vector128<float> CompareLessThanOrEqual(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> CompareLessThanOrEqual(Vector128<float> left, Vector128<float> right) => CompareLessThanOrEqual(left, right);
/// <summary>
/// __m128 _mm_cmpneq_ps (__m128 a, __m128 b)
/// </summary>
- public static Vector128<float> CompareNotEqual(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> CompareNotEqual(Vector128<float> left, Vector128<float> right) => CompareNotEqual(left, right);
/// <summary>
/// __m128 _mm_cmpngt_ps (__m128 a, __m128 b)
/// </summary>
- public static Vector128<float> CompareNotGreaterThan(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> CompareNotGreaterThan(Vector128<float> left, Vector128<float> right) => CompareNotGreaterThan(left, right);
/// <summary>
/// __m128 _mm_cmpnge_ps (__m128 a, __m128 b)
/// </summary>
- public static Vector128<float> CompareNotGreaterThanOrEqual(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> CompareNotGreaterThanOrEqual(Vector128<float> left, Vector128<float> right) => CompareNotGreaterThanOrEqual(left, right);
/// <summary>
/// __m128 _mm_cmpnlt_ps (__m128 a, __m128 b)
/// </summary>
- public static Vector128<float> CompareNotLessThan(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> CompareNotLessThan(Vector128<float> left, Vector128<float> right) => CompareNotLessThan(left, right);
/// <summary>
/// __m128 _mm_cmpnle_ps (__m128 a, __m128 b)
/// </summary>
- public static Vector128<float> CompareNotLessThanOrEqual(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> CompareNotLessThanOrEqual(Vector128<float> left, Vector128<float> right) => CompareNotLessThanOrEqual(left, right);
/// <summary>
/// __m128 _mm_cmpord_ps (__m128 a, __m128 b)
/// </summary>
- public static Vector128<float> CompareOrdered(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> CompareOrdered(Vector128<float> left, Vector128<float> right) => CompareOrdered(left, right);
/// <summary>
/// __m128 _mm_cmpunord_ps (__m128 a, __m128 b)
/// </summary>
- public static Vector128<float> CompareUnordered(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> CompareUnordered(Vector128<float> left, Vector128<float> right) => CompareUnordered(left, right);
/// <summary>
/// __m128 _mm_div_ps (__m128 a, __m128 b)
/// </summary>
- public static Vector128<float> Divide(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> Divide(Vector128<float> left, Vector128<float> right) => Divide(left, right);
/// <summary>
/// __m128 _mm_loadu_ps (float const* mem_address)
/// </summary>
- public static unsafe Vector128<float> Load(float* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<float> Load(float* address) => Load(address);
/// <summary>
/// __m128 _mm_load_ps (float const* mem_address)
/// </summary>
- public static unsafe Vector128<float> LoadAligned(float* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<float> LoadAligned(float* address) => LoadAligned(address);
/// <summary>
/// __m128 _mm_max_ps (__m128 a, __m128 b)
/// </summary>
- public static Vector128<float> Max(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> Max(Vector128<float> left, Vector128<float> right) => Max(left, right);
/// <summary>
/// __m128 _mm_min_ps (__m128 a, __m128 b)
/// </summary>
- public static Vector128<float> Min(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> Min(Vector128<float> left, Vector128<float> right) => Min(left, right);
/// <summary>
/// __m128 _mm_movehl_ps (__m128 a, __m128 b)
/// </summary>
- public static Vector128<float> MoveHighToLow(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> MoveHighToLow(Vector128<float> left, Vector128<float> right) => MoveHighToLow(left, right);
/// <summary>
/// __m128 _mm_movelh_ps (__m128 a, __m128 b)
/// </summary>
- public static Vector128<float> MoveLowToHigh(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> MoveLowToHigh(Vector128<float> left, Vector128<float> right) => MoveLowToHigh(left, right);
/// <summary>
/// __m128 _mm_mul_ps (__m128 a, __m128 b)
/// </summary>
- public static Vector128<float> Multiply(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> Multiply(Vector128<float> left, Vector128<float> right) => Multiply(left, right);
/// <summary>
/// __m128 _mm_or_ps (__m128 a, __m128 b)
/// </summary>
- public static Vector128<float> Or(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> Or(Vector128<float> left, Vector128<float> right) => Or(left, right);
/// <summary>
/// __m128 _mm_rcp_ps (__m128 a)
/// </summary>
- public static Vector128<float> Reciprocal(Vector128<float> value) { throw new NotImplementedException(); }
+ public static Vector128<float> Reciprocal(Vector128<float> value) => Reciprocal(value);
/// <summary>
/// __m128 _mm_rsqrt_ps (__m128 a)
/// </summary>
- public static Vector128<float> ReciprocalSquareRoot(Vector128<float> value) { throw new NotImplementedException(); }
+ public static Vector128<float> ReciprocalSquareRoot(Vector128<float> value) => ReciprocalSquareRoot(value);
/// <summary>
/// __m128 _mm_set_ps (float e3, float e2, float e1, float e0)
/// </summary>
- public static Vector128<float> Set(float e3, float e2, float e1, float e0) { throw new NotImplementedException(); }
+ public static Vector128<float> Set(float e3, float e2, float e1, float e0) => Set(e3, e2, e1, e0);
/// <summary>
/// __m128 _mm_set1_ps (float a)
/// </summary>
- public static Vector128<float> Set1(float value) { throw new NotImplementedException(); }
+ public static Vector128<float> Set1(float value) => Set1(value);
/// <summary>
/// __m128d _mm_setzero_ps (void)
/// </summary>
- public static Vector128<float> SetZero() { throw new NotImplementedException(); }
+ public static Vector128<float> SetZero() => SetZero();
/// <summary>
/// __m128 _mm_castpd_ps (__m128d a)
@@ -168,51 +168,51 @@ namespace System.Runtime.Intrinsics.X86
/// __m128d _mm_castsi128_pd (__m128i a)
/// __m128 _mm_castsi128_ps (__m128i a)
/// </summary>
- public static Vector128<U> StaticCast<T, U>(Vector128<T> value) where T : struct where U : struct { throw new NotImplementedException(); }
+ public static Vector128<U> StaticCast<T, U>(Vector128<T> value) where T : struct where U : struct => StaticCast<T, U>(value);
/// <summary>
/// __m128 _mm_shuffle_ps (__m128 a, __m128 b, unsigned int control)
/// </summary>
- public static Vector128<float> Shuffle(Vector128<float> left, Vector128<float> right, byte control) { throw new NotImplementedException(); }
+ public static Vector128<float> Shuffle(Vector128<float> left, Vector128<float> right, byte control) => Shuffle(left, right, control);
/// <summary>
/// __m128 _mm_sqrt_ps (__m128 a)
/// </summary>
- public static Vector128<float> Sqrt(Vector128<float> value) { throw new NotImplementedException(); }
+ public static Vector128<float> Sqrt(Vector128<float> value) => Sqrt(value);
/// <summary>
/// void _mm_store_ps (float* mem_addr, __m128 a)
/// </summary>
- public static unsafe void StoreAligned(float* address, Vector128<float> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAligned(float* address, Vector128<float> source) => StoreAligned(address, source);
/// <summary>
/// void _mm_stream_ps (float* mem_addr, __m128 a)
/// </summary>
- public static unsafe void StoreAlignedNonTemporal(float* address, Vector128<float> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAlignedNonTemporal(float* address, Vector128<float> source) => StoreAlignedNonTemporal(address, source);
/// <summary>
/// void _mm_storeu_ps (float* mem_addr, __m128 a)
/// </summary>
- public static unsafe void Store(float* address, Vector128<float> source) { throw new NotImplementedException(); }
+ public static unsafe void Store(float* address, Vector128<float> source) => Store(address, source);
/// <summary>
/// __m128d _mm_sub_ps (__m128d a, __m128d b)
/// </summary>
- public static Vector128<float> Subtract(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> Subtract(Vector128<float> left, Vector128<float> right) => Subtract(left, right);
/// <summary>
/// __m128 _mm_unpackhi_ps (__m128 a, __m128 b)
/// </summary>
- public static Vector128<float> UnpackHigh(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> UnpackHigh(Vector128<float> left, Vector128<float> right) => UnpackHigh(left, right);
/// <summary>
/// __m128 _mm_unpacklo_ps (__m128 a, __m128 b)
/// </summary>
- public static Vector128<float> UnpackLow(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> UnpackLow(Vector128<float> left, Vector128<float> right) => UnpackLow(left, right);
/// <summary>
/// __m128 _mm_xor_ps (__m128 a, __m128 b)
/// </summary>
- public static Vector128<float> Xor(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> Xor(Vector128<float> left, Vector128<float> right) => Xor(left, right);
}
}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse2.PlatformNotSupported.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse2.PlatformNotSupported.cs
new file mode 100644
index 0000000000..64db5ca701
--- /dev/null
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse2.PlatformNotSupported.cs
@@ -0,0 +1,1057 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.Intrinsics;
+
+namespace System.Runtime.Intrinsics.X86
+{
+ /// <summary>
+ /// This class provides access to Intel SSE2 hardware instructions via intrinsics
+ /// </summary>
+ [CLSCompliant(false)]
+ public static class Sse2
+ {
+ public static bool IsSupported { get { return false; } }
+
+ /// <summary>
+ /// __m128i _mm_add_epi8 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<byte> Add(Vector128<byte> left, Vector128<byte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_add_epi8 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<sbyte> Add(Vector128<sbyte> left, Vector128<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_add_epi16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<short> Add(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_add_epi16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<ushort> Add(Vector128<ushort> left, Vector128<ushort> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_add_epi32 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<int> Add(Vector128<int> left, Vector128<int> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_add_epi32 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<uint> Add(Vector128<uint> left, Vector128<uint> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_add_epi64 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<long> Add(Vector128<byte> left, Vector128<long> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_add_epi64 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<ulong> Add(Vector128<sbyte> left, Vector128<ulong> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_add_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static Vector128<double> Add(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_adds_epi8 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<sbyte> AddSaturate(Vector128<sbyte> left, Vector128<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_adds_epu8 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<byte> AddSaturate(Vector128<byte> left, Vector128<byte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_adds_epi16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<short> AddSaturate(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_adds_epu16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<ushort> AddSaturate(Vector128<ushort> left, Vector128<ushort> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_and_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<byte> And(Vector128<byte> left, Vector128<byte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_and_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<sbyte> And(Vector128<sbyte> left, Vector128<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_and_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<short> And(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_and_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<ushort> And(Vector128<ushort> left, Vector128<ushort> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_and_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<int> And(Vector128<int> left, Vector128<int> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_and_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<uint> And(Vector128<uint> left, Vector128<uint> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_and_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<long> And(Vector128<long> left, Vector128<long> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_and_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<ulong> And(Vector128<ulong> left, Vector128<ulong> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_and_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static Vector128<double> And(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_andnot_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<byte> AndNot(Vector128<byte> left, Vector128<byte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_andnot_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<sbyte> AndNot(Vector128<sbyte> left, Vector128<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_andnot_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<short> AndNot(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_andnot_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<ushort> AndNot(Vector128<ushort> left, Vector128<ushort> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_andnot_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<int> AndNot(Vector128<int> left, Vector128<int> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_andnot_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<uint> AndNot(Vector128<uint> left, Vector128<uint> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_andnot_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<long> AndNot(Vector128<long> left, Vector128<long> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_andnot_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<ulong> AndNot(Vector128<ulong> left, Vector128<ulong> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_andnot_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static Vector128<double> AndNot(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_avg_epu8 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<byte> Average(Vector128<byte> left, Vector128<byte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_avg_epu16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<ushort> Average(Vector128<ushort> left, Vector128<ushort> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_cmpeq_epi8 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<sbyte> CompareEqual(Vector128<sbyte> left, Vector128<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_cmpeq_epi8 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<byte> CompareEqual(Vector128<byte> left, Vector128<byte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_cmpeq_epi16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<short> CompareEqual(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_cmpeq_epi16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<ushort> CompareEqual(Vector128<ushort> left, Vector128<ushort> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_cmpeq_epi32 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<int> CompareEqual(Vector128<int> left, Vector128<int> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_cmpeq_epi32 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<uint> CompareEqual(Vector128<uint> left, Vector128<uint> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_cmpeq_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static Vector128<double> CompareEqual(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_cmpgt_epi8 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<sbyte> CompareGreaterThan(Vector128<sbyte> left, Vector128<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_cmpgt_epi16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<short> CompareGreaterThan(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_cmpgt_epi32 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<int> CompareGreaterThan(Vector128<int> left, Vector128<int> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_cmpgt_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static Vector128<double> CompareGreaterThan(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128d _mm_cmpge_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static Vector128<double> CompareGreaterThanOrEqual(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_cmplt_epi8 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<sbyte> CompareLessThan(Vector128<sbyte> left, Vector128<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_cmplt_epi16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<short> CompareLessThan(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_cmplt_epi32 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<int> CompareLessThan(Vector128<int> left, Vector128<int> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_cmplt_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static Vector128<double> CompareLessThan(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128d _mm_cmple_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static Vector128<double> CompareLessThanOrEqual(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128d _mm_cmpneq_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static Vector128<double> CompareNotEqual(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128d _mm_cmpngt_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static Vector128<double> CompareNotGreaterThan(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128d _mm_cmpnge_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static Vector128<double> CompareNotGreaterThanOrEqual(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128d _mm_cmpnlt_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static Vector128<double> CompareNotLessThan(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128d _mm_cmpnle_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static Vector128<double> CompareNotLessThanOrEqual(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128d _mm_cmpord_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static Vector128<double> CompareOrdered(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128d _mm_cmpunord_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static Vector128<double> CompareUnordered(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_cvtps_epi32 (__m128 a)
+ /// </summary>
+ public static Vector128<int> ConvertToInt(Vector128<float> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_cvtpd_epi32 (__m128d a)
+ /// </summary>
+ public static Vector128<int> ConvertToInt(Vector128<double> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128 _mm_cvtepi32_ps (__m128i a)
+ /// </summary>
+ public static Vector128<float> ConvertToFloat(Vector128<int> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128 _mm_cvtpd_ps (__m128d a)
+ /// </summary>
+ public static Vector128<float> ConvertToFloat(Vector128<double> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_cvtepi32_pd (__m128i a)
+ /// </summary>
+ public static Vector128<double> ConvertToDouble(Vector128<int> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_cvtps_pd (__m128 a)
+ /// </summary>
+ public static Vector128<double> ConvertToDouble(Vector128<float> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_cvttps_epi32 (__m128 a)
+ /// </summary>
+ public static Vector128<int> ConvertToIntWithTruncation(Vector128<float> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_cvttpd_epi32 (__m128d a)
+ /// </summary>
+ public static Vector128<int> ConvertToIntWithTruncation(Vector128<double> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128d _mm_div_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static Vector128<double> Divide(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_extract_epi16 (__m128i a, int immediate)
+ /// </summary>
+ public static short ExtractShort<T>(Vector128<T> value, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// int _mm_extract_epi16 (__m128i a, int immediate)
+ /// </summary>
+ public static ushort ExtractUshort<T>(Vector128<T> value, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_insert_epi16 (__m128i a, int i, int immediate)
+ /// </summary>
+ public static Vector128<T> InsertShort<T>(Vector128<T> value, short data, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_insert_epi16 (__m128i a, int i, int immediate)
+ /// </summary>
+ public static Vector128<T> InsertUshort<T>(Vector128<T> value, ushort data, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_loadu_si128 (__m128i const* mem_address)
+ /// </summary>
+ public static unsafe Vector128<sbyte> Load(sbyte* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_loadu_si128 (__m128i const* mem_address)
+ /// </summary>
+ public static unsafe Vector128<byte> Load(byte* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_loadu_si128 (__m128i const* mem_address)
+ /// </summary>
+ public static unsafe Vector128<short> Load(short* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_loadu_si128 (__m128i const* mem_address)
+ /// </summary>
+ public static unsafe Vector128<ushort> Load(ushort* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_loadu_si128 (__m128i const* mem_address)
+ /// </summary>
+ public static unsafe Vector128<int> Load(int* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_loadu_si128 (__m128i const* mem_address)
+ /// </summary>
+ public static unsafe Vector128<uint> Load(uint* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_loadu_si128 (__m128i const* mem_address)
+ /// </summary>
+ public static unsafe Vector128<long> Load(long* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_loadu_si128 (__m128i const* mem_address)
+ /// </summary>
+ public static unsafe Vector128<ulong> Load(ulong* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_loadu_pd (double const* mem_address)
+ /// </summary>
+ public static unsafe Vector128<double> Load(double* address) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_load_si128 (__m128i const* mem_address)
+ /// </summary>
+ public static unsafe Vector128<sbyte> LoadAligned(sbyte* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_load_si128 (__m128i const* mem_address)
+ /// </summary>
+ public static unsafe Vector128<byte> LoadAligned(byte* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_load_si128 (__m128i const* mem_address)
+ /// </summary>
+ public static unsafe Vector128<short> LoadAligned(short* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_load_si128 (__m128i const* mem_address)
+ /// </summary>
+ public static unsafe Vector128<ushort> LoadAligned(ushort* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_load_si128 (__m128i const* mem_address)
+ /// </summary>
+ public static unsafe Vector128<int> LoadAligned(int* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_load_si128 (__m128i const* mem_address)
+ /// </summary>
+ public static unsafe Vector128<uint> LoadAligned(uint* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_load_si128 (__m128i const* mem_address)
+ /// </summary>
+ public static unsafe Vector128<long> LoadAligned(long* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_load_si128 (__m128i const* mem_address)
+ /// </summary>
+ public static unsafe Vector128<ulong> LoadAligned(ulong* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_load_pd (double const* mem_address)
+ /// </summary>
+ public static unsafe Vector128<double> LoadAligned(double* address) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// void _mm_maskmoveu_si128 (__m128i a, __m128i mask, char* mem_address)
+ /// </summary>
+ public static unsafe void MaskMove(Vector128<sbyte> source, Vector128<sbyte> mask, sbyte* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_maskmoveu_si128 (__m128i a, __m128i mask, char* mem_address)
+ /// </summary>
+ public static unsafe void MaskMove(Vector128<byte> source, Vector128<byte> mask, byte* address) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_max_epu8 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<byte> Max(Vector128<byte> left, Vector128<byte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_max_epi16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<short> Max(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_max_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static Vector128<double> Max(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_min_epu8 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<byte> Min(Vector128<byte> left, Vector128<byte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_min_epi16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<short> Min(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_min_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static Vector128<double> Min(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_movemask_epi8 (__m128i a)
+ /// </summary>
+ public static int MoveMask(Vector128<sbyte> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// int _mm_movemask_pd (__m128d a)
+ /// </summary>
+ public static int MoveMask(Vector128<double> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_mul_epu32 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<ulong> Multiply(Vector128<uint> left, Vector128<uint> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_mul_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static Vector128<double> Multiply(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_mulhi_epi16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<short> MultiplyHi(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_mulhi_epu16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<ushort> MultiplyHi(Vector128<ushort> left, Vector128<ushort> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_madd_epi16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<int> MultiplyHorizontalAdd(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_mullo_epi16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<short> MultiplyLow(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_or_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<byte> Or(Vector128<byte> left, Vector128<byte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_or_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<sbyte> Or(Vector128<sbyte> left, Vector128<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_or_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<short> Or(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_or_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<ushort> Or(Vector128<ushort> left, Vector128<ushort> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_or_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<int> Or(Vector128<int> left, Vector128<int> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_or_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<uint> Or(Vector128<uint> left, Vector128<uint> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_or_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<long> Or(Vector128<long> left, Vector128<long> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_or_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<ulong> Or(Vector128<ulong> left, Vector128<ulong> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_or_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static Vector128<double> Or(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_packs_epi16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<sbyte> PackSignedSaturate(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_packs_epi32 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<short> PackSignedSaturate(Vector128<int> left, Vector128<int> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_packus_epi16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<byte> PackUnsignedSaturate(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// ___m128i _mm_set_epi8 (char e15, char e14, char e13, char e12, char e11, char e10, char e9, char e8, char e7, char e6, char e5, char e4, char e3, char e2, char e1, char e0)
+ /// </summary>
+ public static Vector128<sbyte> Set(sbyte e15, sbyte e14, sbyte e13, sbyte e12, sbyte e11, sbyte e10, sbyte e9, sbyte e8, sbyte e7, sbyte e6, sbyte e5, sbyte e4, sbyte e3, sbyte e2, sbyte e1, sbyte e0) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// ___m128i _mm_set_epi8 (char e15, char e14, char e13, char e12, char e11, char e10, char e9, char e8, char e7, char e6, char e5, char e4, char e3, char e2, char e1, char e0)
+ /// </summary>
+ public static Vector128<byte> Set(byte e15, byte e14, byte e13, byte e12, byte e11, byte e10, byte e9, byte e8, byte e7, byte e6, byte e5, byte e4, byte e3, byte e2, byte e1, byte e0) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_set_epi16 (short e7, short e6, short e5, short e4, short e3, short e2, short e1, short e0)
+ /// </summary>
+ public static Vector128<short> Set(short e7, short e6, short e5, short e4, short e3, short e2, short e1, short e0) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_set_epi16 (short e7, short e6, short e5, short e4, short e3, short e2, short e1, short e0)
+ /// </summary>
+ public static Vector128<ushort> Set(ushort e7, ushort e6, ushort e5, ushort e4, ushort e3, ushort e2, ushort e1, ushort e0) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_set_epi32 (int e3, int e2, int e1, int e0)
+ /// </summary>
+ public static Vector128<int> Set(int e3, int e2, int e1, int e0) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_set_epi32 (int e3, int e2, int e1, int e0)
+ /// </summary>
+ public static Vector128<uint> Set(uint e3, uint e2, uint e1, uint e0) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_set_epi64x (__int64 e1, __int64 e0)
+ /// </summary>
+ public static Vector128<long> Set(long e1, long e0) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_set_epi64x (__int64 e1, __int64 e0)
+ /// </summary>
+ public static Vector128<ulong> Set(ulong e1, ulong e0) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_set_pd (double e1, double e0)
+ /// </summary>
+ public static Vector128<double> Set(double e1, double e0) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_set1_epi8 (char a)
+ /// </summary>
+ public static Vector128<byte> Set1(byte value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_set1_epi8 (char a)
+ /// </summary>
+ public static Vector128<sbyte> Set1(sbyte value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_set1_epi16 (short a)
+ /// </summary>
+ public static Vector128<short> Set1(short value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_set1_epi16 (short a)
+ /// </summary>
+ public static Vector128<ushort> Set1(ushort value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_set1_epi32 (int a)
+ /// </summary>
+ public static Vector128<int> Set1(int value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_set1_epi32 (int a)
+ /// </summary>
+ public static Vector128<uint> Set1(uint value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_set1_epi64x (long long a)
+ /// </summary>
+ public static Vector128<long> Set1(long value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_set1_epi64x (long long a)
+ /// </summary>
+ public static Vector128<ulong> Set1(ulong value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_set1_pd (double a)
+ /// </summary>
+ public static Vector128<double> Set1(double value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_setzero_si128 ()
+ /// __m128d _mm_setzero_pd (void)
+ /// </summary>
+ public static Vector128<T> SetZero<T>() where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_sad_epu8 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<long> SumAbsoluteDifferences(Vector128<byte> left, Vector128<byte> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_shuffle_epi32 (__m128i a, int immediate)
+ /// </summary>
+ public static Vector128<int> Shuffle(Vector128<int> value, byte control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_shuffle_epi32 (__m128i a, int immediate)
+ /// </summary>
+ public static Vector128<uint> Shuffle(Vector128<uint> value, byte control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_shuffle_pd (__m128d a, __m128d b, int immediate)
+ /// </summary>
+ public static Vector128<double> Shuffle(Vector128<double> left, Vector128<double> right, byte control) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_shufflehi_epi16 (__m128i a, int immediate)
+ /// </summary>
+ public static Vector128<short> ShuffleHigh(Vector128<short> value, byte control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_shufflehi_epi16 (__m128i a, int control)
+ /// </summary>
+ public static Vector128<ushort> ShuffleHigh(Vector128<ushort> value, byte control) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_shufflelo_epi16 (__m128i a, int control)
+ /// </summary>
+ public static Vector128<short> ShuffleLow(Vector128<short> value, byte control) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_shufflelo_epi16 (__m128i a, int control)
+ /// </summary>
+ public static Vector128<ushort> ShuffleLow(Vector128<ushort> value, byte control) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_slli_epi16 (__m128i a, int immediate)
+ /// </summary>
+ public static Vector128<short> ShiftLeftLogical(Vector128<short> value, byte count) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_slli_epi16 (__m128i a, int immediate)
+ /// </summary>
+ public static Vector128<ushort> ShiftLeftLogical(Vector128<ushort> value, byte count) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_slli_epi32 (__m128i a, int immediate)
+ /// </summary>
+ public static Vector128<int> ShiftLeftLogical(Vector128<int> value, byte count) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_slli_epi32 (__m128i a, int immediate)
+ /// </summary>
+ public static Vector128<uint> ShiftLeftLogical(Vector128<uint> value, byte count) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_slli_epi64 (__m128i a, int immediate)
+ /// </summary>
+ public static Vector128<long> ShiftLeftLogical(Vector128<long> value, byte count) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_slli_epi64 (__m128i a, int immediate)
+ /// </summary>
+ public static Vector128<ulong> ShiftLeftLogical(Vector128<ulong> value, byte count) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_bslli_si128 (__m128i a, int imm8)
+ /// </summary>
+ public static Vector128<sbyte> ShiftLeftLogical128BitLane(Vector128<sbyte> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_bslli_si128 (__m128i a, int imm8)
+ /// </summary>
+ public static Vector128<byte> ShiftLeftLogical128BitLane(Vector128<byte> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_bslli_si128 (__m128i a, int imm8)
+ /// </summary>
+ public static Vector128<short> ShiftLeftLogical128BitLane(Vector128<short> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_bslli_si128 (__m128i a, int imm8)
+ /// </summary>
+ public static Vector128<ushort> ShiftLeftLogical128BitLane(Vector128<ushort> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_bslli_si128 (__m128i a, int imm8)
+ /// </summary>
+ public static Vector128<int> ShiftLeftLogical128BitLane(Vector128<int> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_bslli_si128 (__m128i a, int imm8)
+ /// </summary>
+ public static Vector128<uint> ShiftLeftLogical128BitLane(Vector128<uint> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_bslli_si128 (__m128i a, int imm8)
+ /// </summary>
+ public static Vector128<long> ShiftLeftLogical128BitLane(Vector128<long> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_bslli_si128 (__m128i a, int imm8)
+ /// </summary>
+ public static Vector128<ulong> ShiftLeftLogical128BitLane(Vector128<ulong> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_srai_epi16 (__m128i a, int immediate)
+ /// </summary>
+ public static Vector128<short> ShiftRightArithmetic(Vector128<short> value, byte count) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_srai_epi32 (__m128i a, int immediate)
+ /// </summary>
+ public static Vector128<int> ShiftRightArithmetic(Vector128<int> value, byte count) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_srli_epi16 (__m128i a, int immediate)
+ /// </summary>
+ public static Vector128<short> ShiftRightLogical(Vector128<short> value, byte count) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_srli_epi16 (__m128i a, int immediate)
+ /// </summary>
+ public static Vector128<ushort> ShiftRightLogical(Vector128<ushort> value, byte count) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_srli_epi32 (__m128i a, int immediate)
+ /// </summary>
+ public static Vector128<int> ShiftRightLogical(Vector128<int> value, byte count) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_srli_epi32 (__m128i a, int immediate)
+ /// </summary>
+ public static Vector128<uint> ShiftRightLogical(Vector128<uint> value, byte count) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_srli_epi64 (__m128i a, int immediate)
+ /// </summary>
+ public static Vector128<long> ShiftRightLogical(Vector128<long> value, byte count) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_srli_epi64 (__m128i a, int immediate)
+ /// </summary>
+ public static Vector128<ulong> ShiftRightLogical(Vector128<ulong> value, byte count) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_bsrli_si128 (__m128i a, int imm8)
+ /// </summary>
+ public static Vector128<sbyte> ShiftRightLogical128BitLane(Vector128<sbyte> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_bsrli_si128 (__m128i a, int imm8)
+ /// </summary>
+ public static Vector128<byte> ShiftRightLogical128BitLane(Vector128<byte> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_bsrli_si128 (__m128i a, int imm8)
+ /// </summary>
+ public static Vector128<short> ShiftRightLogical128BitLane(Vector128<short> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_bsrli_si128 (__m128i a, int imm8)
+ /// </summary>
+ public static Vector128<ushort> ShiftRightLogical128BitLane(Vector128<ushort> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_bsrli_si128 (__m128i a, int imm8)
+ /// </summary>
+ public static Vector128<int> ShiftRightLogical128BitLane(Vector128<int> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_bsrli_si128 (__m128i a, int imm8)
+ /// </summary>
+ public static Vector128<uint> ShiftRightLogical128BitLane(Vector128<uint> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_bsrli_si128 (__m128i a, int imm8)
+ /// </summary>
+ public static Vector128<long> ShiftRightLogical128BitLane(Vector128<long> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_bsrli_si128 (__m128i a, int imm8)
+ /// </summary>
+ public static Vector128<ulong> ShiftRightLogical128BitLane(Vector128<ulong> value, byte numBytes) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128d _mm_sqrt_pd (__m128d a)
+ /// </summary>
+ public static Vector128<double> Sqrt(Vector128<double> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// void _mm_store_si128 (__m128i* mem_addr, __m128i a)
+ /// </summary>
+ public static unsafe void StoreAligned(sbyte* address, Vector128<sbyte> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_store_si128 (__m128i* mem_addr, __m128i a)
+ /// </summary>
+ public static unsafe void StoreAligned(byte* address, Vector128<byte> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_store_si128 (__m128i* mem_addr, __m128i a)
+ /// </summary>
+ public static unsafe void StoreAligned(short* address, Vector128<short> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_store_si128 (__m128i* mem_addr, __m128i a)
+ /// </summary>
+ public static unsafe void StoreAligned(ushort* address, Vector128<ushort> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_store_si128 (__m128i* mem_addr, __m128i a)
+ /// </summary>
+ public static unsafe void StoreAligned(int* address, Vector128<int> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_store_si128 (__m128i* mem_addr, __m128i a)
+ /// </summary>
+ public static unsafe void StoreAligned(uint* address, Vector128<uint> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_store_si128 (__m128i* mem_addr, __m128i a)
+ /// </summary>
+ public static unsafe void StoreAligned(long* address, Vector128<long> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_store_si128 (__m128i* mem_addr, __m128i a)
+ /// </summary>
+ public static unsafe void StoreAligned(ulong* address, Vector128<ulong> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_store_pd (double* mem_addr, __m128d a)
+ /// </summary>
+ public static unsafe void StoreAligned(double* address, Vector128<double> source) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// void _mm_stream_si128 (__m128i* mem_addr, __m128i a)
+ /// </summary>
+ public static unsafe void StoreAlignedNonTemporal(sbyte* address, Vector128<sbyte> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_stream_si128 (__m128i* mem_addr, __m128i a)
+ /// </summary>
+ public static unsafe void StoreAlignedNonTemporal(byte* address, Vector128<byte> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_stream_si128 (__m128i* mem_addr, __m128i a)
+ /// </summary>
+ public static unsafe void StoreAlignedNonTemporal(short* address, Vector128<short> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_stream_si128 (__m128i* mem_addr, __m128i a)
+ /// </summary>
+ public static unsafe void StoreAlignedNonTemporal(ushort* address, Vector128<ushort> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_stream_si128 (__m128i* mem_addr, __m128i a)
+ /// </summary>
+ public static unsafe void StoreAlignedNonTemporal(int* address, Vector128<int> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_stream_si128 (__m128i* mem_addr, __m128i a)
+ /// </summary>
+ public static unsafe void StoreAlignedNonTemporal(uint* address, Vector128<uint> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_stream_si128 (__m128i* mem_addr, __m128i a)
+ /// </summary>
+ public static unsafe void StoreAlignedNonTemporal(long* address, Vector128<long> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_stream_si128 (__m128i* mem_addr, __m128i a)
+ /// </summary>
+ public static unsafe void StoreAlignedNonTemporal(ulong* address, Vector128<ulong> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_stream_pd (double* mem_addr, __m128d a)
+ /// </summary>
+ public static unsafe void StoreAlignedNonTemporal(double* address, Vector128<double> source) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// void _mm_storeu_si128 (__m128i* mem_addr, __m128i a)
+ /// </summary>
+ public static unsafe void Store(sbyte* address, Vector128<sbyte> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_storeu_si128 (__m128i* mem_addr, __m128i a)
+ /// </summary>
+ public static unsafe void Store(byte* address, Vector128<byte> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_storeu_si128 (__m128i* mem_addr, __m128i a)
+ /// </summary>
+ public static unsafe void Store(short* address, Vector128<short> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_storeu_si128 (__m128i* mem_addr, __m128i a)
+ /// </summary>
+ public static unsafe void Store(ushort* address, Vector128<ushort> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_storeu_si128 (__m128i* mem_addr, __m128i a)
+ /// </summary>
+ public static unsafe void Store(int* address, Vector128<int> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_storeu_si128 (__m128i* mem_addr, __m128i a)
+ /// </summary>
+ public static unsafe void Store(uint* address, Vector128<uint> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_storeu_si128 (__m128i* mem_addr, __m128i a)
+ /// </summary>
+ public static unsafe void Store(long* address, Vector128<long> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_storeu_si128 (__m128i* mem_addr, __m128i a)
+ /// </summary>
+ public static unsafe void Store(ulong* address, Vector128<ulong> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_storeu_pd (double* mem_addr, __m128d a)
+ /// </summary>
+ public static unsafe void Store(double* address, Vector128<double> source) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// void _mm_storeh_pd (double* mem_addr, __m128d a)
+ /// </summary>
+ public static unsafe void StoreHigh(double* address, Vector128<double> source) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// void _mm_storel_epi64 (__m128i* mem_addr, __m128i a)
+ /// </summary>
+ public static unsafe void StoreLow(long* address, Vector128<long> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_storel_epi64 (__m128i* mem_addr, __m128i a)
+ /// </summary>
+ public static unsafe void StoreLow(ulong* address, Vector128<ulong> source) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// void _mm_storel_pd (double* mem_addr, __m128d a)
+ /// </summary>
+ public static unsafe void StoreLow(double* address, Vector128<double> source) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_sub_epi8 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<byte> Subtract(Vector128<byte> left, Vector128<byte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_sub_epi8 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<sbyte> Subtract(Vector128<sbyte> left, Vector128<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_sub_epi16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<short> Subtract(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_sub_epi16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<ushort> Subtract(Vector128<ushort> left, Vector128<ushort> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_sub_epi32 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<int> Subtract(Vector128<int> left, Vector128<int> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_sub_epi32 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<uint> Subtract(Vector128<uint> left, Vector128<uint> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_sub_epi64 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<long> Subtract(Vector128<long> left, Vector128<long> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_sub_epi64 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<ulong> Subtract(Vector128<ulong> left, Vector128<ulong> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_sub_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static Vector128<double> Subtract(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_subs_epi8 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<sbyte> SubtractSaturate(Vector128<sbyte> left, Vector128<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_subs_epi16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<short> SubtractSaturate(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_subs_epu8 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<byte> SubtractSaturate(Vector128<byte> left, Vector128<byte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_subs_epu16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<ushort> SubtractSaturate(Vector128<ushort> left, Vector128<ushort> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_unpackhi_epi8 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<byte> UnpackHigh(Vector128<byte> left, Vector128<byte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_unpackhi_epi8 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<sbyte> UnpackHigh(Vector128<sbyte> left, Vector128<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_unpackhi_epi16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<short> UnpackHigh(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_unpackhi_epi16 (__m128i a, __m128i b)
+ /// </summary
+ public static Vector128<ushort> UnpackHigh(Vector128<ushort> left, Vector128<ushort> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_unpackhi_epi32 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<int> UnpackHigh(Vector128<int> left, Vector128<int> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_unpackhi_epi32 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<uint> UnpackHigh(Vector128<uint> left, Vector128<uint> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_unpackhi_epi64 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<long> UnpackHigh(Vector128<long> left, Vector128<long> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_unpackhi_epi64 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<ulong> UnpackHigh(Vector128<ulong> left, Vector128<ulong> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_unpackhi_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static Vector128<double> UnpackHigh(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_unpacklo_epi8 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<byte> UnpackLow(Vector128<byte> left, Vector128<byte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_unpacklo_epi8 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<sbyte> UnpackLow(Vector128<sbyte> left, Vector128<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_unpacklo_epi16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<short> UnpackLow(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_unpacklo_epi16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<ushort> UnpackLow(Vector128<ushort> left, Vector128<ushort> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_unpacklo_epi32 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<int> UnpackLow(Vector128<int> left, Vector128<int> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_unpacklo_epi32 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<uint> UnpackLow(Vector128<uint> left, Vector128<uint> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_unpacklo_epi64 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<long> UnpackLow(Vector128<long> left, Vector128<long> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_unpacklo_epi64 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<ulong> UnpackLow(Vector128<ulong> left, Vector128<ulong> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_unpacklo_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static Vector128<double> UnpackLow(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_xor_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<byte> Xor(Vector128<byte> left, Vector128<byte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_xor_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<sbyte> Xor(Vector128<sbyte> left, Vector128<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_xor_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<short> Xor(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_xor_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<ushort> Xor(Vector128<ushort> left, Vector128<ushort> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_xor_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<int> Xor(Vector128<int> left, Vector128<int> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_xor_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<uint> Xor(Vector128<uint> left, Vector128<uint> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_xor_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<long> Xor(Vector128<long> left, Vector128<long> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_xor_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<ulong> Xor(Vector128<ulong> left, Vector128<ulong> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_xor_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static Vector128<double> Xor(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+ }
+}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse2.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse2.cs
index ffe35f883c..fef550741c 100644
--- a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse2.cs
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse2.cs
@@ -13,1045 +13,1045 @@ namespace System.Runtime.Intrinsics.X86
[CLSCompliant(false)]
public static class Sse2
{
- public static bool IsSupported { get { return false; } }
+ public static bool IsSupported { get => IsSupported; }
/// <summary>
/// __m128i _mm_add_epi8 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<byte> Add(Vector128<byte> left, Vector128<byte> right) { throw new NotImplementedException(); }
+ public static Vector128<byte> Add(Vector128<byte> left, Vector128<byte> right) => Add(left, right);
/// <summary>
/// __m128i _mm_add_epi8 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<sbyte> Add(Vector128<sbyte> left, Vector128<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> Add(Vector128<sbyte> left, Vector128<sbyte> right) => Add(left, right);
/// <summary>
/// __m128i _mm_add_epi16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<short> Add(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
+ public static Vector128<short> Add(Vector128<short> left, Vector128<short> right) => Add(left, right);
/// <summary>
/// __m128i _mm_add_epi16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<ushort> Add(Vector128<ushort> left, Vector128<ushort> right) { throw new NotImplementedException(); }
+ public static Vector128<ushort> Add(Vector128<ushort> left, Vector128<ushort> right) => Add(left, right);
/// <summary>
/// __m128i _mm_add_epi32 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<int> Add(Vector128<int> left, Vector128<int> right) { throw new NotImplementedException(); }
+ public static Vector128<int> Add(Vector128<int> left, Vector128<int> right) => Add(left, right);
/// <summary>
/// __m128i _mm_add_epi32 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<uint> Add(Vector128<uint> left, Vector128<uint> right) { throw new NotImplementedException(); }
+ public static Vector128<uint> Add(Vector128<uint> left, Vector128<uint> right) => Add(left, right);
/// <summary>
/// __m128i _mm_add_epi64 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<long> Add(Vector128<byte> left, Vector128<long> right) { throw new NotImplementedException(); }
+ public static Vector128<long> Add(Vector128<byte> left, Vector128<long> right) => Add(left, right);
/// <summary>
/// __m128i _mm_add_epi64 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<ulong> Add(Vector128<sbyte> left, Vector128<ulong> right) { throw new NotImplementedException(); }
+ public static Vector128<ulong> Add(Vector128<sbyte> left, Vector128<ulong> right) => Add(left, right);
/// <summary>
/// __m128d _mm_add_pd (__m128d a, __m128d b)
/// </summary>
- public static Vector128<double> Add(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static Vector128<double> Add(Vector128<double> left, Vector128<double> right) => Add(left, right);
/// <summary>
/// __m128i _mm_adds_epi8 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<sbyte> AddSaturate(Vector128<sbyte> left, Vector128<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> AddSaturate(Vector128<sbyte> left, Vector128<sbyte> right) => AddSaturate(left, right);
/// <summary>
/// __m128i _mm_adds_epu8 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<byte> AddSaturate(Vector128<byte> left, Vector128<byte> right) { throw new NotImplementedException(); }
+ public static Vector128<byte> AddSaturate(Vector128<byte> left, Vector128<byte> right) => AddSaturate(left, right);
/// <summary>
/// __m128i _mm_adds_epi16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<short> AddSaturate(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
+ public static Vector128<short> AddSaturate(Vector128<short> left, Vector128<short> right) => AddSaturate(left, right);
/// <summary>
/// __m128i _mm_adds_epu16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<ushort> AddSaturate(Vector128<ushort> left, Vector128<ushort> right) { throw new NotImplementedException(); }
+ public static Vector128<ushort> AddSaturate(Vector128<ushort> left, Vector128<ushort> right) => AddSaturate(left, right);
/// <summary>
/// __m128i _mm_and_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<byte> And(Vector128<byte> left, Vector128<byte> right) { throw new NotImplementedException(); }
+ public static Vector128<byte> And(Vector128<byte> left, Vector128<byte> right) => And(left, right);
/// <summary>
/// __m128i _mm_and_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<sbyte> And(Vector128<sbyte> left, Vector128<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> And(Vector128<sbyte> left, Vector128<sbyte> right) => And(left, right);
/// <summary>
/// __m128i _mm_and_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<short> And(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
+ public static Vector128<short> And(Vector128<short> left, Vector128<short> right) => And(left, right);
/// <summary>
/// __m128i _mm_and_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<ushort> And(Vector128<ushort> left, Vector128<ushort> right) { throw new NotImplementedException(); }
+ public static Vector128<ushort> And(Vector128<ushort> left, Vector128<ushort> right) => And(left, right);
/// <summary>
/// __m128i _mm_and_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<int> And(Vector128<int> left, Vector128<int> right) { throw new NotImplementedException(); }
+ public static Vector128<int> And(Vector128<int> left, Vector128<int> right) => And(left, right);
/// <summary>
/// __m128i _mm_and_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<uint> And(Vector128<uint> left, Vector128<uint> right) { throw new NotImplementedException(); }
+ public static Vector128<uint> And(Vector128<uint> left, Vector128<uint> right) => And(left, right);
/// <summary>
/// __m128i _mm_and_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<long> And(Vector128<long> left, Vector128<long> right) { throw new NotImplementedException(); }
+ public static Vector128<long> And(Vector128<long> left, Vector128<long> right) => And(left, right);
/// <summary>
/// __m128i _mm_and_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<ulong> And(Vector128<ulong> left, Vector128<ulong> right) { throw new NotImplementedException(); }
+ public static Vector128<ulong> And(Vector128<ulong> left, Vector128<ulong> right) => And(left, right);
/// <summary>
/// __m128d _mm_and_pd (__m128d a, __m128d b)
/// </summary>
- public static Vector128<double> And(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static Vector128<double> And(Vector128<double> left, Vector128<double> right) => And(left, right);
/// <summary>
/// __m128i _mm_andnot_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<byte> AndNot(Vector128<byte> left, Vector128<byte> right) { throw new NotImplementedException(); }
+ public static Vector128<byte> AndNot(Vector128<byte> left, Vector128<byte> right) => AndNot(left, right);
/// <summary>
/// __m128i _mm_andnot_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<sbyte> AndNot(Vector128<sbyte> left, Vector128<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> AndNot(Vector128<sbyte> left, Vector128<sbyte> right) => AndNot(left, right);
/// <summary>
/// __m128i _mm_andnot_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<short> AndNot(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
+ public static Vector128<short> AndNot(Vector128<short> left, Vector128<short> right) => AndNot(left, right);
/// <summary>
/// __m128i _mm_andnot_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<ushort> AndNot(Vector128<ushort> left, Vector128<ushort> right) { throw new NotImplementedException(); }
+ public static Vector128<ushort> AndNot(Vector128<ushort> left, Vector128<ushort> right) => AndNot(left, right);
/// <summary>
/// __m128i _mm_andnot_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<int> AndNot(Vector128<int> left, Vector128<int> right) { throw new NotImplementedException(); }
+ public static Vector128<int> AndNot(Vector128<int> left, Vector128<int> right) => AndNot(left, right);
/// <summary>
/// __m128i _mm_andnot_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<uint> AndNot(Vector128<uint> left, Vector128<uint> right) { throw new NotImplementedException(); }
+ public static Vector128<uint> AndNot(Vector128<uint> left, Vector128<uint> right) => AndNot(left, right);
/// <summary>
/// __m128i _mm_andnot_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<long> AndNot(Vector128<long> left, Vector128<long> right) { throw new NotImplementedException(); }
+ public static Vector128<long> AndNot(Vector128<long> left, Vector128<long> right) => AndNot(left, right);
/// <summary>
/// __m128i _mm_andnot_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<ulong> AndNot(Vector128<ulong> left, Vector128<ulong> right) { throw new NotImplementedException(); }
+ public static Vector128<ulong> AndNot(Vector128<ulong> left, Vector128<ulong> right) => AndNot(left, right);
/// <summary>
/// __m128d _mm_andnot_pd (__m128d a, __m128d b)
/// </summary>
- public static Vector128<double> AndNot(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static Vector128<double> AndNot(Vector128<double> left, Vector128<double> right) => AndNot(left, right);
/// <summary>
/// __m128i _mm_avg_epu8 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<byte> Average(Vector128<byte> left, Vector128<byte> right) { throw new NotImplementedException(); }
+ public static Vector128<byte> Average(Vector128<byte> left, Vector128<byte> right) => Average(left, right);
/// <summary>
/// __m128i _mm_avg_epu16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<ushort> Average(Vector128<ushort> left, Vector128<ushort> right) { throw new NotImplementedException(); }
+ public static Vector128<ushort> Average(Vector128<ushort> left, Vector128<ushort> right) => Average(left, right);
/// <summary>
/// __m128i _mm_cmpeq_epi8 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<sbyte> CompareEqual(Vector128<sbyte> left, Vector128<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> CompareEqual(Vector128<sbyte> left, Vector128<sbyte> right) => CompareEqual(left, right);
/// <summary>
/// __m128i _mm_cmpeq_epi8 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<byte> CompareEqual(Vector128<byte> left, Vector128<byte> right) { throw new NotImplementedException(); }
+ public static Vector128<byte> CompareEqual(Vector128<byte> left, Vector128<byte> right) => CompareEqual(left, right);
/// <summary>
/// __m128i _mm_cmpeq_epi16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<short> CompareEqual(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
+ public static Vector128<short> CompareEqual(Vector128<short> left, Vector128<short> right) => CompareEqual(left, right);
/// <summary>
/// __m128i _mm_cmpeq_epi16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<ushort> CompareEqual(Vector128<ushort> left, Vector128<ushort> right) { throw new NotImplementedException(); }
+ public static Vector128<ushort> CompareEqual(Vector128<ushort> left, Vector128<ushort> right) => CompareEqual(left, right);
/// <summary>
/// __m128i _mm_cmpeq_epi32 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<int> CompareEqual(Vector128<int> left, Vector128<int> right) { throw new NotImplementedException(); }
+ public static Vector128<int> CompareEqual(Vector128<int> left, Vector128<int> right) => CompareEqual(left, right);
/// <summary>
/// __m128i _mm_cmpeq_epi32 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<uint> CompareEqual(Vector128<uint> left, Vector128<uint> right) { throw new NotImplementedException(); }
+ public static Vector128<uint> CompareEqual(Vector128<uint> left, Vector128<uint> right) => CompareEqual(left, right);
/// <summary>
/// __m128d _mm_cmpeq_pd (__m128d a, __m128d b)
/// </summary>
- public static Vector128<double> CompareEqual(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static Vector128<double> CompareEqual(Vector128<double> left, Vector128<double> right) => CompareEqual(left, right);
/// <summary>
/// __m128i _mm_cmpgt_epi8 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<sbyte> CompareGreaterThan(Vector128<sbyte> left, Vector128<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> CompareGreaterThan(Vector128<sbyte> left, Vector128<sbyte> right) => CompareGreaterThan(left, right);
/// <summary>
/// __m128i _mm_cmpgt_epi16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<short> CompareGreaterThan(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
+ public static Vector128<short> CompareGreaterThan(Vector128<short> left, Vector128<short> right) => CompareGreaterThan(left, right);
/// <summary>
/// __m128i _mm_cmpgt_epi32 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<int> CompareGreaterThan(Vector128<int> left, Vector128<int> right) { throw new NotImplementedException(); }
+ public static Vector128<int> CompareGreaterThan(Vector128<int> left, Vector128<int> right) => CompareGreaterThan(left, right);
/// <summary>
/// __m128d _mm_cmpgt_pd (__m128d a, __m128d b)
/// </summary>
- public static Vector128<double> CompareGreaterThan(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static Vector128<double> CompareGreaterThan(Vector128<double> left, Vector128<double> right) => CompareGreaterThan(left, right);
/// <summary>
/// __m128d _mm_cmpge_pd (__m128d a, __m128d b)
/// </summary>
- public static Vector128<double> CompareGreaterThanOrEqual(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static Vector128<double> CompareGreaterThanOrEqual(Vector128<double> left, Vector128<double> right) => CompareGreaterThanOrEqual(left, right);
/// <summary>
/// __m128i _mm_cmplt_epi8 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<sbyte> CompareLessThan(Vector128<sbyte> left, Vector128<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> CompareLessThan(Vector128<sbyte> left, Vector128<sbyte> right) => CompareLessThan(left, right);
/// <summary>
/// __m128i _mm_cmplt_epi16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<short> CompareLessThan(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
+ public static Vector128<short> CompareLessThan(Vector128<short> left, Vector128<short> right) => CompareLessThan(left, right);
/// <summary>
/// __m128i _mm_cmplt_epi32 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<int> CompareLessThan(Vector128<int> left, Vector128<int> right) { throw new NotImplementedException(); }
+ public static Vector128<int> CompareLessThan(Vector128<int> left, Vector128<int> right) => CompareLessThan(left, right);
/// <summary>
/// __m128d _mm_cmplt_pd (__m128d a, __m128d b)
/// </summary>
- public static Vector128<double> CompareLessThan(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static Vector128<double> CompareLessThan(Vector128<double> left, Vector128<double> right) => CompareLessThan(left, right);
/// <summary>
/// __m128d _mm_cmple_pd (__m128d a, __m128d b)
/// </summary>
- public static Vector128<double> CompareLessThanOrEqual(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static Vector128<double> CompareLessThanOrEqual(Vector128<double> left, Vector128<double> right) => CompareLessThanOrEqual(left, right);
/// <summary>
/// __m128d _mm_cmpneq_pd (__m128d a, __m128d b)
/// </summary>
- public static Vector128<double> CompareNotEqual(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static Vector128<double> CompareNotEqual(Vector128<double> left, Vector128<double> right) => CompareNotEqual(left, right);
/// <summary>
/// __m128d _mm_cmpngt_pd (__m128d a, __m128d b)
/// </summary>
- public static Vector128<double> CompareNotGreaterThan(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static Vector128<double> CompareNotGreaterThan(Vector128<double> left, Vector128<double> right) => CompareNotGreaterThan(left, right);
/// <summary>
/// __m128d _mm_cmpnge_pd (__m128d a, __m128d b)
/// </summary>
- public static Vector128<double> CompareNotGreaterThanOrEqual(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static Vector128<double> CompareNotGreaterThanOrEqual(Vector128<double> left, Vector128<double> right) => CompareNotGreaterThanOrEqual(left, right);
/// <summary>
/// __m128d _mm_cmpnlt_pd (__m128d a, __m128d b)
/// </summary>
- public static Vector128<double> CompareNotLessThan(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static Vector128<double> CompareNotLessThan(Vector128<double> left, Vector128<double> right) => CompareNotLessThan(left, right);
/// <summary>
/// __m128d _mm_cmpnle_pd (__m128d a, __m128d b)
/// </summary>
- public static Vector128<double> CompareNotLessThanOrEqual(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static Vector128<double> CompareNotLessThanOrEqual(Vector128<double> left, Vector128<double> right) => CompareNotLessThanOrEqual(left, right);
/// <summary>
/// __m128d _mm_cmpord_pd (__m128d a, __m128d b)
/// </summary>
- public static Vector128<double> CompareOrdered(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static Vector128<double> CompareOrdered(Vector128<double> left, Vector128<double> right) => CompareOrdered(left, right);
/// <summary>
/// __m128d _mm_cmpunord_pd (__m128d a, __m128d b)
/// </summary>
- public static Vector128<double> CompareUnordered(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static Vector128<double> CompareUnordered(Vector128<double> left, Vector128<double> right) => CompareUnordered(left, right);
/// <summary>
/// __m128i _mm_cvtps_epi32 (__m128 a)
/// </summary>
- public static Vector128<int> ConvertToInt(Vector128<float> value) { throw new NotImplementedException(); }
+ public static Vector128<int> ConvertToInt(Vector128<float> value) => ConvertToInt(value);
/// <summary>
/// __m128i _mm_cvtpd_epi32 (__m128d a)
/// </summary>
- public static Vector128<int> ConvertToInt(Vector128<double> value) { throw new NotImplementedException(); }
+ public static Vector128<int> ConvertToInt(Vector128<double> value) => ConvertToInt(value);
/// <summary>
/// __m128 _mm_cvtepi32_ps (__m128i a)
/// </summary>
- public static Vector128<float> ConvertToFloat(Vector128<int> value) { throw new NotImplementedException(); }
+ public static Vector128<float> ConvertToFloat(Vector128<int> value) => ConvertToFloat(value);
/// <summary>
/// __m128 _mm_cvtpd_ps (__m128d a)
/// </summary>
- public static Vector128<float> ConvertToFloat(Vector128<double> value) { throw new NotImplementedException(); }
+ public static Vector128<float> ConvertToFloat(Vector128<double> value) => ConvertToFloat(value);
/// <summary>
/// __m128d _mm_cvtepi32_pd (__m128i a)
/// </summary>
- public static Vector128<double> ConvertToDouble(Vector128<int> value) { throw new NotImplementedException(); }
+ public static Vector128<double> ConvertToDouble(Vector128<int> value) => ConvertToDouble(value);
/// <summary>
/// __m128d _mm_cvtps_pd (__m128 a)
/// </summary>
- public static Vector128<double> ConvertToDouble(Vector128<float> value) { throw new NotImplementedException(); }
+ public static Vector128<double> ConvertToDouble(Vector128<float> value) => ConvertToDouble(value);
/// <summary>
/// __m128i _mm_cvttps_epi32 (__m128 a)
/// </summary>
- public static Vector128<int> ConvertToIntWithTruncation(Vector128<float> value) { throw new NotImplementedException(); }
+ public static Vector128<int> ConvertToIntWithTruncation(Vector128<float> value) => ConvertToIntWithTruncation(value);
/// <summary>
/// __m128i _mm_cvttpd_epi32 (__m128d a)
/// </summary>
- public static Vector128<int> ConvertToIntWithTruncation(Vector128<double> value) { throw new NotImplementedException(); }
+ public static Vector128<int> ConvertToIntWithTruncation(Vector128<double> value) => ConvertToIntWithTruncation(value);
/// <summary>
/// __m128d _mm_div_pd (__m128d a, __m128d b)
/// </summary>
- public static Vector128<double> Divide(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static Vector128<double> Divide(Vector128<double> left, Vector128<double> right) => Divide(left, right);
/// <summary>
/// int _mm_extract_epi16 (__m128i a, int immediate)
/// </summary>
- public static short ExtractShort<T>(Vector128<T> value, byte index) where T : struct { throw new NotImplementedException(); }
+ public static short ExtractShort<T>(Vector128<T> value, byte index) where T : struct => ExtractShort<T>(value, index);
/// <summary>
/// int _mm_extract_epi16 (__m128i a, int immediate)
/// </summary>
- public static ushort ExtractUshort<T>(Vector128<T> value, byte index) where T : struct { throw new NotImplementedException(); }
+ public static ushort ExtractUshort<T>(Vector128<T> value, byte index) where T : struct => ExtractUshort<T>(value, index);
/// <summary>
/// __m128i _mm_insert_epi16 (__m128i a, int i, int immediate)
/// </summary>
- public static Vector128<T> InsertShort<T>(Vector128<T> value, short data, byte index) where T : struct { throw new NotImplementedException(); }
+ public static Vector128<T> InsertShort<T>(Vector128<T> value, short data, byte index) where T : struct => InsertShort<T>(value, data, index);
/// <summary>
/// __m128i _mm_insert_epi16 (__m128i a, int i, int immediate)
/// </summary>
- public static Vector128<T> InsertUshort<T>(Vector128<T> value, ushort data, byte index) where T : struct { throw new NotImplementedException(); }
+ public static Vector128<T> InsertUshort<T>(Vector128<T> value, ushort data, byte index) where T : struct => InsertUshort<T>(value, data, index);
/// <summary>
/// __m128i _mm_loadu_si128 (__m128i const* mem_address)
/// </summary>
- public static unsafe Vector128<sbyte> Load(sbyte* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<sbyte> Load(sbyte* address) => Load(address);
/// <summary>
/// __m128i _mm_loadu_si128 (__m128i const* mem_address)
/// </summary>
- public static unsafe Vector128<byte> Load(byte* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<byte> Load(byte* address) => Load(address);
/// <summary>
/// __m128i _mm_loadu_si128 (__m128i const* mem_address)
/// </summary>
- public static unsafe Vector128<short> Load(short* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<short> Load(short* address) => Load(address);
/// <summary>
/// __m128i _mm_loadu_si128 (__m128i const* mem_address)
/// </summary>
- public static unsafe Vector128<ushort> Load(ushort* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<ushort> Load(ushort* address) => Load(address);
/// <summary>
/// __m128i _mm_loadu_si128 (__m128i const* mem_address)
/// </summary>
- public static unsafe Vector128<int> Load(int* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<int> Load(int* address) => Load(address);
/// <summary>
/// __m128i _mm_loadu_si128 (__m128i const* mem_address)
/// </summary>
- public static unsafe Vector128<uint> Load(uint* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<uint> Load(uint* address) => Load(address);
/// <summary>
/// __m128i _mm_loadu_si128 (__m128i const* mem_address)
/// </summary>
- public static unsafe Vector128<long> Load(long* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<long> Load(long* address) => Load(address);
/// <summary>
/// __m128i _mm_loadu_si128 (__m128i const* mem_address)
/// </summary>
- public static unsafe Vector128<ulong> Load(ulong* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<ulong> Load(ulong* address) => Load(address);
/// <summary>
/// __m128d _mm_loadu_pd (double const* mem_address)
/// </summary>
- public static unsafe Vector128<double> Load(double* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<double> Load(double* address) => Load(address);
/// <summary>
/// __m128i _mm_load_si128 (__m128i const* mem_address)
/// </summary>
- public static unsafe Vector128<sbyte> LoadAligned(sbyte* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<sbyte> LoadAligned(sbyte* address) => LoadAligned(address);
/// <summary>
/// __m128i _mm_load_si128 (__m128i const* mem_address)
/// </summary>
- public static unsafe Vector128<byte> LoadAligned(byte* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<byte> LoadAligned(byte* address) => LoadAligned(address);
/// <summary>
/// __m128i _mm_load_si128 (__m128i const* mem_address)
/// </summary>
- public static unsafe Vector128<short> LoadAligned(short* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<short> LoadAligned(short* address) => LoadAligned(address);
/// <summary>
/// __m128i _mm_load_si128 (__m128i const* mem_address)
/// </summary>
- public static unsafe Vector128<ushort> LoadAligned(ushort* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<ushort> LoadAligned(ushort* address) => LoadAligned(address);
/// <summary>
/// __m128i _mm_load_si128 (__m128i const* mem_address)
/// </summary>
- public static unsafe Vector128<int> LoadAligned(int* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<int> LoadAligned(int* address) => LoadAligned(address);
/// <summary>
/// __m128i _mm_load_si128 (__m128i const* mem_address)
/// </summary>
- public static unsafe Vector128<uint> LoadAligned(uint* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<uint> LoadAligned(uint* address) => LoadAligned(address);
/// <summary>
/// __m128i _mm_load_si128 (__m128i const* mem_address)
/// </summary>
- public static unsafe Vector128<long> LoadAligned(long* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<long> LoadAligned(long* address) => LoadAligned(address);
/// <summary>
/// __m128i _mm_load_si128 (__m128i const* mem_address)
/// </summary>
- public static unsafe Vector128<ulong> LoadAligned(ulong* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<ulong> LoadAligned(ulong* address) => LoadAligned(address);
/// <summary>
/// __m128d _mm_load_pd (double const* mem_address)
/// </summary>
- public static unsafe Vector128<double> LoadAligned(double* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<double> LoadAligned(double* address) => LoadAligned(address);
/// <summary>
/// void _mm_maskmoveu_si128 (__m128i a, __m128i mask, char* mem_address)
/// </summary>
- public static unsafe void MaskMove(Vector128<sbyte> source, Vector128<sbyte> mask, sbyte* address) { throw new NotImplementedException(); }
+ public static unsafe void MaskMove(Vector128<sbyte> source, Vector128<sbyte> mask, sbyte* address) => MaskMove(source, mask, address);
/// <summary>
/// void _mm_maskmoveu_si128 (__m128i a, __m128i mask, char* mem_address)
/// </summary>
- public static unsafe void MaskMove(Vector128<byte> source, Vector128<byte> mask, byte* address) { throw new NotImplementedException(); }
+ public static unsafe void MaskMove(Vector128<byte> source, Vector128<byte> mask, byte* address) => MaskMove(source, mask, address);
/// <summary>
/// __m128i _mm_max_epu8 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<byte> Max(Vector128<byte> left, Vector128<byte> right) { throw new NotImplementedException(); }
+ public static Vector128<byte> Max(Vector128<byte> left, Vector128<byte> right) => Max(left, right);
/// <summary>
/// __m128i _mm_max_epi16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<short> Max(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
+ public static Vector128<short> Max(Vector128<short> left, Vector128<short> right) => Max(left, right);
/// <summary>
/// __m128d _mm_max_pd (__m128d a, __m128d b)
/// </summary>
- public static Vector128<double> Max(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static Vector128<double> Max(Vector128<double> left, Vector128<double> right) => Max(left, right);
/// <summary>
/// __m128i _mm_min_epu8 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<byte> Min(Vector128<byte> left, Vector128<byte> right) { throw new NotImplementedException(); }
+ public static Vector128<byte> Min(Vector128<byte> left, Vector128<byte> right) => Min(left, right);
/// <summary>
/// __m128i _mm_min_epi16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<short> Min(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
+ public static Vector128<short> Min(Vector128<short> left, Vector128<short> right) => Min(left, right);
/// <summary>
/// __m128d _mm_min_pd (__m128d a, __m128d b)
/// </summary>
- public static Vector128<double> Min(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static Vector128<double> Min(Vector128<double> left, Vector128<double> right) => Min(left, right);
/// <summary>
/// int _mm_movemask_epi8 (__m128i a)
/// </summary>
- public static int MoveMask(Vector128<sbyte> value) { throw new NotImplementedException(); }
+ public static int MoveMask(Vector128<sbyte> value) => MoveMask(value);
/// <summary>
/// int _mm_movemask_pd (__m128d a)
/// </summary>
- public static int MoveMask(Vector128<double> value) { throw new NotImplementedException(); }
+ public static int MoveMask(Vector128<double> value) => MoveMask(value);
/// <summary>
/// __m128i _mm_mul_epu32 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<ulong> Multiply(Vector128<uint> left, Vector128<uint> right) { throw new NotImplementedException(); }
+ public static Vector128<ulong> Multiply(Vector128<uint> left, Vector128<uint> right) => Multiply(left, right);
/// <summary>
/// __m128d _mm_mul_pd (__m128d a, __m128d b)
/// </summary>
- public static Vector128<double> Multiply(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static Vector128<double> Multiply(Vector128<double> left, Vector128<double> right) => Multiply(left, right);
/// <summary>
/// __m128i _mm_mulhi_epi16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<short> MultiplyHi(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
+ public static Vector128<short> MultiplyHi(Vector128<short> left, Vector128<short> right) => MultiplyHi(left, right);
/// <summary>
/// __m128i _mm_mulhi_epu16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<ushort> MultiplyHi(Vector128<ushort> left, Vector128<ushort> right) { throw new NotImplementedException(); }
+ public static Vector128<ushort> MultiplyHi(Vector128<ushort> left, Vector128<ushort> right) => MultiplyHi(left, right);
/// <summary>
/// __m128i _mm_madd_epi16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<int> MultiplyHorizontalAdd(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
+ public static Vector128<int> MultiplyHorizontalAdd(Vector128<short> left, Vector128<short> right) => MultiplyHorizontalAdd(left, right);
/// <summary>
/// __m128i _mm_mullo_epi16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<short> MultiplyLow(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
+ public static Vector128<short> MultiplyLow(Vector128<short> left, Vector128<short> right) => MultiplyLow(left, right);
/// <summary>
/// __m128i _mm_or_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<byte> Or(Vector128<byte> left, Vector128<byte> right) { throw new NotImplementedException(); }
+ public static Vector128<byte> Or(Vector128<byte> left, Vector128<byte> right) => Or(left, right);
/// <summary>
/// __m128i _mm_or_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<sbyte> Or(Vector128<sbyte> left, Vector128<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> Or(Vector128<sbyte> left, Vector128<sbyte> right) => Or(left, right);
/// <summary>
/// __m128i _mm_or_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<short> Or(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
+ public static Vector128<short> Or(Vector128<short> left, Vector128<short> right) => Or(left, right);
/// <summary>
/// __m128i _mm_or_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<ushort> Or(Vector128<ushort> left, Vector128<ushort> right) { throw new NotImplementedException(); }
+ public static Vector128<ushort> Or(Vector128<ushort> left, Vector128<ushort> right) => Or(left, right);
/// <summary>
/// __m128i _mm_or_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<int> Or(Vector128<int> left, Vector128<int> right) { throw new NotImplementedException(); }
+ public static Vector128<int> Or(Vector128<int> left, Vector128<int> right) => Or(left, right);
/// <summary>
/// __m128i _mm_or_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<uint> Or(Vector128<uint> left, Vector128<uint> right) { throw new NotImplementedException(); }
+ public static Vector128<uint> Or(Vector128<uint> left, Vector128<uint> right) => Or(left, right);
/// <summary>
/// __m128i _mm_or_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<long> Or(Vector128<long> left, Vector128<long> right) { throw new NotImplementedException(); }
+ public static Vector128<long> Or(Vector128<long> left, Vector128<long> right) => Or(left, right);
/// <summary>
/// __m128i _mm_or_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<ulong> Or(Vector128<ulong> left, Vector128<ulong> right) { throw new NotImplementedException(); }
+ public static Vector128<ulong> Or(Vector128<ulong> left, Vector128<ulong> right) => Or(left, right);
/// <summary>
/// __m128d _mm_or_pd (__m128d a, __m128d b)
/// </summary>
- public static Vector128<double> Or(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static Vector128<double> Or(Vector128<double> left, Vector128<double> right) => Or(left, right);
/// <summary>
/// __m128i _mm_packs_epi16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<sbyte> PackSignedSaturate(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> PackSignedSaturate(Vector128<short> left, Vector128<short> right) => PackSignedSaturate(left, right);
/// <summary>
/// __m128i _mm_packs_epi32 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<short> PackSignedSaturate(Vector128<int> left, Vector128<int> right) { throw new NotImplementedException(); }
+ public static Vector128<short> PackSignedSaturate(Vector128<int> left, Vector128<int> right) => PackSignedSaturate(left, right);
/// <summary>
/// __m128i _mm_packus_epi16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<byte> PackUnsignedSaturate(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
+ public static Vector128<byte> PackUnsignedSaturate(Vector128<short> left, Vector128<short> right) => PackUnsignedSaturate(left, right);
/// <summary>
/// ___m128i _mm_set_epi8 (char e15, char e14, char e13, char e12, char e11, char e10, char e9, char e8, char e7, char e6, char e5, char e4, char e3, char e2, char e1, char e0)
/// </summary>
- public static Vector128<sbyte> Set(sbyte e15, sbyte e14, sbyte e13, sbyte e12, sbyte e11, sbyte e10, sbyte e9, sbyte e8, sbyte e7, sbyte e6, sbyte e5, sbyte e4, sbyte e3, sbyte e2, sbyte e1, sbyte e0) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> Set(sbyte e15, sbyte e14, sbyte e13, sbyte e12, sbyte e11, sbyte e10, sbyte e9, sbyte e8, sbyte e7, sbyte e6, sbyte e5, sbyte e4, sbyte e3, sbyte e2, sbyte e1, sbyte e0) => Set(e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0);
/// <summary>
/// ___m128i _mm_set_epi8 (char e15, char e14, char e13, char e12, char e11, char e10, char e9, char e8, char e7, char e6, char e5, char e4, char e3, char e2, char e1, char e0)
/// </summary>
- public static Vector128<byte> Set(byte e15, byte e14, byte e13, byte e12, byte e11, byte e10, byte e9, byte e8, byte e7, byte e6, byte e5, byte e4, byte e3, byte e2, byte e1, byte e0) { throw new NotImplementedException(); }
+ public static Vector128<byte> Set(byte e15, byte e14, byte e13, byte e12, byte e11, byte e10, byte e9, byte e8, byte e7, byte e6, byte e5, byte e4, byte e3, byte e2, byte e1, byte e0) => Set(e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0);
/// <summary>
/// __m128i _mm_set_epi16 (short e7, short e6, short e5, short e4, short e3, short e2, short e1, short e0)
/// </summary>
- public static Vector128<short> Set(short e7, short e6, short e5, short e4, short e3, short e2, short e1, short e0) { throw new NotImplementedException(); }
+ public static Vector128<short> Set(short e7, short e6, short e5, short e4, short e3, short e2, short e1, short e0) => Set(e7, e6, e5, e4, e3, e2, e1, e0);
/// <summary>
/// __m128i _mm_set_epi16 (short e7, short e6, short e5, short e4, short e3, short e2, short e1, short e0)
/// </summary>
- public static Vector128<ushort> Set(ushort e7, ushort e6, ushort e5, ushort e4, ushort e3, ushort e2, ushort e1, ushort e0) { throw new NotImplementedException(); }
+ public static Vector128<ushort> Set(ushort e7, ushort e6, ushort e5, ushort e4, ushort e3, ushort e2, ushort e1, ushort e0) => Set(e7, e6, e5, e4, e3, e2, e1, e0);
/// <summary>
/// __m128i _mm_set_epi32 (int e3, int e2, int e1, int e0)
/// </summary>
- public static Vector128<int> Set(int e3, int e2, int e1, int e0) { throw new NotImplementedException(); }
+ public static Vector128<int> Set(int e3, int e2, int e1, int e0) => Set(e3, e2, e1, e0);
/// <summary>
/// __m128i _mm_set_epi32 (int e3, int e2, int e1, int e0)
/// </summary>
- public static Vector128<uint> Set(uint e3, uint e2, uint e1, uint e0) { throw new NotImplementedException(); }
+ public static Vector128<uint> Set(uint e3, uint e2, uint e1, uint e0) => Set(e3, e2, e1, e0);
/// <summary>
/// __m128i _mm_set_epi64x (__int64 e1, __int64 e0)
/// </summary>
- public static Vector128<long> Set(long e1, long e0) { throw new NotImplementedException(); }
+ public static Vector128<long> Set(long e1, long e0) => Set(e1, e0);
/// <summary>
/// __m128i _mm_set_epi64x (__int64 e1, __int64 e0)
/// </summary>
- public static Vector128<ulong> Set(ulong e1, ulong e0) { throw new NotImplementedException(); }
+ public static Vector128<ulong> Set(ulong e1, ulong e0) => Set(e1, e0);
/// <summary>
/// __m128d _mm_set_pd (double e1, double e0)
/// </summary>
- public static Vector128<double> Set(double e1, double e0) { throw new NotImplementedException(); }
+ public static Vector128<double> Set(double e1, double e0) => Set(e1, e0);
/// <summary>
/// __m128i _mm_set1_epi8 (char a)
/// </summary>
- public static Vector128<byte> Set1(byte value) { throw new NotImplementedException(); }
+ public static Vector128<byte> Set1(byte value) => Set1(value);
/// <summary>
/// __m128i _mm_set1_epi8 (char a)
/// </summary>
- public static Vector128<sbyte> Set1(sbyte value) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> Set1(sbyte value) => Set1(value);
/// <summary>
/// __m128i _mm_set1_epi16 (short a)
/// </summary>
- public static Vector128<short> Set1(short value) { throw new NotImplementedException(); }
+ public static Vector128<short> Set1(short value) => Set1(value);
/// <summary>
/// __m128i _mm_set1_epi16 (short a)
/// </summary>
- public static Vector128<ushort> Set1(ushort value) { throw new NotImplementedException(); }
+ public static Vector128<ushort> Set1(ushort value) => Set1(value);
/// <summary>
/// __m128i _mm_set1_epi32 (int a)
/// </summary>
- public static Vector128<int> Set1(int value) { throw new NotImplementedException(); }
+ public static Vector128<int> Set1(int value) => Set1(value);
/// <summary>
/// __m128i _mm_set1_epi32 (int a)
/// </summary>
- public static Vector128<uint> Set1(uint value) { throw new NotImplementedException(); }
+ public static Vector128<uint> Set1(uint value) => Set1(value);
/// <summary>
/// __m128i _mm_set1_epi64x (long long a)
/// </summary>
- public static Vector128<long> Set1(long value) { throw new NotImplementedException(); }
+ public static Vector128<long> Set1(long value) => Set1(value);
/// <summary>
/// __m128i _mm_set1_epi64x (long long a)
/// </summary>
- public static Vector128<ulong> Set1(ulong value) { throw new NotImplementedException(); }
+ public static Vector128<ulong> Set1(ulong value) => Set1(value);
/// <summary>
/// __m128d _mm_set1_pd (double a)
/// </summary>
- public static Vector128<double> Set1(double value) { throw new NotImplementedException(); }
+ public static Vector128<double> Set1(double value) => Set1(value);
/// <summary>
/// __m128i _mm_setzero_si128 ()
/// __m128d _mm_setzero_pd (void)
/// </summary>
- public static Vector128<T> SetZero<T>() where T : struct { throw new NotImplementedException(); }
+ public static Vector128<T> SetZero<T>() where T : struct => SetZero<T>();
/// <summary>
/// __m128i _mm_sad_epu8 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<long> SumAbsoluteDifferences(Vector128<byte> left, Vector128<byte> right) { throw new NotImplementedException(); }
+ public static Vector128<long> SumAbsoluteDifferences(Vector128<byte> left, Vector128<byte> right) => SumAbsoluteDifferences(left, right);
/// <summary>
/// __m128i _mm_shuffle_epi32 (__m128i a, int immediate)
/// </summary>
- public static Vector128<int> Shuffle(Vector128<int> value, byte control) { throw new NotImplementedException(); }
+ public static Vector128<int> Shuffle(Vector128<int> value, byte control) => Shuffle(value, control);
/// <summary>
/// __m128i _mm_shuffle_epi32 (__m128i a, int immediate)
/// </summary>
- public static Vector128<uint> Shuffle(Vector128<uint> value, byte control) { throw new NotImplementedException(); }
+ public static Vector128<uint> Shuffle(Vector128<uint> value, byte control) => Shuffle(value, control);
/// <summary>
/// __m128d _mm_shuffle_pd (__m128d a, __m128d b, int immediate)
/// </summary>
- public static Vector128<double> Shuffle(Vector128<double> left, Vector128<double> right, byte control) { throw new NotImplementedException(); }
+ public static Vector128<double> Shuffle(Vector128<double> left, Vector128<double> right, byte control) => Shuffle(left, right, control);
/// <summary>
/// __m128i _mm_shufflehi_epi16 (__m128i a, int immediate)
/// </summary>
- public static Vector128<short> ShuffleHigh(Vector128<short> value, byte control) { throw new NotImplementedException(); }
+ public static Vector128<short> ShuffleHigh(Vector128<short> value, byte control) => ShuffleHigh(value, control);
/// <summary>
/// __m128i _mm_shufflehi_epi16 (__m128i a, int control)
/// </summary>
- public static Vector128<ushort> ShuffleHigh(Vector128<ushort> value, byte control) { throw new NotImplementedException(); }
+ public static Vector128<ushort> ShuffleHigh(Vector128<ushort> value, byte control) => ShuffleHigh(value, control);
/// <summary>
/// __m128i _mm_shufflelo_epi16 (__m128i a, int control)
/// </summary>
- public static Vector128<short> ShuffleLow(Vector128<short> value, byte control) { throw new NotImplementedException(); }
+ public static Vector128<short> ShuffleLow(Vector128<short> value, byte control) => ShuffleLow(value, control);
/// <summary>
/// __m128i _mm_shufflelo_epi16 (__m128i a, int control)
/// </summary>
- public static Vector128<ushort> ShuffleLow(Vector128<ushort> value, byte control) { throw new NotImplementedException(); }
+ public static Vector128<ushort> ShuffleLow(Vector128<ushort> value, byte control) => ShuffleLow(value, control);
/// <summary>
/// __m128i _mm_slli_epi16 (__m128i a, int immediate)
/// </summary>
- public static Vector128<short> ShiftLeftLogical(Vector128<short> value, byte count) { throw new NotImplementedException(); }
+ public static Vector128<short> ShiftLeftLogical(Vector128<short> value, byte count) => ShiftLeftLogical(value, count);
/// <summary>
/// __m128i _mm_slli_epi16 (__m128i a, int immediate)
/// </summary>
- public static Vector128<ushort> ShiftLeftLogical(Vector128<ushort> value, byte count) { throw new NotImplementedException(); }
+ public static Vector128<ushort> ShiftLeftLogical(Vector128<ushort> value, byte count) => ShiftLeftLogical(value, count);
/// <summary>
/// __m128i _mm_slli_epi32 (__m128i a, int immediate)
/// </summary>
- public static Vector128<int> ShiftLeftLogical(Vector128<int> value, byte count) { throw new NotImplementedException(); }
+ public static Vector128<int> ShiftLeftLogical(Vector128<int> value, byte count) => ShiftLeftLogical(value, count);
/// <summary>
/// __m128i _mm_slli_epi32 (__m128i a, int immediate)
/// </summary>
- public static Vector128<uint> ShiftLeftLogical(Vector128<uint> value, byte count) { throw new NotImplementedException(); }
+ public static Vector128<uint> ShiftLeftLogical(Vector128<uint> value, byte count) => ShiftLeftLogical(value, count);
/// <summary>
/// __m128i _mm_slli_epi64 (__m128i a, int immediate)
/// </summary>
- public static Vector128<long> ShiftLeftLogical(Vector128<long> value, byte count) { throw new NotImplementedException(); }
+ public static Vector128<long> ShiftLeftLogical(Vector128<long> value, byte count) => ShiftLeftLogical(value, count);
/// <summary>
/// __m128i _mm_slli_epi64 (__m128i a, int immediate)
/// </summary>
- public static Vector128<ulong> ShiftLeftLogical(Vector128<ulong> value, byte count) { throw new NotImplementedException(); }
+ public static Vector128<ulong> ShiftLeftLogical(Vector128<ulong> value, byte count) => ShiftLeftLogical(value, count);
/// <summary>
/// __m128i _mm_bslli_si128 (__m128i a, int imm8)
/// </summary>
- public static Vector128<sbyte> ShiftLeftLogical128BitLane(Vector128<sbyte> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> ShiftLeftLogical128BitLane(Vector128<sbyte> value, byte numBytes) => ShiftLeftLogical128BitLane(value, numBytes);
/// <summary>
/// __m128i _mm_bslli_si128 (__m128i a, int imm8)
/// </summary>
- public static Vector128<byte> ShiftLeftLogical128BitLane(Vector128<byte> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector128<byte> ShiftLeftLogical128BitLane(Vector128<byte> value, byte numBytes) => ShiftLeftLogical128BitLane(value, numBytes);
/// <summary>
/// __m128i _mm_bslli_si128 (__m128i a, int imm8)
/// </summary>
- public static Vector128<short> ShiftLeftLogical128BitLane(Vector128<short> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector128<short> ShiftLeftLogical128BitLane(Vector128<short> value, byte numBytes) => ShiftLeftLogical128BitLane(value, numBytes);
/// <summary>
/// __m128i _mm_bslli_si128 (__m128i a, int imm8)
/// </summary>
- public static Vector128<ushort> ShiftLeftLogical128BitLane(Vector128<ushort> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector128<ushort> ShiftLeftLogical128BitLane(Vector128<ushort> value, byte numBytes) => ShiftLeftLogical128BitLane(value, numBytes);
/// <summary>
/// __m128i _mm_bslli_si128 (__m128i a, int imm8)
/// </summary>
- public static Vector128<int> ShiftLeftLogical128BitLane(Vector128<int> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector128<int> ShiftLeftLogical128BitLane(Vector128<int> value, byte numBytes) => ShiftLeftLogical128BitLane(value, numBytes);
/// <summary>
/// __m128i _mm_bslli_si128 (__m128i a, int imm8)
/// </summary>
- public static Vector128<uint> ShiftLeftLogical128BitLane(Vector128<uint> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector128<uint> ShiftLeftLogical128BitLane(Vector128<uint> value, byte numBytes) => ShiftLeftLogical128BitLane(value, numBytes);
/// <summary>
/// __m128i _mm_bslli_si128 (__m128i a, int imm8)
/// </summary>
- public static Vector128<long> ShiftLeftLogical128BitLane(Vector128<long> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector128<long> ShiftLeftLogical128BitLane(Vector128<long> value, byte numBytes) => ShiftLeftLogical128BitLane(value, numBytes);
/// <summary>
/// __m128i _mm_bslli_si128 (__m128i a, int imm8)
/// </summary>
- public static Vector128<ulong> ShiftLeftLogical128BitLane(Vector128<ulong> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector128<ulong> ShiftLeftLogical128BitLane(Vector128<ulong> value, byte numBytes) => ShiftLeftLogical128BitLane(value, numBytes);
/// <summary>
/// __m128i _mm_srai_epi16 (__m128i a, int immediate)
/// </summary>
- public static Vector128<short> ShiftRightArithmetic(Vector128<short> value, byte count) { throw new NotImplementedException(); }
+ public static Vector128<short> ShiftRightArithmetic(Vector128<short> value, byte count) => ShiftRightArithmetic(value, count);
/// <summary>
/// __m128i _mm_srai_epi32 (__m128i a, int immediate)
/// </summary>
- public static Vector128<int> ShiftRightArithmetic(Vector128<int> value, byte count) { throw new NotImplementedException(); }
+ public static Vector128<int> ShiftRightArithmetic(Vector128<int> value, byte count) => ShiftRightArithmetic(value, count);
/// <summary>
/// __m128i _mm_srli_epi16 (__m128i a, int immediate)
/// </summary>
- public static Vector128<short> ShiftRightLogical(Vector128<short> value, byte count) { throw new NotImplementedException(); }
+ public static Vector128<short> ShiftRightLogical(Vector128<short> value, byte count) => ShiftRightLogical(value, count);
/// <summary>
/// __m128i _mm_srli_epi16 (__m128i a, int immediate)
/// </summary>
- public static Vector128<ushort> ShiftRightLogical(Vector128<ushort> value, byte count) { throw new NotImplementedException(); }
+ public static Vector128<ushort> ShiftRightLogical(Vector128<ushort> value, byte count) => ShiftRightLogical(value, count);
/// <summary>
/// __m128i _mm_srli_epi32 (__m128i a, int immediate)
/// </summary>
- public static Vector128<int> ShiftRightLogical(Vector128<int> value, byte count) { throw new NotImplementedException(); }
+ public static Vector128<int> ShiftRightLogical(Vector128<int> value, byte count) => ShiftRightLogical(value, count);
/// <summary>
/// __m128i _mm_srli_epi32 (__m128i a, int immediate)
/// </summary>
- public static Vector128<uint> ShiftRightLogical(Vector128<uint> value, byte count) { throw new NotImplementedException(); }
+ public static Vector128<uint> ShiftRightLogical(Vector128<uint> value, byte count) => ShiftRightLogical(value, count);
/// <summary>
/// __m128i _mm_srli_epi64 (__m128i a, int immediate)
/// </summary>
- public static Vector128<long> ShiftRightLogical(Vector128<long> value, byte count) { throw new NotImplementedException(); }
+ public static Vector128<long> ShiftRightLogical(Vector128<long> value, byte count) => ShiftRightLogical(value, count);
/// <summary>
/// __m128i _mm_srli_epi64 (__m128i a, int immediate)
/// </summary>
- public static Vector128<ulong> ShiftRightLogical(Vector128<ulong> value, byte count) { throw new NotImplementedException(); }
+ public static Vector128<ulong> ShiftRightLogical(Vector128<ulong> value, byte count) => ShiftRightLogical(value, count);
/// <summary>
/// __m128i _mm_bsrli_si128 (__m128i a, int imm8)
/// </summary>
- public static Vector128<sbyte> ShiftRightLogical128BitLane(Vector128<sbyte> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> ShiftRightLogical128BitLane(Vector128<sbyte> value, byte numBytes) => ShiftRightLogical128BitLane(value, numBytes);
/// <summary>
/// __m128i _mm_bsrli_si128 (__m128i a, int imm8)
/// </summary>
- public static Vector128<byte> ShiftRightLogical128BitLane(Vector128<byte> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector128<byte> ShiftRightLogical128BitLane(Vector128<byte> value, byte numBytes) => ShiftRightLogical128BitLane(value, numBytes);
/// <summary>
/// __m128i _mm_bsrli_si128 (__m128i a, int imm8)
/// </summary>
- public static Vector128<short> ShiftRightLogical128BitLane(Vector128<short> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector128<short> ShiftRightLogical128BitLane(Vector128<short> value, byte numBytes) => ShiftRightLogical128BitLane(value, numBytes);
/// <summary>
/// __m128i _mm_bsrli_si128 (__m128i a, int imm8)
/// </summary>
- public static Vector128<ushort> ShiftRightLogical128BitLane(Vector128<ushort> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector128<ushort> ShiftRightLogical128BitLane(Vector128<ushort> value, byte numBytes) => ShiftRightLogical128BitLane(value, numBytes);
/// <summary>
/// __m128i _mm_bsrli_si128 (__m128i a, int imm8)
/// </summary>
- public static Vector128<int> ShiftRightLogical128BitLane(Vector128<int> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector128<int> ShiftRightLogical128BitLane(Vector128<int> value, byte numBytes) => ShiftRightLogical128BitLane(value, numBytes);
/// <summary>
/// __m128i _mm_bsrli_si128 (__m128i a, int imm8)
/// </summary>
- public static Vector128<uint> ShiftRightLogical128BitLane(Vector128<uint> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector128<uint> ShiftRightLogical128BitLane(Vector128<uint> value, byte numBytes) => ShiftRightLogical128BitLane(value, numBytes);
/// <summary>
/// __m128i _mm_bsrli_si128 (__m128i a, int imm8)
/// </summary>
- public static Vector128<long> ShiftRightLogical128BitLane(Vector128<long> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector128<long> ShiftRightLogical128BitLane(Vector128<long> value, byte numBytes) => ShiftRightLogical128BitLane(value, numBytes);
/// <summary>
/// __m128i _mm_bsrli_si128 (__m128i a, int imm8)
/// </summary>
- public static Vector128<ulong> ShiftRightLogical128BitLane(Vector128<ulong> value, byte numBytes) { throw new NotImplementedException(); }
+ public static Vector128<ulong> ShiftRightLogical128BitLane(Vector128<ulong> value, byte numBytes) => ShiftRightLogical128BitLane(value, numBytes);
/// <summary>
/// __m128d _mm_sqrt_pd (__m128d a)
/// </summary>
- public static Vector128<double> Sqrt(Vector128<double> value) { throw new NotImplementedException(); }
+ public static Vector128<double> Sqrt(Vector128<double> value) => Sqrt(value);
/// <summary>
/// void _mm_store_si128 (__m128i* mem_addr, __m128i a)
/// </summary>
- public static unsafe void StoreAligned(sbyte* address, Vector128<sbyte> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAligned(sbyte* address, Vector128<sbyte> source) => StoreAligned(address, source);
/// <summary>
/// void _mm_store_si128 (__m128i* mem_addr, __m128i a)
/// </summary>
- public static unsafe void StoreAligned(byte* address, Vector128<byte> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAligned(byte* address, Vector128<byte> source) => StoreAligned(address, source);
/// <summary>
/// void _mm_store_si128 (__m128i* mem_addr, __m128i a)
/// </summary>
- public static unsafe void StoreAligned(short* address, Vector128<short> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAligned(short* address, Vector128<short> source) => StoreAligned(address, source);
/// <summary>
/// void _mm_store_si128 (__m128i* mem_addr, __m128i a)
/// </summary>
- public static unsafe void StoreAligned(ushort* address, Vector128<ushort> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAligned(ushort* address, Vector128<ushort> source) => StoreAligned(address, source);
/// <summary>
/// void _mm_store_si128 (__m128i* mem_addr, __m128i a)
/// </summary>
- public static unsafe void StoreAligned(int* address, Vector128<int> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAligned(int* address, Vector128<int> source) => StoreAligned(address, source);
/// <summary>
/// void _mm_store_si128 (__m128i* mem_addr, __m128i a)
/// </summary>
- public static unsafe void StoreAligned(uint* address, Vector128<uint> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAligned(uint* address, Vector128<uint> source) => StoreAligned(address, source);
/// <summary>
/// void _mm_store_si128 (__m128i* mem_addr, __m128i a)
/// </summary>
- public static unsafe void StoreAligned(long* address, Vector128<long> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAligned(long* address, Vector128<long> source) => StoreAligned(address, source);
/// <summary>
/// void _mm_store_si128 (__m128i* mem_addr, __m128i a)
/// </summary>
- public static unsafe void StoreAligned(ulong* address, Vector128<ulong> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAligned(ulong* address, Vector128<ulong> source) => StoreAligned(address, source);
/// <summary>
/// void _mm_store_pd (double* mem_addr, __m128d a)
/// </summary>
- public static unsafe void StoreAligned(double* address, Vector128<double> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAligned(double* address, Vector128<double> source) => StoreAligned(address, source);
/// <summary>
/// void _mm_stream_si128 (__m128i* mem_addr, __m128i a)
/// </summary>
- public static unsafe void StoreAlignedNonTemporal(sbyte* address, Vector128<sbyte> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAlignedNonTemporal(sbyte* address, Vector128<sbyte> source) => StoreAlignedNonTemporal(address, source);
/// <summary>
/// void _mm_stream_si128 (__m128i* mem_addr, __m128i a)
/// </summary>
- public static unsafe void StoreAlignedNonTemporal(byte* address, Vector128<byte> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAlignedNonTemporal(byte* address, Vector128<byte> source) => StoreAlignedNonTemporal(address, source);
/// <summary>
/// void _mm_stream_si128 (__m128i* mem_addr, __m128i a)
/// </summary>
- public static unsafe void StoreAlignedNonTemporal(short* address, Vector128<short> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAlignedNonTemporal(short* address, Vector128<short> source) => StoreAlignedNonTemporal(address, source);
/// <summary>
/// void _mm_stream_si128 (__m128i* mem_addr, __m128i a)
/// </summary>
- public static unsafe void StoreAlignedNonTemporal(ushort* address, Vector128<ushort> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAlignedNonTemporal(ushort* address, Vector128<ushort> source) => StoreAlignedNonTemporal(address, source);
/// <summary>
/// void _mm_stream_si128 (__m128i* mem_addr, __m128i a)
/// </summary>
- public static unsafe void StoreAlignedNonTemporal(int* address, Vector128<int> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAlignedNonTemporal(int* address, Vector128<int> source) => StoreAlignedNonTemporal(address, source);
/// <summary>
/// void _mm_stream_si128 (__m128i* mem_addr, __m128i a)
/// </summary>
- public static unsafe void StoreAlignedNonTemporal(uint* address, Vector128<uint> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAlignedNonTemporal(uint* address, Vector128<uint> source) => StoreAlignedNonTemporal(address, source);
/// <summary>
/// void _mm_stream_si128 (__m128i* mem_addr, __m128i a)
/// </summary>
- public static unsafe void StoreAlignedNonTemporal(long* address, Vector128<long> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAlignedNonTemporal(long* address, Vector128<long> source) => StoreAlignedNonTemporal(address, source);
/// <summary>
/// void _mm_stream_si128 (__m128i* mem_addr, __m128i a)
/// </summary>
- public static unsafe void StoreAlignedNonTemporal(ulong* address, Vector128<ulong> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAlignedNonTemporal(ulong* address, Vector128<ulong> source) => StoreAlignedNonTemporal(address, source);
/// <summary>
/// void _mm_stream_pd (double* mem_addr, __m128d a)
/// </summary>
- public static unsafe void StoreAlignedNonTemporal(double* address, Vector128<double> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreAlignedNonTemporal(double* address, Vector128<double> source) => StoreAlignedNonTemporal(address, source);
/// <summary>
/// void _mm_storeu_si128 (__m128i* mem_addr, __m128i a)
/// </summary>
- public static unsafe void Store(sbyte* address, Vector128<sbyte> source) { throw new NotImplementedException(); }
+ public static unsafe void Store(sbyte* address, Vector128<sbyte> source) => Store(address, source);
/// <summary>
/// void _mm_storeu_si128 (__m128i* mem_addr, __m128i a)
/// </summary>
- public static unsafe void Store(byte* address, Vector128<byte> source) { throw new NotImplementedException(); }
+ public static unsafe void Store(byte* address, Vector128<byte> source) => Store(address, source);
/// <summary>
/// void _mm_storeu_si128 (__m128i* mem_addr, __m128i a)
/// </summary>
- public static unsafe void Store(short* address, Vector128<short> source) { throw new NotImplementedException(); }
+ public static unsafe void Store(short* address, Vector128<short> source) => Store(address, source);
/// <summary>
/// void _mm_storeu_si128 (__m128i* mem_addr, __m128i a)
/// </summary>
- public static unsafe void Store(ushort* address, Vector128<ushort> source) { throw new NotImplementedException(); }
+ public static unsafe void Store(ushort* address, Vector128<ushort> source) => Store(address, source);
/// <summary>
/// void _mm_storeu_si128 (__m128i* mem_addr, __m128i a)
/// </summary>
- public static unsafe void Store(int* address, Vector128<int> source) { throw new NotImplementedException(); }
+ public static unsafe void Store(int* address, Vector128<int> source) => Store(address, source);
/// <summary>
/// void _mm_storeu_si128 (__m128i* mem_addr, __m128i a)
/// </summary>
- public static unsafe void Store(uint* address, Vector128<uint> source) { throw new NotImplementedException(); }
+ public static unsafe void Store(uint* address, Vector128<uint> source) => Store(address, source);
/// <summary>
/// void _mm_storeu_si128 (__m128i* mem_addr, __m128i a)
/// </summary>
- public static unsafe void Store(long* address, Vector128<long> source) { throw new NotImplementedException(); }
+ public static unsafe void Store(long* address, Vector128<long> source) => Store(address, source);
/// <summary>
/// void _mm_storeu_si128 (__m128i* mem_addr, __m128i a)
/// </summary>
- public static unsafe void Store(ulong* address, Vector128<ulong> source) { throw new NotImplementedException(); }
+ public static unsafe void Store(ulong* address, Vector128<ulong> source) => Store(address, source);
/// <summary>
/// void _mm_storeu_pd (double* mem_addr, __m128d a)
/// </summary>
- public static unsafe void Store(double* address, Vector128<double> source) { throw new NotImplementedException(); }
+ public static unsafe void Store(double* address, Vector128<double> source) => Store(address, source);
/// <summary>
/// void _mm_storeh_pd (double* mem_addr, __m128d a)
/// </summary>
- public static unsafe void StoreHigh(double* address, Vector128<double> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreHigh(double* address, Vector128<double> source) => StoreHigh(address, source);
/// <summary>
/// void _mm_storel_epi64 (__m128i* mem_addr, __m128i a)
/// </summary>
- public static unsafe void StoreLow(long* address, Vector128<long> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreLow(long* address, Vector128<long> source) => StoreLow(address, source);
/// <summary>
/// void _mm_storel_epi64 (__m128i* mem_addr, __m128i a)
/// </summary>
- public static unsafe void StoreLow(ulong* address, Vector128<ulong> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreLow(ulong* address, Vector128<ulong> source) => StoreLow(address, source);
/// <summary>
/// void _mm_storel_pd (double* mem_addr, __m128d a)
/// </summary>
- public static unsafe void StoreLow(double* address, Vector128<double> source) { throw new NotImplementedException(); }
+ public static unsafe void StoreLow(double* address, Vector128<double> source) => StoreLow(address, source);
/// <summary>
/// __m128i _mm_sub_epi8 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<byte> Subtract(Vector128<byte> left, Vector128<byte> right) { throw new NotImplementedException(); }
+ public static Vector128<byte> Subtract(Vector128<byte> left, Vector128<byte> right) => Subtract(left, right);
/// <summary>
/// __m128i _mm_sub_epi8 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<sbyte> Subtract(Vector128<sbyte> left, Vector128<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> Subtract(Vector128<sbyte> left, Vector128<sbyte> right) => Subtract(left, right);
/// <summary>
/// __m128i _mm_sub_epi16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<short> Subtract(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
+ public static Vector128<short> Subtract(Vector128<short> left, Vector128<short> right) => Subtract(left, right);
/// <summary>
/// __m128i _mm_sub_epi16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<ushort> Subtract(Vector128<ushort> left, Vector128<ushort> right) { throw new NotImplementedException(); }
+ public static Vector128<ushort> Subtract(Vector128<ushort> left, Vector128<ushort> right) => Subtract(left, right);
/// <summary>
/// __m128i _mm_sub_epi32 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<int> Subtract(Vector128<int> left, Vector128<int> right) { throw new NotImplementedException(); }
+ public static Vector128<int> Subtract(Vector128<int> left, Vector128<int> right) => Subtract(left, right);
/// <summary>
/// __m128i _mm_sub_epi32 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<uint> Subtract(Vector128<uint> left, Vector128<uint> right) { throw new NotImplementedException(); }
+ public static Vector128<uint> Subtract(Vector128<uint> left, Vector128<uint> right) => Subtract(left, right);
/// <summary>
/// __m128i _mm_sub_epi64 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<long> Subtract(Vector128<long> left, Vector128<long> right) { throw new NotImplementedException(); }
+ public static Vector128<long> Subtract(Vector128<long> left, Vector128<long> right) => Subtract(left, right);
/// <summary>
/// __m128i _mm_sub_epi64 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<ulong> Subtract(Vector128<ulong> left, Vector128<ulong> right) { throw new NotImplementedException(); }
+ public static Vector128<ulong> Subtract(Vector128<ulong> left, Vector128<ulong> right) => Subtract(left, right);
/// <summary>
/// __m128d _mm_sub_pd (__m128d a, __m128d b)
/// </summary>
- public static Vector128<double> Subtract(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static Vector128<double> Subtract(Vector128<double> left, Vector128<double> right) => Subtract(left, right);
/// <summary>
/// __m128i _mm_subs_epi8 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<sbyte> SubtractSaturate(Vector128<sbyte> left, Vector128<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> SubtractSaturate(Vector128<sbyte> left, Vector128<sbyte> right) => SubtractSaturate(left, right);
/// <summary>
/// __m128i _mm_subs_epi16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<short> SubtractSaturate(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
+ public static Vector128<short> SubtractSaturate(Vector128<short> left, Vector128<short> right) => SubtractSaturate(left, right);
/// <summary>
/// __m128i _mm_subs_epu8 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<byte> SubtractSaturate(Vector128<byte> left, Vector128<byte> right) { throw new NotImplementedException(); }
+ public static Vector128<byte> SubtractSaturate(Vector128<byte> left, Vector128<byte> right) => SubtractSaturate(left, right);
/// <summary>
/// __m128i _mm_subs_epu16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<ushort> SubtractSaturate(Vector128<ushort> left, Vector128<ushort> right) { throw new NotImplementedException(); }
+ public static Vector128<ushort> SubtractSaturate(Vector128<ushort> left, Vector128<ushort> right) => SubtractSaturate(left, right);
/// <summary>
/// __m128i _mm_unpackhi_epi8 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<byte> UnpackHigh(Vector128<byte> left, Vector128<byte> right) { throw new NotImplementedException(); }
+ public static Vector128<byte> UnpackHigh(Vector128<byte> left, Vector128<byte> right) => UnpackHigh(left, right);
/// <summary>
/// __m128i _mm_unpackhi_epi8 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<sbyte> UnpackHigh(Vector128<sbyte> left, Vector128<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> UnpackHigh(Vector128<sbyte> left, Vector128<sbyte> right) => UnpackHigh(left, right);
/// <summary>
/// __m128i _mm_unpackhi_epi16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<short> UnpackHigh(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
+ public static Vector128<short> UnpackHigh(Vector128<short> left, Vector128<short> right) => UnpackHigh(left, right);
/// <summary>
/// __m128i _mm_unpackhi_epi16 (__m128i a, __m128i b)
/// </summary
- public static Vector128<ushort> UnpackHigh(Vector128<ushort> left, Vector128<ushort> right) { throw new NotImplementedException(); }
+ public static Vector128<ushort> UnpackHigh(Vector128<ushort> left, Vector128<ushort> right) => UnpackHigh(left, right);
/// <summary>
/// __m128i _mm_unpackhi_epi32 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<int> UnpackHigh(Vector128<int> left, Vector128<int> right) { throw new NotImplementedException(); }
+ public static Vector128<int> UnpackHigh(Vector128<int> left, Vector128<int> right) => UnpackHigh(left, right);
/// <summary>
/// __m128i _mm_unpackhi_epi32 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<uint> UnpackHigh(Vector128<uint> left, Vector128<uint> right) { throw new NotImplementedException(); }
+ public static Vector128<uint> UnpackHigh(Vector128<uint> left, Vector128<uint> right) => UnpackHigh(left, right);
/// <summary>
/// __m128i _mm_unpackhi_epi64 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<long> UnpackHigh(Vector128<long> left, Vector128<long> right) { throw new NotImplementedException(); }
+ public static Vector128<long> UnpackHigh(Vector128<long> left, Vector128<long> right) => UnpackHigh(left, right);
/// <summary>
/// __m128i _mm_unpackhi_epi64 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<ulong> UnpackHigh(Vector128<ulong> left, Vector128<ulong> right) { throw new NotImplementedException(); }
+ public static Vector128<ulong> UnpackHigh(Vector128<ulong> left, Vector128<ulong> right) => UnpackHigh(left, right);
/// <summary>
/// __m128d _mm_unpackhi_pd (__m128d a, __m128d b)
/// </summary>
- public static Vector128<double> UnpackHigh(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static Vector128<double> UnpackHigh(Vector128<double> left, Vector128<double> right) => UnpackHigh(left, right);
/// <summary>
/// __m128i _mm_unpacklo_epi8 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<byte> UnpackLow(Vector128<byte> left, Vector128<byte> right) { throw new NotImplementedException(); }
+ public static Vector128<byte> UnpackLow(Vector128<byte> left, Vector128<byte> right) => UnpackLow(left, right);
/// <summary>
/// __m128i _mm_unpacklo_epi8 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<sbyte> UnpackLow(Vector128<sbyte> left, Vector128<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> UnpackLow(Vector128<sbyte> left, Vector128<sbyte> right) => UnpackLow(left, right);
/// <summary>
/// __m128i _mm_unpacklo_epi16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<short> UnpackLow(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
+ public static Vector128<short> UnpackLow(Vector128<short> left, Vector128<short> right) => UnpackLow(left, right);
/// <summary>
/// __m128i _mm_unpacklo_epi16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<ushort> UnpackLow(Vector128<ushort> left, Vector128<ushort> right) { throw new NotImplementedException(); }
+ public static Vector128<ushort> UnpackLow(Vector128<ushort> left, Vector128<ushort> right) => UnpackLow(left, right);
/// <summary>
/// __m128i _mm_unpacklo_epi32 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<int> UnpackLow(Vector128<int> left, Vector128<int> right) { throw new NotImplementedException(); }
+ public static Vector128<int> UnpackLow(Vector128<int> left, Vector128<int> right) => UnpackLow(left, right);
/// <summary>
/// __m128i _mm_unpacklo_epi32 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<uint> UnpackLow(Vector128<uint> left, Vector128<uint> right) { throw new NotImplementedException(); }
+ public static Vector128<uint> UnpackLow(Vector128<uint> left, Vector128<uint> right) => UnpackLow(left, right);
/// <summary>
/// __m128i _mm_unpacklo_epi64 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<long> UnpackLow(Vector128<long> left, Vector128<long> right) { throw new NotImplementedException(); }
+ public static Vector128<long> UnpackLow(Vector128<long> left, Vector128<long> right) => UnpackLow(left, right);
/// <summary>
/// __m128i _mm_unpacklo_epi64 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<ulong> UnpackLow(Vector128<ulong> left, Vector128<ulong> right) { throw new NotImplementedException(); }
+ public static Vector128<ulong> UnpackLow(Vector128<ulong> left, Vector128<ulong> right) => UnpackLow(left, right);
/// <summary>
/// __m128d _mm_unpacklo_pd (__m128d a, __m128d b)
/// </summary>
- public static Vector128<double> UnpackLow(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static Vector128<double> UnpackLow(Vector128<double> left, Vector128<double> right) => UnpackLow(left, right);
/// <summary>
/// __m128i _mm_xor_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<byte> Xor(Vector128<byte> left, Vector128<byte> right) { throw new NotImplementedException(); }
+ public static Vector128<byte> Xor(Vector128<byte> left, Vector128<byte> right) => Xor(left, right);
/// <summary>
/// __m128i _mm_xor_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<sbyte> Xor(Vector128<sbyte> left, Vector128<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> Xor(Vector128<sbyte> left, Vector128<sbyte> right) => Xor(left, right);
/// <summary>
/// __m128i _mm_xor_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<short> Xor(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
+ public static Vector128<short> Xor(Vector128<short> left, Vector128<short> right) => Xor(left, right);
/// <summary>
/// __m128i _mm_xor_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<ushort> Xor(Vector128<ushort> left, Vector128<ushort> right) { throw new NotImplementedException(); }
+ public static Vector128<ushort> Xor(Vector128<ushort> left, Vector128<ushort> right) => Xor(left, right);
/// <summary>
/// __m128i _mm_xor_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<int> Xor(Vector128<int> left, Vector128<int> right) { throw new NotImplementedException(); }
+ public static Vector128<int> Xor(Vector128<int> left, Vector128<int> right) => Xor(left, right);
/// <summary>
/// __m128i _mm_xor_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<uint> Xor(Vector128<uint> left, Vector128<uint> right) { throw new NotImplementedException(); }
+ public static Vector128<uint> Xor(Vector128<uint> left, Vector128<uint> right) => Xor(left, right);
/// <summary>
/// __m128i _mm_xor_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<long> Xor(Vector128<long> left, Vector128<long> right) { throw new NotImplementedException(); }
+ public static Vector128<long> Xor(Vector128<long> left, Vector128<long> right) => Xor(left, right);
/// <summary>
/// __m128i _mm_xor_si128 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<ulong> Xor(Vector128<ulong> left, Vector128<ulong> right) { throw new NotImplementedException(); }
+ public static Vector128<ulong> Xor(Vector128<ulong> left, Vector128<ulong> right) => Xor(left, right);
/// <summary>
/// __m128d _mm_xor_pd (__m128d a, __m128d b)
/// </summary>
- public static Vector128<double> Xor(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static Vector128<double> Xor(Vector128<double> left, Vector128<double> right) => Xor(left, right);
}
}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse3.PlatformNotSupported.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse3.PlatformNotSupported.cs
new file mode 100644
index 0000000000..24b9c246f6
--- /dev/null
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse3.PlatformNotSupported.cs
@@ -0,0 +1,78 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.Intrinsics;
+
+namespace System.Runtime.Intrinsics.X86
+{
+ /// <summary>
+ /// This class provides access to Intel SSE3 hardware instructions via intrinsics
+ /// </summary>
+ [CLSCompliant(false)]
+ public static class Sse3
+ {
+ public static bool IsSupported { get { return false; } }
+
+ /// <summary>
+ /// __m128 _mm_addsub_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static Vector128<float> AddSubtract(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_addsub_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static Vector128<double> AddSubtract(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_hadd_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static Vector128<float> HorizontalAdd(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_hadd_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static Vector128<double> HorizontalAdd(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_hsub_ps (__m128 a, __m128 b)
+ /// </summary>
+ public static Vector128<float> HorizontalSubtract(Vector128<float> left, Vector128<float> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_hsub_pd (__m128d a, __m128d b)
+ /// </summary>
+ public static Vector128<double> HorizontalSubtract(Vector128<double> left, Vector128<double> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128d _mm_loaddup_pd (double const* mem_addr)
+ /// </summary>
+ public static unsafe Vector128<double> LoadAndDuplicate(double* address) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_lddqu_si128 (__m128i const* mem_addr)
+ /// </summary>
+ public static unsafe Vector128<sbyte> LoadDqu(sbyte* address) { throw new PlatformNotSupportedException(); }
+ public static unsafe Vector128<byte> LoadDqu(byte* address) { throw new PlatformNotSupportedException(); }
+ public static unsafe Vector128<short> LoadDqu(short* address) { throw new PlatformNotSupportedException(); }
+ public static unsafe Vector128<ushort> LoadDqu(ushort* address) { throw new PlatformNotSupportedException(); }
+ public static unsafe Vector128<int> LoadDqu(int* address) { throw new PlatformNotSupportedException(); }
+ public static unsafe Vector128<uint> LoadDqu(uint* address) { throw new PlatformNotSupportedException(); }
+ public static unsafe Vector128<long> LoadDqu(long* address) { throw new PlatformNotSupportedException(); }
+ public static unsafe Vector128<ulong> LoadDqu(ulong* address) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128d _mm_movedup_pd (__m128d a)
+ /// </summary>
+ public static Vector128<double> MoveAndDuplicate(Vector128<double> source) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_movehdup_ps (__m128 a)
+ /// </summary>
+ public static Vector128<float> MoveHighAndDuplicate(Vector128<float> source) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_moveldup_ps (__m128 a)
+ /// </summary>
+ public static Vector128<float> MoveLowAndDuplicate(Vector128<float> source) { throw new PlatformNotSupportedException(); }
+
+ }
+}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse3.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse3.cs
index 5e4ac9dd0e..0c9fb5b229 100644
--- a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse3.cs
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse3.cs
@@ -13,66 +13,66 @@ namespace System.Runtime.Intrinsics.X86
[CLSCompliant(false)]
public static class Sse3
{
- public static bool IsSupported { get { return false; } }
+ public static bool IsSupported { get => IsSupported; }
/// <summary>
/// __m128 _mm_addsub_ps (__m128 a, __m128 b)
/// </summary>
- public static Vector128<float> AddSubtract(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> AddSubtract(Vector128<float> left, Vector128<float> right) => AddSubtract(left, right);
/// <summary>
/// __m128d _mm_addsub_pd (__m128d a, __m128d b)
/// </summary>
- public static Vector128<double> AddSubtract(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static Vector128<double> AddSubtract(Vector128<double> left, Vector128<double> right) => AddSubtract(left, right);
/// <summary>
/// __m128 _mm_hadd_ps (__m128 a, __m128 b)
/// </summary>
- public static Vector128<float> HorizontalAdd(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> HorizontalAdd(Vector128<float> left, Vector128<float> right) => HorizontalAdd(left, right);
/// <summary>
/// __m128d _mm_hadd_pd (__m128d a, __m128d b)
/// </summary>
- public static Vector128<double> HorizontalAdd(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static Vector128<double> HorizontalAdd(Vector128<double> left, Vector128<double> right) => HorizontalAdd(left, right);
/// <summary>
/// __m128 _mm_hsub_ps (__m128 a, __m128 b)
/// </summary>
- public static Vector128<float> HorizontalSubtract(Vector128<float> left, Vector128<float> right) { throw new NotImplementedException(); }
+ public static Vector128<float> HorizontalSubtract(Vector128<float> left, Vector128<float> right) => HorizontalSubtract(left, right);
/// <summary>
/// __m128d _mm_hsub_pd (__m128d a, __m128d b)
/// </summary>
- public static Vector128<double> HorizontalSubtract(Vector128<double> left, Vector128<double> right) { throw new NotImplementedException(); }
+ public static Vector128<double> HorizontalSubtract(Vector128<double> left, Vector128<double> right) => HorizontalSubtract(left, right);
/// <summary>
/// __m128d _mm_loaddup_pd (double const* mem_addr)
/// </summary>
- public static unsafe Vector128<double> LoadAndDuplicate(double* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<double> LoadAndDuplicate(double* address) => LoadAndDuplicate(address);
/// <summary>
/// __m128i _mm_lddqu_si128 (__m128i const* mem_addr)
/// </summary>
- public static unsafe Vector128<sbyte> LoadDqu(sbyte* address) { throw new NotImplementedException(); }
- public static unsafe Vector128<byte> LoadDqu(byte* address) { throw new NotImplementedException(); }
- public static unsafe Vector128<short> LoadDqu(short* address) { throw new NotImplementedException(); }
- public static unsafe Vector128<ushort> LoadDqu(ushort* address) { throw new NotImplementedException(); }
- public static unsafe Vector128<int> LoadDqu(int* address) { throw new NotImplementedException(); }
- public static unsafe Vector128<uint> LoadDqu(uint* address) { throw new NotImplementedException(); }
- public static unsafe Vector128<long> LoadDqu(long* address) { throw new NotImplementedException(); }
- public static unsafe Vector128<ulong> LoadDqu(ulong* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<sbyte> LoadDqu(sbyte* address) => LoadDqu(address);
+ public static unsafe Vector128<byte> LoadDqu(byte* address) => LoadDqu(address);
+ public static unsafe Vector128<short> LoadDqu(short* address) => LoadDqu(address);
+ public static unsafe Vector128<ushort> LoadDqu(ushort* address) => LoadDqu(address);
+ public static unsafe Vector128<int> LoadDqu(int* address) => LoadDqu(address);
+ public static unsafe Vector128<uint> LoadDqu(uint* address) => LoadDqu(address);
+ public static unsafe Vector128<long> LoadDqu(long* address) => LoadDqu(address);
+ public static unsafe Vector128<ulong> LoadDqu(ulong* address) => LoadDqu(address);
/// <summary>
/// __m128d _mm_movedup_pd (__m128d a)
/// </summary>
- public static Vector128<double> MoveAndDuplicate(Vector128<double> source) { throw new NotImplementedException(); }
+ public static Vector128<double> MoveAndDuplicate(Vector128<double> source) => MoveAndDuplicate(source);
/// <summary>
/// __m128 _mm_movehdup_ps (__m128 a)
/// </summary>
- public static Vector128<float> MoveHighAndDuplicate(Vector128<float> source) { throw new NotImplementedException(); }
+ public static Vector128<float> MoveHighAndDuplicate(Vector128<float> source) => MoveHighAndDuplicate(source);
/// <summary>
/// __m128 _mm_moveldup_ps (__m128 a)
/// </summary>
- public static Vector128<float> MoveLowAndDuplicate(Vector128<float> source) { throw new NotImplementedException(); }
+ public static Vector128<float> MoveLowAndDuplicate(Vector128<float> source) => MoveLowAndDuplicate(source);
}
}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse41.PlatformNotSupported.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse41.PlatformNotSupported.cs
new file mode 100644
index 0000000000..4cc5a1ccbf
--- /dev/null
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse41.PlatformNotSupported.cs
@@ -0,0 +1,408 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.Intrinsics;
+
+namespace System.Runtime.Intrinsics.X86
+{
+ /// <summary>
+ /// This class provides access to Intel SSE4.1 hardware instructions via intrinsics
+ /// </summary>
+ [CLSCompliant(false)]
+ public static class Sse41
+ {
+ public static bool IsSupported { get { return false; } }
+
+ /// <summary>
+ /// __m128i _mm_blend_epi16 (__m128i a, __m128i b, const int imm8)
+ /// </summary>
+ public static Vector128<short> Blend(Vector128<short> left, Vector128<short> right, byte control) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_blend_epi16 (__m128i a, __m128i b, const int imm8)
+ /// </summary>
+ public static Vector128<ushort> Blend(Vector128<ushort> left, Vector128<ushort> right, byte control) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_blend_ps (__m128 a, __m128 b, const int imm8)
+ /// </summary>
+ public static Vector128<float> Blend(Vector128<float> left, Vector128<float> right, byte control) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128d _mm_blend_pd (__m128d a, __m128d b, const int imm8)
+ /// </summary>
+ public static Vector128<double> Blend(Vector128<double> left, Vector128<double> right, byte control) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_blendv_epi8 (__m128i a, __m128i b, __m128i mask)
+ /// </summary>
+ public static Vector128<sbyte> BlendVariable(Vector128<sbyte> left, Vector128<sbyte> right, Vector128<sbyte> mask) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_blendv_epi8 (__m128i a, __m128i b, __m128i mask)
+ /// </summary>
+ public static Vector128<byte> BlendVariable(Vector128<byte> left, Vector128<byte> right, Vector128<byte> mask) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128 _mm_blendv_ps (__m128 a, __m128 b, __m128 mask)
+ /// </summary>
+ public static Vector128<float> BlendVariable(Vector128<float> left, Vector128<float> right, Vector128<float> mask) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_blendv_pd (__m128d a, __m128d b, __m128d mask)
+ /// </summary>
+ public static Vector128<double> BlendVariable(Vector128<double> left, Vector128<double> right, Vector128<double> mask) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_ceil_ps (__m128 a)
+ /// </summary>
+ public static Vector128<float> Ceiling(Vector128<float> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_ceil_pd (__m128d a)
+ /// </summary>
+ public static Vector128<double> Ceiling(Vector128<double> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_cmpeq_epi64 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<long> CompareEqual(Vector128<long> left, Vector128<long> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_cmpeq_epi64 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<ulong> CompareEqual(Vector128<ulong> left, Vector128<ulong> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_cvtepi8_epi16 (__m128i a)
+ /// </summary>
+ public static Vector128<short> ConvertToShort(Vector128<sbyte> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_cvtepu8_epi16 (__m128i a)
+ /// </summary>
+ public static Vector128<short> ConvertToShort(Vector128<byte> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_cvtepi8_epi32 (__m128i a)
+ /// </summary>
+ public static Vector128<int> ConvertToInt(Vector128<sbyte> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_cvtepu8_epi32 (__m128i a)
+ /// </summary>
+ public static Vector128<int> ConvertToInt(Vector128<byte> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_cvtepi16_epi32 (__m128i a)
+ /// </summary>
+ public static Vector128<int> ConvertToInt(Vector128<short> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_cvtepu16_epi32 (__m128i a)
+ /// </summary>
+ public static Vector128<int> ConvertToInt(Vector128<ushort> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_cvtepi8_epi64 (__m128i a)
+ /// </summary>
+ public static Vector128<long> ConvertToLong(Vector128<sbyte> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_cvtepu8_epi64 (__m128i a)
+ /// </summary>
+ public static Vector128<long> ConvertToLong(Vector128<byte> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_cvtepi16_epi64 (__m128i a)
+ /// </summary>
+ public static Vector128<long> ConvertToLong(Vector128<short> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_cvtepu16_epi64 (__m128i a)
+ /// </summary>
+ public static Vector128<long> ConvertToLong(Vector128<ushort> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_cvtepi32_epi64 (__m128i a)
+ /// </summary>
+ public static Vector128<long> ConvertToLong(Vector128<int> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_cvtepu32_epi64 (__m128i a)
+ /// </summary>
+ public static Vector128<long> ConvertToLong(Vector128<uint> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_extract_epi8 (__m128i a, const int imm8)
+ /// </summary>
+ public static sbyte ExtractSbyte<T>(Vector128<T> value, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// int _mm_extract_epi8 (__m128i a, const int imm8)
+ /// </summary>
+ public static byte ExtractByte<T>(Vector128<T> value, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_extract_epi32 (__m128i a, const int imm8)
+ /// </summary>
+ public static int ExtractInt<T>(Vector128<T> value, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_extract_epi32 (__m128i a, const int imm8)
+ /// </summary>
+ public static uint ExtractUint<T>(Vector128<T> value, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __int64 _mm_extract_epi64 (__m128i a, const int imm8)
+ /// </summary>
+ public static long ExtractLong<T>(Vector128<T> value, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __int64 _mm_extract_epi64 (__m128i a, const int imm8)
+ /// </summary>
+ public static ulong ExtractUlong<T>(Vector128<T> value, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_extract_ps (__m128 a, const int imm8)
+ /// </summary>
+ public static float ExtractFloat<T>(Vector128<T> value, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_floor_ps (__m128 a)
+ /// </summary>
+ public static Vector128<float> Floor(Vector128<float> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128d _mm_floor_pd (__m128d a)
+ /// </summary>
+ public static Vector128<double> Floor(Vector128<double> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_insert_epi8 (__m128i a, int i, const int imm8)
+ /// </summary>
+ public static Vector128<T> InsertSbyte<T>(Vector128<T> value, sbyte data, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_insert_epi8 (__m128i a, int i, const int imm8)
+ /// </summary>
+ public static Vector128<T> InsertByte<T>(Vector128<T> value, byte data, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_insert_epi32 (__m128i a, int i, const int imm8)
+ /// </summary>
+ public static Vector128<T> InsertInt<T>(Vector128<T> value, int data, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_insert_epi32 (__m128i a, int i, const int imm8)
+ /// </summary>
+ public static Vector128<T> InsertUint<T>(Vector128<T> value, uint data, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_insert_epi64 (__m128i a, __int64 i, const int imm8)
+ /// </summary>
+ public static Vector128<T> InsertLong<T>(Vector128<T> value, long data, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_insert_epi64 (__m128i a, __int64 i, const int imm8)
+ /// </summary>
+ public static Vector128<T> InsertUlong<T>(Vector128<T> value, ulong data, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_insert_ps (__m128 a, __m128 b, const int imm8)
+ /// </summary>
+ public static Vector128<T> InsertFloat<T>(Vector128<T> value, float data, byte index) where T : struct { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_max_epi8 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<sbyte> Max(Vector128<sbyte> left, Vector128<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_max_epu16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<ushort> Max(Vector128<ushort> left, Vector128<ushort> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_max_epi32 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<int> Max(Vector128<int> left, Vector128<int> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_max_epu32 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<uint> Max(Vector128<uint> left, Vector128<uint> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_min_epi8 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<sbyte> Min(Vector128<sbyte> left, Vector128<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_min_epu16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<ushort> Min(Vector128<ushort> left, Vector128<ushort> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_min_epi32 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<int> Min(Vector128<int> left, Vector128<int> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_min_epu32 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<uint> Min(Vector128<uint> left, Vector128<uint> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_minpos_epu16 (__m128i a)
+ /// </summary>
+ public static Vector128<ushort> MinHorizontal(Vector128<ushort> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_mpsadbw_epu8 (__m128i a, __m128i b, const int imm8)
+ /// </summary>
+ public static Vector128<ushort> MultipleSumAbsoluteDifferences(Vector128<byte> left, Vector128<byte> right, byte mask) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_mul_epi32 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<long> Multiply(Vector128<int> left, Vector128<int> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_mullo_epi32 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<int> MultiplyLow(Vector128<int> left, Vector128<int> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_packus_epi32 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<ushort> PackUnsignedSaturate(Vector128<int> left, Vector128<int> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128 _mm_round_ps (__m128 a, int rounding)
+ /// _MM_FROUND_TO_NEAREST_INT |_MM_FROUND_NO_EXC
+ /// </summary>
+ public static Vector128<float> RoundToNearestInteger(Vector128<float> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// _MM_FROUND_TO_NEG_INF |_MM_FROUND_NO_EXC
+ /// </summary>
+ public static Vector128<float> RoundToNegativeInfinity(Vector128<float> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// _MM_FROUND_TO_POS_INF |_MM_FROUND_NO_EXC
+ /// </summary>
+ public static Vector128<float> RoundToPositiveInfinity(Vector128<float> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// _MM_FROUND_TO_ZERO |_MM_FROUND_NO_EXC
+ /// </summary>
+ public static Vector128<float> RoundToZero(Vector128<float> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// _MM_FROUND_CUR_DIRECTION
+ /// </summary>
+ public static Vector128<float> RoundCurrentDirection(Vector128<float> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128d _mm_round_pd (__m128d a, int rounding)
+ /// _MM_FROUND_TO_NEAREST_INT |_MM_FROUND_NO_EXC
+ /// </summary>
+ public static Vector128<double> RoundToNearestInteger(Vector128<double> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// _MM_FROUND_TO_NEG_INF |_MM_FROUND_NO_EXC
+ /// </summary>
+ public static Vector128<double> RoundToNegativeInfinity(Vector128<double> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// _MM_FROUND_TO_POS_INF |_MM_FROUND_NO_EXC
+ /// </summary>
+ public static Vector128<double> RoundToPositiveInfinity(Vector128<double> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// _MM_FROUND_TO_ZERO |_MM_FROUND_NO_EXC
+ /// </summary>
+ public static Vector128<double> RoundToZero(Vector128<double> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// _MM_FROUND_CUR_DIRECTION
+ /// </summary>
+ public static Vector128<double> RoundCurrentDirection(Vector128<double> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_stream_load_si128 (const __m128i* mem_addr)
+ /// </summary>
+ public static unsafe Vector128<sbyte> LoadAlignedNonTemporal(sbyte* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_stream_load_si128 (const __m128i* mem_addr)
+ /// </summary>
+ public static unsafe Vector128<byte> LoadAlignedNonTemporal(byte* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_stream_load_si128 (const __m128i* mem_addr)
+ /// </summary>
+ public static unsafe Vector128<short> LoadAlignedNonTemporal(short* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_stream_load_si128 (const __m128i* mem_addr)
+ /// </summary>
+ public static unsafe Vector128<ushort> LoadAlignedNonTemporal(ushort* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_stream_load_si128 (const __m128i* mem_addr)
+ /// </summary>
+ public static unsafe Vector128<int> LoadAlignedNonTemporal(int* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_stream_load_si128 (const __m128i* mem_addr)
+ /// </summary>
+ public static unsafe Vector128<uint> LoadAlignedNonTemporal(uint* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_stream_load_si128 (const __m128i* mem_addr)
+ /// </summary>
+ public static unsafe Vector128<long> LoadAlignedNonTemporal(long* address) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_stream_load_si128 (const __m128i* mem_addr)
+ /// </summary>
+ public static unsafe Vector128<ulong> LoadAlignedNonTemporal(ulong* address) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_test_all_ones (__m128i a)
+ /// </summary>
+ public static bool TestAllOnes(Vector128<sbyte> value) { throw new PlatformNotSupportedException(); }
+ public static bool TestAllOnes(Vector128<byte> value) { throw new PlatformNotSupportedException(); }
+ public static bool TestAllOnes(Vector128<short> value) { throw new PlatformNotSupportedException(); }
+ public static bool TestAllOnes(Vector128<ushort> value) { throw new PlatformNotSupportedException(); }
+ public static bool TestAllOnes(Vector128<int> value) { throw new PlatformNotSupportedException(); }
+ public static bool TestAllOnes(Vector128<uint> value) { throw new PlatformNotSupportedException(); }
+ public static bool TestAllOnes(Vector128<long> value) { throw new PlatformNotSupportedException(); }
+ public static bool TestAllOnes(Vector128<ulong> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_test_all_zeros (__m128i a, __m128i mask)
+ /// </summary>
+ public static bool TestAllZeros(Vector128<sbyte> left, Vector128<sbyte> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestAllZeros(Vector128<byte> left, Vector128<byte> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestAllZeros(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestAllZeros(Vector128<ushort> left, Vector128<ushort> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestAllZeros(Vector128<int> left, Vector128<int> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestAllZeros(Vector128<uint> left, Vector128<uint> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestAllZeros(Vector128<long> left, Vector128<long> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestAllZeros(Vector128<ulong> left, Vector128<ulong> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_testc_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static bool TestC(Vector128<sbyte> left, Vector128<sbyte> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestC(Vector128<byte> left, Vector128<byte> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestC(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestC(Vector128<ushort> left, Vector128<ushort> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestC(Vector128<int> left, Vector128<int> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestC(Vector128<uint> left, Vector128<uint> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestC(Vector128<long> left, Vector128<long> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestC(Vector128<ulong> left, Vector128<ulong> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_test_mix_ones_zeros (__m128i a, __m128i mask)
+ /// </summary>
+ public static bool TestMixOnesZeros(Vector128<sbyte> left, Vector128<sbyte> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestMixOnesZeros(Vector128<byte> left, Vector128<byte> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestMixOnesZeros(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestMixOnesZeros(Vector128<ushort> left, Vector128<ushort> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestMixOnesZeros(Vector128<int> left, Vector128<int> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestMixOnesZeros(Vector128<uint> left, Vector128<uint> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestMixOnesZeros(Vector128<long> left, Vector128<long> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestMixOnesZeros(Vector128<ulong> left, Vector128<ulong> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_testnzc_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static bool TestNotZAndNotC(Vector128<sbyte> left, Vector128<sbyte> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestNotZAndNotC(Vector128<byte> left, Vector128<byte> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestNotZAndNotC(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestNotZAndNotC(Vector128<ushort> left, Vector128<ushort> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestNotZAndNotC(Vector128<int> left, Vector128<int> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestNotZAndNotC(Vector128<uint> left, Vector128<uint> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestNotZAndNotC(Vector128<long> left, Vector128<long> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestNotZAndNotC(Vector128<ulong> left, Vector128<ulong> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_testz_si128 (__m128i a, __m128i b)
+ /// </summary>
+ public static bool TestZ(Vector128<sbyte> left, Vector128<sbyte> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestZ(Vector128<byte> left, Vector128<byte> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestZ(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestZ(Vector128<ushort> left, Vector128<ushort> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestZ(Vector128<int> left, Vector128<int> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestZ(Vector128<uint> left, Vector128<uint> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestZ(Vector128<long> left, Vector128<long> right) { throw new PlatformNotSupportedException(); }
+ public static bool TestZ(Vector128<ulong> left, Vector128<ulong> right) { throw new PlatformNotSupportedException(); }
+ }
+}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse41.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse41.cs
index 5a498bcf4e..7003478398 100644
--- a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse41.cs
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse41.cs
@@ -13,396 +13,396 @@ namespace System.Runtime.Intrinsics.X86
[CLSCompliant(false)]
public static class Sse41
{
- public static bool IsSupported { get { return false; } }
+ public static bool IsSupported { get => IsSupported; }
/// <summary>
/// __m128i _mm_blend_epi16 (__m128i a, __m128i b, const int imm8)
/// </summary>
- public static Vector128<short> Blend(Vector128<short> left, Vector128<short> right, byte control) { throw new NotImplementedException(); }
+ public static Vector128<short> Blend(Vector128<short> left, Vector128<short> right, byte control) => Blend(left, right, control);
/// <summary>
/// __m128i _mm_blend_epi16 (__m128i a, __m128i b, const int imm8)
/// </summary>
- public static Vector128<ushort> Blend(Vector128<ushort> left, Vector128<ushort> right, byte control) { throw new NotImplementedException(); }
+ public static Vector128<ushort> Blend(Vector128<ushort> left, Vector128<ushort> right, byte control) => Blend(left, right, control);
/// <summary>
/// __m128 _mm_blend_ps (__m128 a, __m128 b, const int imm8)
/// </summary>
- public static Vector128<float> Blend(Vector128<float> left, Vector128<float> right, byte control) { throw new NotImplementedException(); }
+ public static Vector128<float> Blend(Vector128<float> left, Vector128<float> right, byte control) => Blend(left, right, control);
/// <summary>
/// __m128d _mm_blend_pd (__m128d a, __m128d b, const int imm8)
/// </summary>
- public static Vector128<double> Blend(Vector128<double> left, Vector128<double> right, byte control) { throw new NotImplementedException(); }
+ public static Vector128<double> Blend(Vector128<double> left, Vector128<double> right, byte control) => Blend(left, right, control);
/// <summary>
/// __m128i _mm_blendv_epi8 (__m128i a, __m128i b, __m128i mask)
/// </summary>
- public static Vector128<sbyte> BlendVariable(Vector128<sbyte> left, Vector128<sbyte> right, Vector128<sbyte> mask) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> BlendVariable(Vector128<sbyte> left, Vector128<sbyte> right, Vector128<sbyte> mask) => BlendVariable(left, right, mask);
/// <summary>
/// __m128i _mm_blendv_epi8 (__m128i a, __m128i b, __m128i mask)
/// </summary>
- public static Vector128<byte> BlendVariable(Vector128<byte> left, Vector128<byte> right, Vector128<byte> mask) { throw new NotImplementedException(); }
+ public static Vector128<byte> BlendVariable(Vector128<byte> left, Vector128<byte> right, Vector128<byte> mask) => BlendVariable(left, right, mask);
/// <summary>
/// __m128 _mm_blendv_ps (__m128 a, __m128 b, __m128 mask)
/// </summary>
- public static Vector128<float> BlendVariable(Vector128<float> left, Vector128<float> right, Vector128<float> mask) { throw new NotImplementedException(); }
+ public static Vector128<float> BlendVariable(Vector128<float> left, Vector128<float> right, Vector128<float> mask) => BlendVariable(left, right, mask);
/// <summary>
/// __m128d _mm_blendv_pd (__m128d a, __m128d b, __m128d mask)
/// </summary>
- public static Vector128<double> BlendVariable(Vector128<double> left, Vector128<double> right, Vector128<double> mask) { throw new NotImplementedException(); }
+ public static Vector128<double> BlendVariable(Vector128<double> left, Vector128<double> right, Vector128<double> mask) => BlendVariable(left, right, mask);
/// <summary>
/// __m128 _mm_ceil_ps (__m128 a)
/// </summary>
- public static Vector128<float> Ceiling(Vector128<float> value) { throw new NotImplementedException(); }
+ public static Vector128<float> Ceiling(Vector128<float> value) => Ceiling(value);
/// <summary>
/// __m128d _mm_ceil_pd (__m128d a)
/// </summary>
- public static Vector128<double> Ceiling(Vector128<double> value) { throw new NotImplementedException(); }
+ public static Vector128<double> Ceiling(Vector128<double> value) => Ceiling(value);
/// <summary>
/// __m128i _mm_cmpeq_epi64 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<long> CompareEqual(Vector128<long> left, Vector128<long> right) { throw new NotImplementedException(); }
+ public static Vector128<long> CompareEqual(Vector128<long> left, Vector128<long> right) => CompareEqual(left, right);
/// <summary>
/// __m128i _mm_cmpeq_epi64 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<ulong> CompareEqual(Vector128<ulong> left, Vector128<ulong> right) { throw new NotImplementedException(); }
+ public static Vector128<ulong> CompareEqual(Vector128<ulong> left, Vector128<ulong> right) => CompareEqual(left, right);
/// <summary>
/// __m128i _mm_cvtepi8_epi16 (__m128i a)
/// </summary>
- public static Vector128<short> ConvertToShort(Vector128<sbyte> value) { throw new NotImplementedException(); }
+ public static Vector128<short> ConvertToShort(Vector128<sbyte> value) => ConvertToShort(value);
/// <summary>
/// __m128i _mm_cvtepu8_epi16 (__m128i a)
/// </summary>
- public static Vector128<short> ConvertToShort(Vector128<byte> value) { throw new NotImplementedException(); }
+ public static Vector128<short> ConvertToShort(Vector128<byte> value) => ConvertToShort(value);
/// <summary>
/// __m128i _mm_cvtepi8_epi32 (__m128i a)
/// </summary>
- public static Vector128<int> ConvertToInt(Vector128<sbyte> value) { throw new NotImplementedException(); }
+ public static Vector128<int> ConvertToInt(Vector128<sbyte> value) => ConvertToInt(value);
/// <summary>
/// __m128i _mm_cvtepu8_epi32 (__m128i a)
/// </summary>
- public static Vector128<int> ConvertToInt(Vector128<byte> value) { throw new NotImplementedException(); }
+ public static Vector128<int> ConvertToInt(Vector128<byte> value) => ConvertToInt(value);
/// <summary>
/// __m128i _mm_cvtepi16_epi32 (__m128i a)
/// </summary>
- public static Vector128<int> ConvertToInt(Vector128<short> value) { throw new NotImplementedException(); }
+ public static Vector128<int> ConvertToInt(Vector128<short> value) => ConvertToInt(value);
/// <summary>
/// __m128i _mm_cvtepu16_epi32 (__m128i a)
/// </summary>
- public static Vector128<int> ConvertToInt(Vector128<ushort> value) { throw new NotImplementedException(); }
+ public static Vector128<int> ConvertToInt(Vector128<ushort> value) => ConvertToInt(value);
/// <summary>
/// __m128i _mm_cvtepi8_epi64 (__m128i a)
/// </summary>
- public static Vector128<long> ConvertToLong(Vector128<sbyte> value) { throw new NotImplementedException(); }
+ public static Vector128<long> ConvertToLong(Vector128<sbyte> value) => ConvertToLong(value);
/// <summary>
/// __m128i _mm_cvtepu8_epi64 (__m128i a)
/// </summary>
- public static Vector128<long> ConvertToLong(Vector128<byte> value) { throw new NotImplementedException(); }
+ public static Vector128<long> ConvertToLong(Vector128<byte> value) => ConvertToLong(value);
/// <summary>
/// __m128i _mm_cvtepi16_epi64 (__m128i a)
/// </summary>
- public static Vector128<long> ConvertToLong(Vector128<short> value) { throw new NotImplementedException(); }
+ public static Vector128<long> ConvertToLong(Vector128<short> value) => ConvertToLong(value);
/// <summary>
/// __m128i _mm_cvtepu16_epi64 (__m128i a)
/// </summary>
- public static Vector128<long> ConvertToLong(Vector128<ushort> value) { throw new NotImplementedException(); }
+ public static Vector128<long> ConvertToLong(Vector128<ushort> value) => ConvertToLong(value);
/// <summary>
/// __m128i _mm_cvtepi32_epi64 (__m128i a)
/// </summary>
- public static Vector128<long> ConvertToLong(Vector128<int> value) { throw new NotImplementedException(); }
+ public static Vector128<long> ConvertToLong(Vector128<int> value) => ConvertToLong(value);
/// <summary>
/// __m128i _mm_cvtepu32_epi64 (__m128i a)
/// </summary>
- public static Vector128<long> ConvertToLong(Vector128<uint> value) { throw new NotImplementedException(); }
+ public static Vector128<long> ConvertToLong(Vector128<uint> value) => ConvertToLong(value);
/// <summary>
/// int _mm_extract_epi8 (__m128i a, const int imm8)
/// </summary>
- public static sbyte ExtractSbyte<T>(Vector128<T> value, byte index) where T : struct { throw new NotImplementedException(); }
+ public static sbyte ExtractSbyte<T>(Vector128<T> value, byte index) where T : struct => ExtractSbyte<T>(value, index);
/// <summary>
/// int _mm_extract_epi8 (__m128i a, const int imm8)
/// </summary>
- public static byte ExtractByte<T>(Vector128<T> value, byte index) where T : struct { throw new NotImplementedException(); }
+ public static byte ExtractByte<T>(Vector128<T> value, byte index) where T : struct => ExtractByte<T>(value, index);
/// <summary>
/// int _mm_extract_epi32 (__m128i a, const int imm8)
/// </summary>
- public static int ExtractInt<T>(Vector128<T> value, byte index) where T : struct { throw new NotImplementedException(); }
+ public static int ExtractInt<T>(Vector128<T> value, byte index) where T : struct => ExtractInt<T>(value, index);
/// <summary>
/// int _mm_extract_epi32 (__m128i a, const int imm8)
/// </summary>
- public static uint ExtractUint<T>(Vector128<T> value, byte index) where T : struct { throw new NotImplementedException(); }
+ public static uint ExtractUint<T>(Vector128<T> value, byte index) where T : struct => ExtractUint<T>(value, index);
/// <summary>
/// __int64 _mm_extract_epi64 (__m128i a, const int imm8)
/// </summary>
- public static long ExtractLong<T>(Vector128<T> value, byte index) where T : struct { throw new NotImplementedException(); }
+ public static long ExtractLong<T>(Vector128<T> value, byte index) where T : struct => ExtractLong<T>(value, index);
/// <summary>
/// __int64 _mm_extract_epi64 (__m128i a, const int imm8)
/// </summary>
- public static ulong ExtractUlong<T>(Vector128<T> value, byte index) where T : struct { throw new NotImplementedException(); }
+ public static ulong ExtractUlong<T>(Vector128<T> value, byte index) where T : struct => ExtractUlong<T>(value, index);
/// <summary>
/// int _mm_extract_ps (__m128 a, const int imm8)
/// </summary>
- public static float ExtractFloat<T>(Vector128<T> value, byte index) where T : struct { throw new NotImplementedException(); }
+ public static float ExtractFloat<T>(Vector128<T> value, byte index) where T : struct => ExtractFloat<T>(value, index);
/// <summary>
/// __m128 _mm_floor_ps (__m128 a)
/// </summary>
- public static Vector128<float> Floor(Vector128<float> value) { throw new NotImplementedException(); }
+ public static Vector128<float> Floor(Vector128<float> value) => Floor(value);
/// <summary>
/// __m128d _mm_floor_pd (__m128d a)
/// </summary>
- public static Vector128<double> Floor(Vector128<double> value) { throw new NotImplementedException(); }
+ public static Vector128<double> Floor(Vector128<double> value) => Floor(value);
/// <summary>
/// __m128i _mm_insert_epi8 (__m128i a, int i, const int imm8)
/// </summary>
- public static Vector128<T> InsertSbyte<T>(Vector128<T> value, sbyte data, byte index) where T : struct { throw new NotImplementedException(); }
+ public static Vector128<T> InsertSbyte<T>(Vector128<T> value, sbyte data, byte index) where T : struct => InsertSbyte<T>(value, data, index);
/// <summary>
/// __m128i _mm_insert_epi8 (__m128i a, int i, const int imm8)
/// </summary>
- public static Vector128<T> InsertByte<T>(Vector128<T> value, byte data, byte index) where T : struct { throw new NotImplementedException(); }
+ public static Vector128<T> InsertByte<T>(Vector128<T> value, byte data, byte index) where T : struct => InsertByte<T>(value, data, index);
/// <summary>
/// __m128i _mm_insert_epi32 (__m128i a, int i, const int imm8)
/// </summary>
- public static Vector128<T> InsertInt<T>(Vector128<T> value, int data, byte index) where T : struct { throw new NotImplementedException(); }
+ public static Vector128<T> InsertInt<T>(Vector128<T> value, int data, byte index) where T : struct => InsertInt<T>(value, data, index);
/// <summary>
/// __m128i _mm_insert_epi32 (__m128i a, int i, const int imm8)
/// </summary>
- public static Vector128<T> InsertUint<T>(Vector128<T> value, uint data, byte index) where T : struct { throw new NotImplementedException(); }
+ public static Vector128<T> InsertUint<T>(Vector128<T> value, uint data, byte index) where T : struct => InsertUint<T>(value, data, index);
/// <summary>
/// __m128i _mm_insert_epi64 (__m128i a, __int64 i, const int imm8)
/// </summary>
- public static Vector128<T> InsertLong<T>(Vector128<T> value, long data, byte index) where T : struct { throw new NotImplementedException(); }
+ public static Vector128<T> InsertLong<T>(Vector128<T> value, long data, byte index) where T : struct => InsertLong<T>(value, data, index);
/// <summary>
/// __m128i _mm_insert_epi64 (__m128i a, __int64 i, const int imm8)
/// </summary>
- public static Vector128<T> InsertUlong<T>(Vector128<T> value, ulong data, byte index) where T : struct { throw new NotImplementedException(); }
+ public static Vector128<T> InsertUlong<T>(Vector128<T> value, ulong data, byte index) where T : struct => InsertUlong<T>(value, data, index);
/// <summary>
/// __m128 _mm_insert_ps (__m128 a, __m128 b, const int imm8)
/// </summary>
- public static Vector128<T> InsertFloat<T>(Vector128<T> value, float data, byte index) where T : struct { throw new NotImplementedException(); }
+ public static Vector128<T> InsertFloat<T>(Vector128<T> value, float data, byte index) where T : struct => InsertFloat<T>(value, data, index);
/// <summary>
/// __m128i _mm_max_epi8 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<sbyte> Max(Vector128<sbyte> left, Vector128<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> Max(Vector128<sbyte> left, Vector128<sbyte> right) => Max(left, right);
/// <summary>
/// __m128i _mm_max_epu16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<ushort> Max(Vector128<ushort> left, Vector128<ushort> right) { throw new NotImplementedException(); }
+ public static Vector128<ushort> Max(Vector128<ushort> left, Vector128<ushort> right) => Max(left, right);
/// <summary>
/// __m128i _mm_max_epi32 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<int> Max(Vector128<int> left, Vector128<int> right) { throw new NotImplementedException(); }
+ public static Vector128<int> Max(Vector128<int> left, Vector128<int> right) => Max(left, right);
/// <summary>
/// __m128i _mm_max_epu32 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<uint> Max(Vector128<uint> left, Vector128<uint> right) { throw new NotImplementedException(); }
+ public static Vector128<uint> Max(Vector128<uint> left, Vector128<uint> right) => Max(left, right);
/// <summary>
/// __m128i _mm_min_epi8 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<sbyte> Min(Vector128<sbyte> left, Vector128<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> Min(Vector128<sbyte> left, Vector128<sbyte> right) => Min(left, right);
/// <summary>
/// __m128i _mm_min_epu16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<ushort> Min(Vector128<ushort> left, Vector128<ushort> right) { throw new NotImplementedException(); }
+ public static Vector128<ushort> Min(Vector128<ushort> left, Vector128<ushort> right) => Min(left, right);
/// <summary>
/// __m128i _mm_min_epi32 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<int> Min(Vector128<int> left, Vector128<int> right) { throw new NotImplementedException(); }
+ public static Vector128<int> Min(Vector128<int> left, Vector128<int> right) => Min(left, right);
/// <summary>
/// __m128i _mm_min_epu32 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<uint> Min(Vector128<uint> left, Vector128<uint> right) { throw new NotImplementedException(); }
+ public static Vector128<uint> Min(Vector128<uint> left, Vector128<uint> right) => Min(left, right);
/// <summary>
/// __m128i _mm_minpos_epu16 (__m128i a)
/// </summary>
- public static Vector128<ushort> MinHorizontal(Vector128<ushort> value) { throw new NotImplementedException(); }
+ public static Vector128<ushort> MinHorizontal(Vector128<ushort> value) => MinHorizontal(value);
/// <summary>
/// __m128i _mm_mpsadbw_epu8 (__m128i a, __m128i b, const int imm8)
/// </summary>
- public static Vector128<ushort> MultipleSumAbsoluteDifferences(Vector128<byte> left, Vector128<byte> right, byte mask) { throw new NotImplementedException(); }
+ public static Vector128<ushort> MultipleSumAbsoluteDifferences(Vector128<byte> left, Vector128<byte> right, byte mask) => MultipleSumAbsoluteDifferences(left, right, mask);
/// <summary>
/// __m128i _mm_mul_epi32 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<long> Multiply(Vector128<int> left, Vector128<int> right) { throw new NotImplementedException(); }
+ public static Vector128<long> Multiply(Vector128<int> left, Vector128<int> right) => Multiply(left, right);
/// <summary>
/// __m128i _mm_mullo_epi32 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<int> MultiplyLow(Vector128<int> left, Vector128<int> right) { throw new NotImplementedException(); }
+ public static Vector128<int> MultiplyLow(Vector128<int> left, Vector128<int> right) => MultiplyLow(left, right);
/// <summary>
/// __m128i _mm_packus_epi32 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<ushort> PackUnsignedSaturate(Vector128<int> left, Vector128<int> right) { throw new NotImplementedException(); }
+ public static Vector128<ushort> PackUnsignedSaturate(Vector128<int> left, Vector128<int> right) => PackUnsignedSaturate(left, right);
/// <summary>
/// __m128 _mm_round_ps (__m128 a, int rounding)
/// _MM_FROUND_TO_NEAREST_INT |_MM_FROUND_NO_EXC
/// </summary>
- public static Vector128<float> RoundToNearestInteger(Vector128<float> value) { throw new NotImplementedException(); }
+ public static Vector128<float> RoundToNearestInteger(Vector128<float> value) => RoundToNearestInteger(value);
/// <summary>
/// _MM_FROUND_TO_NEG_INF |_MM_FROUND_NO_EXC
/// </summary>
- public static Vector128<float> RoundToNegativeInfinity(Vector128<float> value) { throw new NotImplementedException(); }
+ public static Vector128<float> RoundToNegativeInfinity(Vector128<float> value) => RoundToNegativeInfinity(value);
/// <summary>
/// _MM_FROUND_TO_POS_INF |_MM_FROUND_NO_EXC
/// </summary>
- public static Vector128<float> RoundToPositiveInfinity(Vector128<float> value) { throw new NotImplementedException(); }
+ public static Vector128<float> RoundToPositiveInfinity(Vector128<float> value) => RoundToPositiveInfinity(value);
/// <summary>
/// _MM_FROUND_TO_ZERO |_MM_FROUND_NO_EXC
/// </summary>
- public static Vector128<float> RoundToZero(Vector128<float> value) { throw new NotImplementedException(); }
+ public static Vector128<float> RoundToZero(Vector128<float> value) => RoundToZero(value);
/// <summary>
/// _MM_FROUND_CUR_DIRECTION
/// </summary>
- public static Vector128<float> RoundCurrentDirection(Vector128<float> value) { throw new NotImplementedException(); }
+ public static Vector128<float> RoundCurrentDirection(Vector128<float> value) => RoundCurrentDirection(value);
/// <summary>
/// __m128d _mm_round_pd (__m128d a, int rounding)
/// _MM_FROUND_TO_NEAREST_INT |_MM_FROUND_NO_EXC
/// </summary>
- public static Vector128<double> RoundToNearestInteger(Vector128<double> value) { throw new NotImplementedException(); }
+ public static Vector128<double> RoundToNearestInteger(Vector128<double> value) => RoundToNearestInteger(value);
/// <summary>
/// _MM_FROUND_TO_NEG_INF |_MM_FROUND_NO_EXC
/// </summary>
- public static Vector128<double> RoundToNegativeInfinity(Vector128<double> value) { throw new NotImplementedException(); }
+ public static Vector128<double> RoundToNegativeInfinity(Vector128<double> value) => RoundToNegativeInfinity(value);
/// <summary>
/// _MM_FROUND_TO_POS_INF |_MM_FROUND_NO_EXC
/// </summary>
- public static Vector128<double> RoundToPositiveInfinity(Vector128<double> value) { throw new NotImplementedException(); }
+ public static Vector128<double> RoundToPositiveInfinity(Vector128<double> value) => RoundToPositiveInfinity(value);
/// <summary>
/// _MM_FROUND_TO_ZERO |_MM_FROUND_NO_EXC
/// </summary>
- public static Vector128<double> RoundToZero(Vector128<double> value) { throw new NotImplementedException(); }
+ public static Vector128<double> RoundToZero(Vector128<double> value) => RoundToZero(value);
/// <summary>
/// _MM_FROUND_CUR_DIRECTION
/// </summary>
- public static Vector128<double> RoundCurrentDirection(Vector128<double> value) { throw new NotImplementedException(); }
+ public static Vector128<double> RoundCurrentDirection(Vector128<double> value) => RoundCurrentDirection(value);
/// <summary>
/// __m128i _mm_stream_load_si128 (const __m128i* mem_addr)
/// </summary>
- public static unsafe Vector128<sbyte> LoadAlignedNonTemporal(sbyte* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<sbyte> LoadAlignedNonTemporal(sbyte* address) => LoadAlignedNonTemporal(address);
/// <summary>
/// __m128i _mm_stream_load_si128 (const __m128i* mem_addr)
/// </summary>
- public static unsafe Vector128<byte> LoadAlignedNonTemporal(byte* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<byte> LoadAlignedNonTemporal(byte* address) => LoadAlignedNonTemporal(address);
/// <summary>
/// __m128i _mm_stream_load_si128 (const __m128i* mem_addr)
/// </summary>
- public static unsafe Vector128<short> LoadAlignedNonTemporal(short* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<short> LoadAlignedNonTemporal(short* address) => LoadAlignedNonTemporal(address);
/// <summary>
/// __m128i _mm_stream_load_si128 (const __m128i* mem_addr)
/// </summary>
- public static unsafe Vector128<ushort> LoadAlignedNonTemporal(ushort* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<ushort> LoadAlignedNonTemporal(ushort* address) => LoadAlignedNonTemporal(address);
/// <summary>
/// __m128i _mm_stream_load_si128 (const __m128i* mem_addr)
/// </summary>
- public static unsafe Vector128<int> LoadAlignedNonTemporal(int* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<int> LoadAlignedNonTemporal(int* address) => LoadAlignedNonTemporal(address);
/// <summary>
/// __m128i _mm_stream_load_si128 (const __m128i* mem_addr)
/// </summary>
- public static unsafe Vector128<uint> LoadAlignedNonTemporal(uint* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<uint> LoadAlignedNonTemporal(uint* address) => LoadAlignedNonTemporal(address);
/// <summary>
/// __m128i _mm_stream_load_si128 (const __m128i* mem_addr)
/// </summary>
- public static unsafe Vector128<long> LoadAlignedNonTemporal(long* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<long> LoadAlignedNonTemporal(long* address) => LoadAlignedNonTemporal(address);
/// <summary>
/// __m128i _mm_stream_load_si128 (const __m128i* mem_addr)
/// </summary>
- public static unsafe Vector128<ulong> LoadAlignedNonTemporal(ulong* address) { throw new NotImplementedException(); }
+ public static unsafe Vector128<ulong> LoadAlignedNonTemporal(ulong* address) => LoadAlignedNonTemporal(address);
/// <summary>
/// int _mm_test_all_ones (__m128i a)
/// </summary>
- public static bool TestAllOnes(Vector128<sbyte> value) { throw new NotImplementedException(); }
- public static bool TestAllOnes(Vector128<byte> value) { throw new NotImplementedException(); }
- public static bool TestAllOnes(Vector128<short> value) { throw new NotImplementedException(); }
- public static bool TestAllOnes(Vector128<ushort> value) { throw new NotImplementedException(); }
- public static bool TestAllOnes(Vector128<int> value) { throw new NotImplementedException(); }
- public static bool TestAllOnes(Vector128<uint> value) { throw new NotImplementedException(); }
- public static bool TestAllOnes(Vector128<long> value) { throw new NotImplementedException(); }
- public static bool TestAllOnes(Vector128<ulong> value) { throw new NotImplementedException(); }
+ public static bool TestAllOnes(Vector128<sbyte> value) => TestAllOnes(value);
+ public static bool TestAllOnes(Vector128<byte> value) => TestAllOnes(value);
+ public static bool TestAllOnes(Vector128<short> value) => TestAllOnes(value);
+ public static bool TestAllOnes(Vector128<ushort> value) => TestAllOnes(value);
+ public static bool TestAllOnes(Vector128<int> value) => TestAllOnes(value);
+ public static bool TestAllOnes(Vector128<uint> value) => TestAllOnes(value);
+ public static bool TestAllOnes(Vector128<long> value) => TestAllOnes(value);
+ public static bool TestAllOnes(Vector128<ulong> value) => TestAllOnes(value);
/// <summary>
/// int _mm_test_all_zeros (__m128i a, __m128i mask)
/// </summary>
- public static bool TestAllZeros(Vector128<sbyte> left, Vector128<sbyte> right) { throw new NotImplementedException(); }
- public static bool TestAllZeros(Vector128<byte> left, Vector128<byte> right) { throw new NotImplementedException(); }
- public static bool TestAllZeros(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
- public static bool TestAllZeros(Vector128<ushort> left, Vector128<ushort> right) { throw new NotImplementedException(); }
- public static bool TestAllZeros(Vector128<int> left, Vector128<int> right) { throw new NotImplementedException(); }
- public static bool TestAllZeros(Vector128<uint> left, Vector128<uint> right) { throw new NotImplementedException(); }
- public static bool TestAllZeros(Vector128<long> left, Vector128<long> right) { throw new NotImplementedException(); }
- public static bool TestAllZeros(Vector128<ulong> left, Vector128<ulong> right) { throw new NotImplementedException(); }
+ public static bool TestAllZeros(Vector128<sbyte> left, Vector128<sbyte> right) => TestAllZeros(left, right);
+ public static bool TestAllZeros(Vector128<byte> left, Vector128<byte> right) => TestAllZeros(left, right);
+ public static bool TestAllZeros(Vector128<short> left, Vector128<short> right) => TestAllZeros(left, right);
+ public static bool TestAllZeros(Vector128<ushort> left, Vector128<ushort> right) => TestAllZeros(left, right);
+ public static bool TestAllZeros(Vector128<int> left, Vector128<int> right) => TestAllZeros(left, right);
+ public static bool TestAllZeros(Vector128<uint> left, Vector128<uint> right) => TestAllZeros(left, right);
+ public static bool TestAllZeros(Vector128<long> left, Vector128<long> right) => TestAllZeros(left, right);
+ public static bool TestAllZeros(Vector128<ulong> left, Vector128<ulong> right) => TestAllZeros(left, right);
/// <summary>
/// int _mm_testc_si128 (__m128i a, __m128i b)
/// </summary>
- public static bool TestC(Vector128<sbyte> left, Vector128<sbyte> right) { throw new NotImplementedException(); }
- public static bool TestC(Vector128<byte> left, Vector128<byte> right) { throw new NotImplementedException(); }
- public static bool TestC(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
- public static bool TestC(Vector128<ushort> left, Vector128<ushort> right) { throw new NotImplementedException(); }
- public static bool TestC(Vector128<int> left, Vector128<int> right) { throw new NotImplementedException(); }
- public static bool TestC(Vector128<uint> left, Vector128<uint> right) { throw new NotImplementedException(); }
- public static bool TestC(Vector128<long> left, Vector128<long> right) { throw new NotImplementedException(); }
- public static bool TestC(Vector128<ulong> left, Vector128<ulong> right) { throw new NotImplementedException(); }
+ public static bool TestC(Vector128<sbyte> left, Vector128<sbyte> right) => TestC(left, right);
+ public static bool TestC(Vector128<byte> left, Vector128<byte> right) => TestC(left, right);
+ public static bool TestC(Vector128<short> left, Vector128<short> right) => TestC(left, right);
+ public static bool TestC(Vector128<ushort> left, Vector128<ushort> right) => TestC(left, right);
+ public static bool TestC(Vector128<int> left, Vector128<int> right) => TestC(left, right);
+ public static bool TestC(Vector128<uint> left, Vector128<uint> right) => TestC(left, right);
+ public static bool TestC(Vector128<long> left, Vector128<long> right) => TestC(left, right);
+ public static bool TestC(Vector128<ulong> left, Vector128<ulong> right) => TestC(left, right);
/// <summary>
/// int _mm_test_mix_ones_zeros (__m128i a, __m128i mask)
/// </summary>
- public static bool TestMixOnesZeros(Vector128<sbyte> left, Vector128<sbyte> right) { throw new NotImplementedException(); }
- public static bool TestMixOnesZeros(Vector128<byte> left, Vector128<byte> right) { throw new NotImplementedException(); }
- public static bool TestMixOnesZeros(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
- public static bool TestMixOnesZeros(Vector128<ushort> left, Vector128<ushort> right) { throw new NotImplementedException(); }
- public static bool TestMixOnesZeros(Vector128<int> left, Vector128<int> right) { throw new NotImplementedException(); }
- public static bool TestMixOnesZeros(Vector128<uint> left, Vector128<uint> right) { throw new NotImplementedException(); }
- public static bool TestMixOnesZeros(Vector128<long> left, Vector128<long> right) { throw new NotImplementedException(); }
- public static bool TestMixOnesZeros(Vector128<ulong> left, Vector128<ulong> right) { throw new NotImplementedException(); }
+ public static bool TestMixOnesZeros(Vector128<sbyte> left, Vector128<sbyte> right) => TestMixOnesZeros(left, right);
+ public static bool TestMixOnesZeros(Vector128<byte> left, Vector128<byte> right) => TestMixOnesZeros(left, right);
+ public static bool TestMixOnesZeros(Vector128<short> left, Vector128<short> right) => TestMixOnesZeros(left, right);
+ public static bool TestMixOnesZeros(Vector128<ushort> left, Vector128<ushort> right) => TestMixOnesZeros(left, right);
+ public static bool TestMixOnesZeros(Vector128<int> left, Vector128<int> right) => TestMixOnesZeros(left, right);
+ public static bool TestMixOnesZeros(Vector128<uint> left, Vector128<uint> right) => TestMixOnesZeros(left, right);
+ public static bool TestMixOnesZeros(Vector128<long> left, Vector128<long> right) => TestMixOnesZeros(left, right);
+ public static bool TestMixOnesZeros(Vector128<ulong> left, Vector128<ulong> right) => TestMixOnesZeros(left, right);
/// <summary>
/// int _mm_testnzc_si128 (__m128i a, __m128i b)
/// </summary>
- public static bool TestNotZAndNotC(Vector128<sbyte> left, Vector128<sbyte> right) { throw new NotImplementedException(); }
- public static bool TestNotZAndNotC(Vector128<byte> left, Vector128<byte> right) { throw new NotImplementedException(); }
- public static bool TestNotZAndNotC(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
- public static bool TestNotZAndNotC(Vector128<ushort> left, Vector128<ushort> right) { throw new NotImplementedException(); }
- public static bool TestNotZAndNotC(Vector128<int> left, Vector128<int> right) { throw new NotImplementedException(); }
- public static bool TestNotZAndNotC(Vector128<uint> left, Vector128<uint> right) { throw new NotImplementedException(); }
- public static bool TestNotZAndNotC(Vector128<long> left, Vector128<long> right) { throw new NotImplementedException(); }
- public static bool TestNotZAndNotC(Vector128<ulong> left, Vector128<ulong> right) { throw new NotImplementedException(); }
+ public static bool TestNotZAndNotC(Vector128<sbyte> left, Vector128<sbyte> right) => TestNotZAndNotC(left, right);
+ public static bool TestNotZAndNotC(Vector128<byte> left, Vector128<byte> right) => TestNotZAndNotC(left, right);
+ public static bool TestNotZAndNotC(Vector128<short> left, Vector128<short> right) => TestNotZAndNotC(left, right);
+ public static bool TestNotZAndNotC(Vector128<ushort> left, Vector128<ushort> right) => TestNotZAndNotC(left, right);
+ public static bool TestNotZAndNotC(Vector128<int> left, Vector128<int> right) => TestNotZAndNotC(left, right);
+ public static bool TestNotZAndNotC(Vector128<uint> left, Vector128<uint> right) => TestNotZAndNotC(left, right);
+ public static bool TestNotZAndNotC(Vector128<long> left, Vector128<long> right) => TestNotZAndNotC(left, right);
+ public static bool TestNotZAndNotC(Vector128<ulong> left, Vector128<ulong> right) => TestNotZAndNotC(left, right);
/// <summary>
/// int _mm_testz_si128 (__m128i a, __m128i b)
/// </summary>
- public static bool TestZ(Vector128<sbyte> left, Vector128<sbyte> right) { throw new NotImplementedException(); }
- public static bool TestZ(Vector128<byte> left, Vector128<byte> right) { throw new NotImplementedException(); }
- public static bool TestZ(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
- public static bool TestZ(Vector128<ushort> left, Vector128<ushort> right) { throw new NotImplementedException(); }
- public static bool TestZ(Vector128<int> left, Vector128<int> right) { throw new NotImplementedException(); }
- public static bool TestZ(Vector128<uint> left, Vector128<uint> right) { throw new NotImplementedException(); }
- public static bool TestZ(Vector128<long> left, Vector128<long> right) { throw new NotImplementedException(); }
- public static bool TestZ(Vector128<ulong> left, Vector128<ulong> right) { throw new NotImplementedException(); }
+ public static bool TestZ(Vector128<sbyte> left, Vector128<sbyte> right) => TestZ(left, right);
+ public static bool TestZ(Vector128<byte> left, Vector128<byte> right) => TestZ(left, right);
+ public static bool TestZ(Vector128<short> left, Vector128<short> right) => TestZ(left, right);
+ public static bool TestZ(Vector128<ushort> left, Vector128<ushort> right) => TestZ(left, right);
+ public static bool TestZ(Vector128<int> left, Vector128<int> right) => TestZ(left, right);
+ public static bool TestZ(Vector128<uint> left, Vector128<uint> right) => TestZ(left, right);
+ public static bool TestZ(Vector128<long> left, Vector128<long> right) => TestZ(left, right);
+ public static bool TestZ(Vector128<ulong> left, Vector128<ulong> right) => TestZ(left, right);
}
}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse42.PlatformNotSupported.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse42.PlatformNotSupported.cs
new file mode 100644
index 0000000000..3db94c1afb
--- /dev/null
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse42.PlatformNotSupported.cs
@@ -0,0 +1,233 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.Intrinsics;
+
+namespace System.Runtime.Intrinsics.X86
+{
+ /// <summary>
+ /// This class provides access to Intel SSE4.2 hardware instructions via intrinsics
+ /// </summary>
+ [CLSCompliant(false)]
+ public static class Sse42
+ {
+ public static bool IsSupported { get { return false; } }
+
+ /// <summary>
+ /// int _mm_cmpistra (__m128i a, __m128i b, const int imm8)
+ /// int _mm_cmpistrc (__m128i a, __m128i b, const int imm8)
+ /// int _mm_cmpistro (__m128i a, __m128i b, const int imm8)
+ /// int _mm_cmpistrs (__m128i a, __m128i b, const int imm8)
+ /// int _mm_cmpistrz (__m128i a, __m128i b, const int imm8)
+ /// </summary>
+ public static bool CompareImplicitLength(Vector128<sbyte> left, Vector128<sbyte> right, ResultsFlag flag, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_cmpistra (__m128i a, __m128i b, const int imm8)
+ /// int _mm_cmpistrc (__m128i a, __m128i b, const int imm8)
+ /// int _mm_cmpistro (__m128i a, __m128i b, const int imm8)
+ /// int _mm_cmpistrs (__m128i a, __m128i b, const int imm8)
+ /// int _mm_cmpistrz (__m128i a, __m128i b, const int imm8)
+ /// </summary>
+ public static bool CompareImplicitLength(Vector128<byte> left, Vector128<byte> right, ResultsFlag flag, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_cmpistra (__m128i a, __m128i b, const int imm8)
+ /// int _mm_cmpistrc (__m128i a, __m128i b, const int imm8)
+ /// int _mm_cmpistro (__m128i a, __m128i b, const int imm8)
+ /// int _mm_cmpistrs (__m128i a, __m128i b, const int imm8)
+ /// int _mm_cmpistrz (__m128i a, __m128i b, const int imm8)
+ /// </summary>
+ public static bool CompareImplicitLength(Vector128<short> left, Vector128<short> right, ResultsFlag flag, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+
+ /// <summary>
+ /// int _mm_cmpistra (__m128i a, __m128i b, const int imm8)
+ /// int _mm_cmpistrc (__m128i a, __m128i b, const int imm8)
+ /// int _mm_cmpistro (__m128i a, __m128i b, const int imm8)
+ /// int _mm_cmpistrs (__m128i a, __m128i b, const int imm8)
+ /// int _mm_cmpistrz (__m128i a, __m128i b, const int imm8)
+ /// </summary>
+ public static bool CompareImplicitLength(Vector128<ushort> left, Vector128<ushort> right, ResultsFlag flag, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_cmpestra (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// int _mm_cmpestrc (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// int _mm_cmpestro (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// int _mm_cmpestrs (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// int _mm_cmpestrz (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// </summary>
+ public static bool CompareExplicitLength(Vector128<sbyte> left, byte leftLength, Vector128<sbyte> right, byte rightLength, ResultsFlag flag, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_cmpestra (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// int _mm_cmpestrc (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// int _mm_cmpestro (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// int _mm_cmpestrs (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// int _mm_cmpestrz (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// </summary>
+ public static bool CompareExplicitLength(Vector128<byte> left, byte leftLength, Vector128<byte> right, byte rightLength, ResultsFlag flag, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_cmpestra (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// int _mm_cmpestrc (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// int _mm_cmpestro (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// int _mm_cmpestrs (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// int _mm_cmpestrz (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// </summary>
+ public static bool CompareExplicitLength(Vector128<short> left, byte leftLength, Vector128<short> right, byte rightLength, ResultsFlag flag, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_cmpestra (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// int _mm_cmpestrc (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// int _mm_cmpestro (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// int _mm_cmpestrs (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// int _mm_cmpestrz (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// </summary>
+ public static bool CompareExplicitLength(Vector128<ushort> left, byte leftLength, Vector128<ushort> right, byte rightLength, ResultsFlag flag, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_cmpistri (__m128i a, __m128i b, const int imm8)
+ /// </summary>
+ public static int CompareImplicitLengthIndex(Vector128<sbyte> left, Vector128<sbyte> right, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_cmpistri (__m128i a, __m128i b, const int imm8)
+ /// </summary>
+ public static int CompareImplicitLengthIndex(Vector128<byte> left, Vector128<byte> right, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_cmpistri (__m128i a, __m128i b, const int imm8)
+ /// </summary>
+ public static int CompareImplicitLengthIndex(Vector128<short> left, Vector128<short> right, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_cmpistri (__m128i a, __m128i b, const int imm8)
+ /// </summary>
+ public static int CompareImplicitLengthIndex(Vector128<ushort> left, Vector128<ushort> right, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_cmpestri (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// </summary>
+ public static int CompareExplicitLengthIndex(Vector128<sbyte> left, byte leftLength, Vector128<sbyte> right, byte rightLength, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_cmpestri (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// </summary>
+ public static int CompareExplicitLengthIndex(Vector128<byte> left, byte leftLength, Vector128<byte> right, byte rightLength, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_cmpestri (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// </summary>
+ public static int CompareExplicitLengthIndex(Vector128<short> left, byte leftLength, Vector128<short> right, byte rightLength, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// int _mm_cmpestri (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// </summary>
+ public static int CompareExplicitLengthIndex(Vector128<ushort> left, byte leftLength, Vector128<ushort> right, byte rightLength, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_cmpistrm (__m128i a, __m128i b, const int imm8)
+ /// </summary>
+ public static Vector128<ushort> CompareImplicitLengthBitMask(Vector128<sbyte> left, Vector128<sbyte> right, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_cmpistrm (__m128i a, __m128i b, const int imm8)
+ /// </summary>
+ public static Vector128<ushort> CompareImplicitLengthBitMask(Vector128<byte> left, Vector128<byte> right, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_cmpistrm (__m128i a, __m128i b, const int imm8)
+ /// </summary>
+ public static Vector128<byte> CompareImplicitLengthBitMask(Vector128<short> left, Vector128<short> right, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_cmpistrm (__m128i a, __m128i b, const int imm8)
+ /// </summary>
+ public static Vector128<byte> CompareImplicitLengthBitMask(Vector128<ushort> left, Vector128<ushort> right, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_cmpistrm (__m128i a, __m128i b, const int imm8)
+ /// </summary>
+ public static Vector128<byte> CompareImplicitLengthUnitMask(Vector128<sbyte> left, Vector128<sbyte> right, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_cmpistrm (__m128i a, __m128i b, const int imm8)
+ /// </summary>
+ public static Vector128<byte> CompareImplicitLengthUnitMask(Vector128<byte> left, Vector128<byte> right, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_cmpistrm (__m128i a, __m128i b, const int imm8)
+ /// </summary>
+ public static Vector128<ushort> CompareImplicitLengthUnitMask(Vector128<short> left, Vector128<short> right, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_cmpistrm (__m128i a, __m128i b, const int imm8)
+ /// </summary>
+ public static Vector128<ushort> CompareImplicitLengthUnitMask(Vector128<ushort> left, Vector128<ushort> right, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_cmpestrm (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// </summary>
+ public static Vector128<ushort> CompareExplicitLengthBitMask(Vector128<sbyte> left, byte leftLength, Vector128<sbyte> right, byte rightLength, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_cmpestrm (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// </summary>
+ public static Vector128<ushort> CompareExplicitLengthBitMask(Vector128<byte> left, byte leftLength, Vector128<byte> right, byte rightLength, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_cmpestrm (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// </summary>
+ public static Vector128<byte> CompareExplicitLengthBitMask(Vector128<short> left, byte leftLength, Vector128<short> right, byte rightLength, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_cmpestrm (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// </summary>
+ public static Vector128<byte> CompareExplicitLengthBitMask(Vector128<ushort> left, byte leftLength, Vector128<ushort> right, byte rightLength, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_cmpestrm (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// </summary>
+ public static Vector128<byte> CompareExplicitLengthUnitMask(Vector128<sbyte> left, byte leftLength, Vector128<sbyte> right, byte rightLength, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_cmpestrm (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// </summary>
+ public static Vector128<byte> CompareExplicitLengthUnitMask(Vector128<byte> left, byte leftLength, Vector128<byte> right, byte rightLength, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_cmpestrm (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// </summary>
+ public static Vector128<ushort> CompareExplicitLengthUnitMask(Vector128<short> left, byte leftLength, Vector128<short> right, byte rightLength, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_cmpestrm (__m128i a, int la, __m128i b, int lb, const int imm8)
+ /// </summary>
+ public static Vector128<ushort> CompareExplicitLengthUnitMask(Vector128<ushort> left, byte leftLength, Vector128<ushort> right, byte rightLength, StringComparisonMode mode) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_cmpgt_epi64 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<long> CompareGreaterThan(Vector128<long> left, Vector128<long> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// unsigned int _mm_crc32_u8 (unsigned int crc, unsigned char v)
+ /// </summary>
+ public static uint Crc32(uint crc, byte data) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// unsigned int _mm_crc32_u16 (unsigned int crc, unsigned short v)
+ /// </summary>
+ public static uint Crc32(uint crc, ushort data) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// unsigned int _mm_crc32_u32 (unsigned int crc, unsigned int v)
+ /// </summary>
+ public static uint Crc32(uint crc, uint data) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// unsigned __int64 _mm_crc32_u64 (unsigned __int64 crc, unsigned __int64 v)
+ /// </summary>
+ public static ulong Crc32(ulong crc, ulong data) { throw new PlatformNotSupportedException(); }
+ }
+}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse42.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse42.cs
index f644577ae1..f98867cb9d 100644
--- a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse42.cs
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Sse42.cs
@@ -13,7 +13,7 @@ namespace System.Runtime.Intrinsics.X86
[CLSCompliant(false)]
public static class Sse42
{
- public static bool IsSupported { get { return false; } }
+ public static bool IsSupported { get => IsSupported; }
/// <summary>
/// int _mm_cmpistra (__m128i a, __m128i b, const int imm8)
@@ -22,7 +22,7 @@ namespace System.Runtime.Intrinsics.X86
/// int _mm_cmpistrs (__m128i a, __m128i b, const int imm8)
/// int _mm_cmpistrz (__m128i a, __m128i b, const int imm8)
/// </summary>
- public static bool CompareImplicitLength(Vector128<sbyte> left, Vector128<sbyte> right, ResultsFlag flag, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static bool CompareImplicitLength(Vector128<sbyte> left, Vector128<sbyte> right, ResultsFlag flag, StringComparisonMode mode) => CompareImplicitLength(left, right, flag, mode);
/// <summary>
/// int _mm_cmpistra (__m128i a, __m128i b, const int imm8)
@@ -31,7 +31,7 @@ namespace System.Runtime.Intrinsics.X86
/// int _mm_cmpistrs (__m128i a, __m128i b, const int imm8)
/// int _mm_cmpistrz (__m128i a, __m128i b, const int imm8)
/// </summary>
- public static bool CompareImplicitLength(Vector128<byte> left, Vector128<byte> right, ResultsFlag flag, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static bool CompareImplicitLength(Vector128<byte> left, Vector128<byte> right, ResultsFlag flag, StringComparisonMode mode) => CompareImplicitLength(left, right, flag, mode);
/// <summary>
/// int _mm_cmpistra (__m128i a, __m128i b, const int imm8)
@@ -40,7 +40,7 @@ namespace System.Runtime.Intrinsics.X86
/// int _mm_cmpistrs (__m128i a, __m128i b, const int imm8)
/// int _mm_cmpistrz (__m128i a, __m128i b, const int imm8)
/// </summary>
- public static bool CompareImplicitLength(Vector128<short> left, Vector128<short> right, ResultsFlag flag, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static bool CompareImplicitLength(Vector128<short> left, Vector128<short> right, ResultsFlag flag, StringComparisonMode mode) => CompareImplicitLength(left, right, flag, mode);
/// <summary>
@@ -50,7 +50,7 @@ namespace System.Runtime.Intrinsics.X86
/// int _mm_cmpistrs (__m128i a, __m128i b, const int imm8)
/// int _mm_cmpistrz (__m128i a, __m128i b, const int imm8)
/// </summary>
- public static bool CompareImplicitLength(Vector128<ushort> left, Vector128<ushort> right, ResultsFlag flag, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static bool CompareImplicitLength(Vector128<ushort> left, Vector128<ushort> right, ResultsFlag flag, StringComparisonMode mode) => CompareImplicitLength(left, right, flag, mode);
/// <summary>
/// int _mm_cmpestra (__m128i a, int la, __m128i b, int lb, const int imm8)
@@ -59,7 +59,7 @@ namespace System.Runtime.Intrinsics.X86
/// int _mm_cmpestrs (__m128i a, int la, __m128i b, int lb, const int imm8)
/// int _mm_cmpestrz (__m128i a, int la, __m128i b, int lb, const int imm8)
/// </summary>
- public static bool CompareExplicitLength(Vector128<sbyte> left, byte leftLength, Vector128<sbyte> right, byte rightLength, ResultsFlag flag, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static bool CompareExplicitLength(Vector128<sbyte> left, byte leftLength, Vector128<sbyte> right, byte rightLength, ResultsFlag flag, StringComparisonMode mode) => CompareExplicitLength(left, leftLength, right, rightLength, flag, mode);
/// <summary>
/// int _mm_cmpestra (__m128i a, int la, __m128i b, int lb, const int imm8)
@@ -68,7 +68,7 @@ namespace System.Runtime.Intrinsics.X86
/// int _mm_cmpestrs (__m128i a, int la, __m128i b, int lb, const int imm8)
/// int _mm_cmpestrz (__m128i a, int la, __m128i b, int lb, const int imm8)
/// </summary>
- public static bool CompareExplicitLength(Vector128<byte> left, byte leftLength, Vector128<byte> right, byte rightLength, ResultsFlag flag, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static bool CompareExplicitLength(Vector128<byte> left, byte leftLength, Vector128<byte> right, byte rightLength, ResultsFlag flag, StringComparisonMode mode) => CompareExplicitLength(left, leftLength, right, rightLength, flag, mode);
/// <summary>
/// int _mm_cmpestra (__m128i a, int la, __m128i b, int lb, const int imm8)
@@ -77,7 +77,7 @@ namespace System.Runtime.Intrinsics.X86
/// int _mm_cmpestrs (__m128i a, int la, __m128i b, int lb, const int imm8)
/// int _mm_cmpestrz (__m128i a, int la, __m128i b, int lb, const int imm8)
/// </summary>
- public static bool CompareExplicitLength(Vector128<short> left, byte leftLength, Vector128<short> right, byte rightLength, ResultsFlag flag, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static bool CompareExplicitLength(Vector128<short> left, byte leftLength, Vector128<short> right, byte rightLength, ResultsFlag flag, StringComparisonMode mode) => CompareExplicitLength(left, leftLength, right, rightLength, flag, mode);
/// <summary>
/// int _mm_cmpestra (__m128i a, int la, __m128i b, int lb, const int imm8)
@@ -86,148 +86,148 @@ namespace System.Runtime.Intrinsics.X86
/// int _mm_cmpestrs (__m128i a, int la, __m128i b, int lb, const int imm8)
/// int _mm_cmpestrz (__m128i a, int la, __m128i b, int lb, const int imm8)
/// </summary>
- public static bool CompareExplicitLength(Vector128<ushort> left, byte leftLength, Vector128<ushort> right, byte rightLength, ResultsFlag flag, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static bool CompareExplicitLength(Vector128<ushort> left, byte leftLength, Vector128<ushort> right, byte rightLength, ResultsFlag flag, StringComparisonMode mode) => CompareExplicitLength(left, leftLength, right, rightLength, flag, mode);
/// <summary>
/// int _mm_cmpistri (__m128i a, __m128i b, const int imm8)
/// </summary>
- public static int CompareImplicitLengthIndex(Vector128<sbyte> left, Vector128<sbyte> right, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static int CompareImplicitLengthIndex(Vector128<sbyte> left, Vector128<sbyte> right, StringComparisonMode mode) => CompareImplicitLengthIndex(left, right, mode);
/// <summary>
/// int _mm_cmpistri (__m128i a, __m128i b, const int imm8)
/// </summary>
- public static int CompareImplicitLengthIndex(Vector128<byte> left, Vector128<byte> right, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static int CompareImplicitLengthIndex(Vector128<byte> left, Vector128<byte> right, StringComparisonMode mode) => CompareImplicitLengthIndex(left, right, mode);
/// <summary>
/// int _mm_cmpistri (__m128i a, __m128i b, const int imm8)
/// </summary>
- public static int CompareImplicitLengthIndex(Vector128<short> left, Vector128<short> right, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static int CompareImplicitLengthIndex(Vector128<short> left, Vector128<short> right, StringComparisonMode mode) => CompareImplicitLengthIndex(left, right, mode);
/// <summary>
/// int _mm_cmpistri (__m128i a, __m128i b, const int imm8)
/// </summary>
- public static int CompareImplicitLengthIndex(Vector128<ushort> left, Vector128<ushort> right, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static int CompareImplicitLengthIndex(Vector128<ushort> left, Vector128<ushort> right, StringComparisonMode mode) => CompareImplicitLengthIndex(left, right, mode);
/// <summary>
/// int _mm_cmpestri (__m128i a, int la, __m128i b, int lb, const int imm8)
/// </summary>
- public static int CompareExplicitLengthIndex(Vector128<sbyte> left, byte leftLength, Vector128<sbyte> right, byte rightLength, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static int CompareExplicitLengthIndex(Vector128<sbyte> left, byte leftLength, Vector128<sbyte> right, byte rightLength, StringComparisonMode mode) => CompareExplicitLengthIndex(left, leftLength, right, rightLength, mode);
/// <summary>
/// int _mm_cmpestri (__m128i a, int la, __m128i b, int lb, const int imm8)
/// </summary>
- public static int CompareExplicitLengthIndex(Vector128<byte> left, byte leftLength, Vector128<byte> right, byte rightLength, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static int CompareExplicitLengthIndex(Vector128<byte> left, byte leftLength, Vector128<byte> right, byte rightLength, StringComparisonMode mode) => CompareExplicitLengthIndex(left, leftLength, right, rightLength, mode);
/// <summary>
/// int _mm_cmpestri (__m128i a, int la, __m128i b, int lb, const int imm8)
/// </summary>
- public static int CompareExplicitLengthIndex(Vector128<short> left, byte leftLength, Vector128<short> right, byte rightLength, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static int CompareExplicitLengthIndex(Vector128<short> left, byte leftLength, Vector128<short> right, byte rightLength, StringComparisonMode mode) => CompareExplicitLengthIndex(left, leftLength, right, rightLength, mode);
/// <summary>
/// int _mm_cmpestri (__m128i a, int la, __m128i b, int lb, const int imm8)
/// </summary>
- public static int CompareExplicitLengthIndex(Vector128<ushort> left, byte leftLength, Vector128<ushort> right, byte rightLength, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static int CompareExplicitLengthIndex(Vector128<ushort> left, byte leftLength, Vector128<ushort> right, byte rightLength, StringComparisonMode mode) => CompareExplicitLengthIndex(left, leftLength, right, rightLength, mode);
/// <summary>
/// __m128i _mm_cmpistrm (__m128i a, __m128i b, const int imm8)
/// </summary>
- public static Vector128<ushort> CompareImplicitLengthBitMask(Vector128<sbyte> left, Vector128<sbyte> right, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static Vector128<ushort> CompareImplicitLengthBitMask(Vector128<sbyte> left, Vector128<sbyte> right, StringComparisonMode mode) => CompareImplicitLengthBitMask(left, right, mode);
/// <summary>
/// __m128i _mm_cmpistrm (__m128i a, __m128i b, const int imm8)
/// </summary>
- public static Vector128<ushort> CompareImplicitLengthBitMask(Vector128<byte> left, Vector128<byte> right, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static Vector128<ushort> CompareImplicitLengthBitMask(Vector128<byte> left, Vector128<byte> right, StringComparisonMode mode) => CompareImplicitLengthBitMask(left, right, mode);
/// <summary>
/// __m128i _mm_cmpistrm (__m128i a, __m128i b, const int imm8)
/// </summary>
- public static Vector128<byte> CompareImplicitLengthBitMask(Vector128<short> left, Vector128<short> right, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static Vector128<byte> CompareImplicitLengthBitMask(Vector128<short> left, Vector128<short> right, StringComparisonMode mode) => CompareImplicitLengthBitMask(left, right, mode);
/// <summary>
/// __m128i _mm_cmpistrm (__m128i a, __m128i b, const int imm8)
/// </summary>
- public static Vector128<byte> CompareImplicitLengthBitMask(Vector128<ushort> left, Vector128<ushort> right, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static Vector128<byte> CompareImplicitLengthBitMask(Vector128<ushort> left, Vector128<ushort> right, StringComparisonMode mode) => CompareImplicitLengthBitMask(left, right, mode);
/// <summary>
/// __m128i _mm_cmpistrm (__m128i a, __m128i b, const int imm8)
/// </summary>
- public static Vector128<byte> CompareImplicitLengthUnitMask(Vector128<sbyte> left, Vector128<sbyte> right, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static Vector128<byte> CompareImplicitLengthUnitMask(Vector128<sbyte> left, Vector128<sbyte> right, StringComparisonMode mode) => CompareImplicitLengthUnitMask(left, right, mode);
/// <summary>
/// __m128i _mm_cmpistrm (__m128i a, __m128i b, const int imm8)
/// </summary>
- public static Vector128<byte> CompareImplicitLengthUnitMask(Vector128<byte> left, Vector128<byte> right, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static Vector128<byte> CompareImplicitLengthUnitMask(Vector128<byte> left, Vector128<byte> right, StringComparisonMode mode) => CompareImplicitLengthUnitMask(left, right, mode);
/// <summary>
/// __m128i _mm_cmpistrm (__m128i a, __m128i b, const int imm8)
/// </summary>
- public static Vector128<ushort> CompareImplicitLengthUnitMask(Vector128<short> left, Vector128<short> right, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static Vector128<ushort> CompareImplicitLengthUnitMask(Vector128<short> left, Vector128<short> right, StringComparisonMode mode) => CompareImplicitLengthUnitMask(left, right, mode);
/// <summary>
/// __m128i _mm_cmpistrm (__m128i a, __m128i b, const int imm8)
/// </summary>
- public static Vector128<ushort> CompareImplicitLengthUnitMask(Vector128<ushort> left, Vector128<ushort> right, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static Vector128<ushort> CompareImplicitLengthUnitMask(Vector128<ushort> left, Vector128<ushort> right, StringComparisonMode mode) => CompareImplicitLengthUnitMask(left, right, mode);
/// <summary>
/// __m128i _mm_cmpestrm (__m128i a, int la, __m128i b, int lb, const int imm8)
/// </summary>
- public static Vector128<ushort> CompareExplicitLengthBitMask(Vector128<sbyte> left, byte leftLength, Vector128<sbyte> right, byte rightLength, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static Vector128<ushort> CompareExplicitLengthBitMask(Vector128<sbyte> left, byte leftLength, Vector128<sbyte> right, byte rightLength, StringComparisonMode mode) => CompareExplicitLengthBitMask(left, leftLength, right, rightLength, mode);
/// <summary>
/// __m128i _mm_cmpestrm (__m128i a, int la, __m128i b, int lb, const int imm8)
/// </summary>
- public static Vector128<ushort> CompareExplicitLengthBitMask(Vector128<byte> left, byte leftLength, Vector128<byte> right, byte rightLength, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static Vector128<ushort> CompareExplicitLengthBitMask(Vector128<byte> left, byte leftLength, Vector128<byte> right, byte rightLength, StringComparisonMode mode) => CompareExplicitLengthBitMask(left, leftLength, right, rightLength, mode);
/// <summary>
/// __m128i _mm_cmpestrm (__m128i a, int la, __m128i b, int lb, const int imm8)
/// </summary>
- public static Vector128<byte> CompareExplicitLengthBitMask(Vector128<short> left, byte leftLength, Vector128<short> right, byte rightLength, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static Vector128<byte> CompareExplicitLengthBitMask(Vector128<short> left, byte leftLength, Vector128<short> right, byte rightLength, StringComparisonMode mode) => CompareExplicitLengthBitMask(left, leftLength, right, rightLength, mode);
/// <summary>
/// __m128i _mm_cmpestrm (__m128i a, int la, __m128i b, int lb, const int imm8)
/// </summary>
- public static Vector128<byte> CompareExplicitLengthBitMask(Vector128<ushort> left, byte leftLength, Vector128<ushort> right, byte rightLength, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static Vector128<byte> CompareExplicitLengthBitMask(Vector128<ushort> left, byte leftLength, Vector128<ushort> right, byte rightLength, StringComparisonMode mode) => CompareExplicitLengthBitMask(left, leftLength, right, rightLength, mode);
/// <summary>
/// __m128i _mm_cmpestrm (__m128i a, int la, __m128i b, int lb, const int imm8)
/// </summary>
- public static Vector128<byte> CompareExplicitLengthUnitMask(Vector128<sbyte> left, byte leftLength, Vector128<sbyte> right, byte rightLength, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static Vector128<byte> CompareExplicitLengthUnitMask(Vector128<sbyte> left, byte leftLength, Vector128<sbyte> right, byte rightLength, StringComparisonMode mode) => CompareExplicitLengthUnitMask(left, leftLength, right, rightLength, mode);
/// <summary>
/// __m128i _mm_cmpestrm (__m128i a, int la, __m128i b, int lb, const int imm8)
/// </summary>
- public static Vector128<byte> CompareExplicitLengthUnitMask(Vector128<byte> left, byte leftLength, Vector128<byte> right, byte rightLength, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static Vector128<byte> CompareExplicitLengthUnitMask(Vector128<byte> left, byte leftLength, Vector128<byte> right, byte rightLength, StringComparisonMode mode) => CompareExplicitLengthUnitMask(left, leftLength, right, rightLength, mode);
/// <summary>
/// __m128i _mm_cmpestrm (__m128i a, int la, __m128i b, int lb, const int imm8)
/// </summary>
- public static Vector128<ushort> CompareExplicitLengthUnitMask(Vector128<short> left, byte leftLength, Vector128<short> right, byte rightLength, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static Vector128<ushort> CompareExplicitLengthUnitMask(Vector128<short> left, byte leftLength, Vector128<short> right, byte rightLength, StringComparisonMode mode) => CompareExplicitLengthUnitMask(left, leftLength, right, rightLength, mode);
/// <summary>
/// __m128i _mm_cmpestrm (__m128i a, int la, __m128i b, int lb, const int imm8)
/// </summary>
- public static Vector128<ushort> CompareExplicitLengthUnitMask(Vector128<ushort> left, byte leftLength, Vector128<ushort> right, byte rightLength, StringComparisonMode mode) { throw new NotImplementedException(); }
+ public static Vector128<ushort> CompareExplicitLengthUnitMask(Vector128<ushort> left, byte leftLength, Vector128<ushort> right, byte rightLength, StringComparisonMode mode) => CompareExplicitLengthUnitMask(left, leftLength, right, rightLength, mode);
/// <summary>
/// __m128i _mm_cmpgt_epi64 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<long> CompareGreaterThan(Vector128<long> left, Vector128<long> right) { throw new NotImplementedException(); }
+ public static Vector128<long> CompareGreaterThan(Vector128<long> left, Vector128<long> right) => CompareGreaterThan(left, right);
/// <summary>
/// unsigned int _mm_crc32_u8 (unsigned int crc, unsigned char v)
/// </summary>
- public static uint Crc32(uint crc, byte data) { throw new NotImplementedException(); }
+ public static uint Crc32(uint crc, byte data) => Crc32(crc, data);
/// <summary>
/// unsigned int _mm_crc32_u16 (unsigned int crc, unsigned short v)
/// </summary>
- public static uint Crc32(uint crc, ushort data) { throw new NotImplementedException(); }
+ public static uint Crc32(uint crc, ushort data) => Crc32(crc, data);
/// <summary>
/// unsigned int _mm_crc32_u32 (unsigned int crc, unsigned int v)
/// </summary>
- public static uint Crc32(uint crc, uint data) { throw new NotImplementedException(); }
+ public static uint Crc32(uint crc, uint data) => Crc32(crc, data);
/// <summary>
/// unsigned __int64 _mm_crc32_u64 (unsigned __int64 crc, unsigned __int64 v)
/// </summary>
- public static ulong Crc32(ulong crc, ulong data) { throw new NotImplementedException(); }
+ public static ulong Crc32(ulong crc, ulong data) => Crc32(crc, data);
}
}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Ssse3.PlatformNotSupported.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Ssse3.PlatformNotSupported.cs
new file mode 100644
index 0000000000..1bc8e232fd
--- /dev/null
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Ssse3.PlatformNotSupported.cs
@@ -0,0 +1,92 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.Intrinsics;
+
+namespace System.Runtime.Intrinsics.X86
+{
+ /// <summary>
+ /// This class provides access to Intel SSSE3 hardware instructions via intrinsics
+ /// </summary>
+ [CLSCompliant(false)]
+ public static class Ssse3
+ {
+ public static bool IsSupported { get { return false; } }
+
+ /// <summary>
+ /// __m128i _mm_abs_epi8 (__m128i a)
+ /// </summary>
+ public static Vector128<byte> Abs(Vector128<sbyte> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_abs_epi16 (__m128i a)
+ /// </summary>
+ public static Vector128<ushort> Abs(Vector128<short> value) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_abs_epi32 (__m128i a)
+ /// </summary>
+ public static Vector128<uint> Abs(Vector128<int> value) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_alignr_epi8 (__m128i a, __m128i b, int count)
+ /// </summary>
+ public static Vector128<sbyte> AlignRight(Vector128<sbyte> left, Vector128<sbyte> right, byte mask) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_hadd_epi16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<short> HorizontalAdd(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_hadd_epi32 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<int> HorizontalAdd(Vector128<int> left, Vector128<int> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_hadds_epi16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<short> HorizontalAddSaturate(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_hsub_epi16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<short> HorizontalSubtract(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_hsub_epi32 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<int> HorizontalSubtract(Vector128<int> left, Vector128<int> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_hsubs_epi16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<short> HorizontalSubtractSaturate(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_maddubs_epi16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<short> MultiplyAddAdjacent(Vector128<byte> left, Vector128<sbyte> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_mulhrs_epi16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<short> MultiplyHighRoundScale(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_shuffle_epi8 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<sbyte> Shuffle(Vector128<sbyte> value, Vector128<sbyte> mask) { throw new PlatformNotSupportedException(); }
+
+ /// <summary>
+ /// __m128i _mm_sign_epi8 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<sbyte> Sign(Vector128<sbyte> left, Vector128<sbyte> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_sign_epi16 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<short> Sign(Vector128<short> left, Vector128<short> right) { throw new PlatformNotSupportedException(); }
+ /// <summary>
+ /// __m128i _mm_sign_epi32 (__m128i a, __m128i b)
+ /// </summary>
+ public static Vector128<int> Sign(Vector128<int> left, Vector128<int> right) { throw new PlatformNotSupportedException(); }
+ }
+}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Ssse3.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Ssse3.cs
index 0ce9036a8f..d336d2eef9 100644
--- a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Ssse3.cs
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Ssse3.cs
@@ -13,80 +13,80 @@ namespace System.Runtime.Intrinsics.X86
[CLSCompliant(false)]
public static class Ssse3
{
- public static bool IsSupported { get { return false; } }
+ public static bool IsSupported { get => IsSupported; }
/// <summary>
/// __m128i _mm_abs_epi8 (__m128i a)
/// </summary>
- public static Vector128<byte> Abs(Vector128<sbyte> value) { throw new NotImplementedException(); }
+ public static Vector128<byte> Abs(Vector128<sbyte> value) => Abs(value);
/// <summary>
/// __m128i _mm_abs_epi16 (__m128i a)
/// </summary>
- public static Vector128<ushort> Abs(Vector128<short> value) { throw new NotImplementedException(); }
+ public static Vector128<ushort> Abs(Vector128<short> value) => Abs(value);
/// <summary>
/// __m128i _mm_abs_epi32 (__m128i a)
/// </summary>
- public static Vector128<uint> Abs(Vector128<int> value) { throw new NotImplementedException(); }
+ public static Vector128<uint> Abs(Vector128<int> value) => Abs(value);
/// <summary>
/// __m128i _mm_alignr_epi8 (__m128i a, __m128i b, int count)
/// </summary>
- public static Vector128<sbyte> AlignRight(Vector128<sbyte> left, Vector128<sbyte> right, byte mask) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> AlignRight(Vector128<sbyte> left, Vector128<sbyte> right, byte mask) => AlignRight(left, right, mask);
/// <summary>
/// __m128i _mm_hadd_epi16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<short> HorizontalAdd(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
+ public static Vector128<short> HorizontalAdd(Vector128<short> left, Vector128<short> right) => HorizontalAdd(left, right);
/// <summary>
/// __m128i _mm_hadd_epi32 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<int> HorizontalAdd(Vector128<int> left, Vector128<int> right) { throw new NotImplementedException(); }
+ public static Vector128<int> HorizontalAdd(Vector128<int> left, Vector128<int> right) => HorizontalAdd(left, right);
/// <summary>
/// __m128i _mm_hadds_epi16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<short> HorizontalAddSaturate(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
+ public static Vector128<short> HorizontalAddSaturate(Vector128<short> left, Vector128<short> right) => HorizontalAddSaturate(left, right);
/// <summary>
/// __m128i _mm_hsub_epi16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<short> HorizontalSubtract(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
+ public static Vector128<short> HorizontalSubtract(Vector128<short> left, Vector128<short> right) => HorizontalSubtract(left, right);
/// <summary>
/// __m128i _mm_hsub_epi32 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<int> HorizontalSubtract(Vector128<int> left, Vector128<int> right) { throw new NotImplementedException(); }
+ public static Vector128<int> HorizontalSubtract(Vector128<int> left, Vector128<int> right) => HorizontalSubtract(left, right);
/// <summary>
/// __m128i _mm_hsubs_epi16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<short> HorizontalSubtractSaturate(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
+ public static Vector128<short> HorizontalSubtractSaturate(Vector128<short> left, Vector128<short> right) => HorizontalSubtractSaturate(left, right);
/// <summary>
/// __m128i _mm_maddubs_epi16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<short> MultiplyAddAdjacent(Vector128<byte> left, Vector128<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector128<short> MultiplyAddAdjacent(Vector128<byte> left, Vector128<sbyte> right) => MultiplyAddAdjacent(left, right);
/// <summary>
/// __m128i _mm_mulhrs_epi16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<short> MultiplyHighRoundScale(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
+ public static Vector128<short> MultiplyHighRoundScale(Vector128<short> left, Vector128<short> right) => MultiplyHighRoundScale(left, right);
/// <summary>
/// __m128i _mm_shuffle_epi8 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<sbyte> Shuffle(Vector128<sbyte> value, Vector128<sbyte> mask) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> Shuffle(Vector128<sbyte> value, Vector128<sbyte> mask) => Shuffle(value, mask);
/// <summary>
/// __m128i _mm_sign_epi8 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<sbyte> Sign(Vector128<sbyte> left, Vector128<sbyte> right) { throw new NotImplementedException(); }
+ public static Vector128<sbyte> Sign(Vector128<sbyte> left, Vector128<sbyte> right) => Sign(left, right);
/// <summary>
/// __m128i _mm_sign_epi16 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<short> Sign(Vector128<short> left, Vector128<short> right) { throw new NotImplementedException(); }
+ public static Vector128<short> Sign(Vector128<short> left, Vector128<short> right) => Sign(left, right);
/// <summary>
/// __m128i _mm_sign_epi32 (__m128i a, __m128i b)
/// </summary>
- public static Vector128<int> Sign(Vector128<int> left, Vector128<int> right) { throw new NotImplementedException(); }
+ public static Vector128<int> Sign(Vector128<int> left, Vector128<int> right) => Sign(left, right);
}
}
diff --git a/src/mscorlib/src/System/Runtime/Loader/AssemblyLoadContext.cs b/src/mscorlib/src/System/Runtime/Loader/AssemblyLoadContext.cs
index a7bf871a39..0481581c18 100644
--- a/src/mscorlib/src/System/Runtime/Loader/AssemblyLoadContext.cs
+++ b/src/mscorlib/src/System/Runtime/Loader/AssemblyLoadContext.cs
@@ -5,7 +5,6 @@
using System;
using System.Reflection;
-using System.Diagnostics.Contracts;
using System.IO;
using System.Runtime.Versioning;
using System.Runtime.CompilerServices;
diff --git a/src/mscorlib/src/System/Runtime/MemoryFailPoint.cs b/src/mscorlib/src/System/Runtime/MemoryFailPoint.cs
index 4b96836daf..899bd44d96 100644
--- a/src/mscorlib/src/System/Runtime/MemoryFailPoint.cs
+++ b/src/mscorlib/src/System/Runtime/MemoryFailPoint.cs
@@ -22,7 +22,6 @@ using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
using System.Runtime.Versioning;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
/*
This class allows an application to fail before starting certain
@@ -156,7 +155,6 @@ namespace System.Runtime
{
if (sizeInMegabytes <= 0)
throw new ArgumentOutOfRangeException(nameof(sizeInMegabytes), SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
#if !FEATURE_PAL // Remove this when CheckForAvailableMemory is able to provide legitimate estimates
ulong size = ((ulong)sizeInMegabytes) << 20;
diff --git a/src/mscorlib/src/System/Runtime/Serialization/FormatterConverter.cs b/src/mscorlib/src/System/Runtime/Serialization/FormatterConverter.cs
index 52e748db89..a6e03e7099 100644
--- a/src/mscorlib/src/System/Runtime/Serialization/FormatterConverter.cs
+++ b/src/mscorlib/src/System/Runtime/Serialization/FormatterConverter.cs
@@ -15,7 +15,6 @@
using System;
using System.Globalization;
-using System.Diagnostics.Contracts;
namespace System.Runtime.Serialization
{
@@ -31,7 +30,6 @@ namespace System.Runtime.Serialization
{
throw new ArgumentNullException(nameof(value));
}
- Contract.EndContractBlock();
return System.Convert.ChangeType(value, type, CultureInfo.InvariantCulture);
}
@@ -41,7 +39,6 @@ namespace System.Runtime.Serialization
{
throw new ArgumentNullException(nameof(value));
}
- Contract.EndContractBlock();
return System.Convert.ChangeType(value, typeCode, CultureInfo.InvariantCulture);
}
@@ -51,7 +48,6 @@ namespace System.Runtime.Serialization
{
throw new ArgumentNullException(nameof(value));
}
- Contract.EndContractBlock();
return System.Convert.ToBoolean(value, CultureInfo.InvariantCulture);
}
@@ -61,7 +57,6 @@ namespace System.Runtime.Serialization
{
throw new ArgumentNullException(nameof(value));
}
- Contract.EndContractBlock();
return System.Convert.ToChar(value, CultureInfo.InvariantCulture);
}
@@ -72,7 +67,6 @@ namespace System.Runtime.Serialization
{
throw new ArgumentNullException(nameof(value));
}
- Contract.EndContractBlock();
return System.Convert.ToSByte(value, CultureInfo.InvariantCulture);
}
@@ -82,7 +76,6 @@ namespace System.Runtime.Serialization
{
throw new ArgumentNullException(nameof(value));
}
- Contract.EndContractBlock();
return System.Convert.ToByte(value, CultureInfo.InvariantCulture);
}
@@ -92,7 +85,6 @@ namespace System.Runtime.Serialization
{
throw new ArgumentNullException(nameof(value));
}
- Contract.EndContractBlock();
return System.Convert.ToInt16(value, CultureInfo.InvariantCulture);
}
@@ -103,7 +95,6 @@ namespace System.Runtime.Serialization
{
throw new ArgumentNullException(nameof(value));
}
- Contract.EndContractBlock();
return System.Convert.ToUInt16(value, CultureInfo.InvariantCulture);
}
@@ -113,7 +104,6 @@ namespace System.Runtime.Serialization
{
throw new ArgumentNullException(nameof(value));
}
- Contract.EndContractBlock();
return System.Convert.ToInt32(value, CultureInfo.InvariantCulture);
}
@@ -124,7 +114,6 @@ namespace System.Runtime.Serialization
{
throw new ArgumentNullException(nameof(value));
}
- Contract.EndContractBlock();
return System.Convert.ToUInt32(value, CultureInfo.InvariantCulture);
}
@@ -134,7 +123,6 @@ namespace System.Runtime.Serialization
{
throw new ArgumentNullException(nameof(value));
}
- Contract.EndContractBlock();
return System.Convert.ToInt64(value, CultureInfo.InvariantCulture);
}
@@ -145,7 +133,6 @@ namespace System.Runtime.Serialization
{
throw new ArgumentNullException(nameof(value));
}
- Contract.EndContractBlock();
return System.Convert.ToUInt64(value, CultureInfo.InvariantCulture);
}
@@ -155,7 +142,6 @@ namespace System.Runtime.Serialization
{
throw new ArgumentNullException(nameof(value));
}
- Contract.EndContractBlock();
return System.Convert.ToSingle(value, CultureInfo.InvariantCulture);
}
@@ -165,7 +151,6 @@ namespace System.Runtime.Serialization
{
throw new ArgumentNullException(nameof(value));
}
- Contract.EndContractBlock();
return System.Convert.ToDouble(value, CultureInfo.InvariantCulture);
}
@@ -175,7 +160,6 @@ namespace System.Runtime.Serialization
{
throw new ArgumentNullException(nameof(value));
}
- Contract.EndContractBlock();
return System.Convert.ToDecimal(value, CultureInfo.InvariantCulture);
}
@@ -185,7 +169,6 @@ namespace System.Runtime.Serialization
{
throw new ArgumentNullException(nameof(value));
}
- Contract.EndContractBlock();
return System.Convert.ToDateTime(value, CultureInfo.InvariantCulture);
}
@@ -195,7 +178,6 @@ namespace System.Runtime.Serialization
{
throw new ArgumentNullException(nameof(value));
}
- Contract.EndContractBlock();
return System.Convert.ToString(value, CultureInfo.InvariantCulture);
}
}
diff --git a/src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs b/src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs
index b49b372b4b..1377350b80 100644
--- a/src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs
+++ b/src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs
@@ -24,7 +24,6 @@ using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Runtime.Serialization
{
@@ -45,7 +44,6 @@ namespace System.Runtime.Serialization
{
throw new ArgumentNullException(nameof(type));
}
- Contract.EndContractBlock();
if (!(type is RuntimeType))
{
diff --git a/src/mscorlib/src/System/Runtime/Serialization/SerializationInfo.cs b/src/mscorlib/src/System/Runtime/Serialization/SerializationInfo.cs
index 8fb54c79a7..694a382148 100644
--- a/src/mscorlib/src/System/Runtime/Serialization/SerializationInfo.cs
+++ b/src/mscorlib/src/System/Runtime/Serialization/SerializationInfo.cs
@@ -17,7 +17,6 @@ using System.Collections.Generic;
using System.Reflection;
using System.Globalization;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Security;
using System.Runtime.CompilerServices;
@@ -63,7 +62,6 @@ namespace System.Runtime.Serialization
throw new ArgumentNullException(nameof(converter));
}
- Contract.EndContractBlock();
objectType = type;
m_fullTypeName = type.FullName;
@@ -92,7 +90,6 @@ namespace System.Runtime.Serialization
{
throw new ArgumentNullException(nameof(value));
}
- Contract.EndContractBlock();
m_fullTypeName = value;
isFullTypeNameSetExplicit = true;
@@ -111,7 +108,6 @@ namespace System.Runtime.Serialization
{
throw new ArgumentNullException(nameof(value));
}
- Contract.EndContractBlock();
if (requireSameTokenInPartialTrust)
{
DemandForUnsafeAssemblyNameAssignments(m_assemName, value);
@@ -127,7 +123,6 @@ namespace System.Runtime.Serialization
{
throw new ArgumentNullException(nameof(type));
}
- Contract.EndContractBlock();
if (requireSameTokenInPartialTrust)
{
@@ -233,7 +228,6 @@ namespace System.Runtime.Serialization
{
throw new ArgumentNullException(nameof(type));
}
- Contract.EndContractBlock();
AddValueInternal(name, value, type);
}
@@ -389,7 +383,6 @@ namespace System.Runtime.Serialization
{
throw new ArgumentNullException(nameof(name));
}
- Contract.EndContractBlock();
BCLDebug.Trace("SER", "[SerializationInfo.FindElement]Looking for ", name, " CurrMember is: ", m_currMember);
int index;
if (m_nameToIndex.TryGetValue(name, out index))
@@ -453,7 +446,6 @@ namespace System.Runtime.Serialization
{
throw new ArgumentNullException(nameof(type));
}
- Contract.EndContractBlock();
RuntimeType rt = type as RuntimeType;
if (rt == null)
diff --git a/src/mscorlib/src/System/RuntimeHandles.cs b/src/mscorlib/src/System/RuntimeHandles.cs
index 20783ef467..428155ad60 100644
--- a/src/mscorlib/src/System/RuntimeHandles.cs
+++ b/src/mscorlib/src/System/RuntimeHandles.cs
@@ -20,7 +20,6 @@ namespace System
using System.Globalization;
using System.Security;
using Microsoft.Win32.SafeHandles;
- using System.Diagnostics.Contracts;
using StackCrawlMark = System.Threading.StackCrawlMark;
public unsafe struct RuntimeTypeHandle : ISerializable
@@ -476,7 +475,6 @@ namespace System
{
if (name == null || name.Length == 0)
throw new ArgumentException(null, nameof(name));
- Contract.EndContractBlock();
RuntimeType type = null;
GetTypeByNameUsingCARules(name, scope.GetNativeHandle(), JitHelpers.GetObjectHandleOnStack(ref type));
@@ -806,7 +804,6 @@ namespace System
return handle.Value == Value;
}
- [Pure]
internal bool IsNullHandle()
{
return m_value == null;
@@ -838,7 +835,6 @@ namespace System
return _GetCurrentMethod(ref stackMark);
}
- [Pure]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern MethodAttributes GetAttributes(RuntimeMethodHandleInternal method);
@@ -878,7 +874,7 @@ namespace System
internal static int GetSlot(IRuntimeMethodInfo method)
{
- Contract.Requires(method != null);
+ Debug.Assert(method != null);
int slot = RuntimeMethodHandle.GetSlot(method.Value);
GC.KeepAlive(method);
diff --git a/src/mscorlib/src/System/SharedStatics.cs b/src/mscorlib/src/System/SharedStatics.cs
index 5c37f25446..dd9c63b334 100644
--- a/src/mscorlib/src/System/SharedStatics.cs
+++ b/src/mscorlib/src/System/SharedStatics.cs
@@ -16,7 +16,6 @@ using System.Security;
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System
{
diff --git a/src/mscorlib/src/System/String.Comparison.cs b/src/mscorlib/src/System/String.Comparison.cs
index 6c6c5856be..bcb0ee058a 100644
--- a/src/mscorlib/src/System/String.Comparison.cs
+++ b/src/mscorlib/src/System/String.Comparison.cs
@@ -4,7 +4,6 @@
using System.Collections;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
@@ -20,9 +19,8 @@ namespace System
private unsafe static int CompareOrdinalIgnoreCaseHelper(String strA, String strB)
{
- Contract.Requires(strA != null);
- Contract.Requires(strB != null);
- Contract.EndContractBlock();
+ Debug.Assert(strA != null);
+ Debug.Assert(strB != null);
int length = Math.Min(strA.Length, strB.Length);
fixed (char* ap = &strA._firstChar) fixed (char* bp = &strB._firstChar)
@@ -76,9 +74,9 @@ namespace System
private unsafe static bool EqualsHelper(String strA, String strB)
{
- Contract.Requires(strA != null);
- Contract.Requires(strB != null);
- Contract.Requires(strA.Length == strB.Length);
+ Debug.Assert(strA != null);
+ Debug.Assert(strB != null);
+ Debug.Assert(strA.Length == strB.Length);
int length = strA.Length;
@@ -133,10 +131,9 @@ namespace System
private unsafe static bool EqualsIgnoreCaseAsciiHelper(String strA, String strB)
{
- Contract.Requires(strA != null);
- Contract.Requires(strB != null);
- Contract.Requires(strA.Length == strB.Length);
- Contract.EndContractBlock();
+ Debug.Assert(strA != null);
+ Debug.Assert(strB != null);
+ Debug.Assert(strA.Length == strB.Length);
int length = strA.Length;
fixed (char* ap = &strA._firstChar) fixed (char* bp = &strB._firstChar)
@@ -172,9 +169,9 @@ namespace System
private unsafe static bool StartsWithOrdinalHelper(String str, String startsWith)
{
- Contract.Requires(str != null);
- Contract.Requires(startsWith != null);
- Contract.Requires(str.Length >= startsWith.Length);
+ Debug.Assert(str != null);
+ Debug.Assert(startsWith != null);
+ Debug.Assert(str.Length >= startsWith.Length);
int length = startsWith.Length;
@@ -224,8 +221,8 @@ namespace System
private unsafe static int CompareOrdinalHelper(String strA, String strB)
{
- Contract.Requires(strA != null);
- Contract.Requires(strB != null);
+ Debug.Assert(strA != null);
+ Debug.Assert(strB != null);
// NOTE: This may be subject to change if eliminating the check
// in the callers makes them small enough to be inlined by the JIT
@@ -346,7 +343,6 @@ namespace System
// to determine whether it is lexicographically less, equal, or greater, and then returns
// either a negative integer, 0, or a positive integer; respectively.
//
- [Pure]
public static int Compare(String strA, String strB)
{
return Compare(strA, strB, StringComparison.CurrentCulture);
@@ -358,7 +354,6 @@ namespace System
// negative integer, 0, or a positive integer is returned; respectively.
// The case-sensitive option is set by ignoreCase
//
- [Pure]
public static int Compare(String strA, String strB, bool ignoreCase)
{
var comparisonType = ignoreCase ? StringComparison.CurrentCultureIgnoreCase : StringComparison.CurrentCulture;
@@ -368,7 +363,6 @@ namespace System
// Provides a more flexible function for string comparision. See StringComparison
// for meaning of different comparisonType.
- [Pure]
public static int Compare(String strA, String strB, StringComparison comparisonType)
{
// Single comparison to check if comparisonType is within [CurrentCulture .. OrdinalIgnoreCase]
@@ -376,7 +370,6 @@ namespace System
{
throw new ArgumentException(SR.NotSupported_StringComparison, nameof(comparisonType));
}
- Contract.EndContractBlock();
if (object.ReferenceEquals(strA, strB))
{
@@ -436,14 +429,12 @@ namespace System
// to determine whether it is lexicographically less, equal, or greater, and then a
// negative integer, 0, or a positive integer is returned; respectively.
//
- [Pure]
public static int Compare(String strA, String strB, CultureInfo culture, CompareOptions options)
{
if (culture == null)
{
throw new ArgumentNullException(nameof(culture));
}
- Contract.EndContractBlock();
return culture.CompareInfo.Compare(strA, strB, options);
}
@@ -456,7 +447,6 @@ namespace System
// The case-sensitive option is set by ignoreCase, and the culture is set
// by culture
//
- [Pure]
public static int Compare(String strA, String strB, bool ignoreCase, CultureInfo culture)
{
var options = ignoreCase ? CompareOptions.IgnoreCase : CompareOptions.None;
@@ -467,7 +457,6 @@ namespace System
// at indexA of length count is compared with the substring of strB
// beginning at indexB of the same length.
//
- [Pure]
public static int Compare(String strA, int indexA, String strB, int indexB, int length)
{
// NOTE: It's important we call the boolean overload, and not the StringComparison
@@ -479,7 +468,6 @@ namespace System
// at indexA of length count is compared with the substring of strB
// beginning at indexB of the same length. Case sensitivity is determined by the ignoreCase boolean.
//
- [Pure]
public static int Compare(String strA, int indexA, String strB, int indexB, int length, bool ignoreCase)
{
// Ideally we would just forward to the string.Compare overload that takes
@@ -518,7 +506,6 @@ namespace System
// beginning at indexB of the same length. Case sensitivity is determined by the ignoreCase boolean,
// and the culture is set by culture.
//
- [Pure]
public static int Compare(String strA, int indexA, String strB, int indexB, int length, bool ignoreCase, CultureInfo culture)
{
var options = ignoreCase ? CompareOptions.IgnoreCase : CompareOptions.None;
@@ -530,14 +517,12 @@ namespace System
// at indexA of length length is compared with the substring of strB
// beginning at indexB of the same length.
//
- [Pure]
public static int Compare(String strA, int indexA, String strB, int indexB, int length, CultureInfo culture, CompareOptions options)
{
if (culture == null)
{
throw new ArgumentNullException(nameof(culture));
}
- Contract.EndContractBlock();
int lengthA = length;
int lengthB = length;
@@ -555,14 +540,12 @@ namespace System
return culture.CompareInfo.Compare(strA, indexA, lengthA, strB, indexB, lengthB, options);
}
- [Pure]
public static int Compare(String strA, int indexA, String strB, int indexB, int length, StringComparison comparisonType)
{
if (comparisonType < StringComparison.CurrentCulture || comparisonType > StringComparison.OrdinalIgnoreCase)
{
throw new ArgumentException(SR.NotSupported_StringComparison, nameof(comparisonType));
}
- Contract.EndContractBlock();
if (strA == null || strB == null)
{
@@ -627,7 +610,6 @@ namespace System
// Compares strA and strB using an ordinal (code-point) comparison.
//
- [Pure]
public static int CompareOrdinal(String strA, String strB)
{
if (object.ReferenceEquals(strA, strB))
@@ -658,7 +640,6 @@ namespace System
// Compares strA and strB using an ordinal (code-point) comparison.
//
- [Pure]
public static int CompareOrdinal(String strA, int indexA, String strB, int indexB, int length)
{
if (strA == null || strB == null)
@@ -707,7 +688,6 @@ namespace System
// indicates the relationship. This method returns a value less than 0 if this is less than value, 0
// if this is equal to value, or a value greater than 0 if this is greater than value.
//
- [Pure]
public int CompareTo(Object value)
{
if (value == null)
@@ -727,7 +707,6 @@ namespace System
// Determines the sorting relation of StrB to the current instance.
//
- [Pure]
public int CompareTo(String strB)
{
return string.Compare(this, strB, StringComparison.CurrentCulture);
@@ -738,13 +717,11 @@ namespace System
// The case-sensitive and culture-sensitive option is set by options,
// and the default culture is used.
//
- [Pure]
public Boolean EndsWith(String value)
{
return EndsWith(value, StringComparison.CurrentCulture);
}
- [Pure]
public Boolean EndsWith(String value, StringComparison comparisonType)
{
if ((Object)value == null)
@@ -756,7 +733,6 @@ namespace System
{
throw new ArgumentException(SR.NotSupported_StringComparison, nameof(comparisonType));
}
- Contract.EndContractBlock();
if ((Object)this == (Object)value)
{
@@ -792,14 +768,12 @@ namespace System
}
}
- [Pure]
public Boolean EndsWith(String value, Boolean ignoreCase, CultureInfo culture)
{
if (null == value)
{
throw new ArgumentNullException(nameof(value));
}
- Contract.EndContractBlock();
if ((object)this == (object)value)
{
@@ -815,7 +789,6 @@ namespace System
return referenceCulture.CompareInfo.IsSuffix(this, value, ignoreCase ? CompareOptions.IgnoreCase : CompareOptions.None);
}
- [Pure]
public bool EndsWith(char value)
{
int thisLen = Length;
@@ -839,7 +812,6 @@ namespace System
}
// Determines whether two strings match.
- [Pure]
public bool Equals(String value)
{
if (object.ReferenceEquals(this, value))
@@ -858,12 +830,10 @@ namespace System
return EqualsHelper(this, value);
}
- [Pure]
public bool Equals(String value, StringComparison comparisonType)
{
if (comparisonType < StringComparison.CurrentCulture || comparisonType > StringComparison.OrdinalIgnoreCase)
throw new ArgumentException(SR.NotSupported_StringComparison, nameof(comparisonType));
- Contract.EndContractBlock();
if ((Object)this == (Object)value)
{
@@ -913,7 +883,6 @@ namespace System
// Determines whether two Strings match.
- [Pure]
public static bool Equals(String a, String b)
{
if ((Object)a == (Object)b)
@@ -929,12 +898,10 @@ namespace System
return EqualsHelper(a, b);
}
- [Pure]
public static bool Equals(String a, String b, StringComparison comparisonType)
{
if (comparisonType < StringComparison.CurrentCulture || comparisonType > StringComparison.OrdinalIgnoreCase)
throw new ArgumentException(SR.NotSupported_StringComparison, nameof(comparisonType));
- Contract.EndContractBlock();
if ((Object)a == (Object)b)
{
@@ -1070,18 +1037,15 @@ namespace System
// Determines whether a specified string is a prefix of the current instance
//
- [Pure]
public Boolean StartsWith(String value)
{
if ((Object)value == null)
{
throw new ArgumentNullException(nameof(value));
}
- Contract.EndContractBlock();
return StartsWith(value, StringComparison.CurrentCulture);
}
- [Pure]
public Boolean StartsWith(String value, StringComparison comparisonType)
{
if ((Object)value == null)
@@ -1093,7 +1057,6 @@ namespace System
{
throw new ArgumentException(SR.NotSupported_StringComparison, nameof(comparisonType));
}
- Contract.EndContractBlock();
if ((Object)this == (Object)value)
{
@@ -1141,14 +1104,12 @@ namespace System
}
}
- [Pure]
public Boolean StartsWith(String value, Boolean ignoreCase, CultureInfo culture)
{
if (null == value)
{
throw new ArgumentNullException(nameof(value));
}
- Contract.EndContractBlock();
if ((object)this == (object)value)
{
@@ -1164,7 +1125,6 @@ namespace System
return referenceCulture.CompareInfo.IsPrefix(this, value, ignoreCase ? CompareOptions.IgnoreCase : CompareOptions.None);
}
- [Pure]
public bool StartsWith(char value) => Length != 0 && _firstChar == value;
}
}
diff --git a/src/mscorlib/src/System/String.Manipulation.cs b/src/mscorlib/src/System/String.Manipulation.cs
index ba78a94b63..9cb4204159 100644
--- a/src/mscorlib/src/System/String.Manipulation.cs
+++ b/src/mscorlib/src/System/String.Manipulation.cs
@@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -16,13 +15,12 @@ namespace System
{
unsafe private static void FillStringChecked(String dest, int destPos, String src)
{
- Contract.Requires(dest != null);
- Contract.Requires(src != null);
+ Debug.Assert(dest != null);
+ Debug.Assert(src != null);
if (src.Length > dest.Length - destPos)
{
throw new IndexOutOfRangeException();
}
- Contract.EndContractBlock();
fixed (char* pDest = &dest._firstChar)
fixed (char* pSrc = &src._firstChar)
@@ -33,9 +31,6 @@ namespace System
public static String Concat(Object arg0)
{
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.EndContractBlock();
-
if (arg0 == null)
{
return String.Empty;
@@ -45,9 +40,6 @@ namespace System
public static String Concat(Object arg0, Object arg1)
{
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.EndContractBlock();
-
if (arg0 == null)
{
arg0 = String.Empty;
@@ -62,9 +54,6 @@ namespace System
public static String Concat(Object arg0, Object arg1, Object arg2)
{
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.EndContractBlock();
-
if (arg0 == null)
{
arg0 = String.Empty;
@@ -89,8 +78,6 @@ namespace System
{
throw new ArgumentNullException(nameof(args));
}
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.EndContractBlock();
if (args.Length <= 1)
{
@@ -154,8 +141,6 @@ namespace System
{
if (values == null)
throw new ArgumentNullException(nameof(values));
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.EndContractBlock();
using (IEnumerator<T> en = values.GetEnumerator())
{
@@ -204,8 +189,6 @@ namespace System
{
if (values == null)
throw new ArgumentNullException(nameof(values));
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.EndContractBlock();
using (IEnumerator<string> en = values.GetEnumerator())
{
@@ -235,12 +218,6 @@ namespace System
public static String Concat(String str0, String str1)
{
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.Ensures(Contract.Result<String>().Length ==
- (str0 == null ? 0 : str0.Length) +
- (str1 == null ? 0 : str1.Length));
- Contract.EndContractBlock();
-
if (IsNullOrEmpty(str0))
{
if (IsNullOrEmpty(str1))
@@ -267,13 +244,6 @@ namespace System
public static String Concat(String str0, String str1, String str2)
{
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.Ensures(Contract.Result<String>().Length ==
- (str0 == null ? 0 : str0.Length) +
- (str1 == null ? 0 : str1.Length) +
- (str2 == null ? 0 : str2.Length));
- Contract.EndContractBlock();
-
if (IsNullOrEmpty(str0))
{
return Concat(str1, str2);
@@ -301,14 +271,6 @@ namespace System
public static String Concat(String str0, String str1, String str2, String str3)
{
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.Ensures(Contract.Result<String>().Length ==
- (str0 == null ? 0 : str0.Length) +
- (str1 == null ? 0 : str1.Length) +
- (str2 == null ? 0 : str2.Length) +
- (str3 == null ? 0 : str3.Length));
- Contract.EndContractBlock();
-
if (IsNullOrEmpty(str0))
{
return Concat(str1, str2, str3);
@@ -344,8 +306,6 @@ namespace System
{
if (values == null)
throw new ArgumentNullException(nameof(values));
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.EndContractBlock();
if (values.Length <= 1)
{
@@ -412,19 +372,16 @@ namespace System
public static String Format(String format, Object arg0)
{
- Contract.Ensures(Contract.Result<String>() != null);
return FormatHelper(null, format, new ParamsArray(arg0));
}
public static String Format(String format, Object arg0, Object arg1)
{
- Contract.Ensures(Contract.Result<String>() != null);
return FormatHelper(null, format, new ParamsArray(arg0, arg1));
}
public static String Format(String format, Object arg0, Object arg1, Object arg2)
{
- Contract.Ensures(Contract.Result<String>() != null);
return FormatHelper(null, format, new ParamsArray(arg0, arg1, arg2));
}
@@ -436,27 +393,22 @@ namespace System
// args and format are null. The actual null check for format is in FormatHelper.
throw new ArgumentNullException((format == null) ? nameof(format) : nameof(args));
}
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.EndContractBlock();
return FormatHelper(null, format, new ParamsArray(args));
}
public static String Format(IFormatProvider provider, String format, Object arg0)
{
- Contract.Ensures(Contract.Result<String>() != null);
return FormatHelper(provider, format, new ParamsArray(arg0));
}
public static String Format(IFormatProvider provider, String format, Object arg0, Object arg1)
{
- Contract.Ensures(Contract.Result<String>() != null);
return FormatHelper(provider, format, new ParamsArray(arg0, arg1));
}
public static String Format(IFormatProvider provider, String format, Object arg0, Object arg1, Object arg2)
{
- Contract.Ensures(Contract.Result<String>() != null);
return FormatHelper(provider, format, new ParamsArray(arg0, arg1, arg2));
}
@@ -468,8 +420,6 @@ namespace System
// args and format are null. The actual null check for format is in FormatHelper.
throw new ArgumentNullException((format == null) ? nameof(format) : nameof(args));
}
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.EndContractBlock();
return FormatHelper(provider, format, new ParamsArray(args));
}
@@ -491,9 +441,6 @@ namespace System
throw new ArgumentNullException(nameof(value));
if (startIndex < 0 || startIndex > this.Length)
throw new ArgumentOutOfRangeException(nameof(startIndex));
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.Ensures(Contract.Result<String>().Length == this.Length + value.Length);
- Contract.EndContractBlock();
int oldLength = Length;
int insertLength = value.Length;
@@ -830,13 +777,11 @@ namespace System
//
//
- [Pure]
public String PadLeft(int totalWidth)
{
return PadLeft(totalWidth, ' ');
}
- [Pure]
public String PadLeft(int totalWidth, char paddingChar)
{
if (totalWidth < 0)
@@ -861,13 +806,11 @@ namespace System
return result;
}
- [Pure]
public String PadRight(int totalWidth)
{
return PadRight(totalWidth, ' ');
}
- [Pure]
public String PadRight(int totalWidth, char paddingChar)
{
if (totalWidth < 0)
@@ -903,9 +846,6 @@ namespace System
if (count > Length - startIndex)
throw new ArgumentOutOfRangeException(nameof(count),
SR.ArgumentOutOfRange_IndexCount);
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.Ensures(Contract.Result<String>().Length == this.Length - count);
- Contract.EndContractBlock();
if (count == 0)
return this;
@@ -943,25 +883,17 @@ namespace System
SR.ArgumentOutOfRange_StartIndexLessThanLength);
}
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.EndContractBlock();
return Substring(0, startIndex);
}
public string Replace(string oldValue, string newValue, bool ignoreCase, CultureInfo culture)
{
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.EndContractBlock();
-
return ReplaceCore(oldValue, newValue, culture, ignoreCase ? CompareOptions.IgnoreCase : CompareOptions.None);
}
public string Replace(string oldValue, string newValue, StringComparison comparisonType)
{
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.EndContractBlock();
-
switch (comparisonType)
{
case StringComparison.CurrentCulture:
@@ -1044,10 +976,6 @@ namespace System
//
public String Replace(char oldChar, char newChar)
{
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.Ensures(Contract.Result<String>().Length == this.Length);
- Contract.EndContractBlock();
-
if (oldChar == newChar)
return this;
@@ -1120,21 +1048,17 @@ namespace System
if (oldValue == null)
throw new ArgumentNullException(nameof(oldValue));
// Note that if newValue is null, we treat it like String.Empty.
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.EndContractBlock();
return ReplaceInternal(oldValue, newValue);
}
public unsafe String[] Split(char separator, StringSplitOptions options = StringSplitOptions.None)
{
- Contract.Ensures(Contract.Result<String[]>() != null);
return SplitInternal(&separator, 1, int.MaxValue, options);
}
public unsafe String[] Split(char separator, int count, StringSplitOptions options = StringSplitOptions.None)
{
- Contract.Ensures(Contract.Result<String[]>() != null);
return SplitInternal(&separator, 1, count, options);
}
@@ -1149,7 +1073,6 @@ namespace System
//
public String[] Split(params char[] separator)
{
- Contract.Ensures(Contract.Result<String[]>() != null);
return SplitInternal(separator, Int32.MaxValue, StringSplitOptions.None);
}
@@ -1166,19 +1089,16 @@ namespace System
//
public string[] Split(char[] separator, int count)
{
- Contract.Ensures(Contract.Result<String[]>() != null);
return SplitInternal(separator, count, StringSplitOptions.None);
}
public String[] Split(char[] separator, StringSplitOptions options)
{
- Contract.Ensures(Contract.Result<String[]>() != null);
return SplitInternal(separator, Int32.MaxValue, options);
}
public String[] Split(char[] separator, int count, StringSplitOptions options)
{
- Contract.Ensures(Contract.Result<String[]>() != null);
return SplitInternal(separator, count, options);
}
@@ -1199,8 +1119,6 @@ namespace System
if (options < StringSplitOptions.None || options > StringSplitOptions.RemoveEmptyEntries)
throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, options));
- Contract.Ensures(Contract.Result<String[]>() != null);
- Contract.EndContractBlock();
bool omitEmptyEntries = (options == StringSplitOptions.RemoveEmptyEntries);
@@ -1235,25 +1153,21 @@ namespace System
public String[] Split(String separator, StringSplitOptions options = StringSplitOptions.None)
{
- Contract.Ensures(Contract.Result<String[]>() != null);
return SplitInternal(separator ?? String.Empty, null, Int32.MaxValue, options);
}
public String[] Split(String separator, Int32 count, StringSplitOptions options = StringSplitOptions.None)
{
- Contract.Ensures(Contract.Result<String[]>() != null);
return SplitInternal(separator ?? String.Empty, null, count, options);
}
public String[] Split(String[] separator, StringSplitOptions options)
{
- Contract.Ensures(Contract.Result<String[]>() != null);
return SplitInternal(null, separator, Int32.MaxValue, options);
}
public String[] Split(String[] separator, Int32 count, StringSplitOptions options)
{
- Contract.Ensures(Contract.Result<String[]>() != null);
return SplitInternal(null, separator, count, options);
}
@@ -1269,7 +1183,6 @@ namespace System
{
throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, (int)options));
}
- Contract.EndContractBlock();
bool omitEmptyEntries = (options == StringSplitOptions.RemoveEmptyEntries);
@@ -1331,9 +1244,8 @@ namespace System
private String[] SplitKeepEmptyEntries(Int32[] sepList, Int32[] lengthList, Int32 defaultLength, Int32 numReplaces, int count)
{
- Contract.Requires(numReplaces >= 0);
- Contract.Requires(count >= 2);
- Contract.Ensures(Contract.Result<String[]>() != null);
+ Debug.Assert(numReplaces >= 0);
+ Debug.Assert(count >= 2);
int currIndex = 0;
int arrIndex = 0;
@@ -1370,9 +1282,8 @@ namespace System
// This function will not keep the Empty String
private String[] SplitOmitEmptyEntries(Int32[] sepList, Int32[] lengthList, Int32 defaultLength, Int32 numReplaces, int count)
{
- Contract.Requires(numReplaces >= 0);
- Contract.Requires(count >= 2);
- Contract.Ensures(Contract.Result<String[]>() != null);
+ Debug.Assert(numReplaces >= 0);
+ Debug.Assert(count >= 2);
// Allocate array to hold items. This array may not be
// filled completely in this function, we will create a
@@ -1580,7 +1491,6 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_IndexLength);
}
- Contract.EndContractBlock();
if (length == 0)
{
@@ -1612,78 +1522,56 @@ namespace System
}
// Creates a copy of this string in lower case.
- [Pure]
public String ToLower()
{
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.EndContractBlock();
return this.ToLower(CultureInfo.CurrentCulture);
}
// Creates a copy of this string in lower case. The culture is set by culture.
- [Pure]
public String ToLower(CultureInfo culture)
{
if (culture == null)
{
throw new ArgumentNullException(nameof(culture));
}
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.EndContractBlock();
return culture.TextInfo.ToLower(this);
}
// Creates a copy of this string in lower case based on invariant culture.
- [Pure]
public String ToLowerInvariant()
{
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.EndContractBlock();
return this.ToLower(CultureInfo.InvariantCulture);
}
// Creates a copy of this string in upper case.
- [Pure]
public String ToUpper()
{
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.EndContractBlock();
return this.ToUpper(CultureInfo.CurrentCulture);
}
// Creates a copy of this string in upper case. The culture is set by culture.
- [Pure]
public String ToUpper(CultureInfo culture)
{
if (culture == null)
{
throw new ArgumentNullException(nameof(culture));
}
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.EndContractBlock();
return culture.TextInfo.ToUpper(this);
}
//Creates a copy of this string in upper case based on invariant culture.
- [Pure]
public String ToUpperInvariant()
{
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.EndContractBlock();
return this.ToUpper(CultureInfo.InvariantCulture);
}
// Trims the whitespace from both ends of the string. Whitespace is defined by
// Char.IsWhiteSpace.
//
- [Pure]
public string Trim()
{
- Contract.Ensures(Contract.Result<string>() != null);
- Contract.EndContractBlock();
-
return TrimWhiteSpaceHelper(TrimType.Both);
}
@@ -1691,7 +1579,6 @@ namespace System
public unsafe string Trim(char trimChar) => TrimHelper(&trimChar, 1, TrimType.Both);
// Removes a set of characters from the beginning and end of this string.
- [Pure]
public unsafe string Trim(params char[] trimChars)
{
if (trimChars == null || trimChars.Length == 0)
diff --git a/src/mscorlib/src/System/String.Searching.cs b/src/mscorlib/src/System/String.Searching.cs
index 02e800427b..0be214d0d9 100644
--- a/src/mscorlib/src/System/String.Searching.cs
+++ b/src/mscorlib/src/System/String.Searching.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Diagnostics.Contracts;
using System.Globalization;
using System.Runtime.CompilerServices;
@@ -10,13 +9,11 @@ namespace System
{
public partial class String
{
- [Pure]
public bool Contains(string value)
{
return (IndexOf(value, StringComparison.Ordinal) >= 0);
}
- [Pure]
public bool Contains(string value, StringComparison comparisonType)
{
return (IndexOf(value, comparisonType) >= 0);
@@ -25,19 +22,16 @@ namespace System
// Returns the index of the first occurrence of a specified character in the current instance.
// The search starts at startIndex and runs thorough the next count characters.
//
- [Pure]
public int IndexOf(char value)
{
return IndexOf(value, 0, this.Length);
}
- [Pure]
public int IndexOf(char value, int startIndex)
{
return IndexOf(value, startIndex, this.Length - startIndex);
}
- [Pure]
public unsafe int IndexOf(char value, int startIndex, int count)
{
if (startIndex < 0 || startIndex > Length)
@@ -83,19 +77,16 @@ namespace System
// Returns the index of the first occurrence of any specified character in the current instance.
// The search starts at startIndex and runs to startIndex + count -1.
//
- [Pure]
public int IndexOfAny(char[] anyOf)
{
return IndexOfAny(anyOf, 0, this.Length);
}
- [Pure]
public int IndexOfAny(char[] anyOf, int startIndex)
{
return IndexOfAny(anyOf, startIndex, this.Length - startIndex);
}
- [Pure]
public int IndexOfAny(char[] anyOf, int startIndex, int count)
{
if (anyOf == null)
@@ -194,7 +185,6 @@ namespace System
// the first character of this string, it is case-sensitive and the current culture
// comparison is used.
//
- [Pure]
public int IndexOf(String value)
{
return IndexOf(value, StringComparison.CurrentCulture);
@@ -204,7 +194,6 @@ namespace System
// string, according to the specified search criteria. The search begins at
// startIndex, it is case-sensitive and the current culture comparison is used.
//
- [Pure]
public int IndexOf(String value, int startIndex)
{
return IndexOf(value, startIndex, StringComparison.CurrentCulture);
@@ -214,7 +203,6 @@ namespace System
// string, according to the specified search criteria. The search begins at
// startIndex, ends at endIndex and the current culture comparison is used.
//
- [Pure]
public int IndexOf(String value, int startIndex, int count)
{
if (startIndex < 0 || startIndex > this.Length)
@@ -226,24 +214,20 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_Count);
}
- Contract.EndContractBlock();
return IndexOf(value, startIndex, count, StringComparison.CurrentCulture);
}
- [Pure]
public int IndexOf(String value, StringComparison comparisonType)
{
return IndexOf(value, 0, this.Length, comparisonType);
}
- [Pure]
public int IndexOf(String value, int startIndex, StringComparison comparisonType)
{
return IndexOf(value, startIndex, this.Length - startIndex, comparisonType);
}
- [Pure]
public int IndexOf(String value, int startIndex, int count, StringComparison comparisonType)
{
// Validate inputs
@@ -255,7 +239,6 @@ namespace System
if (count < 0 || startIndex > this.Length - count)
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_Count);
- Contract.EndContractBlock();
switch (comparisonType)
{
@@ -290,19 +273,16 @@ namespace System
// The character at position startIndex is included in the search. startIndex is the larger
// index within the string.
//
- [Pure]
public int LastIndexOf(char value)
{
return LastIndexOf(value, this.Length - 1, this.Length);
}
- [Pure]
public int LastIndexOf(char value, int startIndex)
{
return LastIndexOf(value, startIndex, startIndex + 1);
}
- [Pure]
public unsafe int LastIndexOf(char value, int startIndex, int count)
{
if (Length == 0)
@@ -356,19 +336,16 @@ namespace System
//
//ForceInline ... Jit can't recognize String.get_Length to determine that this is "fluff"
- [Pure]
public int LastIndexOfAny(char[] anyOf)
{
return LastIndexOfAny(anyOf, this.Length - 1, this.Length);
}
- [Pure]
public int LastIndexOfAny(char[] anyOf, int startIndex)
{
return LastIndexOfAny(anyOf, startIndex, startIndex + 1);
}
- [Pure]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern int LastIndexOfAny(char[] anyOf, int startIndex, int count);
@@ -378,48 +355,40 @@ namespace System
// The character at position startIndex is included in the search. startIndex is the larger
// index within the string.
//
- [Pure]
public int LastIndexOf(String value)
{
return LastIndexOf(value, this.Length - 1, this.Length, StringComparison.CurrentCulture);
}
- [Pure]
public int LastIndexOf(String value, int startIndex)
{
return LastIndexOf(value, startIndex, startIndex + 1, StringComparison.CurrentCulture);
}
- [Pure]
public int LastIndexOf(String value, int startIndex, int count)
{
if (count < 0)
{
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_Count);
}
- Contract.EndContractBlock();
return LastIndexOf(value, startIndex, count, StringComparison.CurrentCulture);
}
- [Pure]
public int LastIndexOf(String value, StringComparison comparisonType)
{
return LastIndexOf(value, this.Length - 1, this.Length, comparisonType);
}
- [Pure]
public int LastIndexOf(String value, int startIndex, StringComparison comparisonType)
{
return LastIndexOf(value, startIndex, startIndex + 1, comparisonType);
}
- [Pure]
public int LastIndexOf(String value, int startIndex, int count, StringComparison comparisonType)
{
if (value == null)
throw new ArgumentNullException(nameof(value));
- Contract.EndContractBlock();
// Special case for 0 length input strings
if (this.Length == 0 && (startIndex == -1 || startIndex == 0))
diff --git a/src/mscorlib/src/System/String.cs b/src/mscorlib/src/System/String.cs
index c74abe9903..cd9689978e 100644
--- a/src/mscorlib/src/System/String.cs
+++ b/src/mscorlib/src/System/String.cs
@@ -28,7 +28,6 @@ namespace System
using System.Runtime.Versioning;
using Microsoft.Win32;
using System.Diagnostics;
- using System.Diagnostics.Contracts;
using System.Security;
//
@@ -72,8 +71,7 @@ namespace System
//
internal unsafe static string SmallCharToUpper(string strIn)
{
- Contract.Requires(strIn != null);
- Contract.EndContractBlock();
+ Debug.Assert(strIn != null);
//
// Get the length and pointers to each of the buffers. Walk the length
// of the string and copy the characters from the inBuffer to the outBuffer,
@@ -102,7 +100,6 @@ namespace System
// Gets the character at a specified position.
//
- // Spec#: Apply the precondition here using a contract assembly. Potential perf issue.
[System.Runtime.CompilerServices.IndexerName("Chars")]
public extern char this[int index]
{
@@ -127,7 +124,6 @@ namespace System
throw new ArgumentOutOfRangeException(nameof(sourceIndex), SR.ArgumentOutOfRange_IndexCount);
if (destinationIndex > destination.Length - count || destinationIndex < 0)
throw new ArgumentOutOfRangeException(nameof(destinationIndex), SR.ArgumentOutOfRange_IndexCount);
- Contract.EndContractBlock();
// Note: fixed does not like empty arrays
if (count > 0)
@@ -164,7 +160,6 @@ namespace System
throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_Index);
if (length < 0)
throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_Index);
- Contract.EndContractBlock();
if (length > 0)
{
@@ -179,13 +174,11 @@ namespace System
return Array.Empty<char>();
}
- [Pure]
public static bool IsNullOrEmpty(String value)
{
return (value == null || value.Length == 0);
}
- [Pure]
public static bool IsNullOrWhiteSpace(String value)
{
if (value == null) return true;
@@ -205,7 +198,6 @@ namespace System
/// for(int i = 0; i < str.Length; i++) str[i]
/// The actually code generated for this will be one instruction and will be inlined.
//
- // Spec#: Add postcondition in a contract assembly. Potential perf problem.
public extern int Length
{
[MethodImplAttribute(MethodImplOptions.InternalCall)]
@@ -265,8 +257,8 @@ namespace System
unsafe static internal String CreateStringFromEncoding(
byte* bytes, int byteLength, Encoding encoding)
{
- Contract.Requires(bytes != null);
- Contract.Requires(byteLength >= 0);
+ Debug.Assert(bytes != null);
+ Debug.Assert(byteLength >= 0);
// Get our string length
int stringLength = encoding.GetCharCount(bytes, byteLength, null);
@@ -437,7 +429,6 @@ namespace System
if (startIndex > value.Length - length)
throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_Index);
- Contract.EndContractBlock();
if (length > 0)
{
@@ -637,7 +628,6 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_StartIndex);
}
- Contract.EndContractBlock();
Debug.Assert(this == null, "this == null"); // this is the string constructor, we allocate it
char* pFrom = ptr + startIndex;
@@ -710,15 +700,11 @@ namespace System
// Returns this string.
public override String ToString()
{
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.EndContractBlock();
return this;
}
public String ToString(IFormatProvider provider)
{
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.EndContractBlock();
return this;
}
@@ -726,8 +712,6 @@ namespace System
// There's no point in cloning a string since they're immutable, so we simply return this.
public Object Clone()
{
- Contract.Ensures(Contract.Result<Object>() != null);
- Contract.EndContractBlock();
return this;
}
@@ -737,8 +721,6 @@ namespace System
{
throw new ArgumentNullException(nameof(str));
}
- Contract.Ensures(Contract.Result<String>() != null);
- Contract.EndContractBlock();
int length = str.Length;
@@ -758,22 +740,16 @@ namespace System
{
throw new ArgumentNullException(nameof(str));
}
- Contract.Ensures(Contract.Result<String>().Length == str.Length);
- Contract.Ensures(str.Equals(Contract.Result<String>()));
- Contract.EndContractBlock();
return Thread.GetDomain().GetOrInternString(str);
}
- [Pure]
public static String IsInterned(String str)
{
if (str == null)
{
throw new ArgumentNullException(nameof(str));
}
- Contract.Ensures(Contract.Result<String>() == null || Contract.Result<String>().Length == str.Length);
- Contract.EndContractBlock();
return Thread.GetDomain().IsStringInterned(str);
}
@@ -882,24 +858,18 @@ namespace System
public CharEnumerator GetEnumerator()
{
- Contract.Ensures(Contract.Result<CharEnumerator>() != null);
- Contract.EndContractBlock();
BCLDebug.Perf(false, "Avoid using String's CharEnumerator until C# special cases foreach on String - use the indexed property on String instead.");
return new CharEnumerator(this);
}
IEnumerator<char> IEnumerable<char>.GetEnumerator()
{
- Contract.Ensures(Contract.Result<IEnumerator<char>>() != null);
- Contract.EndContractBlock();
BCLDebug.Perf(false, "Avoid using String's CharEnumerator until C# special cases foreach on String - use the indexed property on String instead.");
return new CharEnumerator(this);
}
IEnumerator IEnumerable.GetEnumerator()
{
- Contract.Ensures(Contract.Result<IEnumerator>() != null);
- Contract.EndContractBlock();
BCLDebug.Perf(false, "Avoid using String's CharEnumerator until C# special cases foreach on String - use the indexed property on String instead.");
return new CharEnumerator(this);
}
diff --git a/src/mscorlib/src/System/StubHelpers.cs b/src/mscorlib/src/System/StubHelpers.cs
index e8ddd393f6..ff74d4c3c5 100644
--- a/src/mscorlib/src/System/StubHelpers.cs
+++ b/src/mscorlib/src/System/StubHelpers.cs
@@ -17,7 +17,6 @@ namespace System.StubHelpers
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
using System.Diagnostics;
- using System.Diagnostics.Contracts;
internal static class AnsiCharMarshaler
{
@@ -1446,8 +1445,6 @@ namespace System.StubHelpers
static internal unsafe Exception ConvertToManaged(int hr)
{
- Contract.Ensures(Contract.Result<Exception>() != null || hr >= 0);
-
if (!Environment.IsWinRTSupported)
{
throw new PlatformNotSupportedException(SR.PlatformNotSupported_WinRT);
diff --git a/src/mscorlib/src/System/Text/Normalization.Windows.cs b/src/mscorlib/src/System/Text/Normalization.Windows.cs
index 8e284e798d..96389bfa18 100644
--- a/src/mscorlib/src/System/Text/Normalization.Windows.cs
+++ b/src/mscorlib/src/System/Text/Normalization.Windows.cs
@@ -10,7 +10,6 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Text
{
diff --git a/src/mscorlib/src/System/Threading/EventWaitHandle.cs b/src/mscorlib/src/System/Threading/EventWaitHandle.cs
index cfb9c28415..82312e644d 100644
--- a/src/mscorlib/src/System/Threading/EventWaitHandle.cs
+++ b/src/mscorlib/src/System/Threading/EventWaitHandle.cs
@@ -34,7 +34,6 @@ namespace System.Threading
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.AccessControl;
- using System.Diagnostics.Contracts;
[ComVisibleAttribute(true)]
public class EventWaitHandle : WaitHandle
@@ -57,7 +56,6 @@ namespace System.Threading
}
#endif
}
- Contract.EndContractBlock();
uint eventFlags = initialState ? Win32Native.CREATE_EVENT_INITIAL_SET : 0;
switch (mode)
@@ -106,7 +104,6 @@ namespace System.Threading
}
#endif
}
- Contract.EndContractBlock();
Win32Native.SECURITY_ATTRIBUTES secAttrs = null;
uint eventFlags = initialState ? Win32Native.CREATE_EVENT_INITIAL_SET : 0;
@@ -192,7 +189,6 @@ namespace System.Threading
throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, Path.MaxPath), nameof(name));
}
- Contract.EndContractBlock();
result = null;
diff --git a/src/mscorlib/src/System/Threading/ManualResetEventSlim.cs b/src/mscorlib/src/System/Threading/ManualResetEventSlim.cs
index 0807e19301..d2767710ec 100644
--- a/src/mscorlib/src/System/Threading/ManualResetEventSlim.cs
+++ b/src/mscorlib/src/System/Threading/ManualResetEventSlim.cs
@@ -13,7 +13,6 @@
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Threading
{
@@ -242,8 +241,6 @@ namespace System.Threading
/// </summary>
private void EnsureLockObjectCreated()
{
- Contract.Ensures(m_lock != null);
-
if (m_lock != null)
return;
diff --git a/src/mscorlib/src/System/Threading/Monitor.cs b/src/mscorlib/src/System/Threading/Monitor.cs
index 0df64a5e5c..dee4118fe1 100644
--- a/src/mscorlib/src/System/Threading/Monitor.cs
+++ b/src/mscorlib/src/System/Threading/Monitor.cs
@@ -22,7 +22,6 @@ using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
using System.Runtime.Versioning;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Threading
{
@@ -217,7 +216,6 @@ namespace System.Threading
{
throw new ArgumentNullException(nameof(obj));
}
- Contract.EndContractBlock();
ObjPulse(obj);
}
@@ -233,7 +231,6 @@ namespace System.Threading
{
throw new ArgumentNullException(nameof(obj));
}
- Contract.EndContractBlock();
ObjPulseAll(obj);
}
diff --git a/src/mscorlib/src/System/Threading/Mutex.cs b/src/mscorlib/src/System/Threading/Mutex.cs
index 095c27bf8e..64bfc85234 100644
--- a/src/mscorlib/src/System/Threading/Mutex.cs
+++ b/src/mscorlib/src/System/Threading/Mutex.cs
@@ -24,7 +24,6 @@ namespace System.Threading
using System.Runtime.Versioning;
using System.Security;
using System.Diagnostics;
- using System.Diagnostics.Contracts;
public sealed class Mutex : WaitHandle
{
@@ -55,7 +54,6 @@ namespace System.Threading
throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, Path.MaxPath), nameof(name));
}
#endif // PLATFORM_WINDOWS
- Contract.EndContractBlock();
Win32Native.SECURITY_ATTRIBUTES secAttrs = null;
CreateMutexWithGuaranteedCleanup(initiallyOwned, name, out createdNew, secAttrs);
@@ -230,7 +228,6 @@ namespace System.Threading
throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, Path.MaxPath), nameof(name));
}
#endif
- Contract.EndContractBlock();
result = null;
diff --git a/src/mscorlib/src/System/Threading/Overlapped.cs b/src/mscorlib/src/System/Threading/Overlapped.cs
index 0830ee6b6c..2a9f1e2999 100644
--- a/src/mscorlib/src/System/Threading/Overlapped.cs
+++ b/src/mscorlib/src/System/Threading/Overlapped.cs
@@ -31,7 +31,6 @@ using System.Runtime.Versioning;
using System.Security;
using System.Runtime.ConstrainedExecution;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Collections.Concurrent;
namespace System.Threading
@@ -348,7 +347,6 @@ namespace System.Threading
{
if (nativeOverlappedPtr == null)
throw new ArgumentNullException(nameof(nativeOverlappedPtr));
- Contract.EndContractBlock();
Overlapped overlapped = OverlappedData.GetOverlappedFromNative(nativeOverlappedPtr).m_overlapped;
@@ -360,7 +358,6 @@ namespace System.Threading
{
if (nativeOverlappedPtr == null)
throw new ArgumentNullException(nameof(nativeOverlappedPtr));
- Contract.EndContractBlock();
Overlapped overlapped = OverlappedData.GetOverlappedFromNative(nativeOverlappedPtr).m_overlapped;
OverlappedData.FreeNativeOverlapped(nativeOverlappedPtr);
diff --git a/src/mscorlib/src/System/Threading/Semaphore.cs b/src/mscorlib/src/System/Threading/Semaphore.cs
index 136eee6e76..cec37a51cf 100644
--- a/src/mscorlib/src/System/Threading/Semaphore.cs
+++ b/src/mscorlib/src/System/Threading/Semaphore.cs
@@ -5,7 +5,6 @@
using Microsoft.Win32;
using Microsoft.Win32.SafeHandles;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.IO;
using System.Runtime.InteropServices;
using System.Security;
diff --git a/src/mscorlib/src/System/Threading/SemaphoreSlim.cs b/src/mscorlib/src/System/Threading/SemaphoreSlim.cs
index a61753d9a9..9e713cefd7 100644
--- a/src/mscorlib/src/System/Threading/SemaphoreSlim.cs
+++ b/src/mscorlib/src/System/Threading/SemaphoreSlim.cs
@@ -17,7 +17,6 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Security;
using System.Runtime.InteropServices;
-using System.Diagnostics.Contracts;
using System.Threading.Tasks;
// The class will be part of the current System.Threading namespace
@@ -709,7 +708,7 @@ namespace System.Threading
/// <returns>true if the waiter was in the list; otherwise, false.</returns>
private bool RemoveAsyncWaiter(TaskNode task)
{
- Contract.Requires(task != null, "Expected non-null task");
+ Debug.Assert(task != null, "Expected non-null task");
Debug.Assert(Monitor.IsEntered(m_lockObj), "Requires the lock be held");
// Is the task in the list? To be in the list, either it's the head or it has a predecessor that's in the list.
diff --git a/src/mscorlib/src/System/Threading/SynchronizationContext.cs b/src/mscorlib/src/System/Threading/SynchronizationContext.cs
index 676a198ee7..be4bff7dd5 100644
--- a/src/mscorlib/src/System/Threading/SynchronizationContext.cs
+++ b/src/mscorlib/src/System/Threading/SynchronizationContext.cs
@@ -22,7 +22,6 @@ namespace System.Threading
using System.Reflection;
using System.Security;
using System.Diagnostics;
- using System.Diagnostics.Contracts;
using System.Diagnostics.CodeAnalysis;
@@ -143,7 +142,6 @@ namespace System.Threading
{
throw new ArgumentNullException(nameof(waitHandles));
}
- Contract.EndContractBlock();
return WaitHelperNative(waitHandles, waitAll, millisecondsTimeout);
}
diff --git a/src/mscorlib/src/System/Threading/Tasks/AsyncCausalityTracer.cs b/src/mscorlib/src/System/Threading/Tasks/AsyncCausalityTracer.cs
index ec154f9efb..2b14f375d3 100644
--- a/src/mscorlib/src/System/Threading/Tasks/AsyncCausalityTracer.cs
+++ b/src/mscorlib/src/System/Threading/Tasks/AsyncCausalityTracer.cs
@@ -8,7 +8,6 @@
using System;
using System.Security;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
diff --git a/src/mscorlib/src/System/Threading/Tasks/ConcurrentExclusiveSchedulerPair.cs b/src/mscorlib/src/System/Threading/Tasks/ConcurrentExclusiveSchedulerPair.cs
index 765dcd8408..7d60e4ca16 100644
--- a/src/mscorlib/src/System/Threading/Tasks/ConcurrentExclusiveSchedulerPair.cs
+++ b/src/mscorlib/src/System/Threading/Tasks/ConcurrentExclusiveSchedulerPair.cs
@@ -18,7 +18,6 @@ using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
-using System.Diagnostics.Contracts;
using System.Security;
namespace System.Threading.Tasks
@@ -105,7 +104,6 @@ namespace System.Threading.Tasks
if (taskScheduler == null) throw new ArgumentNullException(nameof(taskScheduler));
if (maxConcurrencyLevel == 0 || maxConcurrencyLevel < -1) throw new ArgumentOutOfRangeException(nameof(maxConcurrencyLevel));
if (maxItemsPerTask == 0 || maxItemsPerTask < -1) throw new ArgumentOutOfRangeException(nameof(maxItemsPerTask));
- Contract.EndContractBlock();
// Store configuration
m_underlyingTaskScheduler = taskScheduler;
@@ -202,7 +200,7 @@ namespace System.Threading.Tasks
/// <summary>Completes the completion task asynchronously.</summary>
private void CompleteTaskAsync()
{
- Contract.Requires(ReadyToComplete, "The block must be ready to complete to be here.");
+ Debug.Assert(ReadyToComplete, "The block must be ready to complete to be here.");
ContractAssertMonitorStatus(ValueLock, held: true);
// Ensure we only try to complete once, then schedule completion
@@ -229,7 +227,7 @@ namespace System.Threading.Tasks
/// <param name="faultedTask">The faulted worker task that's initiating the shutdown.</param>
private void FaultWithTask(Task faultedTask)
{
- Contract.Requires(faultedTask != null && faultedTask.IsFaulted && faultedTask.Exception.InnerExceptions.Count > 0,
+ Debug.Assert(faultedTask != null && faultedTask.IsFaulted && faultedTask.Exception.InnerExceptions.Count > 0,
"Needs a task in the faulted state and thus with exceptions.");
ContractAssertMonitorStatus(ValueLock, held: true);
@@ -346,8 +344,8 @@ namespace System.Threading.Tasks
/// </summary>
private void ProcessExclusiveTasks()
{
- Contract.Requires(m_processingCount == EXCLUSIVE_PROCESSING_SENTINEL, "Processing exclusive tasks requires being in exclusive mode.");
- Contract.Requires(!m_exclusiveTaskScheduler.m_tasks.IsEmpty, "Processing exclusive tasks requires tasks to be processed.");
+ Debug.Assert(m_processingCount == EXCLUSIVE_PROCESSING_SENTINEL, "Processing exclusive tasks requires being in exclusive mode.");
+ Debug.Assert(!m_exclusiveTaskScheduler.m_tasks.IsEmpty, "Processing exclusive tasks requires tasks to be processed.");
ContractAssertMonitorStatus(ValueLock, held: false);
try
{
@@ -396,7 +394,7 @@ namespace System.Threading.Tasks
/// </summary>
private void ProcessConcurrentTasks()
{
- Contract.Requires(m_processingCount > 0, "Processing concurrent tasks requires us to be in concurrent mode.");
+ Debug.Assert(m_processingCount > 0, "Processing concurrent tasks requires us to be in concurrent mode.");
ContractAssertMonitorStatus(ValueLock, held: false);
try
{
@@ -504,10 +502,10 @@ namespace System.Threading.Tasks
/// <param name="processingMode">The processing mode of this scheduler.</param>
internal ConcurrentExclusiveTaskScheduler(ConcurrentExclusiveSchedulerPair pair, int maxConcurrencyLevel, ProcessingMode processingMode)
{
- Contract.Requires(pair != null, "Scheduler must be associated with a valid pair.");
- Contract.Requires(processingMode == ProcessingMode.ProcessingConcurrentTasks || processingMode == ProcessingMode.ProcessingExclusiveTask,
+ Debug.Assert(pair != null, "Scheduler must be associated with a valid pair.");
+ Debug.Assert(processingMode == ProcessingMode.ProcessingConcurrentTasks || processingMode == ProcessingMode.ProcessingExclusiveTask,
"Scheduler must be for concurrent or exclusive processing.");
- Contract.Requires(
+ Debug.Assert(
(processingMode == ProcessingMode.ProcessingConcurrentTasks && (maxConcurrencyLevel >= 1 || maxConcurrencyLevel == UNLIMITED_PROCESSING)) ||
(processingMode == ProcessingMode.ProcessingExclusiveTask && maxConcurrencyLevel == 1),
"If we're in concurrent mode, our concurrency level should be positive or unlimited. If exclusive, it should be 1.");
@@ -664,7 +662,7 @@ namespace System.Threading.Tasks
/// <param name="scheduler">The scheduler being debugged.</param>
public DebugView(ConcurrentExclusiveTaskScheduler scheduler)
{
- Contract.Requires(scheduler != null, "Need a scheduler with which to construct the debug view.");
+ Debug.Assert(scheduler != null, "Need a scheduler with which to construct the debug view.");
m_taskScheduler = scheduler;
}
@@ -687,7 +685,7 @@ namespace System.Threading.Tasks
/// <param name="pair">The pair being debugged.</param>
public DebugView(ConcurrentExclusiveSchedulerPair pair)
{
- Contract.Requires(pair != null, "Need a pair with which to construct the debug view.");
+ Debug.Assert(pair != null, "Need a pair with which to construct the debug view.");
m_pair = pair;
}
@@ -730,7 +728,7 @@ namespace System.Threading.Tasks
[Conditional("DEBUG")]
internal static void ContractAssertMonitorStatus(object syncObj, bool held)
{
- Contract.Requires(syncObj != null, "The monitor object to check must be provided.");
+ Debug.Assert(syncObj != null, "The monitor object to check must be provided.");
#if PRENET45
#if DEBUG
// This check is expensive,
diff --git a/src/mscorlib/src/System/Threading/Tasks/FutureFactory.cs b/src/mscorlib/src/System/Threading/Tasks/FutureFactory.cs
index bf63a53df9..4615d43826 100644
--- a/src/mscorlib/src/System/Threading/Tasks/FutureFactory.cs
+++ b/src/mscorlib/src/System/Threading/Tasks/FutureFactory.cs
@@ -15,7 +15,6 @@ using System.Security;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.Versioning;
namespace System.Threading.Tasks
@@ -517,7 +516,7 @@ namespace System.Threading.Tasks
Task<TResult> promise,
bool requiresSynchronization)
{
- Contract.Requires((endFunction != null) != (endAction != null), "Expected exactly one of endFunction/endAction to be non-null");
+ Debug.Assert((endFunction != null) != (endAction != null), "Expected exactly one of endFunction/endAction to be non-null");
Exception ex = null;
OperationCanceledException oce = null;
@@ -666,11 +665,10 @@ namespace System.Threading.Tasks
if (endFunction == null && endAction == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.endMethod);
- Contract.Requires((endFunction != null) != (endAction != null), "Both endFunction and endAction were non-null");
+ Debug.Assert((endFunction != null) != (endAction != null), "Both endFunction and endAction were non-null");
if (scheduler == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.scheduler);
- Contract.EndContractBlock();
TaskFactory.CheckFromAsyncOptions(creationOptions, false);
@@ -789,7 +787,7 @@ namespace System.Threading.Tasks
if (endFunction == null && endAction == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.endMethod);
- Contract.Requires((endFunction != null) != (endAction != null), "Both endFunction and endAction were non-null");
+ Debug.Assert((endFunction != null) != (endAction != null), "Both endFunction and endAction were non-null");
TaskFactory.CheckFromAsyncOptions(creationOptions, true);
@@ -911,7 +909,7 @@ namespace System.Threading.Tasks
if (endFunction == null && endAction == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.endFunction);
- Contract.Requires((endFunction != null) != (endAction != null), "Both endFunction and endAction were non-null");
+ Debug.Assert((endFunction != null) != (endAction != null), "Both endFunction and endAction were non-null");
TaskFactory.CheckFromAsyncOptions(creationOptions, true);
@@ -1040,7 +1038,7 @@ namespace System.Threading.Tasks
if (endFunction == null && endAction == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.endMethod);
- Contract.Requires((endFunction != null) != (endAction != null), "Both endFunction and endAction were non-null");
+ Debug.Assert((endFunction != null) != (endAction != null), "Both endFunction and endAction were non-null");
TaskFactory.CheckFromAsyncOptions(creationOptions, true);
@@ -1177,7 +1175,7 @@ namespace System.Threading.Tasks
if (endFunction == null && endAction == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.endMethod);
- Contract.Requires((endFunction != null) != (endAction != null), "Both endFunction and endAction were non-null");
+ Debug.Assert((endFunction != null) != (endAction != null), "Both endFunction and endAction were non-null");
TaskFactory.CheckFromAsyncOptions(creationOptions, true);
@@ -1285,8 +1283,8 @@ namespace System.Threading.Tasks
/// <param name="endMethod">The end method.</param>
internal FromAsyncTrimPromise(TInstance thisRef, Func<TInstance, IAsyncResult, TResult> endMethod) : base()
{
- Contract.Requires(thisRef != null, "Expected a non-null thisRef");
- Contract.Requires(endMethod != null, "Expected a non-null endMethod");
+ Debug.Assert(thisRef != null, "Expected a non-null thisRef");
+ Debug.Assert(endMethod != null, "Expected a non-null endMethod");
m_thisRef = thisRef;
m_endMethod = endMethod;
}
@@ -1300,7 +1298,6 @@ namespace System.Threading.Tasks
{
// Validate argument
if (asyncResult == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.asyncResult);
- Contract.EndContractBlock();
var promise = asyncResult.AsyncState as FromAsyncTrimPromise<TInstance>;
if (promise == null) ThrowHelper.ThrowArgumentException(ExceptionResource.InvalidOperation_WrongAsyncResultOrEndCalledMultiple, ExceptionArgument.asyncResult);
@@ -1403,7 +1400,6 @@ namespace System.Threading.Tasks
public Task<TResult> ContinueWhenAll(Task[] tasks, Func<Task[], TResult> continuationFunction)
{
if (continuationFunction == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.continuationFunction);
- Contract.EndContractBlock();
return ContinueWhenAllImpl(tasks, continuationFunction, null, m_defaultContinuationOptions, m_defaultCancellationToken, DefaultScheduler);
}
@@ -1432,7 +1428,6 @@ namespace System.Threading.Tasks
public Task<TResult> ContinueWhenAll(Task[] tasks, Func<Task[], TResult> continuationFunction, CancellationToken cancellationToken)
{
if (continuationFunction == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.continuationFunction);
- Contract.EndContractBlock();
return ContinueWhenAllImpl(tasks, continuationFunction, null, m_defaultContinuationOptions, cancellationToken, DefaultScheduler);
}
@@ -1467,7 +1462,6 @@ namespace System.Threading.Tasks
public Task<TResult> ContinueWhenAll(Task[] tasks, Func<Task[], TResult> continuationFunction, TaskContinuationOptions continuationOptions)
{
if (continuationFunction == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.continuationFunction);
- Contract.EndContractBlock();
return ContinueWhenAllImpl(tasks, continuationFunction, null, continuationOptions, m_defaultCancellationToken, DefaultScheduler);
}
@@ -1513,7 +1507,6 @@ namespace System.Threading.Tasks
CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
{
if (continuationFunction == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.continuationFunction);
- Contract.EndContractBlock();
return ContinueWhenAllImpl(tasks, continuationFunction, null, continuationOptions, cancellationToken, scheduler);
}
@@ -1538,7 +1531,6 @@ namespace System.Threading.Tasks
public Task<TResult> ContinueWhenAll<TAntecedentResult>(Task<TAntecedentResult>[] tasks, Func<Task<TAntecedentResult>[], TResult> continuationFunction)
{
if (continuationFunction == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.continuationFunction);
- Contract.EndContractBlock();
return ContinueWhenAllImpl<TAntecedentResult>(tasks, continuationFunction, null, m_defaultContinuationOptions, m_defaultCancellationToken, DefaultScheduler);
}
@@ -1569,7 +1561,6 @@ namespace System.Threading.Tasks
CancellationToken cancellationToken)
{
if (continuationFunction == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.continuationFunction);
- Contract.EndContractBlock();
return ContinueWhenAllImpl<TAntecedentResult>(tasks, continuationFunction, null, m_defaultContinuationOptions, cancellationToken, DefaultScheduler);
}
@@ -1606,7 +1597,6 @@ namespace System.Threading.Tasks
TaskContinuationOptions continuationOptions)
{
if (continuationFunction == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.continuationFunction);
- Contract.EndContractBlock();
return ContinueWhenAllImpl<TAntecedentResult>(tasks, continuationFunction, null, continuationOptions, m_defaultCancellationToken, DefaultScheduler);
}
@@ -1653,7 +1643,6 @@ namespace System.Threading.Tasks
CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
{
if (continuationFunction == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.continuationFunction);
- Contract.EndContractBlock();
return ContinueWhenAllImpl<TAntecedentResult>(tasks, continuationFunction, null, continuationOptions, cancellationToken, scheduler);
}
@@ -1669,9 +1658,8 @@ namespace System.Threading.Tasks
TaskFactory.CheckMultiTaskContinuationOptions(continuationOptions);
if (tasks == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.tasks);
//ArgumentNullException of continuationFunction or continuationAction is checked by the caller
- Contract.Requires((continuationFunction != null) != (continuationAction != null), "Expected exactly one of endFunction/endAction to be non-null");
+ Debug.Assert((continuationFunction != null) != (continuationAction != null), "Expected exactly one of endFunction/endAction to be non-null");
if (scheduler == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.scheduler);
- Contract.EndContractBlock();
// Check tasks array and make defensive copy
Task<TAntecedentResult>[] tasksCopy = TaskFactory.CheckMultiContinuationTasksAndCopy<TAntecedentResult>(tasks);
@@ -1716,9 +1704,8 @@ namespace System.Threading.Tasks
TaskFactory.CheckMultiTaskContinuationOptions(continuationOptions);
if (tasks == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.tasks);
//ArgumentNullException of continuationFunction or continuationAction is checked by the caller
- Contract.Requires((continuationFunction != null) != (continuationAction != null), "Expected exactly one of endFunction/endAction to be non-null");
+ Debug.Assert((continuationFunction != null) != (continuationAction != null), "Expected exactly one of endFunction/endAction to be non-null");
if (scheduler == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.scheduler);
- Contract.EndContractBlock();
// Check tasks array and make defensive copy
Task[] tasksCopy = TaskFactory.CheckMultiContinuationTasksAndCopy(tasks);
@@ -1787,7 +1774,6 @@ namespace System.Threading.Tasks
public Task<TResult> ContinueWhenAny(Task[] tasks, Func<Task, TResult> continuationFunction)
{
if (continuationFunction == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.continuationFunction);
- Contract.EndContractBlock();
return ContinueWhenAnyImpl(tasks, continuationFunction, null, m_defaultContinuationOptions, m_defaultCancellationToken, DefaultScheduler);
}
@@ -1816,7 +1802,6 @@ namespace System.Threading.Tasks
public Task<TResult> ContinueWhenAny(Task[] tasks, Func<Task, TResult> continuationFunction, CancellationToken cancellationToken)
{
if (continuationFunction == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.continuationFunction);
- Contract.EndContractBlock();
return ContinueWhenAnyImpl(tasks, continuationFunction, null, m_defaultContinuationOptions, cancellationToken, DefaultScheduler);
}
@@ -1851,7 +1836,6 @@ namespace System.Threading.Tasks
public Task<TResult> ContinueWhenAny(Task[] tasks, Func<Task, TResult> continuationFunction, TaskContinuationOptions continuationOptions)
{
if (continuationFunction == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.continuationFunction);
- Contract.EndContractBlock();
return ContinueWhenAnyImpl(tasks, continuationFunction, null, continuationOptions, m_defaultCancellationToken, DefaultScheduler);
}
@@ -1897,7 +1881,6 @@ namespace System.Threading.Tasks
CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
{
if (continuationFunction == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.continuationFunction);
- Contract.EndContractBlock();
return ContinueWhenAnyImpl(tasks, continuationFunction, null, continuationOptions, cancellationToken, scheduler);
}
@@ -1922,7 +1905,6 @@ namespace System.Threading.Tasks
public Task<TResult> ContinueWhenAny<TAntecedentResult>(Task<TAntecedentResult>[] tasks, Func<Task<TAntecedentResult>, TResult> continuationFunction)
{
if (continuationFunction == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.continuationFunction);
- Contract.EndContractBlock();
return ContinueWhenAnyImpl<TAntecedentResult>(tasks, continuationFunction, null, m_defaultContinuationOptions, m_defaultCancellationToken, DefaultScheduler);
}
@@ -1953,7 +1935,6 @@ namespace System.Threading.Tasks
CancellationToken cancellationToken)
{
if (continuationFunction == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.continuationFunction);
- Contract.EndContractBlock();
return ContinueWhenAnyImpl<TAntecedentResult>(tasks, continuationFunction, null, m_defaultContinuationOptions, cancellationToken, DefaultScheduler);
}
@@ -1990,7 +1971,6 @@ namespace System.Threading.Tasks
TaskContinuationOptions continuationOptions)
{
if (continuationFunction == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.continuationFunction);
- Contract.EndContractBlock();
return ContinueWhenAnyImpl<TAntecedentResult>(tasks, continuationFunction, null, continuationOptions, m_defaultCancellationToken, DefaultScheduler);
}
@@ -2037,7 +2017,6 @@ namespace System.Threading.Tasks
CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
{
if (continuationFunction == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.continuationFunction);
- Contract.EndContractBlock();
return ContinueWhenAnyImpl<TAntecedentResult>(tasks, continuationFunction, null, continuationOptions, cancellationToken, scheduler);
}
@@ -2054,9 +2033,8 @@ namespace System.Threading.Tasks
if (tasks.Length == 0) ThrowHelper.ThrowArgumentException(ExceptionResource.Task_MultiTaskContinuation_EmptyTaskList, ExceptionArgument.tasks);
//ArgumentNullException of continuationFunction or continuationAction is checked by the caller
- Contract.Requires((continuationFunction != null) != (continuationAction != null), "Expected exactly one of endFunction/endAction to be non-null");
+ Debug.Assert((continuationFunction != null) != (continuationAction != null), "Expected exactly one of endFunction/endAction to be non-null");
if (scheduler == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.scheduler);
- Contract.EndContractBlock();
// Call common ContinueWhenAny() setup logic, extract starter
Task<Task> starter = TaskFactory.CommonCWAnyLogic(tasks);
@@ -2101,9 +2079,8 @@ namespace System.Threading.Tasks
if (tasks == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.tasks);
if (tasks.Length == 0) ThrowHelper.ThrowArgumentException(ExceptionResource.Task_MultiTaskContinuation_EmptyTaskList, ExceptionArgument.tasks);
//ArgumentNullException of continuationFunction or continuationAction is checked by the caller
- Contract.Requires((continuationFunction != null) != (continuationAction != null), "Expected exactly one of endFunction/endAction to be non-null");
+ Debug.Assert((continuationFunction != null) != (continuationAction != null), "Expected exactly one of endFunction/endAction to be non-null");
if (scheduler == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.scheduler);
- Contract.EndContractBlock();
// Call common ContinueWhenAny setup logic, extract starter
var starter = TaskFactory.CommonCWAnyLogic(tasks);
diff --git a/src/mscorlib/src/System/Threading/Tasks/ProducerConsumerQueues.cs b/src/mscorlib/src/System/Threading/Tasks/ProducerConsumerQueues.cs
index df0dbe3942..1994c490d3 100644
--- a/src/mscorlib/src/System/Threading/Tasks/ProducerConsumerQueues.cs
+++ b/src/mscorlib/src/System/Threading/Tasks/ProducerConsumerQueues.cs
@@ -25,7 +25,6 @@ using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
namespace System.Threading.Tasks
@@ -164,7 +163,7 @@ namespace System.Threading.Tasks
/// <param name="segment">The segment in which to first attempt to store the item.</param>
private void EnqueueSlow(T item, ref Segment segment)
{
- Contract.Requires(segment != null, "Expected a non-null segment.");
+ Debug.Assert(segment != null, "Expected a non-null segment.");
if (segment.m_state.m_firstCopy != segment.m_state.m_first)
{
@@ -220,8 +219,8 @@ namespace System.Threading.Tasks
/// <returns>true if an item could be dequeued; otherwise, false.</returns>
private bool TryDequeueSlow(ref Segment segment, ref T[] array, out T result)
{
- Contract.Requires(segment != null, "Expected a non-null segment.");
- Contract.Requires(array != null, "Expected a non-null item array.");
+ Debug.Assert(segment != null, "Expected a non-null segment.");
+ Debug.Assert(array != null, "Expected a non-null item array.");
if (segment.m_state.m_last != segment.m_state.m_lastCopy)
{
@@ -322,7 +321,7 @@ namespace System.Threading.Tasks
/// <param name="size">The size to use for this segment.</param>
internal Segment(int size)
{
- Contract.Requires((size & (size - 1)) == 0, "Size must be a power of 2");
+ Debug.Assert((size & (size - 1)) == 0, "Size must be a power of 2");
m_array = new T[size];
}
}
@@ -361,7 +360,7 @@ namespace System.Threading.Tasks
/// <param name="enumerable">The queue being debugged.</param>
public SingleProducerSingleConsumerQueue_DebugView(SingleProducerSingleConsumerQueue<T> queue)
{
- Contract.Requires(queue != null, "Expected a non-null queue.");
+ Debug.Assert(queue != null, "Expected a non-null queue.");
m_queue = queue;
}
}
diff --git a/src/mscorlib/src/System/Threading/Tasks/Task.cs b/src/mscorlib/src/System/Threading/Tasks/Task.cs
index 84811fb068..e3dd01c0a9 100644
--- a/src/mscorlib/src/System/Threading/Tasks/Task.cs
+++ b/src/mscorlib/src/System/Threading/Tasks/Task.cs
@@ -13,7 +13,6 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Diagnostics.Tracing;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
@@ -214,7 +213,7 @@ namespace System.Threading.Tasks
[FriendAccessAllowed]
internal static bool AddToActiveTasks(Task task)
{
- Contract.Requires(task != null, "Null Task objects can't be added to the ActiveTasks collection");
+ Debug.Assert(task != null, "Null Task objects can't be added to the ActiveTasks collection");
lock (s_activeTasksLock)
{
s_currentActiveTasks[task.Id] = task;
@@ -515,7 +514,6 @@ namespace System.Threading.Tasks
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.action);
}
- Contract.EndContractBlock();
// Keep a link to the parent if attached
if (parent != null && (creationOptions & TaskCreationOptions.AttachedToParent) != 0)
@@ -1073,7 +1071,6 @@ namespace System.Threading.Tasks
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.scheduler);
}
- Contract.EndContractBlock();
InternalRunSynchronously(scheduler, waitForCompletion: true);
}
@@ -1083,7 +1080,7 @@ namespace System.Threading.Tasks
//
internal void InternalRunSynchronously(TaskScheduler scheduler, bool waitForCompletion)
{
- Contract.Requires(scheduler != null, "Task.InternalRunSynchronously(): null TaskScheduler");
+ Debug.Assert(scheduler != null, "Task.InternalRunSynchronously(): null TaskScheduler");
// Read the volatile m_stateFlags field once and cache it for subsequent operations
int flags = m_stateFlags;
@@ -1193,7 +1190,6 @@ namespace System.Threading.Tasks
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.scheduler);
}
- Contract.EndContractBlock();
// Create and schedule the task. This throws an InvalidOperationException if already shut down.
// Here we add the InternalTaskOptions.QueuedByRuntime to the internalOptions, so that TaskConstructorCore can skip the cancellation token registration
@@ -1810,7 +1806,7 @@ namespace System.Threading.Tasks
/// <param name="exceptionObject">An object representing either an Exception or a collection of Exceptions.</param>
internal void AddException(object exceptionObject)
{
- Contract.Requires(exceptionObject != null, "Task.AddException: Expected a non-null exception object");
+ Debug.Assert(exceptionObject != null, "Task.AddException: Expected a non-null exception object");
AddException(exceptionObject, representsCancellation: false);
}
@@ -1821,7 +1817,7 @@ namespace System.Threading.Tasks
/// <param name="representsCancellation">Whether the exceptionObject is an OperationCanceledException representing cancellation.</param>
internal void AddException(object exceptionObject, bool representsCancellation)
{
- Contract.Requires(exceptionObject != null, "Task.AddException: Expected a non-null exception object");
+ Debug.Assert(exceptionObject != null, "Task.AddException: Expected a non-null exception object");
#if DEBUG
var eoAsException = exceptionObject as Exception;
@@ -1964,7 +1960,7 @@ namespace System.Threading.Tasks
/// </summary>
internal void ThrowIfExceptional(bool includeTaskCanceledExceptions)
{
- Contract.Requires(IsCompleted, "ThrowIfExceptional(): Expected IsCompleted == true");
+ Debug.Assert(IsCompleted, "ThrowIfExceptional(): Expected IsCompleted == true");
Exception exception = GetExceptions(includeTaskCanceledExceptions);
if (exception != null)
@@ -2212,8 +2208,8 @@ namespace System.Threading.Tasks
/// </summary>
internal void ProcessChildCompletion(Task childTask)
{
- Contract.Requires(childTask != null);
- Contract.Requires(childTask.IsCompleted, "ProcessChildCompletion was called for an uncompleted task");
+ Debug.Assert(childTask != null);
+ Debug.Assert(childTask.IsCompleted, "ProcessChildCompletion was called for an uncompleted task");
Debug.Assert(childTask.m_contingentProperties?.m_parent == this, "ProcessChildCompletion should only be called for a child of this task");
@@ -2512,7 +2508,7 @@ namespace System.Threading.Tasks
/// <param name="unhandledException">The exception that went unhandled.</param>
private void HandleException(Exception unhandledException)
{
- Contract.Requires(unhandledException != null);
+ Debug.Assert(unhandledException != null);
OperationCanceledException exceptionAsOce = unhandledException as OperationCanceledException;
if (exceptionAsOce != null && IsCancellationRequested &&
@@ -2568,7 +2564,7 @@ namespace System.Threading.Tasks
internal void SetContinuationForAwait(
Action continuationAction, bool continueOnCapturedContext, bool flowExecutionContext)
{
- Contract.Requires(continuationAction != null);
+ Debug.Assert(continuationAction != null);
// Create the best AwaitTaskContinuation object given the request.
// If this remains null by the end of the function, we can use the
@@ -2627,6 +2623,57 @@ namespace System.Threading.Tasks
}
}
+ /// <summary>
+ /// Sets a continuation onto the <see cref="System.Threading.Tasks.Task"/>.
+ /// The continuation is scheduled to run in the current synchronization context is one exists,
+ /// otherwise in the current task scheduler.
+ /// </summary>
+ /// <param name="stateMachineBox">The action to invoke when the <see cref="System.Threading.Tasks.Task"/> has completed.</param>
+ /// <param name="continueOnCapturedContext">
+ /// true to attempt to marshal the continuation back to the original context captured; otherwise, false.
+ /// </param>
+ /// <exception cref="System.InvalidOperationException">The awaiter was not properly initialized.</exception>
+ internal void UnsafeSetContinuationForAwait(IAsyncStateMachineBox stateMachineBox, bool continueOnCapturedContext)
+ {
+ Debug.Assert(stateMachineBox != null);
+
+ // If the caller wants to continue on the current context/scheduler and there is one,
+ // fall back to using the state machine's delegate.
+ if (continueOnCapturedContext)
+ {
+ SynchronizationContext syncCtx = SynchronizationContext.CurrentNoFlow;
+ if (syncCtx != null && syncCtx.GetType() != typeof(SynchronizationContext))
+ {
+ Action moveNextAction = stateMachineBox.MoveNextAction;
+ if (!AddTaskContinuation(new SynchronizationContextAwaitTaskContinuation(syncCtx, moveNextAction, flowExecutionContext: false), addBeforeOthers: false))
+ {
+ AwaitTaskContinuation.UnsafeScheduleAction(moveNextAction, this);
+ }
+ return;
+ }
+ else
+ {
+ TaskScheduler scheduler = TaskScheduler.InternalCurrent;
+ if (scheduler != null && scheduler != TaskScheduler.Default)
+ {
+ Action moveNextAction = stateMachineBox.MoveNextAction;
+ if (!AddTaskContinuation(new TaskSchedulerAwaitTaskContinuation(scheduler, moveNextAction, flowExecutionContext: false), addBeforeOthers: false))
+ {
+ AwaitTaskContinuation.UnsafeScheduleAction(moveNextAction, this);
+ }
+ return;
+ }
+ }
+ }
+
+ // Otherwise, add the state machine box directly as the ITaskCompletionAction continuation.
+ // If we're unable to because the task has already completed, queue the delegate.
+ if (!AddTaskContinuation(stateMachineBox, addBeforeOthers: false))
+ {
+ AwaitTaskContinuation.UnsafeScheduleAction(stateMachineBox.MoveNextAction, this);
+ }
+ }
+
/// <summary>Creates an awaitable that asynchronously yields back to the current context when awaited.</summary>
/// <returns>
/// A context that, when awaited, will asynchronously transition back into the current context at the
@@ -2761,7 +2808,6 @@ namespace System.Threading.Tasks
{
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.millisecondsTimeout);
}
- Contract.EndContractBlock();
// Return immediately if we know that we've completed "clean" -- no exceptions, no cancellations
// and if no notification to the debugger is required
@@ -2992,7 +3038,7 @@ namespace System.Threading.Tasks
/// <returns>true if the task was successfully canceled; otherwise, false.</returns>
internal bool InternalCancel(bool bCancelNonExecutingOnly)
{
- Contract.Requires((Options & (TaskCreationOptions)InternalTaskOptions.PromiseTask) == 0, "Task.InternalCancel() did not expect promise-style task");
+ Debug.Assert((Options & (TaskCreationOptions)InternalTaskOptions.PromiseTask) == 0, "Task.InternalCancel() did not expect promise-style task");
bool bPopSucceeded = false;
bool mustCleanup = false;
@@ -3505,7 +3551,6 @@ namespace System.Threading.Tasks
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.scheduler);
}
- Contract.EndContractBlock();
TaskCreationOptions creationOptions;
InternalTaskOptions internalOptions;
@@ -3696,7 +3741,6 @@ namespace System.Threading.Tasks
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.scheduler);
}
- Contract.EndContractBlock();
TaskCreationOptions creationOptions;
InternalTaskOptions internalOptions;
@@ -3900,7 +3944,6 @@ namespace System.Threading.Tasks
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.scheduler);
}
- Contract.EndContractBlock();
TaskCreationOptions creationOptions;
InternalTaskOptions internalOptions;
@@ -4108,7 +4151,6 @@ namespace System.Threading.Tasks
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.scheduler);
}
- Contract.EndContractBlock();
TaskCreationOptions creationOptions;
InternalTaskOptions internalOptions;
@@ -4195,9 +4237,9 @@ namespace System.Threading.Tasks
CancellationToken cancellationToken,
TaskContinuationOptions options)
{
- Contract.Requires(continuationTask != null, "Task.ContinueWithCore(): null continuationTask");
- Contract.Requires(scheduler != null, "Task.ContinueWithCore(): null scheduler");
- Contract.Requires(!continuationTask.IsCompleted, "Did not expect continuationTask to be completed");
+ Debug.Assert(continuationTask != null, "Task.ContinueWithCore(): null continuationTask");
+ Debug.Assert(scheduler != null, "Task.ContinueWithCore(): null scheduler");
+ Debug.Assert(!continuationTask.IsCompleted, "Did not expect continuationTask to be completed");
// Create a TaskContinuation
TaskContinuation continuation = new StandardTaskContinuation(continuationTask, options, scheduler);
@@ -4288,7 +4330,7 @@ namespace System.Threading.Tasks
// care of in the calling method, AddTaskContinuation().
private bool AddTaskContinuationComplex(object tc, bool addBeforeOthers)
{
- Contract.Requires(tc != null, "Expected non-null tc object in AddTaskContinuationComplex");
+ Debug.Assert(tc != null, "Expected non-null tc object in AddTaskContinuationComplex");
object oldValue = m_continuationObject;
@@ -4352,7 +4394,7 @@ namespace System.Threading.Tasks
// Return true if and only if we successfully queued a continuation.
private bool AddTaskContinuation(object tc, bool addBeforeOthers)
{
- Contract.Requires(tc != null);
+ Debug.Assert(tc != null);
// Make sure that, if someone calls ContinueWith() right after waiting for the predecessor to complete,
// we don't queue up a continuation.
@@ -4613,7 +4655,6 @@ namespace System.Threading.Tasks
{
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.millisecondsTimeout);
}
- Contract.EndContractBlock();
cancellationToken.ThrowIfCancellationRequested(); // early check before we make any allocations
@@ -4990,7 +5031,6 @@ namespace System.Threading.Tasks
{
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.millisecondsTimeout);
}
- Contract.EndContractBlock();
cancellationToken.ThrowIfCancellationRequested(); // early check before we make any allocations
@@ -5068,7 +5108,6 @@ namespace System.Threading.Tasks
public static Task<TResult> FromException<TResult>(Exception exception)
{
if (exception == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.exception);
- Contract.EndContractBlock();
var task = new Task<TResult>();
bool succeeded = task.TrySetException(exception);
@@ -5083,7 +5122,6 @@ namespace System.Threading.Tasks
{
if (!cancellationToken.IsCancellationRequested)
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.cancellationToken);
- Contract.EndContractBlock();
return new Task(true, TaskCreationOptions.None, cancellationToken);
}
@@ -5095,7 +5133,6 @@ namespace System.Threading.Tasks
{
if (!cancellationToken.IsCancellationRequested)
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.cancellationToken);
- Contract.EndContractBlock();
return new Task<TResult>(true, default(TResult), TaskCreationOptions.None, cancellationToken);
}
@@ -5106,7 +5143,6 @@ namespace System.Threading.Tasks
internal static Task<TResult> FromCancellation<TResult>(OperationCanceledException exception)
{
if (exception == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.exception);
- Contract.EndContractBlock();
var task = new Task<TResult>();
bool succeeded = task.TrySetCanceled(exception.CancellationToken, exception);
@@ -5234,7 +5270,6 @@ namespace System.Threading.Tasks
{
// Check arguments
if (function == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.function);
- Contract.EndContractBlock();
// Short-circuit if we are given a pre-canceled token
if (cancellationToken.IsCancellationRequested)
@@ -5280,7 +5315,6 @@ namespace System.Threading.Tasks
{
// Check arguments
if (function == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.function);
- Contract.EndContractBlock();
// Short-circuit if we are given a pre-canceled token
if (cancellationToken.IsCancellationRequested)
@@ -5385,7 +5419,6 @@ namespace System.Threading.Tasks
{
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.millisecondsDelay, ExceptionResource.Task_Delay_InvalidMillisecondsDelay);
}
- Contract.EndContractBlock();
// some short-cuts in case quick completion is in order
if (cancellationToken.IsCancellationRequested)
@@ -5565,7 +5598,6 @@ namespace System.Threading.Tasks
{
// Do some argument checking and make a defensive copy of the tasks array
if (tasks == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.tasks);
- Contract.EndContractBlock();
int taskCount = tasks.Length;
if (taskCount == 0) return InternalWhenAll(tasks); // Small optimization in the case of an empty array.
@@ -5586,7 +5618,7 @@ namespace System.Threading.Tasks
// tasks should be a defensive copy.
private static Task InternalWhenAll(Task[] tasks)
{
- Contract.Requires(tasks != null, "Expected a non-null tasks array");
+ Debug.Assert(tasks != null, "Expected a non-null tasks array");
return (tasks.Length == 0) ? // take shortcut if there are no tasks upon which to wait
Task.CompletedTask :
new WhenAllPromise(tasks);
@@ -5617,8 +5649,8 @@ namespace System.Threading.Tasks
internal WhenAllPromise(Task[] tasks) :
base()
{
- Contract.Requires(tasks != null, "Expected a non-null task array");
- Contract.Requires(tasks.Length > 0, "Expected a non-zero length task array");
+ Debug.Assert(tasks != null, "Expected a non-null task array");
+ Debug.Assert(tasks.Length > 0, "Expected a non-zero length task array");
if (AsyncCausalityTracer.LoggingOn)
AsyncCausalityTracer.TraceOperationCreation(CausalityTraceLevel.Required, this.Id, "Task.WhenAll", 0);
@@ -5819,7 +5851,6 @@ namespace System.Threading.Tasks
{
// Do some argument checking and make a defensive copy of the tasks array
if (tasks == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.tasks);
- Contract.EndContractBlock();
int taskCount = tasks.Length;
if (taskCount == 0) return InternalWhenAll<TResult>(tasks); // small optimization in the case of an empty task array
@@ -5839,7 +5870,7 @@ namespace System.Threading.Tasks
// Some common logic to support WhenAll<TResult> methods
private static Task<TResult[]> InternalWhenAll<TResult>(Task<TResult>[] tasks)
{
- Contract.Requires(tasks != null, "Expected a non-null tasks array");
+ Debug.Assert(tasks != null, "Expected a non-null tasks array");
return (tasks.Length == 0) ? // take shortcut if there are no tasks upon which to wait
new Task<TResult[]>(false, new TResult[0], TaskCreationOptions.None, default(CancellationToken)) :
new WhenAllPromise<TResult>(tasks);
@@ -5863,8 +5894,8 @@ namespace System.Threading.Tasks
internal WhenAllPromise(Task<T>[] tasks) :
base()
{
- Contract.Requires(tasks != null, "Expected a non-null task array");
- Contract.Requires(tasks.Length > 0, "Expected a non-zero length task array");
+ Debug.Assert(tasks != null, "Expected a non-null task array");
+ Debug.Assert(tasks.Length > 0, "Expected a non-zero length task array");
m_tasks = tasks;
m_count = tasks.Length;
@@ -5995,7 +6026,6 @@ namespace System.Threading.Tasks
{
ThrowHelper.ThrowArgumentException(ExceptionResource.Task_MultiTaskContinuation_EmptyTaskList, ExceptionArgument.tasks);
}
- Contract.EndContractBlock();
// Make a defensive copy, as the user may manipulate the tasks array
// after we return but before the WhenAny asynchronously completes.
@@ -6030,7 +6060,6 @@ namespace System.Threading.Tasks
public static Task<Task> WhenAny(IEnumerable<Task> tasks)
{
if (tasks == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.tasks);
- Contract.EndContractBlock();
// Make a defensive copy, as the user may manipulate the tasks collection
// after we return but before the WhenAny asynchronously completes.
@@ -6112,7 +6141,7 @@ namespace System.Threading.Tasks
[FriendAccessAllowed]
internal static Task<TResult> CreateUnwrapPromise<TResult>(Task outerTask, bool lookForOce)
{
- Contract.Requires(outerTask != null);
+ Debug.Assert(outerTask != null);
return new UnwrapPromise<TResult>(outerTask, lookForOce);
}
@@ -6516,7 +6545,7 @@ namespace System.Threading.Tasks
public UnwrapPromise(Task outerTask, bool lookForOce)
: base((object)null, outerTask.CreationOptions & TaskCreationOptions.AttachedToParent)
{
- Contract.Requires(outerTask != null, "Expected non-null outerTask");
+ Debug.Assert(outerTask != null, "Expected non-null outerTask");
_lookForOce = lookForOce;
_state = STATE_WAITING_ON_OUTER_TASK;
@@ -6601,7 +6630,7 @@ namespace System.Threading.Tasks
/// <param name="task">The now-completed outer task.</param>
private void ProcessCompletedOuterTask(Task task)
{
- Contract.Requires(task != null && task.IsCompleted, "Expected non-null, completed outer task");
+ Debug.Assert(task != null && task.IsCompleted, "Expected non-null, completed outer task");
Debug.Assert(_state == STATE_WAITING_ON_OUTER_TASK, "We're in the wrong state!");
// Bump our state before proceeding any further
@@ -6632,7 +6661,7 @@ namespace System.Threading.Tasks
/// <returns>true if the transfer was successful; otherwise, false.</returns>
private bool TrySetFromTask(Task task, bool lookForOce)
{
- Contract.Requires(task != null && task.IsCompleted, "TrySetFromTask: Expected task to have completed.");
+ Debug.Assert(task != null && task.IsCompleted, "TrySetFromTask: Expected task to have completed.");
if (AsyncCausalityTracer.LoggingOn)
AsyncCausalityTracer.TraceOperationRelation(CausalityTraceLevel.Important, this.Id, CausalityRelation.Join);
diff --git a/src/mscorlib/src/System/Threading/Tasks/TaskCompletionSource.cs b/src/mscorlib/src/System/Threading/Tasks/TaskCompletionSource.cs
index 47a51a45f5..dc59caf04f 100644
--- a/src/mscorlib/src/System/Threading/Tasks/TaskCompletionSource.cs
+++ b/src/mscorlib/src/System/Threading/Tasks/TaskCompletionSource.cs
@@ -13,7 +13,6 @@
using System;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
diff --git a/src/mscorlib/src/System/Threading/Tasks/TaskContinuation.cs b/src/mscorlib/src/System/Threading/Tasks/TaskContinuation.cs
index de222352c9..06539f956c 100644
--- a/src/mscorlib/src/System/Threading/Tasks/TaskContinuation.cs
+++ b/src/mscorlib/src/System/Threading/Tasks/TaskContinuation.cs
@@ -12,7 +12,6 @@
using System.Security;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.ExceptionServices;
using System.Runtime.CompilerServices;
using System.Threading;
@@ -32,7 +31,7 @@ namespace System.Threading.Tasks
Task antecedent, Delegate action, object state, TaskCreationOptions creationOptions, InternalTaskOptions internalOptions) :
base(action, state, Task.InternalCurrentIfAttached(creationOptions), default(CancellationToken), creationOptions, internalOptions, null)
{
- Contract.Requires(action is Action<Task> || action is Action<Task, object>,
+ Debug.Assert(action is Action<Task> || action is Action<Task, object>,
"Invalid delegate type in ContinuationTaskFromTask");
m_antecedent = antecedent;
}
@@ -79,7 +78,7 @@ namespace System.Threading.Tasks
Task antecedent, Delegate function, object state, TaskCreationOptions creationOptions, InternalTaskOptions internalOptions) :
base(function, state, Task.InternalCurrentIfAttached(creationOptions), default(CancellationToken), creationOptions, internalOptions, null)
{
- Contract.Requires(function is Func<Task, TResult> || function is Func<Task, object, TResult>,
+ Debug.Assert(function is Func<Task, TResult> || function is Func<Task, object, TResult>,
"Invalid delegate type in ContinuationResultTaskFromTask");
m_antecedent = antecedent;
}
@@ -126,7 +125,7 @@ namespace System.Threading.Tasks
Task<TAntecedentResult> antecedent, Delegate action, object state, TaskCreationOptions creationOptions, InternalTaskOptions internalOptions) :
base(action, state, Task.InternalCurrentIfAttached(creationOptions), default(CancellationToken), creationOptions, internalOptions, null)
{
- Contract.Requires(action is Action<Task<TAntecedentResult>> || action is Action<Task<TAntecedentResult>, object>,
+ Debug.Assert(action is Action<Task<TAntecedentResult>> || action is Action<Task<TAntecedentResult>, object>,
"Invalid delegate type in ContinuationTaskFromResultTask");
m_antecedent = antecedent;
}
@@ -173,7 +172,7 @@ namespace System.Threading.Tasks
Task<TAntecedentResult> antecedent, Delegate function, object state, TaskCreationOptions creationOptions, InternalTaskOptions internalOptions) :
base(function, state, Task.InternalCurrentIfAttached(creationOptions), default(CancellationToken), creationOptions, internalOptions, null)
{
- Contract.Requires(function is Func<Task<TAntecedentResult>, TResult> || function is Func<Task<TAntecedentResult>, object, TResult>,
+ Debug.Assert(function is Func<Task<TAntecedentResult>, TResult> || function is Func<Task<TAntecedentResult>, object, TResult>,
"Invalid delegate type in ContinuationResultTaskFromResultTask");
m_antecedent = antecedent;
}
@@ -234,7 +233,7 @@ namespace System.Threading.Tasks
/// </param>
protected static void InlineIfPossibleOrElseQueue(Task task, bool needsProtection)
{
- Contract.Requires(task != null);
+ Debug.Assert(task != null);
Debug.Assert(task.m_taskScheduler != null);
// Set the TASK_STATE_STARTED flag. This only needs to be done
@@ -294,8 +293,8 @@ namespace System.Threading.Tasks
/// <param name="scheduler">The scheduler to use for the continuation.</param>
internal StandardTaskContinuation(Task task, TaskContinuationOptions options, TaskScheduler scheduler)
{
- Contract.Requires(task != null, "TaskContinuation ctor: task is null");
- Contract.Requires(scheduler != null, "TaskContinuation ctor: scheduler is null");
+ Debug.Assert(task != null, "TaskContinuation ctor: task is null");
+ Debug.Assert(scheduler != null, "TaskContinuation ctor: scheduler is null");
m_task = task;
m_options = options;
m_taskScheduler = scheduler;
@@ -539,7 +538,7 @@ namespace System.Threading.Tasks
/// <param name="flowExecutionContext">Whether to capture and restore ExecutionContext.</param>
internal AwaitTaskContinuation(Action action, bool flowExecutionContext)
{
- Contract.Requires(action != null);
+ Debug.Assert(action != null);
m_action = action;
if (flowExecutionContext)
{
@@ -554,8 +553,8 @@ namespace System.Threading.Tasks
/// <returns>The created task.</returns>
protected Task CreateTask(Action<object> action, object state, TaskScheduler scheduler)
{
- Contract.Requires(action != null);
- Contract.Requires(scheduler != null);
+ Debug.Assert(action != null);
+ Debug.Assert(scheduler != null);
return new Task(
action, state, null, default(CancellationToken),
@@ -699,7 +698,7 @@ namespace System.Threading.Tasks
/// <param name="currentTask">A reference to Task.t_currentTask.</param>
protected void RunCallback(ContextCallback callback, object state, ref Task currentTask)
{
- Contract.Requires(callback != null);
+ Debug.Assert(callback != null);
Debug.Assert(currentTask == Task.t_currentTask);
// Pretend there's no current task, so that no task is seen as a parent
diff --git a/src/mscorlib/src/System/Threading/Tasks/TaskExceptionHolder.cs b/src/mscorlib/src/System/Threading/Tasks/TaskExceptionHolder.cs
index 1385d907e0..a96852a6f0 100644
--- a/src/mscorlib/src/System/Threading/Tasks/TaskExceptionHolder.cs
+++ b/src/mscorlib/src/System/Threading/Tasks/TaskExceptionHolder.cs
@@ -19,7 +19,6 @@ namespace System.Threading.Tasks
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
- using System.Diagnostics.Contracts;
using System.Runtime.ExceptionServices;
using System.Security;
@@ -58,7 +57,7 @@ namespace System.Threading.Tasks
/// <param name="task">The task this holder belongs to.</param>
internal TaskExceptionHolder(Task task)
{
- Contract.Requires(task != null, "Expected a non-null task.");
+ Debug.Assert(task != null, "Expected a non-null task.");
m_task = task;
EnsureADUnloadCallbackRegistered();
}
@@ -162,8 +161,8 @@ namespace System.Threading.Tasks
/// </remarks>
internal void Add(object exceptionObject, bool representsCancellation)
{
- Contract.Requires(exceptionObject != null, "TaskExceptionHolder.Add(): Expected a non-null exceptionObject");
- Contract.Requires(
+ Debug.Assert(exceptionObject != null, "TaskExceptionHolder.Add(): Expected a non-null exceptionObject");
+ Debug.Assert(
exceptionObject is Exception || exceptionObject is IEnumerable<Exception> ||
exceptionObject is ExceptionDispatchInfo || exceptionObject is IEnumerable<ExceptionDispatchInfo>,
"TaskExceptionHolder.Add(): Expected Exception, IEnumerable<Exception>, ExceptionDispatchInfo, or IEnumerable<ExceptionDispatchInfo>");
@@ -179,7 +178,7 @@ namespace System.Threading.Tasks
/// </remarks>
private void SetCancellationException(object exceptionObject)
{
- Contract.Requires(exceptionObject != null, "Expected exceptionObject to be non-null.");
+ Debug.Assert(exceptionObject != null, "Expected exceptionObject to be non-null.");
Debug.Assert(m_cancellationException == null,
"Expected SetCancellationException to be called only once.");
@@ -216,7 +215,7 @@ namespace System.Threading.Tasks
/// </remarks>
private void AddFaultException(object exceptionObject)
{
- Contract.Requires(exceptionObject != null, "AddFaultException(): Expected a non-null exceptionObject");
+ Debug.Assert(exceptionObject != null, "AddFaultException(): Expected a non-null exceptionObject");
// Initialize the exceptions list if necessary. The list should be non-null iff it contains exceptions.
var exceptions = m_faultExceptions;
diff --git a/src/mscorlib/src/System/Threading/Tasks/TaskFactory.cs b/src/mscorlib/src/System/Threading/Tasks/TaskFactory.cs
index e193d0e4e2..875d47b1e7 100644
--- a/src/mscorlib/src/System/Threading/Tasks/TaskFactory.cs
+++ b/src/mscorlib/src/System/Threading/Tasks/TaskFactory.cs
@@ -18,7 +18,6 @@ using System.Security;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Threading.Tasks
{
@@ -202,7 +201,6 @@ namespace System.Threading.Tasks
m_defaultContinuationOptions = continuationOptions;
}
- [ContractArgumentValidatorAttribute]
internal static void CheckCreationOptions(TaskCreationOptions creationOptions)
{
// Check for validity of options
@@ -216,7 +214,6 @@ namespace System.Threading.Tasks
{
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.creationOptions);
}
- Contract.EndContractBlock();
}
/* Properties */
@@ -1560,7 +1557,7 @@ namespace System.Threading.Tasks
internal CompleteOnCountdownPromise(Task[] tasksCopy) : base()
{
- Contract.Requires((tasksCopy != null) && (tasksCopy.Length > 0), "Expected non-null task array with at least one element in it");
+ Debug.Assert((tasksCopy != null) && (tasksCopy.Length > 0), "Expected non-null task array with at least one element in it");
_tasks = tasksCopy;
_count = tasksCopy.Length;
@@ -1614,7 +1611,7 @@ namespace System.Threading.Tasks
// Performs some logic common to all ContinueWhenAll() overloads
internal static Task<Task[]> CommonCWAllLogic(Task[] tasksCopy)
{
- Contract.Requires(tasksCopy != null);
+ Debug.Assert(tasksCopy != null);
// Create a promise task to be returned to the user
CompleteOnCountdownPromise promise = new CompleteOnCountdownPromise(tasksCopy);
@@ -1640,7 +1637,7 @@ namespace System.Threading.Tasks
internal CompleteOnCountdownPromise(Task<T>[] tasksCopy) : base()
{
- Contract.Requires((tasksCopy != null) && (tasksCopy.Length > 0), "Expected non-null task array with at least one element in it");
+ Debug.Assert((tasksCopy != null) && (tasksCopy.Length > 0), "Expected non-null task array with at least one element in it");
_tasks = tasksCopy;
_count = tasksCopy.Length;
@@ -1694,7 +1691,7 @@ namespace System.Threading.Tasks
internal static Task<Task<T>[]> CommonCWAllLogic<T>(Task<T>[] tasksCopy)
{
- Contract.Requires(tasksCopy != null);
+ Debug.Assert(tasksCopy != null);
// Create a promise task to be returned to the user
CompleteOnCountdownPromise<T> promise = new CompleteOnCountdownPromise<T>(tasksCopy);
@@ -1726,7 +1723,6 @@ namespace System.Threading.Tasks
public Task ContinueWhenAll(Task[] tasks, Action<Task[]> continuationAction)
{
if (continuationAction == null) throw new ArgumentNullException(nameof(continuationAction));
- Contract.EndContractBlock();
return TaskFactory<VoidTaskResult>.ContinueWhenAllImpl(tasks, null, continuationAction, m_defaultContinuationOptions, m_defaultCancellationToken, DefaultScheduler);
}
@@ -1756,7 +1752,6 @@ namespace System.Threading.Tasks
public Task ContinueWhenAll(Task[] tasks, Action<Task[]> continuationAction, CancellationToken cancellationToken)
{
if (continuationAction == null) throw new ArgumentNullException(nameof(continuationAction));
- Contract.EndContractBlock();
return TaskFactory<VoidTaskResult>.ContinueWhenAllImpl(tasks, null, continuationAction, m_defaultContinuationOptions, cancellationToken, DefaultScheduler);
}
@@ -1791,7 +1786,6 @@ namespace System.Threading.Tasks
public Task ContinueWhenAll(Task[] tasks, Action<Task[]> continuationAction, TaskContinuationOptions continuationOptions)
{
if (continuationAction == null) throw new ArgumentNullException(nameof(continuationAction));
- Contract.EndContractBlock();
return TaskFactory<VoidTaskResult>.ContinueWhenAllImpl(tasks, null, continuationAction, continuationOptions, m_defaultCancellationToken, DefaultScheduler);
}
@@ -1837,7 +1831,6 @@ namespace System.Threading.Tasks
TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
{
if (continuationAction == null) throw new ArgumentNullException(nameof(continuationAction));
- Contract.EndContractBlock();
return TaskFactory<VoidTaskResult>.ContinueWhenAllImpl(tasks, null, continuationAction, continuationOptions, cancellationToken, scheduler);
}
@@ -1862,7 +1855,6 @@ namespace System.Threading.Tasks
public Task ContinueWhenAll<TAntecedentResult>(Task<TAntecedentResult>[] tasks, Action<Task<TAntecedentResult>[]> continuationAction)
{
if (continuationAction == null) throw new ArgumentNullException(nameof(continuationAction));
- Contract.EndContractBlock();
return TaskFactory<VoidTaskResult>.ContinueWhenAllImpl<TAntecedentResult>(tasks, null, continuationAction, m_defaultContinuationOptions, m_defaultCancellationToken, DefaultScheduler);
}
@@ -1894,7 +1886,6 @@ namespace System.Threading.Tasks
CancellationToken cancellationToken)
{
if (continuationAction == null) throw new ArgumentNullException(nameof(continuationAction));
- Contract.EndContractBlock();
return TaskFactory<VoidTaskResult>.ContinueWhenAllImpl<TAntecedentResult>(tasks, null, continuationAction, m_defaultContinuationOptions, cancellationToken, DefaultScheduler);
}
@@ -1931,7 +1922,6 @@ namespace System.Threading.Tasks
TaskContinuationOptions continuationOptions)
{
if (continuationAction == null) throw new ArgumentNullException(nameof(continuationAction));
- Contract.EndContractBlock();
return TaskFactory<VoidTaskResult>.ContinueWhenAllImpl<TAntecedentResult>(tasks, null, continuationAction, continuationOptions, m_defaultCancellationToken, DefaultScheduler);
}
@@ -1978,7 +1968,6 @@ namespace System.Threading.Tasks
CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
{
if (continuationAction == null) throw new ArgumentNullException(nameof(continuationAction));
- Contract.EndContractBlock();
return TaskFactory<VoidTaskResult>.ContinueWhenAllImpl<TAntecedentResult>(tasks, null, continuationAction, continuationOptions, cancellationToken, scheduler);
}
@@ -2006,7 +1995,6 @@ namespace System.Threading.Tasks
public Task<TResult> ContinueWhenAll<TResult>(Task[] tasks, Func<Task[], TResult> continuationFunction)
{
if (continuationFunction == null) throw new ArgumentNullException(nameof(continuationFunction));
- Contract.EndContractBlock();
return TaskFactory<TResult>.ContinueWhenAllImpl(tasks, continuationFunction, null, m_defaultContinuationOptions, m_defaultCancellationToken, DefaultScheduler);
}
@@ -2040,7 +2028,6 @@ namespace System.Threading.Tasks
public Task<TResult> ContinueWhenAll<TResult>(Task[] tasks, Func<Task[], TResult> continuationFunction, CancellationToken cancellationToken)
{
if (continuationFunction == null) throw new ArgumentNullException(nameof(continuationFunction));
- Contract.EndContractBlock();
return TaskFactory<TResult>.ContinueWhenAllImpl(tasks, continuationFunction, null, m_defaultContinuationOptions, cancellationToken, DefaultScheduler);
}
@@ -2079,7 +2066,6 @@ namespace System.Threading.Tasks
public Task<TResult> ContinueWhenAll<TResult>(Task[] tasks, Func<Task[], TResult> continuationFunction, TaskContinuationOptions continuationOptions)
{
if (continuationFunction == null) throw new ArgumentNullException(nameof(continuationFunction));
- Contract.EndContractBlock();
return TaskFactory<TResult>.ContinueWhenAllImpl(tasks, continuationFunction, null, continuationOptions, m_defaultCancellationToken, DefaultScheduler);
}
@@ -2129,7 +2115,6 @@ namespace System.Threading.Tasks
TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
{
if (continuationFunction == null) throw new ArgumentNullException(nameof(continuationFunction));
- Contract.EndContractBlock();
return TaskFactory<TResult>.ContinueWhenAllImpl(tasks, continuationFunction, null, continuationOptions, cancellationToken, scheduler);
}
@@ -2159,7 +2144,6 @@ namespace System.Threading.Tasks
public Task<TResult> ContinueWhenAll<TAntecedentResult, TResult>(Task<TAntecedentResult>[] tasks, Func<Task<TAntecedentResult>[], TResult> continuationFunction)
{
if (continuationFunction == null) throw new ArgumentNullException(nameof(continuationFunction));
- Contract.EndContractBlock();
return TaskFactory<TResult>.ContinueWhenAllImpl<TAntecedentResult>(tasks, continuationFunction, null, m_defaultContinuationOptions, m_defaultCancellationToken, DefaultScheduler);
}
@@ -2194,7 +2178,6 @@ namespace System.Threading.Tasks
CancellationToken cancellationToken)
{
if (continuationFunction == null) throw new ArgumentNullException(nameof(continuationFunction));
- Contract.EndContractBlock();
return TaskFactory<TResult>.ContinueWhenAllImpl<TAntecedentResult>(tasks, continuationFunction, null, m_defaultContinuationOptions, cancellationToken, DefaultScheduler);
}
@@ -2235,7 +2218,6 @@ namespace System.Threading.Tasks
TaskContinuationOptions continuationOptions)
{
if (continuationFunction == null) throw new ArgumentNullException(nameof(continuationFunction));
- Contract.EndContractBlock();
return TaskFactory<TResult>.ContinueWhenAllImpl<TAntecedentResult>(tasks, continuationFunction, null, continuationOptions, m_defaultCancellationToken, DefaultScheduler);
}
@@ -2286,7 +2268,6 @@ namespace System.Threading.Tasks
CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
{
if (continuationFunction == null) throw new ArgumentNullException(nameof(continuationFunction));
- Contract.EndContractBlock();
return TaskFactory<TResult>.ContinueWhenAllImpl<TAntecedentResult>(tasks, continuationFunction, null, continuationOptions, cancellationToken, scheduler);
}
@@ -2313,7 +2294,7 @@ namespace System.Threading.Tasks
public CompleteOnInvokePromise(IList<Task> tasks) : base()
{
- Contract.Requires(tasks != null, "Expected non-null collection of tasks");
+ Debug.Assert(tasks != null, "Expected non-null collection of tasks");
_tasks = tasks;
if (AsyncCausalityTracer.LoggingOn)
@@ -2370,7 +2351,7 @@ namespace System.Threading.Tasks
// asynchronously (e.g. WhenAny) rather than synchronously (e.g. WaitAny).
internal static Task<Task> CommonCWAnyLogic(IList<Task> tasks)
{
- Contract.Requires(tasks != null);
+ Debug.Assert(tasks != null);
// Create a promise task to be returned to the user.
// (If this logic ever changes, also update CommonCWAnyLogicCleanup.)
@@ -2452,7 +2433,6 @@ namespace System.Threading.Tasks
public Task ContinueWhenAny(Task[] tasks, Action<Task> continuationAction)
{
if (continuationAction == null) throw new ArgumentNullException(nameof(continuationAction));
- Contract.EndContractBlock();
return TaskFactory<VoidTaskResult>.ContinueWhenAnyImpl(tasks, null, continuationAction, m_defaultContinuationOptions, m_defaultCancellationToken, DefaultScheduler);
}
@@ -2481,7 +2461,6 @@ namespace System.Threading.Tasks
public Task ContinueWhenAny(Task[] tasks, Action<Task> continuationAction, CancellationToken cancellationToken)
{
if (continuationAction == null) throw new ArgumentNullException(nameof(continuationAction));
- Contract.EndContractBlock();
return TaskFactory<VoidTaskResult>.ContinueWhenAnyImpl(tasks, null, continuationAction, m_defaultContinuationOptions, cancellationToken, DefaultScheduler);
}
@@ -2516,7 +2495,6 @@ namespace System.Threading.Tasks
public Task ContinueWhenAny(Task[] tasks, Action<Task> continuationAction, TaskContinuationOptions continuationOptions)
{
if (continuationAction == null) throw new ArgumentNullException(nameof(continuationAction));
- Contract.EndContractBlock();
return TaskFactory<VoidTaskResult>.ContinueWhenAnyImpl(tasks, null, continuationAction, continuationOptions, m_defaultCancellationToken, DefaultScheduler);
}
@@ -2562,7 +2540,6 @@ namespace System.Threading.Tasks
TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
{
if (continuationAction == null) throw new ArgumentNullException(nameof(continuationAction));
- Contract.EndContractBlock();
return TaskFactory<VoidTaskResult>.ContinueWhenAnyImpl(tasks, null, continuationAction, continuationOptions, cancellationToken, scheduler);
}
@@ -2591,7 +2568,6 @@ namespace System.Threading.Tasks
public Task<TResult> ContinueWhenAny<TResult>(Task[] tasks, Func<Task, TResult> continuationFunction)
{
if (continuationFunction == null) throw new ArgumentNullException(nameof(continuationFunction));
- Contract.EndContractBlock();
return TaskFactory<TResult>.ContinueWhenAnyImpl(tasks, continuationFunction, null, m_defaultContinuationOptions, m_defaultCancellationToken, DefaultScheduler);
}
@@ -2624,7 +2600,6 @@ namespace System.Threading.Tasks
public Task<TResult> ContinueWhenAny<TResult>(Task[] tasks, Func<Task, TResult> continuationFunction, CancellationToken cancellationToken)
{
if (continuationFunction == null) throw new ArgumentNullException(nameof(continuationFunction));
- Contract.EndContractBlock();
return TaskFactory<TResult>.ContinueWhenAnyImpl(tasks, continuationFunction, null, m_defaultContinuationOptions, cancellationToken, DefaultScheduler);
}
@@ -2663,7 +2638,6 @@ namespace System.Threading.Tasks
public Task<TResult> ContinueWhenAny<TResult>(Task[] tasks, Func<Task, TResult> continuationFunction, TaskContinuationOptions continuationOptions)
{
if (continuationFunction == null) throw new ArgumentNullException(nameof(continuationFunction));
- Contract.EndContractBlock();
return TaskFactory<TResult>.ContinueWhenAnyImpl(tasks, continuationFunction, null, continuationOptions, m_defaultCancellationToken, DefaultScheduler);
}
@@ -2713,7 +2687,6 @@ namespace System.Threading.Tasks
TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
{
if (continuationFunction == null) throw new ArgumentNullException(nameof(continuationFunction));
- Contract.EndContractBlock();
return TaskFactory<TResult>.ContinueWhenAnyImpl(tasks, continuationFunction, null, continuationOptions, cancellationToken, scheduler);
}
@@ -2775,7 +2748,6 @@ namespace System.Threading.Tasks
CancellationToken cancellationToken)
{
if (continuationFunction == null) throw new ArgumentNullException(nameof(continuationFunction));
- Contract.EndContractBlock();
return TaskFactory<TResult>.ContinueWhenAnyImpl<TAntecedentResult>(tasks, continuationFunction, null, m_defaultContinuationOptions, cancellationToken, DefaultScheduler);
}
@@ -2816,7 +2788,6 @@ namespace System.Threading.Tasks
TaskContinuationOptions continuationOptions)
{
if (continuationFunction == null) throw new ArgumentNullException(nameof(continuationFunction));
- Contract.EndContractBlock();
return TaskFactory<TResult>.ContinueWhenAnyImpl<TAntecedentResult>(tasks, continuationFunction, null, continuationOptions, m_defaultCancellationToken, DefaultScheduler);
}
@@ -2867,7 +2838,6 @@ namespace System.Threading.Tasks
CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
{
if (continuationFunction == null) throw new ArgumentNullException(nameof(continuationFunction));
- Contract.EndContractBlock();
return TaskFactory<TResult>.ContinueWhenAnyImpl<TAntecedentResult>(tasks, continuationFunction, null, continuationOptions, cancellationToken, scheduler);
}
@@ -2893,7 +2863,6 @@ namespace System.Threading.Tasks
public Task ContinueWhenAny<TAntecedentResult>(Task<TAntecedentResult>[] tasks, Action<Task<TAntecedentResult>> continuationAction)
{
if (continuationAction == null) throw new ArgumentNullException(nameof(continuationAction));
- Contract.EndContractBlock();
return TaskFactory<VoidTaskResult>.ContinueWhenAnyImpl<TAntecedentResult>(tasks, null, continuationAction, m_defaultContinuationOptions, m_defaultCancellationToken, DefaultScheduler);
}
@@ -2924,7 +2893,6 @@ namespace System.Threading.Tasks
CancellationToken cancellationToken)
{
if (continuationAction == null) throw new ArgumentNullException(nameof(continuationAction));
- Contract.EndContractBlock();
return TaskFactory<VoidTaskResult>.ContinueWhenAnyImpl<TAntecedentResult>(tasks, null, continuationAction, m_defaultContinuationOptions, cancellationToken, DefaultScheduler);
}
@@ -2961,7 +2929,6 @@ namespace System.Threading.Tasks
TaskContinuationOptions continuationOptions)
{
if (continuationAction == null) throw new ArgumentNullException(nameof(continuationAction));
- Contract.EndContractBlock();
return TaskFactory<VoidTaskResult>.ContinueWhenAnyImpl<TAntecedentResult>(tasks, null, continuationAction, continuationOptions, m_defaultCancellationToken, DefaultScheduler);
}
@@ -3008,7 +2975,6 @@ namespace System.Threading.Tasks
CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
{
if (continuationAction == null) throw new ArgumentNullException(nameof(continuationAction));
- Contract.EndContractBlock();
return TaskFactory<VoidTaskResult>.ContinueWhenAnyImpl<TAntecedentResult>(tasks, null, continuationAction, continuationOptions, cancellationToken, scheduler);
}
@@ -3021,7 +2987,6 @@ namespace System.Threading.Tasks
throw new ArgumentNullException(nameof(tasks));
if (tasks.Length == 0)
throw new ArgumentException(SR.Task_MultiTaskContinuation_EmptyTaskList, nameof(tasks));
- Contract.EndContractBlock();
Task[] tasksCopy = new Task[tasks.Length];
for (int i = 0; i < tasks.Length; i++)
@@ -3041,7 +3006,6 @@ namespace System.Threading.Tasks
throw new ArgumentNullException(nameof(tasks));
if (tasks.Length == 0)
throw new ArgumentException(SR.Task_MultiTaskContinuation_EmptyTaskList, nameof(tasks));
- Contract.EndContractBlock();
Task<TResult>[] tasksCopy = new Task<TResult>[tasks.Length];
for (int i = 0; i < tasks.Length; i++)
@@ -3056,7 +3020,6 @@ namespace System.Threading.Tasks
}
// Throw an exception if "options" argument specifies illegal options
- [ContractArgumentValidatorAttribute]
internal static void CheckMultiTaskContinuationOptions(TaskContinuationOptions continuationOptions)
{
// Construct a mask to check for illegal options
@@ -3088,7 +3051,6 @@ namespace System.Threading.Tasks
// Check that no "fire" options are specified.
if ((continuationOptions & NotOnAny) != 0)
throw new ArgumentOutOfRangeException(nameof(continuationOptions), SR.Task_MultiTaskContinuation_FireOptions);
- Contract.EndContractBlock();
}
}
}
diff --git a/src/mscorlib/src/System/Threading/Tasks/TaskScheduler.cs b/src/mscorlib/src/System/Threading/Tasks/TaskScheduler.cs
index eddaeee9d7..e1fda2530d 100644
--- a/src/mscorlib/src/System/Threading/Tasks/TaskScheduler.cs
+++ b/src/mscorlib/src/System/Threading/Tasks/TaskScheduler.cs
@@ -18,7 +18,6 @@ using System.Globalization;
using System.Threading;
using System.Security;
using System.Collections.Concurrent;
-using System.Diagnostics.Contracts;
using System.Diagnostics;
using System.Runtime.CompilerServices;
@@ -257,7 +256,7 @@ namespace System.Threading.Tasks
/// </summary>
internal void InternalQueueTask(Task task)
{
- Contract.Requires(task != null);
+ Debug.Assert(task != null);
if (TplEtwProvider.Log.IsEnabled())
{
diff --git a/src/mscorlib/src/System/Threading/Tasks/TaskToApm.cs b/src/mscorlib/src/System/Threading/Tasks/TaskToApm.cs
index fdd62c95f5..7e22dfa66d 100644
--- a/src/mscorlib/src/System/Threading/Tasks/TaskToApm.cs
+++ b/src/mscorlib/src/System/Threading/Tasks/TaskToApm.cs
@@ -23,7 +23,6 @@
using System.IO;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Threading.Tasks
{
@@ -42,7 +41,7 @@ namespace System.Threading.Tasks
/// <returns>An IAsyncResult to represent the task's asynchronous operation.</returns>
public static IAsyncResult Begin(Task task, AsyncCallback callback, object state)
{
- Contract.Requires(task != null);
+ Debug.Assert(task != null);
// If the task has already completed, then since the Task's CompletedSynchronously==false
// and we want it to be true, we need to create a new IAsyncResult. (We also need the AsyncState to match.)
@@ -122,9 +121,9 @@ namespace System.Threading.Tasks
/// <param name="asyncResult">The Task used as the IAsyncResult.</param>
private static void InvokeCallbackWhenTaskCompletes(Task antecedent, AsyncCallback callback, IAsyncResult asyncResult)
{
- Contract.Requires(antecedent != null);
- Contract.Requires(callback != null);
- Contract.Requires(asyncResult != null);
+ Debug.Assert(antecedent != null);
+ Debug.Assert(callback != null);
+ Debug.Assert(asyncResult != null);
// We use OnCompleted rather than ContinueWith in order to avoid running synchronously
// if the task has already completed by the time we get here. This is separated out into
@@ -169,8 +168,8 @@ namespace System.Threading.Tasks
/// <param name="completedSynchronously">The new CompletedSynchronously value.</param>
internal TaskWrapperAsyncResult(Task task, object state, bool completedSynchronously)
{
- Contract.Requires(task != null);
- Contract.Requires(!completedSynchronously || task.IsCompleted, "If completedSynchronously is true, the task must be completed.");
+ Debug.Assert(task != null);
+ Debug.Assert(!completedSynchronously || task.IsCompleted, "If completedSynchronously is true, the task must be completed.");
this.Task = task;
m_state = state;
diff --git a/src/mscorlib/src/System/Threading/Tasks/ThreadPoolTaskScheduler.cs b/src/mscorlib/src/System/Threading/Tasks/ThreadPoolTaskScheduler.cs
index e69a89fe66..87d6d7b523 100644
--- a/src/mscorlib/src/System/Threading/Tasks/ThreadPoolTaskScheduler.cs
+++ b/src/mscorlib/src/System/Threading/Tasks/ThreadPoolTaskScheduler.cs
@@ -14,7 +14,6 @@
using System;
using System.Security;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Collections.Generic;
using System.Text;
diff --git a/src/mscorlib/src/System/Threading/Tasks/future.cs b/src/mscorlib/src/System/Threading/Tasks/future.cs
index bf9000ea00..d114f892f0 100644
--- a/src/mscorlib/src/System/Threading/Tasks/future.cs
+++ b/src/mscorlib/src/System/Threading/Tasks/future.cs
@@ -18,7 +18,6 @@ using System.Runtime.ExceptionServices;
using System.Security;
using System.Threading;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
// Disable the "reference to volatile field not treated as volatile" error.
#pragma warning disable 0420
diff --git a/src/mscorlib/src/System/Threading/Thread.cs b/src/mscorlib/src/System/Threading/Thread.cs
index d8ea6410eb..22984d94c5 100644
--- a/src/mscorlib/src/System/Threading/Thread.cs
+++ b/src/mscorlib/src/System/Threading/Thread.cs
@@ -28,7 +28,6 @@ namespace System.Threading
using System.Security;
using System.Runtime.Versioning;
using System.Diagnostics;
- using System.Diagnostics.Contracts;
internal delegate Object InternalCrossContextDelegate(Object[] args);
@@ -166,7 +165,6 @@ namespace System.Threading
{
throw new ArgumentNullException(nameof(start));
}
- Contract.EndContractBlock();
SetStartHelper((Delegate)start, 0); //0 will setup Thread with default stackSize
}
@@ -178,7 +176,6 @@ namespace System.Threading
}
if (0 > maxStackSize)
throw new ArgumentOutOfRangeException(nameof(maxStackSize), SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
SetStartHelper((Delegate)start, maxStackSize);
}
public Thread(ParameterizedThreadStart start)
@@ -187,7 +184,6 @@ namespace System.Threading
{
throw new ArgumentNullException(nameof(start));
}
- Contract.EndContractBlock();
SetStartHelper((Delegate)start, 0);
}
@@ -199,7 +195,6 @@ namespace System.Threading
}
if (0 > maxStackSize)
throw new ArgumentOutOfRangeException(nameof(maxStackSize), SR.ArgumentOutOfRange_NeedNonNegNum);
- Contract.EndContractBlock();
SetStartHelper((Delegate)start, maxStackSize);
}
@@ -354,7 +349,6 @@ namespace System.Threading
{
get
{
- Contract.Ensures(Contract.Result<Thread>() != null);
return GetCurrentThreadNative();
}
}
@@ -439,7 +433,6 @@ namespace System.Threading
{
get
{
- Contract.Ensures(Contract.Result<CultureInfo>() != null);
return CultureInfo.CurrentUICulture;
}
@@ -473,14 +466,11 @@ namespace System.Threading
{
get
{
- Contract.Ensures(Contract.Result<CultureInfo>() != null);
return CultureInfo.CurrentCulture;
}
set
{
- Contract.EndContractBlock();
-
// If you add more pre-conditions to this method, check to see if you also need to
// add them to CultureInfo.DefaultThreadCurrentCulture.set.
@@ -506,8 +496,6 @@ namespace System.Threading
internal static AppDomain GetDomain()
{
- Contract.Ensures(Contract.Result<AppDomain>() != null);
-
AppDomain ad;
ad = GetFastDomainInternal();
diff --git a/src/mscorlib/src/System/Threading/ThreadLocal.cs b/src/mscorlib/src/System/Threading/ThreadLocal.cs
index cdfa2448c0..6c823d5573 100644
--- a/src/mscorlib/src/System/Threading/ThreadLocal.cs
+++ b/src/mscorlib/src/System/Threading/ThreadLocal.cs
@@ -17,7 +17,6 @@
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Threading
{
diff --git a/src/mscorlib/src/System/Threading/ThreadPool.cs b/src/mscorlib/src/System/Threading/ThreadPool.cs
index ec9ceef156..40cb7ea2ae 100644
--- a/src/mscorlib/src/System/Threading/ThreadPool.cs
+++ b/src/mscorlib/src/System/Threading/ThreadPool.cs
@@ -15,7 +15,6 @@ using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
-using System.Diagnostics.Contracts;
using System.Diagnostics.Tracing;
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
@@ -48,12 +47,6 @@ namespace System.Threading
public static WorkStealingQueue[] Queues => _queues;
- // Track whether the WorkStealingQueueList is empty
- // Three states simplifies race conditions. They may be considered.
- // Now Active --> Maybe Inactive -> Confirmed Inactive
- public const int WsqNowActive = 2;
- public static int wsqActive;
-
public static void Add(WorkStealingQueue queue)
{
Debug.Assert(queue != null);
@@ -400,9 +393,6 @@ namespace System.Threading
ThreadPoolWorkQueueThreadLocals.threadLocals ??
(ThreadPoolWorkQueueThreadLocals.threadLocals = new ThreadPoolWorkQueueThreadLocals(this));
- internal bool ThreadRequestNeeded(int count) => (count < ThreadPoolGlobals.processorCount) &&
- (!workItems.IsEmpty || (WorkStealingQueueList.wsqActive > 0));
-
internal void EnsureThreadRequested()
{
//
@@ -413,7 +403,7 @@ namespace System.Threading
// which is handled by RequestWorkerThread.
//
int count = numOutstandingThreadRequests;
- while (ThreadRequestNeeded(count))
+ while (count < ThreadPoolGlobals.processorCount)
{
int prev = Interlocked.CompareExchange(ref numOutstandingThreadRequests, count + 1, count);
if (prev == count)
@@ -425,7 +415,7 @@ namespace System.Threading
}
}
- internal void MarkThreadRequestSatisfied(bool dequeueSuccessful)
+ internal void MarkThreadRequestSatisfied()
{
//
// The VM has called us, so one of our outstanding thread requests has been satisfied.
@@ -434,17 +424,8 @@ namespace System.Threading
// by the time we reach this point.
//
int count = numOutstandingThreadRequests;
-
while (count > 0)
{
- if (dequeueSuccessful && (count == ThreadPoolGlobals.processorCount) && ThreadRequestNeeded(count - 1))
- {
- // If we gated threads due to too many outstanding requests and queue was not empty
- // Request another thread.
- ThreadPool.RequestWorkerThread();
- return;
- }
-
int prev = Interlocked.CompareExchange(ref numOutstandingThreadRequests, count - 1, count);
if (prev == count)
{
@@ -466,18 +447,6 @@ namespace System.Threading
if (null != tl)
{
tl.workStealingQueue.LocalPush(callback);
-
- // We must guarantee wsqActive is set to WsqNowActive after we push
- // The ordering must be global because we rely on other threads
- // observing in this order
- Interlocked.MemoryBarrier();
-
- // We do not want to simply write. We want to prevent unnecessary writes
- // which would invalidate reader's caches
- if (WorkStealingQueueList.wsqActive != WorkStealingQueueList.WsqNowActive)
- {
- Volatile.Write(ref WorkStealingQueueList.wsqActive, WorkStealingQueueList.WsqNowActive);
- }
}
else
{
@@ -495,56 +464,33 @@ namespace System.Threading
public IThreadPoolWorkItem Dequeue(ThreadPoolWorkQueueThreadLocals tl, ref bool missedSteal)
{
+ WorkStealingQueue localWsq = tl.workStealingQueue;
IThreadPoolWorkItem callback;
- int wsqActiveObserved = WorkStealingQueueList.wsqActive;
- if (wsqActiveObserved > 0)
- {
- WorkStealingQueue localWsq = tl.workStealingQueue;
- if ((callback = localWsq.LocalPop()) == null && // first try the local queue
- !workItems.TryDequeue(out callback)) // then try the global queue
+ if ((callback = localWsq.LocalPop()) == null && // first try the local queue
+ !workItems.TryDequeue(out callback)) // then try the global queue
+ {
+ // finally try to steal from another thread's local queue
+ WorkStealingQueue[] queues = WorkStealingQueueList.Queues;
+ int c = queues.Length;
+ Debug.Assert(c > 0, "There must at least be a queue for this thread.");
+ int maxIndex = c - 1;
+ int i = tl.random.Next(c);
+ while (c > 0)
{
- // finally try to steal from another thread's local queue
- WorkStealingQueue[] queues = WorkStealingQueueList.Queues;
- int c = queues.Length;
- Debug.Assert(c > 0, "There must at least be a queue for this thread.");
- int maxIndex = c - 1;
- int i = tl.random.Next(c);
- while (c > 0)
+ i = (i < maxIndex) ? i + 1 : 0;
+ WorkStealingQueue otherQueue = queues[i];
+ if (otherQueue != localWsq && otherQueue.CanSteal)
{
- i = (i < maxIndex) ? i + 1 : 0;
- WorkStealingQueue otherQueue = queues[i];
- if (otherQueue != localWsq && otherQueue.CanSteal)
+ callback = otherQueue.TrySteal(ref missedSteal);
+ if (callback != null)
{
- callback = otherQueue.TrySteal(ref missedSteal);
- if (callback != null)
- {
- break;
- }
+ break;
}
- c--;
- }
- if ((callback == null) && !missedSteal)
- {
- // Only decrement if the value is unchanged since we started looking for work
- // This prevents multiple threads decrementing based on overlapping scans.
- //
- // When we decrement from active, the producer may have inserted a queue item during our scan
- // therefore we cannot transition to empty
- //
- // When we decrement from Maybe Inactive, if the producer inserted a queue item during our scan,
- // the producer must write Active. We may transition to empty briefly if we beat the
- // producer's write, but the producer will then overwrite us before waking threads.
- // So effectively we cannot mark the queue empty when an item is in the queue.
- Interlocked.CompareExchange(ref WorkStealingQueueList.wsqActive, wsqActiveObserved - 1, wsqActiveObserved);
}
+ c--;
}
}
- else
- {
- // We only need to look at the global queue since WorkStealingQueueList is inactive
- workItems.TryDequeue(out callback);
- }
return callback;
}
@@ -558,7 +504,15 @@ namespace System.Threading
//
int quantumStartTime = Environment.TickCount;
- bool markThreadRequestSatisfied = true;
+ //
+ // Update our records to indicate that an outstanding request for a thread has now been fulfilled.
+ // From this point on, we are responsible for requesting another thread if we stop working for any
+ // reason, and we believe there might still be work in the queue.
+ //
+ // Note that if this thread is aborted before we get a chance to request another one, the VM will
+ // record a thread request on our behalf. So we don't need to worry about getting aborted right here.
+ //
+ workQueue.MarkThreadRequestSatisfied();
// Has the desire for logging changed since the last time we entered?
workQueue.loggingEnabled = FrameworkEventSource.Log.IsEnabled(EventLevel.Verbose, FrameworkEventSource.Keywords.ThreadPool | FrameworkEventSource.Keywords.ThreadTransfer);
@@ -607,21 +561,7 @@ namespace System.Threading
// If we found work, there may be more work. Ask for another thread so that the other work can be processed
// in parallel. Note that this will only ask for a max of #procs threads, so it's safe to call it for every dequeue.
//
- if (markThreadRequestSatisfied)
- {
- //
- // Update our records to indicate that an outstanding request for a thread has now been fulfilled
- // and that an item was successfully dispatched and another thread may be needed
- //
- // From this point on, we are responsible for requesting another thread if we stop working for any
- // reason, and we believe there might still be work in the queue.
- //
- // Note that if this thread is aborted before we get a chance to request another one, the VM will
- // record a thread request on our behalf. So we don't need to worry about getting aborted right here.
- //
- workQueue.MarkThreadRequestSatisfied(true);
- markThreadRequestSatisfied = false;
- }
+ workQueue.EnsureThreadRequested();
//
// Execute the workitem outside of any finally blocks, so that it can be aborted if needed.
@@ -676,15 +616,6 @@ namespace System.Threading
}
finally
{
- if (markThreadRequestSatisfied)
- {
- //
- // Update our records to indicate that an outstanding request for a thread has now been fulfilled
- // and that an item was not successfully dispatched. We will request thread below if needed
- //
- workQueue.MarkThreadRequestSatisfied(false);
- }
-
//
// If we are exiting for any reason other than that the queue is definitely empty, ask for another
// thread to pick up where we left off.
@@ -1251,7 +1182,6 @@ namespace System.Threading
{
if (millisecondsTimeOutInterval < -1)
throw new ArgumentOutOfRangeException(nameof(millisecondsTimeOutInterval), SR.ArgumentOutOfRange_NeedNonNegOrNegative1);
- Contract.EndContractBlock();
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return RegisterWaitForSingleObject(waitObject, callBack, state, (UInt32)millisecondsTimeOutInterval, executeOnlyOnce, ref stackMark, true);
}
@@ -1267,7 +1197,6 @@ namespace System.Threading
{
if (millisecondsTimeOutInterval < -1)
throw new ArgumentOutOfRangeException(nameof(millisecondsTimeOutInterval), SR.ArgumentOutOfRange_NeedNonNegOrNegative1);
- Contract.EndContractBlock();
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return RegisterWaitForSingleObject(waitObject, callBack, state, (UInt32)millisecondsTimeOutInterval, executeOnlyOnce, ref stackMark, false);
}
@@ -1283,7 +1212,6 @@ namespace System.Threading
{
if (millisecondsTimeOutInterval < -1)
throw new ArgumentOutOfRangeException(nameof(millisecondsTimeOutInterval), SR.ArgumentOutOfRange_NeedNonNegOrNegative1);
- Contract.EndContractBlock();
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return RegisterWaitForSingleObject(waitObject, callBack, state, (UInt32)millisecondsTimeOutInterval, executeOnlyOnce, ref stackMark, true);
}
@@ -1299,7 +1227,6 @@ namespace System.Threading
{
if (millisecondsTimeOutInterval < -1)
throw new ArgumentOutOfRangeException(nameof(millisecondsTimeOutInterval), SR.ArgumentOutOfRange_NeedNonNegOrNegative1);
- Contract.EndContractBlock();
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return RegisterWaitForSingleObject(waitObject, callBack, state, (UInt32)millisecondsTimeOutInterval, executeOnlyOnce, ref stackMark, false);
}
@@ -1341,9 +1268,12 @@ namespace System.Threading
}
public static bool QueueUserWorkItem(WaitCallback callBack) =>
- QueueUserWorkItem(callBack, null);
+ QueueUserWorkItem(callBack, null, preferLocal: false);
- public static bool QueueUserWorkItem(WaitCallback callBack, object state)
+ public static bool QueueUserWorkItem(WaitCallback callBack, object state) =>
+ QueueUserWorkItem(callBack, state, preferLocal: false);
+
+ public static bool QueueUserWorkItem(WaitCallback callBack, object state, bool preferLocal)
{
if (callBack == null)
{
@@ -1358,7 +1288,7 @@ namespace System.Threading
new QueueUserWorkItemCallbackDefaultContext(callBack, state) :
(IThreadPoolWorkItem)new QueueUserWorkItemCallback(callBack, state, context);
- ThreadPoolGlobals.workQueue.Enqueue(tpcallBack, forceGlobal: true);
+ ThreadPoolGlobals.workQueue.Enqueue(tpcallBack, forceGlobal: !preferLocal);
return true;
}
diff --git a/src/mscorlib/src/System/Threading/Timer.cs b/src/mscorlib/src/System/Threading/Timer.cs
index a5c7945864..918cbd8598 100644
--- a/src/mscorlib/src/System/Threading/Timer.cs
+++ b/src/mscorlib/src/System/Threading/Timer.cs
@@ -14,7 +14,6 @@ namespace System.Threading
using System.Runtime.ConstrainedExecution;
using System.Runtime.Versioning;
using System.Diagnostics;
- using System.Diagnostics.Contracts;
using System.Diagnostics.Tracing;
using Microsoft.Win32.SafeHandles;
@@ -681,7 +680,6 @@ namespace System.Threading
throw new ArgumentOutOfRangeException(nameof(dueTime), SR.ArgumentOutOfRange_NeedNonNegOrNegative1);
if (period < -1)
throw new ArgumentOutOfRangeException(nameof(period), SR.ArgumentOutOfRange_NeedNonNegOrNegative1);
- Contract.EndContractBlock();
TimerSetup(callback, state, (UInt32)dueTime, (UInt32)period);
}
@@ -728,7 +726,6 @@ namespace System.Threading
throw new ArgumentOutOfRangeException(nameof(dueTime), SR.ArgumentOutOfRange_TimeoutTooLarge);
if (period > MAX_SUPPORTED_TIMEOUT)
throw new ArgumentOutOfRangeException(nameof(period), SR.ArgumentOutOfRange_PeriodTooLarge);
- Contract.EndContractBlock();
TimerSetup(callback, state, (UInt32)dueTime, (UInt32)period);
}
@@ -749,7 +746,6 @@ namespace System.Threading
{
if (callback == null)
throw new ArgumentNullException(nameof(TimerCallback));
- Contract.EndContractBlock();
m_timer = new TimerHolder(new TimerQueueTimer(callback, state, dueTime, period));
}
@@ -760,7 +756,6 @@ namespace System.Threading
throw new ArgumentOutOfRangeException(nameof(dueTime), SR.ArgumentOutOfRange_NeedNonNegOrNegative1);
if (period < -1)
throw new ArgumentOutOfRangeException(nameof(period), SR.ArgumentOutOfRange_NeedNonNegOrNegative1);
- Contract.EndContractBlock();
return m_timer.m_timer.Change((UInt32)dueTime, (UInt32)period);
}
@@ -786,7 +781,6 @@ namespace System.Threading
throw new ArgumentOutOfRangeException(nameof(dueTime), SR.ArgumentOutOfRange_TimeoutTooLarge);
if (period > MAX_SUPPORTED_TIMEOUT)
throw new ArgumentOutOfRangeException(nameof(period), SR.ArgumentOutOfRange_PeriodTooLarge);
- Contract.EndContractBlock();
return m_timer.m_timer.Change((UInt32)dueTime, (UInt32)period);
}
@@ -795,7 +789,6 @@ namespace System.Threading
{
if (notifyObject == null)
throw new ArgumentNullException(nameof(notifyObject));
- Contract.EndContractBlock();
return m_timer.Close(notifyObject);
}
diff --git a/src/mscorlib/src/System/Threading/WaitHandle.cs b/src/mscorlib/src/System/Threading/WaitHandle.cs
index d91b488265..125a29ed6c 100644
--- a/src/mscorlib/src/System/Threading/WaitHandle.cs
+++ b/src/mscorlib/src/System/Threading/WaitHandle.cs
@@ -21,7 +21,6 @@ namespace System.Threading
using Microsoft.Win32.SafeHandles;
using System.Runtime.Versioning;
using System.Runtime.ConstrainedExecution;
- using System.Diagnostics.Contracts;
using System.Diagnostics.CodeAnalysis;
using Win32Native = Microsoft.Win32.Win32Native;
@@ -154,7 +153,6 @@ namespace System.Threading
{
throw new ArgumentOutOfRangeException(nameof(millisecondsTimeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1);
}
- Contract.EndContractBlock();
return WaitOne((long)millisecondsTimeout, exitContext);
}
@@ -196,7 +194,6 @@ namespace System.Threading
{
throw new ObjectDisposedException(null, SR.ObjectDisposed_Generic);
}
- Contract.EndContractBlock();
int ret = WaitOneNative(waitableSafeHandle, (uint)millisecondsTimeout, hasThreadAffinity, exitContext);
if (ret == WAIT_ABANDONED)
@@ -214,7 +211,6 @@ namespace System.Threading
{
throw new ObjectDisposedException(null, SR.ObjectDisposed_Generic);
}
- Contract.EndContractBlock();
long timeout = -1;
int ret = WaitOneNative(safeWaitHandle, (uint)timeout, hasThreadAffinity, false);
@@ -267,7 +263,6 @@ namespace System.Threading
{
throw new ArgumentOutOfRangeException(nameof(millisecondsTimeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1);
}
- Contract.EndContractBlock();
WaitHandle[] internalWaitHandles = new WaitHandle[waitHandles.Length];
for (int i = 0; i < waitHandles.Length; i++)
{
@@ -357,7 +352,6 @@ namespace System.Threading
{
throw new ArgumentOutOfRangeException(nameof(millisecondsTimeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1);
}
- Contract.EndContractBlock();
WaitHandle[] internalWaitHandles = new WaitHandle[waitHandles.Length];
for (int i = 0; i < waitHandles.Length; i++)
{
@@ -484,7 +478,6 @@ namespace System.Threading
{
throw new ArgumentOutOfRangeException(nameof(millisecondsTimeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1);
}
- Contract.EndContractBlock();
//NOTE: This API is not supporting Pause/Resume as it's not exposed in CoreCLR (not in WP or SL)
int ret = SignalAndWaitOne(toSignal.safeWaitHandle, toWaitOn.safeWaitHandle, millisecondsTimeout,
diff --git a/src/mscorlib/src/System/ThrowHelper.cs b/src/mscorlib/src/System/ThrowHelper.cs
index 6c5ce05b7f..68eff515f5 100644
--- a/src/mscorlib/src/System/ThrowHelper.cs
+++ b/src/mscorlib/src/System/ThrowHelper.cs
@@ -39,11 +39,9 @@ using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System
{
- [Pure]
internal static class ThrowHelper
{
internal static void ThrowArrayTypeMismatchException()
@@ -432,7 +430,8 @@ namespace System
s,
keyValuePair,
input,
- ownedMemory
+ ownedMemory,
+ pointer
}
//
diff --git a/src/mscorlib/src/System/TimeZoneInfo.AdjustmentRule.cs b/src/mscorlib/src/System/TimeZoneInfo.AdjustmentRule.cs
index 3cab928749..0e949a30ec 100644
--- a/src/mscorlib/src/System/TimeZoneInfo.AdjustmentRule.cs
+++ b/src/mscorlib/src/System/TimeZoneInfo.AdjustmentRule.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Diagnostics.Contracts;
using System.Runtime.Serialization;
namespace System
@@ -185,7 +184,6 @@ namespace System
{
throw new ArgumentException(SR.Argument_DateTimeHasTimeOfDay, nameof(dateEnd));
}
- Contract.EndContractBlock();
}
void IDeserializationCallback.OnDeserialization(object sender)
@@ -210,7 +208,6 @@ namespace System
{
throw new ArgumentNullException(nameof(info));
}
- Contract.EndContractBlock();
info.AddValue("DateStart", _dateStart); // Do not rename (binary serialization)
info.AddValue("DateEnd", _dateEnd); // Do not rename (binary serialization)
diff --git a/src/mscorlib/src/System/TimeZoneInfo.TransitionTime.cs b/src/mscorlib/src/System/TimeZoneInfo.TransitionTime.cs
index 90304c92ea..81c0957f9a 100644
--- a/src/mscorlib/src/System/TimeZoneInfo.TransitionTime.cs
+++ b/src/mscorlib/src/System/TimeZoneInfo.TransitionTime.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Diagnostics.Contracts;
using System.Runtime.Serialization;
namespace System
@@ -31,7 +30,6 @@ namespace System
public bool IsFixedDateRule => _isFixedDateRule;
- [Pure]
public override bool Equals(object obj) =>
obj is TransitionTime && Equals((TransitionTime)obj);
@@ -39,7 +37,6 @@ namespace System
public static bool operator !=(TransitionTime t1, TransitionTime t2) => !t1.Equals(t2);
- [Pure]
public bool Equals(TransitionTime other) =>
_isFixedDateRule == other._isFixedDateRule &&
_timeOfDay == other._timeOfDay &&
@@ -101,7 +98,6 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(dayOfWeek), SR.ArgumentOutOfRange_DayOfWeek);
}
- Contract.EndContractBlock();
timeOfDay.GetDatePart(out int timeOfDayYear, out int timeOfDayMonth, out int timeOfDayDay);
if (timeOfDayYear != 1 || timeOfDayMonth != 1 || timeOfDayDay != 1 || (timeOfDay.Ticks % TimeSpan.TicksPerMillisecond != 0))
@@ -131,7 +127,6 @@ namespace System
{
throw new ArgumentNullException(nameof(info));
}
- Contract.EndContractBlock();
info.AddValue("TimeOfDay", _timeOfDay); // Do not rename (binary serialization)
info.AddValue("Month", _month); // Do not rename (binary serialization)
diff --git a/src/mscorlib/src/System/TimeZoneInfo.Unix.cs b/src/mscorlib/src/System/TimeZoneInfo.Unix.cs
index 921b71cbf7..ba50616098 100644
--- a/src/mscorlib/src/System/TimeZoneInfo.Unix.cs
+++ b/src/mscorlib/src/System/TimeZoneInfo.Unix.cs
@@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Globalization;
using System.IO;
using System.Text;
@@ -1417,7 +1416,6 @@ namespace System
{
throw new ArgumentException(SR.Argument_TimeZoneInfoInvalidTZif, nameof(data));
}
- Contract.EndContractBlock();
UtcOffset = new TimeSpan(0, 0, TZif_ToInt32(data, index + 00));
IsDst = (data[index + 4] != 0);
AbbreviationIndex = data[index + 5];
@@ -1444,7 +1442,6 @@ namespace System
{
throw new ArgumentException("bad data", nameof(data));
}
- Contract.EndContractBlock();
Magic = (uint)TZif_ToInt32(data, index + 00);
diff --git a/src/mscorlib/src/System/TimeZoneInfo.cs b/src/mscorlib/src/System/TimeZoneInfo.cs
index 8d61c98040..f9b5ce872a 100644
--- a/src/mscorlib/src/System/TimeZoneInfo.cs
+++ b/src/mscorlib/src/System/TimeZoneInfo.cs
@@ -5,7 +5,6 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Globalization;
using System.Runtime.Serialization;
using System.Threading;
@@ -168,7 +167,6 @@ namespace System
{
throw new ArgumentException(SR.Argument_DateTimeOffsetIsNotAmbiguous, nameof(dateTimeOffset));
}
- Contract.EndContractBlock();
DateTime adjustedTime = ConvertTime(dateTimeOffset, this).DateTime;
@@ -215,7 +213,6 @@ namespace System
{
throw new ArgumentException(SR.Argument_DateTimeIsNotAmbiguous, nameof(dateTime));
}
- Contract.EndContractBlock();
DateTime adjustedTime;
if (dateTime.Kind == DateTimeKind.Local)
@@ -603,7 +600,6 @@ namespace System
{
throw new ArgumentNullException(nameof(destinationTimeZone));
}
- Contract.EndContractBlock();
// calculate the destination time zone offset
DateTime utcDateTime = dateTimeOffset.UtcDateTime;
@@ -627,7 +623,6 @@ namespace System
{
throw new ArgumentNullException(nameof(destinationTimeZone));
}
- Contract.EndContractBlock();
// Special case to give a way clearing the cache without exposing ClearCachedData()
if (dateTime.Ticks == 0)
@@ -662,7 +657,6 @@ namespace System
{
throw new ArgumentNullException(nameof(destinationTimeZone));
}
- Contract.EndContractBlock();
DateTimeKind sourceKind = cachedData.GetCorrespondingKind(sourceTimeZone);
if (((flags & TimeZoneInfoOptions.NoThrowOnInvalidTime) == 0) && (dateTime.Kind != DateTimeKind.Unspecified) && (dateTime.Kind != sourceKind))
@@ -788,7 +782,6 @@ namespace System
{
throw new ArgumentException(SR.Format(SR.Argument_InvalidSerializedString, source), nameof(source));
}
- Contract.EndContractBlock();
return StringSerializer.GetDeserializedTimeZoneInfo(source);
}
@@ -847,7 +840,6 @@ namespace System
{
throw new ArgumentNullException(nameof(other));
}
- Contract.EndContractBlock();
// check the utcOffset and supportsDaylightSavingTime members
if (_baseUtcOffset != other._baseUtcOffset ||
@@ -1039,7 +1031,6 @@ namespace System
{
throw new ArgumentNullException(nameof(info));
}
- Contract.EndContractBlock();
info.AddValue("Id", _id); // Do not rename (binary serialization)
info.AddValue("DisplayName", _displayName); // Do not rename (binary serialization)
@@ -1929,7 +1920,6 @@ namespace System
/// <summary>
/// Helper function that validates the TimeSpan is within +/- 14.0 hours
/// </summary>
- [Pure]
internal static bool UtcOffsetOutOfRange(TimeSpan offset) =>
offset.TotalHours < -14.0 || offset.TotalHours > 14.0;
@@ -1958,7 +1948,6 @@ namespace System
{
throw new ArgumentException(SR.Argument_TimeSpanHasSeconds, nameof(baseUtcOffset));
}
- Contract.EndContractBlock();
adjustmentRulesSupportDst = false;
diff --git a/src/mscorlib/src/System/Tuple.cs b/src/mscorlib/src/System/Tuple.cs
index 6a8758278c..3381c750d0 100644
--- a/src/mscorlib/src/System/Tuple.cs
+++ b/src/mscorlib/src/System/Tuple.cs
@@ -7,7 +7,6 @@ using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
//
diff --git a/src/mscorlib/src/System/Type.CoreCLR.cs b/src/mscorlib/src/System/Type.CoreCLR.cs
index 23a96fa32f..571f53e473 100644
--- a/src/mscorlib/src/System/Type.CoreCLR.cs
+++ b/src/mscorlib/src/System/Type.CoreCLR.cs
@@ -4,7 +4,6 @@
using System.Reflection;
using System.Runtime.CompilerServices;
-using System.Diagnostics.Contracts;
using StackCrawlMark = System.Threading.StackCrawlMark;
namespace System
@@ -111,7 +110,6 @@ namespace System
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern RuntimeType GetTypeFromHandleUnsafe(IntPtr handle);
- [Pure]
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern Type GetTypeFromHandle(RuntimeTypeHandle handle);
@@ -121,13 +119,11 @@ namespace System
#if FEATURE_COMINTEROP
internal bool IsWindowsRuntimeObject
{
- [Pure]
get { return IsWindowsRuntimeObjectImpl(); }
}
internal bool IsExportedToWindowsRuntime
{
- [Pure]
get { return IsExportedToWindowsRuntimeImpl(); }
}
@@ -156,11 +152,9 @@ namespace System
throw new NotImplementedException();
}
- [Pure]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern bool operator ==(Type left, Type right);
- [Pure]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern bool operator !=(Type left, Type right);
diff --git a/src/mscorlib/src/System/TypeLoadException.cs b/src/mscorlib/src/System/TypeLoadException.cs
index 840d97702b..90541dafef 100644
--- a/src/mscorlib/src/System/TypeLoadException.cs
+++ b/src/mscorlib/src/System/TypeLoadException.cs
@@ -18,7 +18,6 @@ using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
-using System.Diagnostics.Contracts;
namespace System
{
diff --git a/src/mscorlib/src/System/TypeNameParser.cs b/src/mscorlib/src/System/TypeNameParser.cs
index 58bbe6f092..9bd772e574 100644
--- a/src/mscorlib/src/System/TypeNameParser.cs
+++ b/src/mscorlib/src/System/TypeNameParser.cs
@@ -4,7 +4,6 @@
using System;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
using System.IO;
using System.Reflection;
using System.Security;
@@ -75,7 +74,6 @@ namespace System
throw new ArgumentNullException(nameof(typeName));
if (typeName.Length > 0 && typeName[0] == '\0')
throw new ArgumentException(SR.Format_StringZeroLength);
- Contract.EndContractBlock();
Type ret = null;
@@ -192,7 +190,7 @@ namespace System
private static Assembly ResolveAssembly(string asmName, Func<AssemblyName, Assembly> assemblyResolver, bool throwOnError, ref StackCrawlMark stackMark)
{
- Contract.Requires(asmName != null && asmName.Length > 0);
+ Debug.Assert(asmName != null && asmName.Length > 0);
Assembly assembly = null;
@@ -230,7 +228,7 @@ namespace System
private static Type ResolveType(Assembly assembly, string[] names, Func<Assembly, string, bool, Type> typeResolver, bool throwOnError, bool ignoreCase, ref StackCrawlMark stackMark)
{
- Contract.Requires(names != null && names.Length > 0);
+ Debug.Assert(names != null && names.Length > 0);
Type type = null;
diff --git a/src/mscorlib/src/System/TypedReference.cs b/src/mscorlib/src/System/TypedReference.cs
index ca65082158..e29e8808dd 100644
--- a/src/mscorlib/src/System/TypedReference.cs
+++ b/src/mscorlib/src/System/TypedReference.cs
@@ -13,7 +13,6 @@ namespace System
using CultureInfo = System.Globalization.CultureInfo;
using FieldInfo = System.Reflection.FieldInfo;
using System.Runtime.Versioning;
- using System.Diagnostics.Contracts;
[CLSCompliant(false)]
[System.Runtime.Versioning.NonVersionable] // This only applies to field layout
@@ -29,7 +28,6 @@ namespace System
throw new ArgumentNullException(nameof(target));
if (flds == null)
throw new ArgumentNullException(nameof(flds));
- Contract.EndContractBlock();
if (flds.Length == 0)
throw new ArgumentException(SR.Arg_ArrayZeroError);
diff --git a/src/mscorlib/src/System/UIntPtr.cs b/src/mscorlib/src/System/UIntPtr.cs
index 1bed651e6f..d0fe263a32 100644
--- a/src/mscorlib/src/System/UIntPtr.cs
+++ b/src/mscorlib/src/System/UIntPtr.cs
@@ -17,7 +17,6 @@ namespace System
using System.Globalization;
using System.Runtime.Serialization;
using System.Security;
- using System.Diagnostics.Contracts;
[Serializable]
[CLSCompliant(false)]
@@ -70,7 +69,6 @@ namespace System
{
throw new ArgumentNullException(nameof(info));
}
- Contract.EndContractBlock();
info.AddValue("value", (ulong)_value);
}
@@ -116,8 +114,6 @@ namespace System
public unsafe override String ToString()
{
- Contract.Ensures(Contract.Result<String>() != null);
-
#if BIT64
return ((ulong)_value).ToString(CultureInfo.InvariantCulture);
#else // 32
diff --git a/src/mscorlib/src/System/Variant.cs b/src/mscorlib/src/System/Variant.cs
index b468ab2f98..7717fc485f 100644
--- a/src/mscorlib/src/System/Variant.cs
+++ b/src/mscorlib/src/System/Variant.cs
@@ -19,7 +19,6 @@ using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System
{
diff --git a/src/mscorlib/src/System/WeakReference.cs b/src/mscorlib/src/System/WeakReference.cs
index a6a30c1978..bde7586590 100644
--- a/src/mscorlib/src/System/WeakReference.cs
+++ b/src/mscorlib/src/System/WeakReference.cs
@@ -15,7 +15,6 @@ using System.Security;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System
{
@@ -56,7 +55,6 @@ namespace System
{
throw new ArgumentNullException(nameof(info));
}
- Contract.EndContractBlock();
Object target = info.GetValue("TrackedObject", typeof(Object)); // Do not rename (binary serialization)
bool trackResurrection = info.GetBoolean("TrackResurrection"); // Do not rename (binary serialization)
@@ -108,7 +106,6 @@ namespace System
{
throw new ArgumentNullException(nameof(info));
}
- Contract.EndContractBlock();
info.AddValue("TrackedObject", Target, typeof(Object)); // Do not rename (binary serialization)
info.AddValue("TrackResurrection", IsTrackResurrection()); // Do not rename (binary serialization)
}
diff --git a/src/mscorlib/src/System/WeakReferenceOfT.cs b/src/mscorlib/src/System/WeakReferenceOfT.cs
index 7347683e2f..15f6daf07a 100644
--- a/src/mscorlib/src/System/WeakReferenceOfT.cs
+++ b/src/mscorlib/src/System/WeakReferenceOfT.cs
@@ -15,7 +15,6 @@ using System.Security;
using System.Runtime;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
-using System.Diagnostics.Contracts;
namespace System
{
@@ -51,7 +50,6 @@ namespace System
{
throw new ArgumentNullException(nameof(info));
}
- Contract.EndContractBlock();
T target = (T)info.GetValue("TrackedObject", typeof(T)); // Do not rename (binary serialization)
bool trackResurrection = info.GetBoolean("TrackResurrection"); // Do not rename (binary serialization)
@@ -104,7 +102,6 @@ namespace System
{
throw new ArgumentNullException(nameof(info));
}
- Contract.EndContractBlock();
info.AddValue("TrackedObject", this.Target, typeof(T)); // Do not rename (binary serialization)
info.AddValue("TrackResurrection", IsTrackResurrection()); // Do not rename (binary serialization)
diff --git a/src/pal/inc/pal.h b/src/pal/inc/pal.h
index 4ac91db0cf..1a1b6c8625 100644
--- a/src/pal/inc/pal.h
+++ b/src/pal/inc/pal.h
@@ -1467,6 +1467,13 @@ WaitForSingleObject(
PALIMPORT
DWORD
PALAPI
+PAL_WaitForSingleObjectPrioritized(
+ IN HANDLE hHandle,
+ IN DWORD dwMilliseconds);
+
+PALIMPORT
+DWORD
+PALAPI
WaitForSingleObjectEx(
IN HANDLE hHandle,
IN DWORD dwMilliseconds,
@@ -4195,6 +4202,9 @@ InterlockedDecrement(
return __sync_sub_and_fetch(lpAddend, (LONG)1);
}
+#define InterlockedDecrementAcquire InterlockedDecrement
+#define InterlockedDecrementRelease InterlockedDecrement
+
EXTERN_C
PALIMPORT
inline
@@ -4290,39 +4300,8 @@ InterlockedCompareExchange(
Exchange /* The value to be stored */);
}
-EXTERN_C
-PALIMPORT
-inline
-LONG
-PALAPI
-InterlockedCompareExchangeAcquire(
- IN OUT LONG volatile *Destination,
- IN LONG Exchange,
- IN LONG Comperand)
-{
- // TODO: implement the version with only the acquire semantics
- return __sync_val_compare_and_swap(
- Destination, /* The pointer to a variable whose value is to be compared with. */
- Comperand, /* The value to be compared */
- Exchange /* The value to be stored */);
-}
-
-EXTERN_C
-PALIMPORT
-inline
-LONG
-PALAPI
-InterlockedCompareExchangeRelease(
- IN OUT LONG volatile *Destination,
- IN LONG Exchange,
- IN LONG Comperand)
-{
- // TODO: implement the version with only the release semantics
- return __sync_val_compare_and_swap(
- Destination, /* The pointer to a variable whose value is to be compared with. */
- Comperand, /* The value to be compared */
- Exchange /* The value to be stored */);
-}
+#define InterlockedCompareExchangeAcquire InterlockedCompareExchange
+#define InterlockedCompareExchangeRelease InterlockedCompareExchange
// See the 32-bit variant in interlock2.s
EXTERN_C
@@ -4868,6 +4847,15 @@ GetProcessAffinityMask(
OUT PDWORD_PTR lpSystemAffinityMask
);
+PALIMPORT
+BOOL
+PALAPI
+SetThreadIdealProcessorEx(
+ IN HANDLE hThread,
+ IN PPROCESSOR_NUMBER lpIdealProcessor,
+ OUT PPROCESSOR_NUMBER lpPreviousIdealProcessor
+);
+
//
// The types of events that can be logged.
//
diff --git a/src/pal/prebuilt/idl/xclrdata_i.cpp b/src/pal/prebuilt/idl/xclrdata_i.cpp
index 6dd642da4c..349f01108b 100644
--- a/src/pal/prebuilt/idl/xclrdata_i.cpp
+++ b/src/pal/prebuilt/idl/xclrdata_i.cpp
@@ -132,6 +132,9 @@ MIDL_DEFINE_GUID(IID, IID_IXCLRDataExceptionNotification3,0x31201a94,0x4337,0x49
MIDL_DEFINE_GUID(IID, IID_IXCLRDataExceptionNotification4,0xC25E926E,0x5F09,0x4AA2,0xBB,0xAD,0xB7,0xFC,0x7F,0x10,0xCF,0xD7);
+
+MIDL_DEFINE_GUID(IID, IID_IXCLRDataExceptionNotification5,0xe77a39ea,0x3548,0x44d9,0xb1,0x71,0x85,0x69,0xed,0x1a,0x94,0x23);
+
#undef MIDL_DEFINE_GUID
#ifdef __cplusplus
diff --git a/src/pal/prebuilt/inc/xclrdata.h b/src/pal/prebuilt/inc/xclrdata.h
index da7acb34ab..3ce477ec82 100644
--- a/src/pal/prebuilt/inc/xclrdata.h
+++ b/src/pal/prebuilt/inc/xclrdata.h
@@ -7712,6 +7712,185 @@ EXTERN_C const IID IID_IXCLRDataExceptionNotification4;
#endif /* C style interface */
+#ifndef __IXCLRDataExceptionNotification5_INTERFACE_DEFINED__
+#define __IXCLRDataExceptionNotification5_INTERFACE_DEFINED__
+
+/* interface IXCLRDataExceptionNotification5 */
+/* [uuid][local][object] */
+
+
+EXTERN_C const IID IID_IXCLRDataExceptionNotification5;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+
+ MIDL_INTERFACE("e77a39ea-3548-44d9-b171-8569ed1a9423")
+ IXCLRDataExceptionNotification5 : public IXCLRDataExceptionNotification4
+ {
+ public:
+ virtual HRESULT STDMETHODCALLTYPE OnCodeGenerated2(
+ /* [in] */ IXCLRDataMethodInstance *method,
+ /* [in] */ CLRDATA_ADDRESS nativeCodeLocation) = 0;
+
+ };
+
+
+#else /* C style interface */
+
+ typedef struct IXCLRDataExceptionNotification5Vtbl
+ {
+ BEGIN_INTERFACE
+
+ HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
+ IXCLRDataExceptionNotification5 * This,
+ /* [in] */ REFIID riid,
+ /* [annotation][iid_is][out] */
+ _COM_Outptr_ void **ppvObject);
+
+ ULONG ( STDMETHODCALLTYPE *AddRef )(
+ IXCLRDataExceptionNotification5 * This);
+
+ ULONG ( STDMETHODCALLTYPE *Release )(
+ IXCLRDataExceptionNotification5 * This);
+
+ HRESULT ( STDMETHODCALLTYPE *OnCodeGenerated )(
+ IXCLRDataExceptionNotification5 * This,
+ /* [in] */ IXCLRDataMethodInstance *method);
+
+ HRESULT ( STDMETHODCALLTYPE *OnCodeDiscarded )(
+ IXCLRDataExceptionNotification5 * This,
+ /* [in] */ IXCLRDataMethodInstance *method);
+
+ HRESULT ( STDMETHODCALLTYPE *OnProcessExecution )(
+ IXCLRDataExceptionNotification5 * This,
+ /* [in] */ ULONG32 state);
+
+ HRESULT ( STDMETHODCALLTYPE *OnTaskExecution )(
+ IXCLRDataExceptionNotification5 * This,
+ /* [in] */ IXCLRDataTask *task,
+ /* [in] */ ULONG32 state);
+
+ HRESULT ( STDMETHODCALLTYPE *OnModuleLoaded )(
+ IXCLRDataExceptionNotification5 * This,
+ /* [in] */ IXCLRDataModule *mod);
+
+ HRESULT ( STDMETHODCALLTYPE *OnModuleUnloaded )(
+ IXCLRDataExceptionNotification5 * This,
+ /* [in] */ IXCLRDataModule *mod);
+
+ HRESULT ( STDMETHODCALLTYPE *OnTypeLoaded )(
+ IXCLRDataExceptionNotification5 * This,
+ /* [in] */ IXCLRDataTypeInstance *typeInst);
+
+ HRESULT ( STDMETHODCALLTYPE *OnTypeUnloaded )(
+ IXCLRDataExceptionNotification5 * This,
+ /* [in] */ IXCLRDataTypeInstance *typeInst);
+
+ HRESULT ( STDMETHODCALLTYPE *OnAppDomainLoaded )(
+ IXCLRDataExceptionNotification5 * This,
+ /* [in] */ IXCLRDataAppDomain *domain);
+
+ HRESULT ( STDMETHODCALLTYPE *OnAppDomainUnloaded )(
+ IXCLRDataExceptionNotification5 * This,
+ /* [in] */ IXCLRDataAppDomain *domain);
+
+ HRESULT ( STDMETHODCALLTYPE *OnException )(
+ IXCLRDataExceptionNotification5 * This,
+ /* [in] */ IXCLRDataExceptionState *exception);
+
+ HRESULT ( STDMETHODCALLTYPE *OnGcEvent )(
+ IXCLRDataExceptionNotification5 * This,
+ /* [in] */ GcEvtArgs gcEvtArgs);
+
+ HRESULT ( STDMETHODCALLTYPE *ExceptionCatcherEnter )(
+ IXCLRDataExceptionNotification5 * This,
+ /* [in] */ IXCLRDataMethodInstance *catchingMethod,
+ DWORD catcherNativeOffset);
+
+ HRESULT ( STDMETHODCALLTYPE *OnCodeGenerated2 )(
+ IXCLRDataExceptionNotification5 * This,
+ /* [in] */ IXCLRDataMethodInstance *method,
+ /* [in] */ CLRDATA_ADDRESS nativeCodeLocation);
+
+ END_INTERFACE
+ } IXCLRDataExceptionNotification5Vtbl;
+
+ interface IXCLRDataExceptionNotification5
+ {
+ CONST_VTBL struct IXCLRDataExceptionNotification5Vtbl *lpVtbl;
+ };
+
+
+
+#ifdef COBJMACROS
+
+
+#define IXCLRDataExceptionNotification5_QueryInterface(This,riid,ppvObject) \
+ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
+
+#define IXCLRDataExceptionNotification5_AddRef(This) \
+ ( (This)->lpVtbl -> AddRef(This) )
+
+#define IXCLRDataExceptionNotification5_Release(This) \
+ ( (This)->lpVtbl -> Release(This) )
+
+
+#define IXCLRDataExceptionNotification5_OnCodeGenerated(This,method) \
+ ( (This)->lpVtbl -> OnCodeGenerated(This,method) )
+
+#define IXCLRDataExceptionNotification5_OnCodeDiscarded(This,method) \
+ ( (This)->lpVtbl -> OnCodeDiscarded(This,method) )
+
+#define IXCLRDataExceptionNotification5_OnProcessExecution(This,state) \
+ ( (This)->lpVtbl -> OnProcessExecution(This,state) )
+
+#define IXCLRDataExceptionNotification5_OnTaskExecution(This,task,state) \
+ ( (This)->lpVtbl -> OnTaskExecution(This,task,state) )
+
+#define IXCLRDataExceptionNotification5_OnModuleLoaded(This,mod) \
+ ( (This)->lpVtbl -> OnModuleLoaded(This,mod) )
+
+#define IXCLRDataExceptionNotification5_OnModuleUnloaded(This,mod) \
+ ( (This)->lpVtbl -> OnModuleUnloaded(This,mod) )
+
+#define IXCLRDataExceptionNotification5_OnTypeLoaded(This,typeInst) \
+ ( (This)->lpVtbl -> OnTypeLoaded(This,typeInst) )
+
+#define IXCLRDataExceptionNotification5_OnTypeUnloaded(This,typeInst) \
+ ( (This)->lpVtbl -> OnTypeUnloaded(This,typeInst) )
+
+
+#define IXCLRDataExceptionNotification5_OnAppDomainLoaded(This,domain) \
+ ( (This)->lpVtbl -> OnAppDomainLoaded(This,domain) )
+
+#define IXCLRDataExceptionNotification5_OnAppDomainUnloaded(This,domain) \
+ ( (This)->lpVtbl -> OnAppDomainUnloaded(This,domain) )
+
+#define IXCLRDataExceptionNotification5_OnException(This,exception) \
+ ( (This)->lpVtbl -> OnException(This,exception) )
+
+
+#define IXCLRDataExceptionNotification5_OnGcEvent(This,gcEvtArgs) \
+ ( (This)->lpVtbl -> OnGcEvent(This,gcEvtArgs) )
+
+
+#define IXCLRDataExceptionNotification5_ExceptionCatcherEnter(This,catchingMethod,catcherNativeOffset) \
+ ( (This)->lpVtbl -> ExceptionCatcherEnter(This,catchingMethod,catcherNativeOffset) )
+
+
+#define IXCLRDataExceptionNotification5_OnCodeGenerated2(This,method,nativeCodeLocation) \
+ ( (This)->lpVtbl -> OnCodeGenerated2(This,method,nativeCodeLocation) )
+
+#endif /* COBJMACROS */
+
+
+#endif /* C style interface */
+
+
+
+
+#endif /* __IXCLRDataExceptionNotification5_INTERFACE_DEFINED__ */
+
+
#endif /* __IXCLRDataExceptionNotification4_INTERFACE_DEFINED__ */
diff --git a/src/pal/src/file/file.cpp b/src/pal/src/file/file.cpp
index 33316266f9..5db7d10ac5 100644
--- a/src/pal/src/file/file.cpp
+++ b/src/pal/src/file/file.cpp
@@ -3521,6 +3521,9 @@ DWORD FILEGetLastErrorFromErrno( void )
case EIO:
dwRet = ERROR_WRITE_FAULT;
break;
+ case EMFILE:
+ dwRet = ERROR_TOO_MANY_OPEN_FILES;
+ break;
case ERANGE:
dwRet = ERROR_BAD_PATHNAME;
break;
diff --git a/src/pal/src/include/pal/corunix.hpp b/src/pal/src/include/pal/corunix.hpp
index bfdfb6c167..e35c5b056e 100644
--- a/src/pal/src/include/pal/corunix.hpp
+++ b/src/pal/src/include/pal/corunix.hpp
@@ -773,7 +773,8 @@ namespace CorUnix
RegisterWaitingThread(
WaitType eWaitType,
DWORD dwIndex,
- bool fAltertable
+ bool fAltertable,
+ bool fPrioritize
) = 0;
//
diff --git a/src/pal/src/include/pal/synchobjects.hpp b/src/pal/src/include/pal/synchobjects.hpp
index 62f4017492..1ee4f1c57b 100644
--- a/src/pal/src/include/pal/synchobjects.hpp
+++ b/src/pal/src/include/pal/synchobjects.hpp
@@ -40,7 +40,8 @@ namespace CorUnix
CONST HANDLE *lpHandles,
BOOL bWaitAll,
DWORD dwMilliseconds,
- BOOL bAlertable);
+ BOOL bAlertable,
+ BOOL bPrioritize = FALSE);
PAL_ERROR InternalSleepEx(
CPalThread * pthrCurrent,
diff --git a/src/pal/src/init/pal.cpp b/src/pal/src/init/pal.cpp
index 117117a8b0..37c1677f38 100644
--- a/src/pal/src/init/pal.cpp
+++ b/src/pal/src/init/pal.cpp
@@ -1065,6 +1065,14 @@ static BOOL INIT_IncreaseDescriptorLimit(void)
// Set our soft limit for file descriptors to be the same
// as the max limit.
rlp.rlim_cur = rlp.rlim_max;
+#ifdef __APPLE__
+ // Based on compatibility note in setrlimit(2) manpage for OSX,
+ // trim the limit to OPEN_MAX.
+ if (rlp.rlim_cur > OPEN_MAX)
+ {
+ rlp.rlim_cur = OPEN_MAX;
+ }
+#endif
result = setrlimit(RLIMIT_NOFILE, &rlp);
if (result != 0)
{
diff --git a/src/pal/src/numa/numa.cpp b/src/pal/src/numa/numa.cpp
index 91cf6871c1..383fb0e3b0 100644
--- a/src/pal/src/numa/numa.cpp
+++ b/src/pal/src/numa/numa.cpp
@@ -867,3 +867,115 @@ VirtualAllocExNuma(
return result;
}
+
+/*++
+Function:
+ SetThreadIdealProcessorEx
+
+See MSDN doc.
+--*/
+BOOL
+PALAPI
+SetThreadIdealProcessorEx(
+ IN HANDLE hThread,
+ IN PPROCESSOR_NUMBER lpIdealProcessor,
+ OUT PPROCESSOR_NUMBER lpPreviousIdealProcessor)
+{
+ PERF_ENTRY(SetThreadIdealProcessorEx);
+ ENTRY("SetThreadIdealProcessorEx(hThread=%p, lpIdealProcessor=%p)\n", hThread, lpIdealProcessor);
+
+ CPalThread *pCurrentThread = InternalGetCurrentThread();
+ CPalThread *pTargetThread = NULL;
+ IPalObject *pTargetThreadObject = NULL;
+
+ PAL_ERROR palErr =
+ InternalGetThreadDataFromHandle(pCurrentThread, hThread,
+ 0, // THREAD_SET_CONTEXT
+ &pTargetThread, &pTargetThreadObject);
+
+ if (NO_ERROR != palErr)
+ {
+ ERROR("Unable to obtain thread data for handle %p (error %x)!\n", hThread,
+ palErr);
+ return 0;
+ }
+
+ pthread_t thread = pTargetThread->GetPThreadSelf();
+
+#if HAVE_PTHREAD_GETAFFINITY_NP
+ int cpu = -1;
+ if ((lpIdealProcessor->Group < g_groupCount) &&
+ (lpIdealProcessor->Number < MaxCpusPerGroup) &&
+ (lpIdealProcessor->Reserved == 0))
+ {
+ cpu = g_groupAndIndexToCpu[lpIdealProcessor->Group * MaxCpusPerGroup + lpIdealProcessor->Number];
+ }
+
+ if (cpu == -1)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ if (lpPreviousIdealProcessor != NULL)
+ {
+ cpu_set_t prevCpuSet;
+ CPU_ZERO(&prevCpuSet);
+ DWORD prevCpu = GetCurrentProcessorNumber();
+
+ int st = pthread_getaffinity_np(thread, sizeof(cpu_set_t), &prevCpuSet);
+
+ if (st == 0)
+ {
+ for (int i = 0; i < g_possibleCpuCount; i++)
+ {
+ if (CPU_ISSET(i, &prevCpuSet))
+ {
+ prevCpu = i;
+ break;
+ }
+ }
+ }
+
+ _ASSERTE(prevCpu < g_possibleCpuCount);
+ lpPreviousIdealProcessor->Group = g_cpuToAffinity[prevCpu].Group;
+ lpPreviousIdealProcessor->Number = g_cpuToAffinity[prevCpu].Number;
+ lpPreviousIdealProcessor->Reserved = 0;
+ }
+
+ cpu_set_t cpuSet;
+ CPU_ZERO(&cpuSet);
+ CPU_SET(cpu, &cpuSet);
+
+ int st = pthread_setaffinity_np(thread, sizeof(cpu_set_t), &cpuSet);
+
+ if (st != 0)
+ {
+ switch (st)
+ {
+ case EINVAL:
+ // There is no processor in the mask that is allowed to execute the
+ // process
+ SetLastError(ERROR_INVALID_PARAMETER);
+ break;
+ case ESRCH:
+ SetLastError(ERROR_INVALID_HANDLE);
+ break;
+ default:
+ SetLastError(ERROR_GEN_FAILURE);
+ break;
+ }
+ }
+
+ BOOL success = (st == 0);
+
+#else // HAVE_PTHREAD_GETAFFINITY_NP
+ // There is no API to manage thread affinity, so let's ignore the request
+ BOOL success = FALSE;
+#endif // HAVE_PTHREAD_GETAFFINITY_NP
+
+ LOGEXIT("SetThreadIdealProcessorEx returns BOOL %d\n", success);
+ PERF_EXIT(SetThreadIdealProcessorEx);
+
+ return success;
+} \ No newline at end of file
diff --git a/src/pal/src/synchmgr/synchcontrollers.cpp b/src/pal/src/synchmgr/synchcontrollers.cpp
index 68fe429462..6eae9187d9 100644
--- a/src/pal/src/synchmgr/synchcontrollers.cpp
+++ b/src/pal/src/synchmgr/synchcontrollers.cpp
@@ -262,7 +262,8 @@ namespace CorUnix
PAL_ERROR CSynchWaitController::RegisterWaitingThread(
WaitType wtWaitType,
DWORD dwIndex,
- bool fAlertable)
+ bool fAlertable,
+ bool fPrioritize)
{
VALIDATEOBJECT(m_psdSynchData);
@@ -421,12 +422,12 @@ namespace CorUnix
// Add new node to queue
if (fSharedObject)
{
- m_psdSynchData->SharedWaiterEnqueue(shridNewNode);
+ m_psdSynchData->SharedWaiterEnqueue(shridNewNode, fPrioritize);
ptwiWaitInfo->lSharedObjCount += 1;
}
else
{
- m_psdSynchData->WaiterEnqueue(pwtlnNewNode);
+ m_psdSynchData->WaiterEnqueue(pwtlnNewNode, fPrioritize);
}
// Succeeded: update object count
@@ -1821,7 +1822,7 @@ namespace CorUnix
Note: this method must be called while holding the local process
synchronization lock.
--*/
- void CSynchData::WaiterEnqueue(WaitingThreadsListNode * pwtlnNewNode)
+ void CSynchData::WaiterEnqueue(WaitingThreadsListNode * pwtlnNewNode, bool fPrioritize)
{
VALIDATEOBJECT(this);
VALIDATEOBJECT(pwtlnNewNode);
@@ -1833,26 +1834,55 @@ namespace CorUnix
"Trying to add a WaitingThreadsListNode marked as shared "
"as it was a local one\n");
- WaitingThreadsListNode * pwtlnCurrLast = m_ptrWTLTail.ptr;
-
- pwtlnNewNode->ptrNext.ptr = NULL;
- if (NULL == pwtlnCurrLast)
+ if (!fPrioritize)
{
- _ASSERT_MSG(NULL == m_ptrWTLHead.ptr,
- "Corrupted waiting list on local CSynchData @ %p\n",
- this);
+ // Enqueue normally to the end of the queue
+ WaitingThreadsListNode * pwtlnCurrLast = m_ptrWTLTail.ptr;
+
+ pwtlnNewNode->ptrNext.ptr = NULL;
+ if (NULL == pwtlnCurrLast)
+ {
+ _ASSERT_MSG(NULL == m_ptrWTLHead.ptr,
+ "Corrupted waiting list on local CSynchData @ %p\n",
+ this);
- pwtlnNewNode->ptrPrev.ptr = NULL;
- m_ptrWTLHead.ptr = pwtlnNewNode;
- m_ptrWTLTail.ptr = pwtlnNewNode;
+ pwtlnNewNode->ptrPrev.ptr = NULL;
+ m_ptrWTLHead.ptr = pwtlnNewNode;
+ m_ptrWTLTail.ptr = pwtlnNewNode;
+ }
+ else
+ {
+ VALIDATEOBJECT(pwtlnCurrLast);
+
+ pwtlnNewNode->ptrPrev.ptr = pwtlnCurrLast;
+ pwtlnCurrLast->ptrNext.ptr = pwtlnNewNode;
+ m_ptrWTLTail.ptr = pwtlnNewNode;
+ }
}
else
{
- VALIDATEOBJECT(pwtlnCurrLast);
+ // The wait is prioritized, enqueue to the beginning of the queue
+ WaitingThreadsListNode * pwtlnCurrFirst = m_ptrWTLHead.ptr;
+
+ pwtlnNewNode->ptrPrev.ptr = NULL;
+ if (NULL == pwtlnCurrFirst)
+ {
+ _ASSERT_MSG(NULL == m_ptrWTLTail.ptr,
+ "Corrupted waiting list on local CSynchData @ %p\n",
+ this);
+
+ pwtlnNewNode->ptrNext.ptr = NULL;
+ m_ptrWTLHead.ptr = pwtlnNewNode;
+ m_ptrWTLTail.ptr = pwtlnNewNode;
+ }
+ else
+ {
+ VALIDATEOBJECT(pwtlnCurrFirst);
- pwtlnNewNode->ptrPrev.ptr = pwtlnCurrLast;
- pwtlnCurrLast->ptrNext.ptr = pwtlnNewNode;
- m_ptrWTLTail.ptr = pwtlnNewNode;
+ pwtlnNewNode->ptrNext.ptr = pwtlnCurrFirst;
+ pwtlnCurrFirst->ptrPrev.ptr = pwtlnNewNode;
+ m_ptrWTLHead.ptr = pwtlnNewNode;
+ }
}
m_ulcWaitingThreads += 1;
@@ -1872,7 +1902,7 @@ namespace CorUnix
Note: this method must be called while holding both local and shared
synchronization locks.
--*/
- void CSynchData::SharedWaiterEnqueue(SharedID shridNewNode)
+ void CSynchData::SharedWaiterEnqueue(SharedID shridNewNode, bool fPrioritize)
{
VALIDATEOBJECT(this);
@@ -1880,37 +1910,77 @@ namespace CorUnix
"Trying to enqueue a WaitingThreadsListNode as shared "
"on a local object\n");
- SharedID shridCurrLast;
- WaitingThreadsListNode * pwtlnCurrLast, * pwtlnNewNode;
+ if (!fPrioritize)
+ {
+ // Enqueue normally to the end of the queue
+ SharedID shridCurrLast;
+ WaitingThreadsListNode * pwtlnCurrLast, * pwtlnNewNode;
- shridCurrLast = m_ptrWTLTail.shrid;
- pwtlnCurrLast = SharedIDToTypePointer(WaitingThreadsListNode, shridCurrLast);
- pwtlnNewNode = SharedIDToTypePointer(WaitingThreadsListNode, shridNewNode);
+ shridCurrLast = m_ptrWTLTail.shrid;
+ pwtlnCurrLast = SharedIDToTypePointer(WaitingThreadsListNode, shridCurrLast);
+ pwtlnNewNode = SharedIDToTypePointer(WaitingThreadsListNode, shridNewNode);
- _ASSERT_MSG(1 == (WTLN_FLAG_OWNER_OBJECT_IS_SHARED & pwtlnNewNode->dwFlags),
- "Trying to add a WaitingThreadsListNode marked as local "
- "as it was a shared one\n");
+ _ASSERT_MSG(1 == (WTLN_FLAG_OWNER_OBJECT_IS_SHARED & pwtlnNewNode->dwFlags),
+ "Trying to add a WaitingThreadsListNode marked as local "
+ "as it was a shared one\n");
- VALIDATEOBJECT(pwtlnNewNode);
+ VALIDATEOBJECT(pwtlnNewNode);
- pwtlnNewNode->ptrNext.shrid = NULL;
- if (NULL == pwtlnCurrLast)
- {
- _ASSERT_MSG(NULL == m_ptrWTLHead.shrid,
- "Corrupted waiting list on shared CSynchData at "
- "{shrid=%p, p=%p}\n", m_shridThis, this);
+ pwtlnNewNode->ptrNext.shrid = NULL;
+ if (NULL == pwtlnCurrLast)
+ {
+ _ASSERT_MSG(NULL == m_ptrWTLHead.shrid,
+ "Corrupted waiting list on shared CSynchData at "
+ "{shrid=%p, p=%p}\n", m_shridThis, this);
- pwtlnNewNode->ptrPrev.shrid = NULL;
- m_ptrWTLHead.shrid = shridNewNode;
- m_ptrWTLTail.shrid = shridNewNode;
+ pwtlnNewNode->ptrPrev.shrid = NULL;
+ m_ptrWTLHead.shrid = shridNewNode;
+ m_ptrWTLTail.shrid = shridNewNode;
+ }
+ else
+ {
+ VALIDATEOBJECT(pwtlnCurrLast);
+
+ pwtlnNewNode->ptrPrev.shrid = shridCurrLast;
+ pwtlnCurrLast->ptrNext.shrid = shridNewNode;
+ m_ptrWTLTail.shrid = shridNewNode;
+ }
}
else
{
- VALIDATEOBJECT(pwtlnCurrLast);
+ // The wait is prioritized, enqueue to the beginning of the queue
+ SharedID shridCurrFirst;
+ WaitingThreadsListNode * pwtlnCurrFirst, * pwtlnNewNode;
+
+ shridCurrFirst = m_ptrWTLHead.shrid;
+ pwtlnCurrFirst = SharedIDToTypePointer(WaitingThreadsListNode, shridCurrFirst);
+ pwtlnNewNode = SharedIDToTypePointer(WaitingThreadsListNode, shridNewNode);
+
+ _ASSERT_MSG(1 == (WTLN_FLAG_OWNER_OBJECT_IS_SHARED & pwtlnNewNode->dwFlags),
+ "Trying to add a WaitingThreadsListNode marked as local "
+ "as it was a shared one\n");
+
+ VALIDATEOBJECT(pwtlnNewNode);
+
+ pwtlnNewNode->ptrPrev.shrid = NULL;
+ if (NULL == pwtlnCurrFirst)
+ {
+ _ASSERT_MSG(NULL == m_ptrWTLTail.shrid,
+ "Corrupted waiting list on shared CSynchData at "
+ "{shrid=%p, p=%p}\n", m_shridThis, this);
- pwtlnNewNode->ptrPrev.shrid = shridCurrLast;
- pwtlnCurrLast->ptrNext.shrid = shridNewNode;
- m_ptrWTLTail.shrid = shridNewNode;
+ pwtlnNewNode->ptrNext.shrid = NULL;
+ m_ptrWTLHead.shrid = shridNewNode;
+ m_ptrWTLTail.shrid = shridNewNode;
+ }
+ else
+ {
+ VALIDATEOBJECT(pwtlnCurrFirst);
+
+ pwtlnNewNode->ptrNext.shrid = shridCurrFirst;
+ pwtlnCurrFirst->ptrPrev.shrid = shridNewNode;
+ m_ptrWTLHead.shrid = shridNewNode;
+ }
}
m_ulcWaitingThreads += 1;
diff --git a/src/pal/src/synchmgr/synchmanager.cpp b/src/pal/src/synchmgr/synchmanager.cpp
index a683255a3e..048ea3ee7d 100644
--- a/src/pal/src/synchmgr/synchmanager.cpp
+++ b/src/pal/src/synchmgr/synchmanager.cpp
@@ -3867,7 +3867,7 @@ namespace CorUnix
pwtlnNew->shridWaitingState = pwtlnOld->shridWaitingState;
pwtlnNew->ptwiWaitInfo = pwtlnOld->ptwiWaitInfo;
- psdShared->SharedWaiterEnqueue(rgshridWTLNodes[i]);
+ psdShared->SharedWaiterEnqueue(rgshridWTLNodes[i], false);
psdShared->AddRef();
_ASSERTE(pwtlnOld = pwtlnOld->ptwiWaitInfo->rgpWTLNodes[pwtlnOld->dwObjIndex]);
diff --git a/src/pal/src/synchmgr/synchmanager.hpp b/src/pal/src/synchmgr/synchmanager.hpp
index b0cc2e7622..89e1d13568 100644
--- a/src/pal/src/synchmgr/synchmanager.hpp
+++ b/src/pal/src/synchmgr/synchmanager.hpp
@@ -206,8 +206,8 @@ namespace CorUnix
CPalThread * pthrCurrent,
CPalThread * pthrTarget);
- void WaiterEnqueue(WaitingThreadsListNode * pwtlnNewNode);
- void SharedWaiterEnqueue(SharedID shridNewNode);
+ void WaiterEnqueue(WaitingThreadsListNode * pwtlnNewNode, bool fPrioritize);
+ void SharedWaiterEnqueue(SharedID shridNewNode, bool fPrioritize);
// Object Domain accessor methods
ObjectDomain GetObjectDomain(void)
@@ -464,7 +464,8 @@ namespace CorUnix
virtual PAL_ERROR RegisterWaitingThread(
WaitType wtWaitType,
DWORD dwIndex,
- bool fAlertable);
+ bool fAlertable,
+ bool fPrioritize);
virtual void ReleaseController(void);
diff --git a/src/pal/src/synchmgr/wait.cpp b/src/pal/src/synchmgr/wait.cpp
index 8ef65aaa01..fc5bb674db 100644
--- a/src/pal/src/synchmgr/wait.cpp
+++ b/src/pal/src/synchmgr/wait.cpp
@@ -75,6 +75,35 @@ WaitForSingleObject(IN HANDLE hHandle,
/*++
Function:
+ WaitForSingleObjectPrioritized
+
+Similar to WaitForSingleObject, except uses a LIFO release policy for waiting threads by prioritizing new waiters (registering
+them at the beginning of the wait queue rather than at the end).
+--*/
+DWORD
+PALAPI
+PAL_WaitForSingleObjectPrioritized(IN HANDLE hHandle,
+ IN DWORD dwMilliseconds)
+{
+ DWORD dwRet;
+
+ PERF_ENTRY(PAL_WaitForSingleObjectPrioritized);
+ ENTRY("PAL_WaitForSingleObjectPrioritized(hHandle=%p, dwMilliseconds=%u)\n",
+ hHandle, dwMilliseconds);
+
+ CPalThread * pThread = InternalGetCurrentThread();
+
+ dwRet = InternalWaitForMultipleObjectsEx(pThread, 1, &hHandle, FALSE,
+ dwMilliseconds, FALSE, TRUE /* bPrioritize */);
+
+ LOGEXIT("PAL_WaitForSingleObjectPrioritized returns DWORD %u\n", dwRet);
+ PERF_EXIT(PAL_WaitForSingleObjectPrioritized);
+ return dwRet;
+}
+
+
+/*++
+Function:
WaitForSingleObjectEx
See MSDN doc.
@@ -285,7 +314,8 @@ DWORD CorUnix::InternalWaitForMultipleObjectsEx(
CONST HANDLE *lpHandles,
BOOL bWaitAll,
DWORD dwMilliseconds,
- BOOL bAlertable)
+ BOOL bAlertable,
+ BOOL bPrioritize)
{
DWORD dwRet = WAIT_FAILED;
PAL_ERROR palErr = NO_ERROR;
@@ -530,7 +560,8 @@ DWORD CorUnix::InternalWaitForMultipleObjectsEx(
palErr = ppISyncWaitCtrlrs[i]->RegisterWaitingThread(
wtWaitType,
i,
- (TRUE == bAlertable));
+ (TRUE == bAlertable),
+ bPrioritize != FALSE);
if (NO_ERROR != palErr)
{
ERROR("RegisterWaitingThread() failed for %d-th object "
diff --git a/src/scripts/genEventPipe.py b/src/scripts/genEventPipe.py
index 3caa2071fc..8a970794c0 100644
--- a/src/scripts/genEventPipe.py
+++ b/src/scripts/genEventPipe.py
@@ -198,7 +198,7 @@ def generateWriteEventBody(template, providerName, eventName):
}\n\n"""
body = " EventPipe::WriteEvent(*EventPipeEvent" + \
- eventName + ", (BYTE *)buffer, size);\n"
+ eventName + ", (BYTE *)buffer, offset);\n"
footer = """
if (!fixedBuffer)
diff --git a/src/sign.builds b/src/sign.builds
index 831fe668c7..c87e3f877b 100644
--- a/src/sign.builds
+++ b/src/sign.builds
@@ -42,7 +42,7 @@
</Target>
<Target Name="Build"
- Condition="'$(SkipSigning)' != 'true' and '$(SignType)' != 'oss'"
+ Condition="'$(SkipSigning)' != 'true'"
DependsOnTargets="GetFilesToSignItems;SignFiles">
<!-- now that the files have been signed delete the marker files -->
diff --git a/src/vm/amd64/JitHelpers_InlineGetThread.asm b/src/vm/amd64/JitHelpers_InlineGetThread.asm
index 022ec675df..40d63bf729 100644
--- a/src/vm/amd64/JitHelpers_InlineGetThread.asm
+++ b/src/vm/amd64/JitHelpers_InlineGetThread.asm
@@ -305,1010 +305,5 @@ endif ; _DEBUG
LEAF_END JIT_NewArr1OBJ_MP_InlineGetThread, _TEXT
-MON_ENTER_STACK_SIZE equ 00000020h
-MON_EXIT_STACK_SIZE equ 00000068h
-
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
-MON_ENTER_STACK_SIZE_INLINEGETTHREAD equ 00000020h
-MON_EXIT_STACK_SIZE_INLINEGETTHREAD equ 00000068h
-endif
-endif
-
-BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX equ 08000000h ; syncblk.h
-BIT_SBLK_IS_HASHCODE equ 04000000h ; syncblk.h
-BIT_SBLK_SPIN_LOCK equ 10000000h ; syncblk.h
-
-SBLK_MASK_LOCK_THREADID equ 000003FFh ; syncblk.h
-SBLK_LOCK_RECLEVEL_INC equ 00000400h ; syncblk.h
-SBLK_MASK_LOCK_RECLEVEL equ 0000FC00h ; syncblk.h
-
-MASK_SYNCBLOCKINDEX equ 03FFFFFFh ; syncblk.h
-STATE_CHECK equ 0FFFFFFFEh
-
-MT_CTX_PROXY_FLAG equ 10000000h
-
-g_pSyncTable equ ?g_pSyncTable@@3PEAVSyncTableEntry@@EA
-g_SystemInfo equ ?g_SystemInfo@@3U_SYSTEM_INFO@@A
-g_SpinConstants equ ?g_SpinConstants@@3USpinConstants@@A
-
-extern g_pSyncTable:QWORD
-extern g_SystemInfo:QWORD
-extern g_SpinConstants:QWORD
-
-; JITutil_MonEnterWorker(Object* obj, BYTE* pbLockTaken)
-extern JITutil_MonEnterWorker:proc
-; JITutil_MonTryEnter(Object* obj, INT32 timeout, BYTE* pbLockTaken)
-extern JITutil_MonTryEnter:proc
-; JITutil_MonExitWorker(Object* obj, BYTE* pbLockTaken)
-extern JITutil_MonExitWorker:proc
-; JITutil_MonSignal(AwareLock* lock, BYTE* pbLockTaken)
-extern JITutil_MonSignal:proc
-; JITutil_MonContention(AwareLock* lock, BYTE* pbLockTaken)
-extern JITutil_MonContention:proc
-
-ifdef _DEBUG
-MON_DEBUG equ 1
-endif
-
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
-extern EnterSyncHelper:proc
-extern LeaveSyncHelper:proc
-endif
-endif
-
-
-MON_ENTER_EPILOG_ADJUST_STACK macro
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- add rsp, MON_ENTER_STACK_SIZE_INLINEGETTHREAD
-endif
-endif
- endm
-
-
-MON_ENTER_RETURN_SUCCESS macro
- ; This is sensitive to the potential that pbLockTaken is NULL
- test rsi, rsi
- jz @F
- mov byte ptr [rsi], 1
- @@:
- MON_ENTER_EPILOG_ADJUST_STACK
- pop rsi
- ret
-
- endm
-
-
-; The worker versions of these functions are smart about the potential for pbLockTaken
-; to be NULL, and if it is then they treat it as if they don't have a state variable.
-; This is because when locking is not inserted by the JIT (instead by explicit calls to
-; Monitor.Enter() and Monitor.Exit()) we will call these guys.
-;
-; This is a frameless helper for entering a monitor on a object.
-; The object is in ARGUMENT_REG1. This tries the normal case (no
-; blocking or object allocation) in line and calls a framed helper
-; for the other cases.
-;
-; EXTERN_C void JIT_MonEnterWorker_InlineGetThread(Object* obj, /*OUT*/ BYTE* pbLockTaken)
-JIT_HELPER_MONITOR_THUNK JIT_MonEnter, _TEXT
-NESTED_ENTRY JIT_MonEnterWorker_InlineGetThread, _TEXT
- push_nonvol_reg rsi
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- alloc_stack MON_ENTER_STACK_SIZE_INLINEGETTHREAD
-
- save_reg_postrsp rcx, MON_ENTER_STACK_SIZE_INLINEGETTHREAD + 10h + 0h
- save_reg_postrsp rdx, MON_ENTER_STACK_SIZE_INLINEGETTHREAD + 10h + 8h
- save_reg_postrsp r8, MON_ENTER_STACK_SIZE_INLINEGETTHREAD + 10h + 10h
- save_reg_postrsp r9, MON_ENTER_STACK_SIZE_INLINEGETTHREAD + 10h + 18h
-endif
-endif
- END_PROLOGUE
-
- ; Put pbLockTaken in rsi, this can be null
- mov rsi, rdx
-
- ; Check if the instance is NULL
- test rcx, rcx
- jz FramedLockHelper
-
- PATCHABLE_INLINE_GETTHREAD r11, JIT_MonEnterWorker_InlineGetThread_GetThread_PatchLabel
-
- ; Initialize delay value for retry with exponential backoff
- mov r10d, dword ptr [g_SpinConstants + OFFSETOF__g_SpinConstants__dwInitialDuration]
-
- ; Check if we can abort here
- mov eax, dword ptr [r11 + OFFSETOF__Thread__m_State]
- and eax, THREAD_CATCHATSAFEPOINT_BITS
- ; Go through the slow code path to initiate ThreadAbort
- jnz FramedLockHelper
-
- ; r8 will hold the syncblockindex address
- lea r8, [rcx - OFFSETOF__ObjHeader__SyncBlkIndex]
-
- RetryThinLock:
- ; Fetch the syncblock dword
- mov eax, dword ptr [r8]
-
- ; Check whether we have the "thin lock" layout, the lock is free and the spin lock bit is not set
- test eax, BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX + BIT_SBLK_SPIN_LOCK + SBLK_MASK_LOCK_THREADID + SBLK_MASK_LOCK_RECLEVEL
- jnz NeedMoreTests
-
- ; Everything is fine - get the thread id to store in the lock
- mov edx, dword ptr [r11 + OFFSETOF__Thread__m_ThreadId]
-
- ; If the thread id is too large, we need a syncblock for sure
- cmp edx, SBLK_MASK_LOCK_THREADID
- ja FramedLockHelper
-
- ; We want to store a new value with the current thread id set in the low 10 bits
- or edx, eax
- lock cmpxchg dword ptr [r8], edx
- jnz PrepareToWaitThinLock
-
- ; Everything went fine and we're done
- add dword ptr [r11 + OFFSETOF__Thread__m_dwLockCount], 1
-
- ; Done, leave and set pbLockTaken if we have it
- MON_ENTER_RETURN_SUCCESS
-
- NeedMoreTests:
- ; OK, not the simple case, find out which case it is
- test eax, BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX
- jnz HaveHashOrSyncBlockIndex
-
- ; The header is transitioning or the lock, treat this as if the lock was taken
- test eax, BIT_SBLK_SPIN_LOCK
- jnz PrepareToWaitThinLock
-
- ; Here we know we have the "thin lock" layout, but the lock is not free.
- ; It could still be the recursion case, compare the thread id to check
- mov edx, eax
- and edx, SBLK_MASK_LOCK_THREADID
- cmp edx, dword ptr [r11 + OFFSETOF__Thread__m_ThreadId]
- jne PrepareToWaitThinLock
-
- ; Ok, the thread id matches, it's the recursion case.
- ; Bump up the recursion level and check for overflow
- lea edx, [eax + SBLK_LOCK_RECLEVEL_INC]
- test edx, SBLK_MASK_LOCK_RECLEVEL
- jz FramedLockHelper
-
- ; Try to put the new recursion level back. If the header was changed in the meantime
- ; we need a full retry, because the layout could have changed
- lock cmpxchg dword ptr [r8], edx
- jnz RetryHelperThinLock
-
- ; Done, leave and set pbLockTaken if we have it
- MON_ENTER_RETURN_SUCCESS
-
- PrepareToWaitThinLock:
- ; If we are on an MP system, we try spinning for a certain number of iterations
- cmp dword ptr [g_SystemInfo + OFFSETOF__g_SystemInfo__dwNumberOfProcessors], 1
- jle FramedLockHelper
-
- ; Exponential backoff; delay by approximately 2*r10 clock cycles
- mov eax, r10d
- delayLoopThinLock:
- pause ; indicate to the CPU that we are spin waiting
- sub eax, 1
- jnz delayLoopThinLock
-
- ; Next time, wait a factor longer
- imul r10d, dword ptr [g_SpinConstants + OFFSETOF__g_SpinConstants__dwBackoffFactor]
-
- cmp r10d, dword ptr [g_SpinConstants + OFFSETOF__g_SpinConstants__dwMaximumDuration]
- jle RetryHelperThinLock
-
- jmp FramedLockHelper
-
- RetryHelperThinLock:
- jmp RetryThinLock
-
- HaveHashOrSyncBlockIndex:
- ; If we have a hash code already, we need to create a sync block
- test eax, BIT_SBLK_IS_HASHCODE
- jnz FramedLockHelper
-
- ; OK, we have a sync block index, just and out the top bits and grab the synblock index
- and eax, MASK_SYNCBLOCKINDEX
-
- ; Get the sync block pointer
- mov rdx, qword ptr [g_pSyncTable]
- shl eax, 4h
- mov rdx, [rdx + rax + OFFSETOF__SyncTableEntry__m_SyncBlock]
-
- ; Check if the sync block has been allocated
- test rdx, rdx
- jz FramedLockHelper
-
- ; Get a pointer to the lock object
- lea rdx, [rdx + OFFSETOF__SyncBlock__m_Monitor]
-
- ; Attempt to acquire the lock
- RetrySyncBlock:
- mov eax, dword ptr [rdx + OFFSETOF__AwareLock__m_MonitorHeld]
- test eax, eax
- jne HaveWaiters
-
- ; Common case, lock isn't held and there are no waiters. Attempt to
- ; gain ownership ourselves
- xor ecx, ecx
- inc ecx
-
- lock cmpxchg dword ptr [rdx + OFFSETOF__AwareLock__m_MonitorHeld], ecx
- jnz RetryHelperSyncBlock
-
- ; Success. Save the thread object in the lock and increment the use count
- mov qword ptr [rdx + OFFSETOF__AwareLock__m_HoldingThread], r11
- add dword ptr [rdx + OFFSETOF__AwareLock__m_Recursion], 1
- add dword ptr [r11 + OFFSETOF__Thread__m_dwLockCount], 1
-
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- mov rcx, [rsp + MON_ENTER_STACK_SIZE_INLINEGETTHREAD + 8h] ; return address
- ; void EnterSyncHelper(UINT_PTR caller, AwareLock* lock)
- call EnterSyncHelper
-endif
-endif
-
- ; Done, leave and set pbLockTaken if we have it
- MON_ENTER_RETURN_SUCCESS
-
- ; It's possible to get here with waiters by no lock held, but in this
- ; case a signal is about to be fired which will wake up the waiter. So
- ; for fairness sake we should wait too.
- ; Check first for recur11ve lock attempts on the same thread.
- HaveWaiters:
- ; Is mutex already owned by current thread?
- cmp [rdx + OFFSETOF__AwareLock__m_HoldingThread], r11
- jne PrepareToWait
-
- ; Yes, bump our use count.
- add dword ptr [rdx + OFFSETOF__AwareLock__m_Recursion], 1
-
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- mov rcx, [rsp + MON_ENTER_STACK_SIZE_INLINEGETTHREAD + 8h] ; return address
- ; void EnterSyncHelper(UINT_PTR caller, AwareLock* lock)
- call EnterSyncHelper
-endif
-endif
- ; Done, leave and set pbLockTaken if we have it
- MON_ENTER_RETURN_SUCCESS
-
- PrepareToWait:
- ; If we are on a MP system we try spinning for a certain number of iterations
- cmp dword ptr [g_SystemInfo + OFFSETOF__g_SystemInfo__dwNumberOfProcessors], 1
- jle HaveWaiters1
-
- ; Exponential backoff: delay by approximately 2*r10 clock cycles
- mov eax, r10d
- delayLoop:
- pause ; indicate to the CPU that we are spin waiting
- sub eax, 1
- jnz delayLoop
-
- ; Next time, wait a factor longer
- imul r10d, dword ptr [g_SpinConstants + OFFSETOF__g_SpinConstants__dwBackoffFactor]
-
- cmp r10d, dword ptr [g_SpinConstants + OFFSETOF__g_SpinConstants__dwMaximumDuration]
- jle RetrySyncBlock
-
- HaveWaiters1:
- mov rcx, rdx
- mov rdx, rsi
- MON_ENTER_EPILOG_ADJUST_STACK
- pop rsi
- ; void JITutil_MonContention(AwareLock* lock, BYTE* pbLockTaken)
- jmp JITutil_MonContention
-
- RetryHelperSyncBlock:
- jmp RetrySyncBlock
-
- FramedLockHelper:
- mov rdx, rsi
- MON_ENTER_EPILOG_ADJUST_STACK
- pop rsi
- ; void JITutil_MonEnterWorker(Object* obj, BYTE* pbLockTaken)
- jmp JITutil_MonEnterWorker
-
-NESTED_END JIT_MonEnterWorker_InlineGetThread, _TEXT
-
-
-MON_EXIT_EPILOG_ADJUST_STACK macro
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- add rsp, MON_EXIT_STACK_SIZE_INLINEGETTHREAD
-endif
-endif
- endm
-
-MON_EXIT_RETURN_SUCCESS macro
- ; This is sensitive to the potential that pbLockTaken is null
- test r10, r10
- jz @F
- mov byte ptr [r10], 0
- @@:
- MON_EXIT_EPILOG_ADJUST_STACK
- ret
-
- endm
-
-
-; The worker versions of these functions are smart about the potential for pbLockTaken
-; to be NULL, and if it is then they treat it as if they don't have a state variable.
-; This is because when locking is not inserted by the JIT (instead by explicit calls to
-; Monitor.Enter() and Monitor.Exit()) we will call these guys.
-;
-; This is a frameless helper for exiting a monitor on a object.
-; The object is in ARGUMENT_REG1. This tries the normal case (no
-; blocking or object allocation) in line and calls a framed helper
-; for the other cases.
-;
-; void JIT_MonExitWorker_InlineGetThread(Object* obj, BYTE* pbLockTaken)
-JIT_HELPER_MONITOR_THUNK JIT_MonExit, _TEXT
-NESTED_ENTRY JIT_MonExitWorker_InlineGetThread, _TEXT
- .savereg rcx, 0
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- alloc_stack MON_EXIT_STACK_SIZE_INLINEGETTHREAD
-
- save_reg_postrsp rcx, MON_EXIT_STACK_SIZE_INLINEGETTHREAD + 8h + 0h
- save_reg_postrsp rdx, MON_EXIT_STACK_SIZE_INLINEGETTHREAD + 8h + 8h
- save_reg_postrsp r8, MON_EXIT_STACK_SIZE_INLINEGETTHREAD + 8h + 10h
- save_reg_postrsp r9, MON_EXIT_STACK_SIZE_INLINEGETTHREAD + 8h + 18h
-endif
-endif
- END_PROLOGUE
-
- ; pbLockTaken is stored in r10, this can be null
- mov r10, rdx
-
- ; if pbLockTaken is NULL then we got here without a state variable, avoid the
- ; next comparison in that case as it will AV
- test rdx, rdx
- jz Null_pbLockTaken
-
- ; If the lock wasn't taken then we bail quickly without doing anything
- cmp byte ptr [rdx], 0
- je LockNotTaken
-
- Null_pbLockTaken:
- ; Check is the instance is null
- test rcx, rcx
- jz FramedLockHelper
-
- PATCHABLE_INLINE_GETTHREAD r11, JIT_MonExitWorker_InlineGetThread_GetThread_PatchLabel
-
- ; r8 will hold the syncblockindex address
- lea r8, [rcx - OFFSETOF__ObjHeader__SyncBlkIndex]
-
- RetryThinLock:
- ; Fetch the syncblock dword
- mov eax, dword ptr [r8]
- test eax, BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX + BIT_SBLK_SPIN_LOCK
- jnz NeedMoreTests
-
- ; Ok, we have a "thin lock" layout - check whether the thread id matches
- mov edx, eax
- and edx, SBLK_MASK_LOCK_THREADID
- cmp edx, dword ptr [r11 + OFFSETOF__Thread__m_ThreadId]
- jne FramedLockHelper
-
- ; check the recursion level
- test eax, SBLK_MASK_LOCK_RECLEVEL
- jne DecRecursionLevel
-
- ; It's zero -- we're leaving the lock.
- ; So try to put back a zero thread id.
- ; edx and eax match in the thread id bits, and edx is zero else where, so the xor is sufficient
- xor edx, eax
- lock cmpxchg dword ptr [r8], edx
- jnz RetryThinLockHelper1 ; forward jump to avoid mispredict on success
-
- ; Dec the dwLockCount on the thread
- sub dword ptr [r11 + OFFSETOF__Thread__m_dwLockCount], 1
-
- ; Done, leave and set pbLockTaken if we have it
- MON_EXIT_RETURN_SUCCESS
-
- RetryThinLockHelper1:
- jmp RetryThinLock
-
- DecRecursionLevel:
- lea edx, [eax - SBLK_LOCK_RECLEVEL_INC]
- lock cmpxchg dword ptr [r8], edx
- jnz RetryThinLockHelper2 ; forward jump to avoid mispredict on success
-
- ; We're done, leave and set pbLockTaken if we have it
- MON_EXIT_RETURN_SUCCESS
-
- RetryThinLockHelper2:
- jmp RetryThinLock
-
- NeedMoreTests:
- ; Forward all special cases to the slow helper
- test eax, BIT_SBLK_IS_HASHCODE + BIT_SBLK_SPIN_LOCK
- jnz FramedLockHelper
-
- ; Get the sync block index and use it to compute the sync block pointer
- mov rdx, qword ptr [g_pSyncTable]
- and eax, MASK_SYNCBLOCKINDEX
- shl eax, 4
- mov rdx, [rdx + rax + OFFSETOF__SyncTableEntry__m_SyncBlock]
-
- ; Was there a sync block?
- test rdx, rdx
- jz FramedLockHelper
-
- ; Get a pointer to the lock object.
- lea rdx, [rdx + OFFSETOF__SyncBlock__m_Monitor]
-
- ; Check if the lock is held.
- cmp qword ptr [rdx + OFFSETOF__AwareLock__m_HoldingThread], r11
- jne FramedLockHelper
-
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- mov [rsp + 28h], rcx
- mov [rsp + 30h], rdx
- mov [rsp + 38h], r10
- mov [rsp + 40h], r11
-
- mov rcx, [rsp + MON_EXIT_STACK_SIZE_INLINEGETTHREAD ] ; return address
- ; void LeaveSyncHelper(UINT_PTR caller, AwareLock* lock)
- call LeaveSyncHelper
-
- mov rcx, [rsp + 28h]
- mov rdx, [rsp + 30h]
- mov r10, [rsp + 38h]
- mov r11, [rsp + 40h]
-endif
-endif
-
- ; Reduce our recursion count
- sub dword ptr [rdx + OFFSETOF__AwareLock__m_Recursion], 1
- jz LastRecursion
-
- ; Done, leave and set pbLockTaken if we have it
- MON_EXIT_RETURN_SUCCESS
-
- RetryHelperThinLock:
- jmp RetryThinLock
-
- FramedLockHelper:
- mov rdx, r10
- MON_EXIT_EPILOG_ADJUST_STACK
- ; void JITutil_MonExitWorker(Object* obj, BYTE* pbLockTaken)
- jmp JITutil_MonExitWorker
-
- LastRecursion:
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- mov rax, [rdx + OFFSETOF__AwareLock__m_HoldingThread]
-endif
-endif
-
- sub dword ptr [r11 + OFFSETOF__Thread__m_dwLockCount], 1
- mov qword ptr [rdx + OFFSETOF__AwareLock__m_HoldingThread], 0
-
- Retry:
- mov eax, dword ptr [rdx + OFFSETOF__AwareLock__m_MonitorHeld]
- lea r9d, [eax - 1]
- lock cmpxchg dword ptr [rdx + OFFSETOF__AwareLock__m_MonitorHeld], r9d
- jne RetryHelper
-
- test eax, STATE_CHECK
- jne MustSignal
-
- ; Done, leave and set pbLockTaken if we have it
- MON_EXIT_RETURN_SUCCESS
-
- MustSignal:
- mov rcx, rdx
- mov rdx, r10
- MON_EXIT_EPILOG_ADJUST_STACK
- ; void JITutil_MonSignal(AwareLock* lock, BYTE* pbLockTaken)
- jmp JITutil_MonSignal
-
- RetryHelper:
- jmp Retry
-
- LockNotTaken:
- MON_EXIT_EPILOG_ADJUST_STACK
- REPRET
-NESTED_END JIT_MonExitWorker_InlineGetThread, _TEXT
-
-
-; This is a frameless helper for trying to enter a monitor on a object.
-; The object is in ARGUMENT_REG1 and a timeout in ARGUMENT_REG2. This tries the
-; normal case (no object allocation) in line and calls a framed helper for the
-; other cases.
-;
-; void JIT_MonTryEnter_InlineGetThread(Object* obj, INT32 timeOut, BYTE* pbLockTaken)
-NESTED_ENTRY JIT_MonTryEnter_InlineGetThread, _TEXT
- ; save rcx, rdx (timeout) in the shadow space
- .savereg rcx, 8h
- mov [rsp + 8h], rcx
- .savereg rdx, 10h
- mov [rsp + 10h], rdx
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- alloc_stack MON_ENTER_STACK_SIZE_INLINEGETTHREAD
-
-; rcx has already been saved
-; save_reg_postrsp rcx, MON_ENTER_STACK_SIZE_INLINEGETTHREAD + 8h + 0h
-; rdx has already been saved
-; save_reg_postrsp rdx, MON_ENTER_STACK_SIZE + 8h + 8h
- save_reg_postrsp r8, MON_ENTER_STACK_SIZE_INLINEGETTHREAD + 8h + 10h
- save_reg_postrsp r9, MON_ENTER_STACK_SIZE_INLINEGETTHREAD + 8h + 18h
-endif
-endif
- END_PROLOGUE
-
- ; Check if the instance is NULL
- test rcx, rcx
- jz FramedLockHelper
-
- ; Check if the timeout looks valid
- cmp edx, -1
- jl FramedLockHelper
-
- PATCHABLE_INLINE_GETTHREAD r11, JIT_MonTryEnter_GetThread_PatchLabel
-
- ; Initialize delay value for retry with exponential backoff
- mov r10d, dword ptr [g_SpinConstants + OFFSETOF__g_SpinConstants__dwInitialDuration]
-
- ; Check if we can abort here
- mov eax, dword ptr [r11 + OFFSETOF__Thread__m_State]
- and eax, THREAD_CATCHATSAFEPOINT_BITS
- ; Go through the slow code path to initiate THreadAbort
- jnz FramedLockHelper
-
- ; r9 will hold the syncblockindex address
- lea r9, [rcx - OFFSETOF__ObjHeader__SyncBlkIndex]
-
- RetryThinLock:
- ; Fetch the syncblock dword
- mov eax, dword ptr [r9]
-
- ; Check whether we have the "thin lock" layout, the lock is free and the spin lock bit is not set
- test eax, BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX + BIT_SBLK_SPIN_LOCK + SBLK_MASK_LOCK_THREADID + SBLK_MASK_LOCK_RECLEVEL
- jne NeedMoreTests
-
- ; Everything is fine - get the thread id to store in the lock
- mov edx, dword ptr [r11 + OFFSETOF__Thread__m_ThreadId]
-
- ; If the thread id is too large, we need a syncblock for sure
- cmp edx, SBLK_MASK_LOCK_THREADID
- ja FramedLockHelper
-
- ; We want to store a new value with the current thread id set in the low 10 bits
- or edx, eax
- lock cmpxchg dword ptr [r9], edx
- jnz RetryHelperThinLock
-
- ; Got the lock, everything is fine
- add dword ptr [r11 + OFFSETOF__Thread__m_dwLockCount], 1
- ; Return TRUE
- mov byte ptr [r8], 1
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- add rsp, MON_ENTER_STACK_SIZE_INLINEGETTHREAD
-endif
-endif
- ret
-
- NeedMoreTests:
- ; OK, not the simple case, find out which case it is
- test eax, BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX
- jnz HaveHashOrSyncBlockIndex
-
- ; The header is transitioning or the lock
- test eax, BIT_SBLK_SPIN_LOCK
- jnz RetryHelperThinLock
-
- ; Here we know we have the "thin lock" layout, but the lock is not free.
- ; It could still be the recursion case, compare the thread id to check
- mov edx, eax
- and edx, SBLK_MASK_LOCK_THREADID
- cmp edx, dword ptr [r11 + OFFSETOF__Thread__m_ThreadId]
- jne PrepareToWaitThinLock
-
- ; Ok, the thread id matches, it's the recursion case.
- ; Dump up the recursion level and check for overflow
- lea edx, [eax + SBLK_LOCK_RECLEVEL_INC]
- test edx, SBLK_MASK_LOCK_RECLEVEL
- jz FramedLockHelper
-
- ; Try to put the new recursion level back. If the header was changed in the meantime
- ; we need a full retry, because the layout could have changed
- lock cmpxchg dword ptr [r9], edx
- jnz RetryHelperThinLock
-
- ; Everything went fine and we're done, return TRUE
- mov byte ptr [r8], 1
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- add rsp, MON_ENTER_STACK_SIZE_INLINEGETTHREAD
-endif
-endif
- ret
-
- PrepareToWaitThinLock:
- ; Return failure if timeout is zero
- cmp dword ptr [rsp + 10h], 0
- je TimeoutZero
-
- ; If we are on an MP system, we try spinning for a certain number of iterations
- cmp dword ptr [g_SystemInfo + OFFSETOF__g_SystemInfo__dwNumberOfProcessors], 1
- jle FramedLockHelper
-
- ; Exponential backoff; delay by approximately 2*r10d clock cycles
- mov eax, r10d
- DelayLoopThinLock:
- pause ; indicate to the CPU that we are spin waiting
- sub eax, 1
- jnz DelayLoopThinLock
-
- ; Next time, wait a factor longer
- imul r10d, dword ptr [g_SpinConstants + OFFSETOF__g_SpinConstants__dwBackoffFactor]
-
- cmp r10d, dword ptr [g_SpinConstants + OFFSETOF__g_SpinConstants__dwMaximumDuration]
- jle RetryHelperThinLock
-
- jmp FramedLockHelper
-
- RetryHelperThinLock:
- jmp RetryThinLock
-
- TimeoutZero:
- ; Did not acquire, return FALSE
- mov byte ptr [r8], 0
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- add rsp, MON_ENTER_STACK_SIZE_INLINEGETTHREAD
-endif
-endif
- ret
-
- HaveHashOrSyncBlockIndex:
- ; If we have a hash code already, we need to create a sync block
- test eax, BIT_SBLK_IS_HASHCODE
- jnz FramedLockHelper
-
- ; OK, we have a sync block index, just and out the top bits and grab the synblock index
- and eax, MASK_SYNCBLOCKINDEX
-
- ; Get the sync block pointer
- mov rdx, qword ptr [g_pSyncTable]
- shl eax, 4
- mov rdx, [rdx + rax + OFFSETOF__SyncTableEntry__m_SyncBlock]
-
- ; Check if the sync block has been allocated
- test rdx, rdx
- jz FramedLockHelper
-
- ; Get a pointer to the lock object
- lea rdx, [rdx + OFFSETOF__SyncBlock__m_Monitor]
-
- RetrySyncBlock:
- ; Attempt to acuire the lock
- mov eax, dword ptr [rdx + OFFSETOF__AwareLock__m_MonitorHeld]
- test eax, eax
- jne HaveWaiters
-
- ; Common case, lock isn't held and there are no waiters. Attempt to
- ; gain ownership ourselves
- xor ecx, ecx
- inc ecx
- lock cmpxchg dword ptr [rdx + OFFSETOF__AwareLock__m_MonitorHeld], ecx
- jnz RetryHelperSyncBlock
-
- ; Success. Save the thread object in the lock and increment the use count
- mov qword ptr [rdx + OFFSETOF__AwareLock__m_HoldingThread], r11
- add dword ptr [rdx + OFFSETOF__AwareLock__m_Recursion], 1
- add dword ptr [r11 + OFFSETOF__Thread__m_dwLockCount], 1
-
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- mov rcx, [rsp + MON_ENTER_STACK_SIZE_INLINEGETTHREAD] ; return address
- ; void EnterSyncHelper(UINT_PTR caller, AwareLock* lock)
- call EnterSyncHelper
-endif
-endif
-
- ; Return TRUE
- mov byte ptr [r8], 1
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- add rsp, MON_ENTER_STACK_SIZE_INLINEGETTHREAD
-endif
-endif
- ret
-
- ; It's possible to get here with waiters by no lock held, but in this
- ; case a signal is about to be fired which will wake up the waiter. So
- ; for fairness sake we should wait too.
- ; Check first for recur11ve lock attempts on the same thread.
- HaveWaiters:
- ; Is mutex already owned by current thread?
- cmp [rdx + OFFSETOF__AwareLock__m_HoldingThread], r11
- jne PrepareToWait
-
- ; Yes, bump our use count.
- add dword ptr [rdx + OFFSETOF__AwareLock__m_Recursion], 1
-
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- mov rcx, [rsp + MON_ENTER_STACK_SIZE_INLINEGETTHREAD] ; return address
- ; void EnterSyncHelper(UINT_PTR caller, AwareLock* lock)
- call EnterSyncHelper
-endif
-endif
-
- ; Return TRUE
- mov byte ptr [r8], 1
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- add rsp, MON_ENTER_STACK_SIZE_INLINEGETTHREAD
-endif
-endif
- ret
-
- PrepareToWait:
- ; Return failure if timeout is zero
- cmp dword ptr [rsp + 10h], 0
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- ; if we are using the _DEBUG stuff then rsp has been adjusted
- ; so compare the value at the adjusted position
- ; there's really little harm in the extra stack read
- cmp dword ptr [rsp + MON_ENTER_STACK_SIZE_INLINEGETTHREAD + 10h]
-endif
-endif
- je TimeoutZero
-
- ; If we are on an MP system, we try spinning for a certain number of iterations
- cmp dword ptr [g_SystemInfo + OFFSETOF__g_SystemInfo__dwNumberOfProcessors], 1
- jle Block
-
- ; Exponential backoff; delay by approximately 2*r10d clock cycles
- mov eax, r10d
- DelayLoop:
- pause ; indicate to the CPU that we are spin waiting
- sub eax, 1
- jnz DelayLoop
-
- ; Next time, wait a factor longer
- imul r10d, dword ptr [g_SpinConstants + OFFSETOF__g_SpinConstants__dwBackoffFactor]
-
- cmp r10d, dword ptr [g_SpinConstants + OFFSETOF__g_SpinConstants__dwMaximumDuration]
- jle RetrySyncBlock
-
- jmp Block
-
- RetryHelperSyncBlock:
- jmp RetrySyncBlock
-
- Block:
- ; In the Block case we've trashed RCX, restore it
- mov rcx, [rsp + 8h]
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- ; if we're tracking this stuff then rcx is at a different offset to RSP, we just
- ; overwrite the wrong value which we just got... this is for debug purposes only
- ; so there's really no performance issue here
- mov rcx, [rsp + MON_ENTER_STACK_SIZE_INLINEGETTHREAD + 8h]
-endif
-endif
- FramedLockHelper:
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- add rsp, MON_ENTER_STACK_SIZE_INLINEGETTHREAD
-endif
-endif
- mov rdx, [rsp + 10h]
- ; void JITutil_MonTryEnter(Object* obj, INT32 timeout)
- jmp JITutil_MonTryEnter
-
-NESTED_END JIT_MonTryEnter_InlineGetThread, _TEXT
-
-
-MON_ENTER_STATIC_RETURN_SUCCESS macro
- ; pbLockTaken is never null for static helpers
- test rdx, rdx
- mov byte ptr [rdx], 1
- REPRET
-
- endm
-
-MON_EXIT_STATIC_RETURN_SUCCESS macro
- ; pbLockTaken is never null for static helpers
- mov byte ptr [rdx], 0
- REPRET
-
- endm
-
-
-; This is a frameless helper for entering a static monitor on a class.
-; The methoddesc is in ARGUMENT_REG1. This tries the normal case (no
-; blocking or object allocation) in line and calls a framed helper
-; for the other cases.
-;
-; void JIT_MonEnterStatic_InlineGetThread(AwareLock *lock, BYTE *pbLockTaken)
-NESTED_ENTRY JIT_MonEnterStatic_InlineGetThread, _TEXT
- .savereg rcx, 0
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- alloc_stack MIN_SIZE
- save_reg_postrsp rcx, MIN_SIZE + 8h + 0h
-endif
-endif
- END_PROLOGUE
-
- ; Attempt to acquire the lock
- Retry:
- mov eax, dword ptr [rcx + OFFSETOF__AwareLock__m_MonitorHeld]
- test eax, eax
- jne HaveWaiters
-
- ; Common case; lock isn't held and there are no waiters. Attempt to
- ; gain ownership by ourselves.
- mov r10d, 1
-
- lock cmpxchg dword ptr [rcx + OFFSETOF__AwareLock__m_MonitorHeld], r10d
- jnz RetryHelper
-
- PATCHABLE_INLINE_GETTHREAD rax, JIT_MonEnterStaticWorker_InlineGetThread_GetThread_PatchLabel_1
-
- mov qword ptr [rcx + OFFSETOF__AwareLock__m_HoldingThread], rax
- add dword ptr [rcx + OFFSETOF__AwareLock__m_Recursion], 1
- add dword ptr [rax + OFFSETOF__Thread__m_dwLockCount], 1
-
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- mov rdx, rcx
- mov rcx, [rsp]
- add rsp, MIN_SIZE
- ; void EnterSyncHelper(UINT_PTR caller, AwareLock* lock)
- jmp EnterSyncHelper
-endif
-endif
- MON_ENTER_STATIC_RETURN_SUCCESS
-
- ; It's possible to get here with waiters by with no lock held, in this
- ; case a signal is about to be fired which will wake up a waiter. So
- ; for fairness sake we should wait too.
- ; Check first for recursive lock attempts on the same thread.
- HaveWaiters:
- PATCHABLE_INLINE_GETTHREAD rax, JIT_MonEnterStaticWorker_InlineGetThread_GetThread_PatchLabel_2
-
- ; Is mutex alread owned by current thread?
- cmp [rcx + OFFSETOF__AwareLock__m_HoldingThread], rax
- jne PrepareToWait
-
- ; Yes, bump our use count.
- add dword ptr [rcx + OFFSETOF__AwareLock__m_Recursion], 1
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- mov rdx, rcx
- mov rcx, [rsp + MIN_SIZE]
- add rsp, MIN_SIZE
- ; void EnterSyncHelper(UINT_PTR caller, AwareLock* lock)
- jmp EnterSyncHelper
-endif
-endif
- ret
-
- PrepareToWait:
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- add rsp, MIN_SIZE
-endif
-endif
- ; void JITutil_MonContention(AwareLock* obj, BYTE* pbLockTaken)
- jmp JITutil_MonContention
-
- RetryHelper:
- jmp Retry
-NESTED_END JIT_MonEnterStatic_InlineGetThread, _TEXT
-
-; A frameless helper for exiting a static monitor on a class.
-; The methoddesc is in ARGUMENT_REG1. This tries the normal case (no
-; blocking or object allocation) in line and calls a framed helper
-; for the other cases.
-;
-; void JIT_MonExitStatic_InlineGetThread(AwareLock *lock, BYTE *pbLockTaken)
-NESTED_ENTRY JIT_MonExitStatic_InlineGetThread, _TEXT
- .savereg rcx, 0
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- alloc_stack MIN_SIZE
- save_reg_postrsp rcx, MIN_SIZE + 8h + 0h
-endif
-endif
- END_PROLOGUE
-
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- push rsi
- push rdi
- mov rsi, rcx
- mov rdi, rdx
- mov rdx, [rsp + 8]
- call LeaveSyncHelper
- mov rcx, rsi
- mov rdx, rdi
- pop rdi
- pop rsi
-endif
-endif
- PATCHABLE_INLINE_GETTHREAD rax, JIT_MonExitStaticWorker_InlineGetThread_GetThread_PatchLabel
-
- ; Check if lock is held
- cmp [rcx + OFFSETOF__AwareLock__m_HoldingThread], rax
- jne LockError
-
- ; Reduce our recursion count
- sub dword ptr [rcx + OFFSETOF__AwareLock__m_Recursion], 1
- jz LastRecursion
-
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- add rsp, MIN_SIZE
- ret
-endif
-endif
- REPRET
-
- ; This is the last count we held on this lock, so release the lock
- LastRecursion:
- ; Thead* is in rax
- sub dword ptr [rax + OFFSETOF__Thread__m_dwLockCount], 1
- mov qword ptr [rcx + OFFSETOF__AwareLock__m_HoldingThread], 0
-
- Retry:
- mov eax, dword ptr [rcx + OFFSETOF__AwareLock__m_MonitorHeld]
- lea r10d, [eax - 1]
- lock cmpxchg dword ptr [rcx + OFFSETOF__AwareLock__m_MonitorHeld], r10d
- jne RetryHelper
- test eax, STATE_CHECK
- jne MustSignal
-
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- add rsp, MIN_SIZE
- ret
-endif
-endif
- MON_EXIT_STATIC_RETURN_SUCCESS
-
- MustSignal:
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- add rsp, MIN_SIZE
-endif
-endif
- ; void JITutil_MonSignal(AwareLock* lock, BYTE* pbLockTaken)
- jmp JITutil_MonSignal
-
- RetryHelper:
- jmp Retry
-
- LockError:
- mov rcx, CORINFO_SynchronizationLockException_ASM
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- add rsp, MIN_SIZE
-endif
-endif
- ; void JIT_InternalThrow(unsigned exceptNum)
- jmp JIT_InternalThrow
-NESTED_END JIT_MonExitStatic_InlineGetThread, _TEXT
-
end
diff --git a/src/vm/amd64/JitHelpers_Slow.asm b/src/vm/amd64/JitHelpers_Slow.asm
index 448bcb2279..f86d429e33 100644
--- a/src/vm/amd64/JitHelpers_Slow.asm
+++ b/src/vm/amd64/JitHelpers_Slow.asm
@@ -836,894 +836,6 @@ NESTED_ENTRY JIT_GetSharedGCStaticBaseNoCtor_Slow, _TEXT
NESTED_END JIT_GetSharedGCStaticBaseNoCtor_Slow, _TEXT
-MON_ENTER_STACK_SIZE equ 00000020h
-MON_EXIT_STACK_SIZE equ 00000068h
-
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
-MON_ENTER_STACK_SIZE_INLINEGETTHREAD equ 00000020h
-MON_EXIT_STACK_SIZE_INLINEGETTHREAD equ 00000068h
-endif
-endif
-
-BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX equ 08000000h ; syncblk.h
-BIT_SBLK_IS_HASHCODE equ 04000000h ; syncblk.h
-BIT_SBLK_SPIN_LOCK equ 10000000h ; syncblk.h
-
-SBLK_MASK_LOCK_THREADID equ 000003FFh ; syncblk.h
-SBLK_LOCK_RECLEVEL_INC equ 00000400h ; syncblk.h
-SBLK_MASK_LOCK_RECLEVEL equ 0000FC00h ; syncblk.h
-
-MASK_SYNCBLOCKINDEX equ 03FFFFFFh ; syncblk.h
-STATE_CHECK equ 0FFFFFFFEh
-
-MT_CTX_PROXY_FLAG equ 10000000h
-
-g_pSyncTable equ ?g_pSyncTable@@3PEAVSyncTableEntry@@EA
-g_SystemInfo equ ?g_SystemInfo@@3U_SYSTEM_INFO@@A
-g_SpinConstants equ ?g_SpinConstants@@3USpinConstants@@A
-
-extern g_pSyncTable:QWORD
-extern g_SystemInfo:QWORD
-extern g_SpinConstants:QWORD
-
-; JITutil_MonEnterWorker(Object* obj, BYTE* pbLockTaken)
-extern JITutil_MonEnterWorker:proc
-; JITutil_MonTryEnter(Object* obj, INT32 timeout, BYTE* pbLockTaken)
-extern JITutil_MonTryEnter:proc
-; JITutil_MonExitWorker(Object* obj, BYTE* pbLockTaken)
-extern JITutil_MonExitWorker:proc
-; JITutil_MonSignal(AwareLock* lock, BYTE* pbLockTaken)
-extern JITutil_MonSignal:proc
-; JITutil_MonContention(AwareLock* lock, BYTE* pbLockTaken)
-extern JITutil_MonContention:proc
-
-ifdef _DEBUG
-MON_DEBUG equ 1
-endif
-
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
-extern EnterSyncHelper:proc
-extern LeaveSyncHelper:proc
-endif
-endif
-
-
-; This is a frameless helper for entering a monitor on a object.
-; The object is in ARGUMENT_REG1. This tries the normal case (no
-; blocking or object allocation) in line and calls a framed helper
-; for the other cases.
-;
-; EXTERN_C void JIT_MonEnterWorker_Slow(Object* obj, /*OUT*/ BYTE* pbLockTaken)
-NESTED_ENTRY JIT_MonEnterWorker_Slow, _TEXT
- push_nonvol_reg rsi
-
- alloc_stack MON_ENTER_STACK_SIZE
-
- save_reg_postrsp rcx, MON_ENTER_STACK_SIZE + 10h + 0h
- save_reg_postrsp rdx, MON_ENTER_STACK_SIZE + 10h + 8h
- save_reg_postrsp r8, MON_ENTER_STACK_SIZE + 10h + 10h
- save_reg_postrsp r9, MON_ENTER_STACK_SIZE + 10h + 18h
-
- END_PROLOGUE
-
- ; Check if the instance is NULL
- test rcx, rcx
- jz FramedLockHelper
-
- ; Put pbLockTaken in rsi, this can be null
- mov rsi, rdx
-
- ; We store the thread object in r11
- CALL_GETTHREAD
- mov r11, rax
-
- ; Initialize delay value for retry with exponential backoff
- mov r10d, dword ptr [g_SpinConstants + OFFSETOF__g_SpinConstants__dwInitialDuration]
-
- ; Check if we can abort here
- mov eax, dword ptr [r11 + OFFSETOF__Thread__m_State]
- and eax, THREAD_CATCHATSAFEPOINT_BITS
- ; Go through the slow code path to initiate ThreadAbort
- jnz FramedLockHelper
-
- ; r8 will hold the syncblockindex address
- lea r8, [rcx - OFFSETOF__ObjHeader__SyncBlkIndex]
-
- RetryThinLock:
- ; Fetch the syncblock dword
- mov eax, dword ptr [r8]
-
- ; Check whether we have the "thin lock" layout, the lock is free and the spin lock bit is not set
- test eax, BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX + BIT_SBLK_SPIN_LOCK + SBLK_MASK_LOCK_THREADID + SBLK_MASK_LOCK_RECLEVEL
- jnz NeedMoreTests
-
- ; Everything is fine - get the thread id to store in the lock
- mov edx, dword ptr [r11 + OFFSETOF__Thread__m_ThreadId]
-
- ; If the thread id is too large, we need a syncblock for sure
- cmp edx, SBLK_MASK_LOCK_THREADID
- ja FramedLockHelper
-
- ; We want to store a new value with the current thread id set in the low 10 bits
- or edx, eax
- lock cmpxchg dword ptr [r8], edx
- jnz PrepareToWaitThinLock
-
- ; Everything went fine and we're done
- add dword ptr [r11 + OFFSETOF__Thread__m_dwLockCount], 1
-
- ; Done, leave and set pbLockTaken if we have it
- jmp LockTaken
-
- NeedMoreTests:
- ; OK, not the simple case, find out which case it is
- test eax, BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX
- jnz HaveHashOrSyncBlockIndex
-
- ; The header is transitioning or the lock, treat this as if the lock was taken
- test eax, BIT_SBLK_SPIN_LOCK
- jnz PrepareToWaitThinLock
-
- ; Here we know we have the "thin lock" layout, but the lock is not free.
- ; It could still be the recursion case, compare the thread id to check
- mov edx, eax
- and edx, SBLK_MASK_LOCK_THREADID
- cmp edx, dword ptr [r11 + OFFSETOF__Thread__m_ThreadId]
- jne PrepareToWaitThinLock
-
- ; Ok, the thread id matches, it's the recursion case.
- ; Bump up the recursion level and check for overflow
- lea edx, [eax + SBLK_LOCK_RECLEVEL_INC]
- test edx, SBLK_MASK_LOCK_RECLEVEL
- jz FramedLockHelper
-
- ; Try to put the new recursion level back. If the header was changed in the meantime
- ; we need a full retry, because the layout could have changed
- lock cmpxchg dword ptr [r8], edx
- jnz RetryHelperThinLock
-
- ; Done, leave and set pbLockTaken if we have it
- jmp LockTaken
-
- PrepareToWaitThinLock:
- ; If we are on an MP system, we try spinning for a certain number of iterations
- cmp dword ptr [g_SystemInfo + OFFSETOF__g_SystemInfo__dwNumberOfProcessors], 1
- jle FramedLockHelper
-
- ; Exponential backoff; delay by approximately 2*r10 clock cycles
- mov eax, r10d
- delayLoopThinLock:
- pause ; indicate to the CPU that we are spin waiting
- sub eax, 1
- jnz delayLoopThinLock
-
- ; Next time, wait a factor longer
- imul r10d, dword ptr [g_SpinConstants + OFFSETOF__g_SpinConstants__dwBackoffFactor]
-
- cmp r10d, dword ptr [g_SpinConstants + OFFSETOF__g_SpinConstants__dwMaximumDuration]
- jle RetryHelperThinLock
-
- jmp FramedLockHelper
-
- RetryHelperThinLock:
- jmp RetryThinLock
-
- HaveHashOrSyncBlockIndex:
- ; If we have a hash code already, we need to create a sync block
- test eax, BIT_SBLK_IS_HASHCODE
- jnz FramedLockHelper
-
- ; OK, we have a sync block index, just and out the top bits and grab the synblock index
- and eax, MASK_SYNCBLOCKINDEX
-
- ; Get the sync block pointer
- mov rdx, qword ptr [g_pSyncTable]
- shl eax, 4h
- mov rdx, [rdx + rax + OFFSETOF__SyncTableEntry__m_SyncBlock]
-
- ; Check if the sync block has been allocated
- test rdx, rdx
- jz FramedLockHelper
-
- ; Get a pointer to the lock object
- lea rdx, [rdx + OFFSETOF__SyncBlock__m_Monitor]
-
- ; Attempt to acquire the lock
- RetrySyncBlock:
- mov eax, dword ptr [rdx + OFFSETOF__AwareLock__m_MonitorHeld]
- test eax, eax
- jne HaveWaiters
-
- ; Common case, lock isn't held and there are no waiters. Attempt to
- ; gain ownership ourselves
- xor ecx, ecx
- inc ecx
- lock cmpxchg dword ptr [rdx + OFFSETOF__AwareLock__m_MonitorHeld], ecx
- jnz RetryHelperSyncBlock
-
- ; Success. Save the thread object in the lock and increment the use count
- mov qword ptr [rdx + OFFSETOF__AwareLock__m_HoldingThread], r11
- add dword ptr [rdx + OFFSETOF__AwareLock__m_Recursion], 1
- add dword ptr [r11 + OFFSETOF__Thread__m_dwLockCount], 1
-
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- mov rcx, [rsp + MON_ENTER_STACK_SIZE + 8h] ; return address
- ; void EnterSyncHelper(UINT_PTR caller, AwareLock* lock)
- call EnterSyncHelper
-endif
-endif
-
- ; Done, leave and set pbLockTaken if we have it
- jmp LockTaken
-
- ; It's possible to get here with waiters by no lock held, but in this
- ; case a signal is about to be fired which will wake up the waiter. So
- ; for fairness sake we should wait too.
- ; Check first for recur11ve lock attempts on the same thread.
- HaveWaiters:
- ; Is mutex already owned by current thread?
- cmp [rdx + OFFSETOF__AwareLock__m_HoldingThread], r11
- jne PrepareToWait
-
- ; Yes, bump our use count.
- add dword ptr [rdx + OFFSETOF__AwareLock__m_Recursion], 1
-
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- mov rcx, [rsp + MON_ENTER_STACK_SIZE + 8h] ; return address
- ; void EnterSyncHelper(UINT_PTR caller, AwareLock* lock)
- call EnterSyncHelper
-endif
-endif
- ; Done, leave and set pbLockTaken if we have it
- jmp LockTaken
-
- PrepareToWait:
- ; If we are on a MP system we try spinning for a certain number of iterations
- cmp dword ptr [g_SystemInfo + OFFSETOF__g_SystemInfo__dwNumberOfProcessors], 1
- jle HaveWaiters1
-
- ; Exponential backoff: delay by approximately 2*r10 clock cycles
- mov eax, r10d
- delayLoop:
- pause ; indicate to the CPU that we are spin waiting
- sub eax, 1
- jnz delayLoop
-
- ; Next time, wait a factor longer
- imul r10d, dword ptr [g_SpinConstants + OFFSETOF__g_SpinConstants__dwBackoffFactor]
-
- cmp r10d, dword ptr [g_SpinConstants + OFFSETOF__g_SpinConstants__dwMaximumDuration]
- jle RetrySyncBlock
-
- HaveWaiters1:
- mov rcx, rdx
- mov rdx, rsi
- add rsp, MON_ENTER_STACK_SIZE
- pop rsi
- ; void JITutil_MonContention(AwareLock* lock, BYTE* pbLockTaken)
- jmp JITutil_MonContention
-
- RetryHelperSyncBlock:
- jmp RetrySyncBlock
-
- FramedLockHelper:
- mov rdx, rsi
- add rsp, MON_ENTER_STACK_SIZE
- pop rsi
- ; void JITutil_MonEnterWorker(Object* obj, BYTE* pbLockTaken)
- jmp JITutil_MonEnterWorker
-
- align 16
- ; This is sensitive to the potential that pbLockTaken is NULL
- LockTaken:
- test rsi, rsi
- jz LockTaken_Exit
- mov byte ptr [rsi], 1
- LockTaken_Exit:
- add rsp, MON_ENTER_STACK_SIZE
- pop rsi
- ret
-NESTED_END JIT_MonEnterWorker_Slow, _TEXT
-
-; This is a frameless helper for exiting a monitor on a object.
-; The object is in ARGUMENT_REG1. This tries the normal case (no
-; blocking or object allocation) in line and calls a framed helper
-; for the other cases.
-;
-; void JIT_MonExitWorker_Slow(Object* obj, BYTE* pbLockTaken)
-NESTED_ENTRY JIT_MonExitWorker_Slow, _TEXT
- alloc_stack MON_EXIT_STACK_SIZE
-
- save_reg_postrsp rcx, MON_EXIT_STACK_SIZE + 8h + 0h
- save_reg_postrsp rdx, MON_EXIT_STACK_SIZE + 8h + 8h
- save_reg_postrsp r8, MON_EXIT_STACK_SIZE + 8h + 10h
- save_reg_postrsp r9, MON_EXIT_STACK_SIZE + 8h + 18h
-
- END_PROLOGUE
-
- ; pbLockTaken is stored in r10
- mov r10, rdx
-
- ; if pbLockTaken is NULL then we got here without a state variable, avoid the
- ; next comparison in that case as it will AV
- test rdx, rdx
- jz Null_pbLockTaken
-
- ; If the lock wasn't taken then we bail quickly without doing anything
- cmp byte ptr [rdx], 0
- je LockNotTaken
-
- Null_pbLockTaken:
- ; Check is the instance is null
- test rcx, rcx
- jz FramedLockHelper
-
- ; The Thread obj address is stored in r11
- CALL_GETTHREAD
- mov r11, rax
-
- ; r8 will hold the syncblockindex address
- lea r8, [rcx - OFFSETOF__ObjHeader__SyncBlkIndex]
-
- RetryThinLock:
- ; Fetch the syncblock dword
- mov eax, dword ptr [r8]
- test eax, BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX + BIT_SBLK_SPIN_LOCK
- jnz NeedMoreTests
-
- ; Ok, we have a "thin lock" layout - check whether the thread id matches
- mov edx, eax
- and edx, SBLK_MASK_LOCK_THREADID
- cmp edx, dword ptr [r11 + OFFSETOF__Thread__m_ThreadId]
- jne FramedLockHelper
-
- ; check the recursion level
- test eax, SBLK_MASK_LOCK_RECLEVEL
- jne DecRecursionLevel
-
- ; It's zero -- we're leaving the lock.
- ; So try to put back a zero thread id.
- ; edx and eax match in the thread id bits, and edx is zero else where, so the xor is sufficient
- xor edx, eax
- lock cmpxchg dword ptr [r8], edx
- jnz RetryHelperThinLock
-
- ; Dec the dwLockCount on the thread
- sub dword ptr [r11 + OFFSETOF__Thread__m_dwLockCount], 1
-
- ; Done, leave and set pbLockTaken if we have it
- jmp LockReleased
-
- DecRecursionLevel:
- lea edx, [eax - SBLK_LOCK_RECLEVEL_INC]
- lock cmpxchg dword ptr [r8], edx
- jnz RetryHelperThinLock
-
- ; We're done, leave and set pbLockTaken if we have it
- jmp LockReleased
-
- NeedMoreTests:
- ; Forward all special cases to the slow helper
- test eax, BIT_SBLK_IS_HASHCODE + BIT_SBLK_SPIN_LOCK
- jnz FramedLockHelper
-
- ; Get the sync block index and use it to compute the sync block pointer
- mov rdx, qword ptr [g_pSyncTable]
- and eax, MASK_SYNCBLOCKINDEX
- shl eax, 4
- mov rdx, [rdx + rax + OFFSETOF__SyncTableEntry__m_SyncBlock]
-
- ; Was there a sync block?
- test rdx, rdx
- jz FramedLockHelper
-
- ; Get a pointer to the lock object.
- lea rdx, [rdx + OFFSETOF__SyncBlock__m_Monitor]
-
- ; Check if the lock is held.
- cmp qword ptr [rdx + OFFSETOF__AwareLock__m_HoldingThread], r11
- jne FramedLockHelper
-
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- mov [rsp + 28h], rcx
- mov [rsp + 30h], rdx
- mov [rsp + 38h], r10
- mov [rsp + 40h], r11
-
- mov rcx, [rsp + MON_EXIT_STACK_SIZE ] ; return address
- ; void LeaveSyncHelper(UINT_PTR caller, AwareLock* lock)
- call LeaveSyncHelper
-
- mov rcx, [rsp + 28h]
- mov rdx, [rsp + 30h]
- mov r10, [rsp + 38h]
- mov r11, [rsp + 40h]
-endif
-endif
-
- ; Reduce our recursion count
- sub dword ptr [rdx + OFFSETOF__AwareLock__m_Recursion], 1
- jz LastRecursion
-
- ; Done, leave and set pbLockTaken if we have it
- jmp LockReleased
-
- RetryHelperThinLock:
- jmp RetryThinLock
-
- FramedLockHelper:
- mov rdx, r10
- add rsp, MON_EXIT_STACK_SIZE
- ; void JITutil_MonExitWorker(Object* obj, BYTE* pbLockTaken)
- jmp JITutil_MonExitWorker
-
- LastRecursion:
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- mov rax, [rdx + OFFSETOF__AwareLock__m_HoldingThread]
-endif
-endif
-
- sub dword ptr [r11 + OFFSETOF__Thread__m_dwLockCount], 1
- mov qword ptr [rdx + OFFSETOF__AwareLock__m_HoldingThread], 0
-
- Retry:
- mov eax, dword ptr [rdx + OFFSETOF__AwareLock__m_MonitorHeld]
- lea r9d, [eax - 1]
- lock cmpxchg dword ptr [rdx + OFFSETOF__AwareLock__m_MonitorHeld], r9d
- jne RetryHelper
-
- test eax, STATE_CHECK
- jne MustSignal
-
- ; Done, leave and set pbLockTaken if we have it
- jmp LockReleased
-
- MustSignal:
- mov rcx, rdx
- mov rdx, r10
- add rsp, MON_EXIT_STACK_SIZE
- ; void JITutil_MonSignal(AwareLock* lock, BYTE* pbLockTaken)
- jmp JITutil_MonSignal
-
- RetryHelper:
- jmp Retry
-
- LockNotTaken:
- add rsp, MON_EXIT_STACK_SIZE
- ret
-
- align 16
- ; This is sensitive to the potential that pbLockTaken is null
- LockReleased:
- test r10, r10
- jz LockReleased_Exit
- mov byte ptr [r10], 0
- LockReleased_Exit:
- add rsp, MON_EXIT_STACK_SIZE
- ret
-NESTED_END JIT_MonExitWorker_Slow, _TEXT
-
-; This is a frameless helper for trying to enter a monitor on a object.
-; The object is in ARGUMENT_REG1 and a timeout in ARGUMENT_REG2. This tries the
-; normal case (no object allocation) in line and calls a framed helper for the
-; other cases.
-;
-; void JIT_MonTryEnter_Slow(Object* obj, INT32 timeOut, BYTE* pbLockTaken)
-NESTED_ENTRY JIT_MonTryEnter_Slow, _TEXT
- push_nonvol_reg rsi
-
- alloc_stack MON_ENTER_STACK_SIZE
-
- save_reg_postrsp rcx, MON_ENTER_STACK_SIZE + 10h + 0h
- save_reg_postrsp rdx, MON_ENTER_STACK_SIZE + 10h + 8h
- save_reg_postrsp r8, MON_ENTER_STACK_SIZE + 10h + 10h
- save_reg_postrsp r9, MON_ENTER_STACK_SIZE + 10h + 18h
-
- END_PROLOGUE
-
- mov rsi, rdx
-
- ; Check if the instance is NULL
- test rcx, rcx
- jz FramedLockHelper
-
- ; Check if the timeout looks valid
- cmp rdx, -1
- jl FramedLockHelper
-
- ; We store the thread object in r11
- CALL_GETTHREAD
- mov r11, rax
-
- ; Initialize delay value for retry with exponential backoff
- mov r10d, dword ptr [g_SpinConstants + OFFSETOF__g_SpinConstants__dwInitialDuration]
-
- ; Check if we can abort here
- mov eax, dword ptr [r11 + OFFSETOF__Thread__m_State]
- and eax, THREAD_CATCHATSAFEPOINT_BITS
- ; Go through the slow code path to initiate THreadAbort
- jnz FramedLockHelper
-
- ; r9 will hold the syncblockindex address
- lea r9, [rcx - OFFSETOF__ObjHeader__SyncBlkIndex]
-
- RetryThinLock:
- ; Fetch the syncblock dword
- mov eax, dword ptr [r9]
-
- ; Check whether we have the "thin lock" layout, the lock is free and the spin lock bit is not set
- test eax, BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX + BIT_SBLK_SPIN_LOCK + SBLK_MASK_LOCK_THREADID + SBLK_MASK_LOCK_RECLEVEL
- jne NeedMoreTests
-
- ; Everything is fine - get the thread id to store in the lock
- mov edx, dword ptr [r11 + OFFSETOF__Thread__m_ThreadId]
-
- ; If the thread id is too large, we need a syncblock for sure
- cmp edx, SBLK_MASK_LOCK_THREADID
- ja FramedLockHelper
-
- ; We want to store a new value with the current thread id set in the low 10 bits
- or edx, eax
- lock cmpxchg dword ptr [r9], edx
- jnz RetryHelperThinLock
-
- ; Got the lock, everything is fine
- add dword ptr [r11 + OFFSETOF__Thread__m_dwLockCount], 1
- ; Return TRUE
- mov byte ptr [r8], 1
- add rsp, MON_ENTER_STACK_SIZE
- pop rsi
- ret
-
- NeedMoreTests:
- ; OK, not the simple case, find out which case it is
- test eax, BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX
- jnz HaveHashOrSyncBlockIndex
-
- ; The header is transitioning or the lock
- test eax, BIT_SBLK_SPIN_LOCK
- jnz RetryHelperThinLock
-
- ; Here we know we have the "thin lock" layout, but the lock is not free.
- ; It could still be the recursion case, compare the thread id to check
- mov edx, eax
- and edx, SBLK_MASK_LOCK_THREADID
- cmp edx, dword ptr [r11 + OFFSETOF__Thread__m_ThreadId]
- jne PrepareToWaitThinLock
-
- ; Ok, the thread id matches, it's the recursion case.
- ; Dump up the recursion level and check for overflow
- lea edx, [eax + SBLK_LOCK_RECLEVEL_INC]
- test edx, SBLK_MASK_LOCK_RECLEVEL
- jz FramedLockHelper
-
- ; Try to put the new recursion level back. If the header was changed in the meantime
- ; we need a full retry, because the layout could have changed
- lock cmpxchg dword ptr [r9], edx
- jnz RetryHelperThinLock
-
- ; Everything went fine and we're done, return TRUE
- mov byte ptr [r8], 1
- add rsp, MON_ENTER_STACK_SIZE
- pop rsi
- ret
-
- PrepareToWaitThinLock:
- ; Return failure if timeout is zero
- test rsi, rsi
- jz TimeoutZero
-
- ; If we are on an MP system, we try spinning for a certain number of iterations
- cmp dword ptr [g_SystemInfo + OFFSETOF__g_SystemInfo__dwNumberOfProcessors], 1
- jle FramedLockHelper
-
- ; Exponential backoff; delay by approximately 2*r10d clock cycles
- mov eax, r10d
- DelayLoopThinLock:
- pause ; indicate to the CPU that we are spin waiting
- sub eax, 1
- jnz DelayLoopThinLock
-
- ; Next time, wait a factor longer
- imul r10d, dword ptr [g_SpinConstants + OFFSETOF__g_SpinConstants__dwBackoffFactor]
-
- cmp r10d, dword ptr [g_SpinConstants + OFFSETOF__g_SpinConstants__dwMaximumDuration]
- jle RetryHelperThinLock
-
- jmp FramedLockHelper
-
- RetryHelperThinLock:
- jmp RetryThinLock
-
- HaveHashOrSyncBlockIndex:
- ; If we have a hash code already, we need to create a sync block
- test eax, BIT_SBLK_IS_HASHCODE
- jnz FramedLockHelper
-
- ; OK, we have a sync block index, just and out the top bits and grab the synblock index
- and eax, MASK_SYNCBLOCKINDEX
-
- ; Get the sync block pointer
- mov rdx, qword ptr [g_pSyncTable]
- shl eax, 4
- mov rdx, [rdx + rax + OFFSETOF__SyncTableEntry__m_SyncBlock]
-
- ; Check if the sync block has been allocated
- test rdx, rdx
- jz FramedLockHelper
-
- ; Get a pointer to the lock object
- lea rdx, [rdx + OFFSETOF__SyncBlock__m_Monitor]
-
- RetrySyncBlock:
- ; Attempt to acuire the lock
- mov eax, dword ptr [rdx + OFFSETOF__AwareLock__m_MonitorHeld]
- test eax, eax
- jne HaveWaiters
-
- ; Common case, lock isn't held and there are no waiters. Attempt to
- ; gain ownership ourselves
- xor ecx, ecx
- inc ecx
- lock cmpxchg dword ptr [rdx + OFFSETOF__AwareLock__m_MonitorHeld], ecx
- jnz RetryHelperSyncBlock
-
- ; Success. Save the thread object in the lock and increment the use count
- mov qword ptr [rdx + OFFSETOF__AwareLock__m_HoldingThread], r11
- add dword ptr [rdx + OFFSETOF__AwareLock__m_Recursion], 1
- add dword ptr [r11 + OFFSETOF__Thread__m_dwLockCount], 1
-
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- mov rcx, [rsp + MON_ENTER_STACK_SIZE + 8h] ; return address
- ; void EnterSyncHelper(UINT_PTR caller, AwareLock* lock)
- call EnterSyncHelper
-endif
-endif
-
- ; Return TRUE
- mov byte ptr [r8], 1
- add rsp, MON_ENTER_STACK_SIZE
- pop rsi
- ret
-
- ; It's possible to get here with waiters by no lock held, but in this
- ; case a signal is about to be fired which will wake up the waiter. So
- ; for fairness sake we should wait too.
- ; Check first for recur11ve lock attempts on the same thread.
- HaveWaiters:
- ; Is mutex already owned by current thread?
- cmp [rdx + OFFSETOF__AwareLock__m_HoldingThread], r11
- jne PrepareToWait
-
- ; Yes, bump our use count.
- add dword ptr [rdx + OFFSETOF__AwareLock__m_Recursion], 1
-
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- mov rcx, [rsp + MON_ENTER_STACK_SIZE + 8h] ; return address
- ; void EnterSyncHelper(UINT_PTR caller, AwareLock* lock)
- call EnterSyncHelper
-endif
-endif
-
- ; Return TRUE
- mov byte ptr [r8], 1
- add rsp, MON_ENTER_STACK_SIZE
- pop rsi
- ret
-
- PrepareToWait:
- ; Return failure if timeout is zero
- test rsi, rsi
- jz TimeoutZero
-
- ; If we are on an MP system, we try spinning for a certain number of iterations
- cmp dword ptr [g_SystemInfo + OFFSETOF__g_SystemInfo__dwNumberOfProcessors], 1
- jle Block
-
- ; Exponential backoff; delay by approximately 2*r10d clock cycles
- mov eax, r10d
- DelayLoop:
- pause ; indicate to the CPU that we are spin waiting
- sub eax, 1
- jnz DelayLoop
-
- ; Next time, wait a factor longer
- imul r10d, dword ptr [g_SpinConstants + OFFSETOF__g_SpinConstants__dwBackoffFactor]
-
- cmp r10d, dword ptr [g_SpinConstants + OFFSETOF__g_SpinConstants__dwMaximumDuration]
- jle RetrySyncBlock
-
- jmp Block
-
- TimeoutZero:
- ; Return FALSE
- mov byte ptr [r8], 0
- add rsp, MON_ENTER_STACK_SIZE
- pop rsi
- ret
-
- RetryHelperSyncBlock:
- jmp RetrySyncBlock
-
- Block:
- ; In the Block case we've trashed RCX, restore it
- mov rcx, [rsp + MON_ENTER_STACK_SIZE + 10h]
- FramedLockHelper:
- mov rdx, rsi
- add rsp, MON_ENTER_STACK_SIZE
- pop rsi
- ; void JITutil_MonTryEnter(Object* obj, UINT32 timeout, BYTE* pbLockTaken)
- jmp JITutil_MonTryEnter
-
-NESTED_END JIT_MonTryEnter_Slow, _TEXT
-
-MON_ENTER_STATIC_RETURN_SUCCESS macro
- ; pbLockTaken is never null for static helpers
- mov byte ptr [rdx], 1
- add rsp, MIN_SIZE
- ret
-
- endm
-
-MON_EXIT_STATIC_RETURN_SUCCESS macro
- ; pbLockTaken is never null for static helpers
- mov byte ptr [rdx], 0
- add rsp, MIN_SIZE
- ret
-
- endm
-
-
-; This is a frameless helper for entering a static monitor on a class.
-; The methoddesc is in ARGUMENT_REG1. This tries the normal case (no
-; blocking or object allocation) in line and calls a framed helper
-; for the other cases.
-;
-; void JIT_MonEnterStatic_Slow(AwareLock *lock, BYTE *pbLockTaken)
-NESTED_ENTRY JIT_MonEnterStatic_Slow, _TEXT
- alloc_stack MIN_SIZE
- END_PROLOGUE
-
- ; Attempt to acquire the lock
- Retry:
- mov eax, dword ptr [rcx + OFFSETOF__AwareLock__m_MonitorHeld]
- test eax, eax
- jne HaveWaiters
-
- ; Common case; lock isn't held and there are no waiters. Attempt to
- ; gain ownership by ourselves.
- mov r10d, 1
- lock cmpxchg dword ptr [rcx + OFFSETOF__AwareLock__m_MonitorHeld], r10d
- jnz RetryHelper
-
- ; Success. Save the thread object in the lock and increment the use count.
- CALL_GETTHREAD
-
- mov qword ptr [rcx + OFFSETOF__AwareLock__m_HoldingThread], rax
- add dword ptr [rcx + OFFSETOF__AwareLock__m_Recursion], 1
- add dword ptr [rax + OFFSETOF__Thread__m_dwLockCount], 1
-
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- add rsp, MIN_SIZE
- mov rdx, rcx
- mov rcx, [rsp]
- ; void EnterSyncHelper(UINT_PTR caller, AwareLock* lock)
- jmp EnterSyncHelper
-endif
-endif
- MON_ENTER_STATIC_RETURN_SUCCESS
-
- ; It's possible to get here with waiters by with no lock held, in this
- ; case a signal is about to be fired which will wake up a waiter. So
- ; for fairness sake we should wait too.
- ; Check first for recursive lock attempts on the same thread.
- HaveWaiters:
- CALL_GETTHREAD
-
- ; Is mutex alread owned by current thread?
- cmp [rcx + OFFSETOF__AwareLock__m_HoldingThread], rax
- jne PrepareToWait
-
- ; Yes, bump our use count.
- add dword ptr [rcx + OFFSETOF__AwareLock__m_Recursion], 1
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- mov rdx, rcx
- mov rcx, [rsp]
- ; void EnterSyncHelper(UINT_PTR caller, AwareLock* lock)
- add rsp, MIN_SIZE
- jmp EnterSyncHelper
-endif
-endif
- MON_ENTER_STATIC_RETURN_SUCCESS
-
- PrepareToWait:
- add rsp, MIN_SIZE
- ; void JITutil_MonContention(AwareLock* obj, BYTE* pbLockTaken)
- jmp JITutil_MonContention
-
- RetryHelper:
- jmp Retry
-NESTED_END JIT_MonEnterStatic_Slow, _TEXT
-
-; A frameless helper for exiting a static monitor on a class.
-; The methoddesc is in ARGUMENT_REG1. This tries the normal case (no
-; blocking or object allocation) in line and calls a framed helper
-; for the other cases.
-;
-; void JIT_MonExitStatic_Slow(AwareLock *lock, BYTE *pbLockTaken)
-NESTED_ENTRY JIT_MonExitStatic_Slow, _TEXT
- alloc_stack MIN_SIZE
- END_PROLOGUE
-
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- push rsi
- push rdi
- mov rsi, rcx
- mov rdi, rdx
- mov rdx, [rsp + 8]
- call LeaveSyncHelper
- mov rcx, rsi
- mov rdx, rdi
- pop rdi
- pop rsi
-endif
-endif
-
- ; Check if lock is held
- CALL_GETTHREAD
-
- cmp [rcx + OFFSETOF__AwareLock__m_HoldingThread], rax
- jne LockError
-
- ; Reduce our recursion count
- sub dword ptr [rcx + OFFSETOF__AwareLock__m_Recursion], 1
- jz LastRecursion
-
- MON_EXIT_STATIC_RETURN_SUCCESS
-
- ; This is the last count we held on this lock, so release the lock
- LastRecursion:
- ; Thead* is in rax
- sub dword ptr [rax + OFFSETOF__Thread__m_dwLockCount], 1
- mov qword ptr [rcx + OFFSETOF__AwareLock__m_HoldingThread], 0
-
- Retry:
- mov eax, dword ptr [rcx + OFFSETOF__AwareLock__m_MonitorHeld]
- lea r10d, [eax - 1]
- lock cmpxchg dword ptr [rcx + OFFSETOF__AwareLock__m_MonitorHeld], r10d
- jne RetryHelper
- test eax, STATE_CHECK
- jne MustSignal
-
- MON_EXIT_STATIC_RETURN_SUCCESS
-
- MustSignal:
- add rsp, MIN_SIZE
- ; void JITutil_MonSignal(AwareLock* lock, BYTE* pbLockTaken)
- jmp JITutil_MonSignal
-
- RetryHelper:
- jmp Retry
-
- LockError:
- mov rcx, CORINFO_SynchronizationLockException_ASM
- add rsp, MIN_SIZE
- ; void JIT_InternalThrow(unsigned exceptNum)
- jmp JIT_InternalThrow
-NESTED_END JIT_MonExitStatic_Slow, _TEXT
-
-
ifdef _DEBUG
extern Object__DEBUG_SetAppDomain:proc
diff --git a/src/vm/amd64/asmconstants.h b/src/vm/amd64/asmconstants.h
index 4a100c1823..1fef80f66d 100644
--- a/src/vm/amd64/asmconstants.h
+++ b/src/vm/amd64/asmconstants.h
@@ -184,37 +184,12 @@ ASMCONSTANTS_C_ASSERT(THREAD_CATCHATSAFEPOINT_BITS == Thread::TS_CatchAtSafePoin
#define OFFSETOF__NDirectMethodDesc__m_pWriteableData DBG_FRE(0x48, 0x20)
ASMCONSTANTS_C_ASSERT(OFFSETOF__NDirectMethodDesc__m_pWriteableData == offsetof(NDirectMethodDesc, ndirect.m_pWriteableData));
-#define OFFSETOF__ObjHeader__SyncBlkIndex 0x4
-ASMCONSTANTS_C_ASSERT(OFFSETOF__ObjHeader__SyncBlkIndex
- == (sizeof(ObjHeader) - offsetof(ObjHeader, m_SyncBlockValue)));
-
-#define SIZEOF__SyncTableEntry 0x10
-ASMCONSTANT_SIZEOF_ASSERT(SyncTableEntry);
-
-#define OFFSETOF__SyncTableEntry__m_SyncBlock 0x0
-ASMCONSTANT_OFFSETOF_ASSERT(SyncTableEntry, m_SyncBlock);
-
-#define OFFSETOF__SyncBlock__m_Monitor 0x0
-ASMCONSTANT_OFFSETOF_ASSERT(SyncBlock, m_Monitor);
-
#define OFFSETOF__DelegateObject___methodPtr 0x18
ASMCONSTANT_OFFSETOF_ASSERT(DelegateObject, _methodPtr);
#define OFFSETOF__DelegateObject___target 0x08
ASMCONSTANT_OFFSETOF_ASSERT(DelegateObject, _target);
-#define OFFSETOF__AwareLock__m_MonitorHeld 0x0
-ASMCONSTANTS_C_ASSERT(OFFSETOF__AwareLock__m_MonitorHeld
- == offsetof(AwareLock, m_MonitorHeld));
-
-#define OFFSETOF__AwareLock__m_Recursion 0x4
-ASMCONSTANTS_C_ASSERT(OFFSETOF__AwareLock__m_Recursion
- == offsetof(AwareLock, m_Recursion));
-
-#define OFFSETOF__AwareLock__m_HoldingThread 0x8
-ASMCONSTANTS_C_ASSERT(OFFSETOF__AwareLock__m_HoldingThread
- == offsetof(AwareLock, m_HoldingThread));
-
#define OFFSETOF__g_SystemInfo__dwNumberOfProcessors 0x20
ASMCONSTANTS_C_ASSERT(OFFSETOF__g_SystemInfo__dwNumberOfProcessors
== offsetof(SYSTEM_INFO, dwNumberOfProcessors));
@@ -346,10 +321,6 @@ ASMCONSTANTS_C_ASSERT( CORINFO_InvalidCastException_ASM
ASMCONSTANTS_C_ASSERT( CORINFO_IndexOutOfRangeException_ASM
== CORINFO_IndexOutOfRangeException);
-#define CORINFO_SynchronizationLockException_ASM 5
-ASMCONSTANTS_C_ASSERT( CORINFO_SynchronizationLockException_ASM
- == CORINFO_SynchronizationLockException);
-
#define CORINFO_ArrayTypeMismatchException_ASM 6
ASMCONSTANTS_C_ASSERT( CORINFO_ArrayTypeMismatchException_ASM
== CORINFO_ArrayTypeMismatchException);
@@ -613,10 +584,6 @@ ASMCONSTANTS_C_ASSERT(OFFSETOF__StringObject__m_StringLength
ASMCONSTANTS_C_ASSERT(OFFSETOF__ArrayTypeDesc__m_Arg
== offsetof(ArrayTypeDesc, m_Arg));
-#define SYNCBLOCKINDEX_OFFSET 0x4
-ASMCONSTANTS_C_ASSERT(SYNCBLOCKINDEX_OFFSET
- == (sizeof(ObjHeader) - offsetof(ObjHeader, m_SyncBlockValue)));
-
#define CallDescrData__pSrc 0x00
#define CallDescrData__numStackSlots 0x08
#ifdef UNIX_AMD64_ABI
diff --git a/src/vm/amd64/cgencpu.h b/src/vm/amd64/cgencpu.h
index b74e3ca7d3..98e9770858 100644
--- a/src/vm/amd64/cgencpu.h
+++ b/src/vm/amd64/cgencpu.h
@@ -544,20 +544,10 @@ inline BOOL ClrFlushInstructionCache(LPCVOID pCodeAddr, size_t sizeOfCode)
//
// Create alias for optimized implementations of helpers provided on this platform
//
-#define JIT_MonEnter JIT_MonEnter
-#define JIT_MonEnterWorker JIT_MonEnterWorker_InlineGetThread
-#define JIT_MonReliableEnter JIT_MonEnterWorker
-#define JIT_MonTryEnter JIT_MonTryEnter_InlineGetThread
-#define JIT_MonExit JIT_MonExit
-#define JIT_MonExitWorker JIT_MonExitWorker_InlineGetThread
-#define JIT_MonEnterStatic JIT_MonEnterStatic_InlineGetThread
-#define JIT_MonExitStatic JIT_MonExitStatic_InlineGetThread
-
#define JIT_GetSharedGCStaticBase JIT_GetSharedGCStaticBase_InlineGetAppDomain
#define JIT_GetSharedNonGCStaticBase JIT_GetSharedNonGCStaticBase_InlineGetAppDomain
#define JIT_GetSharedGCStaticBaseNoCtor JIT_GetSharedGCStaticBaseNoCtor_InlineGetAppDomain
#define JIT_GetSharedNonGCStaticBaseNoCtor JIT_GetSharedNonGCStaticBaseNoCtor_InlineGetAppDomain
-
#endif // FEATURE_IMPLICIT_TLS
#ifndef FEATURE_PAL
diff --git a/src/vm/class.cpp b/src/vm/class.cpp
index e4268b57ec..9d82f775dc 100644
--- a/src/vm/class.cpp
+++ b/src/vm/class.cpp
@@ -1641,7 +1641,14 @@ bool MethodTable::IsHFA()
#ifdef DACCESS_COMPILE
return false;
#else
- return GetClass()->CheckForHFA();
+ if (GetClass()->GetMethodTable()->IsValueType())
+ {
+ return GetClass()->CheckForHFA();
+ }
+ else
+ {
+ return false;
+ }
#endif
}
#endif // !FEATURE_HFA
diff --git a/src/vm/compile.cpp b/src/vm/compile.cpp
index b3d187c555..196e2163a5 100644
--- a/src/vm/compile.cpp
+++ b/src/vm/compile.cpp
@@ -5162,6 +5162,7 @@ static void SpecializeComparer(SString& ss, Instantiation& inst)
//
// This method has duplicated logic from bcl\system\collections\generic\equalitycomparer.cs
+// and matching logic in jitinterface.cpp
//
static void SpecializeEqualityComparer(SString& ss, Instantiation& inst)
{
diff --git a/src/vm/comsynchronizable.cpp b/src/vm/comsynchronizable.cpp
index 8fce346142..1d7541a74a 100644
--- a/src/vm/comsynchronizable.cpp
+++ b/src/vm/comsynchronizable.cpp
@@ -1632,8 +1632,9 @@ INT32 QCALLTYPE ThreadNative::GetOptimalMaxSpinWaitsPerSpinIteration()
BEGIN_QCALL;
- Thread::EnsureYieldProcessorNormalizedInitialized();
- optimalMaxNormalizedYieldsPerSpinIteration = Thread::GetOptimalMaxNormalizedYieldsPerSpinIteration();
+ // RuntimeThread calls this function only once lazily and caches the result, so ensure initialization
+ EnsureYieldProcessorNormalizedInitialized();
+ optimalMaxNormalizedYieldsPerSpinIteration = g_optimalMaxNormalizedYieldsPerSpinIteration;
END_QCALL;
@@ -1655,10 +1656,11 @@ FCIMPL1(void, ThreadNative::SpinWait, int iterations)
// spinning for less than that number of cycles, then switching to preemptive
// mode won't help a GC start any faster.
//
- if (iterations <= 100000 && Thread::IsYieldProcessorNormalizedInitialized())
+ if (iterations <= 100000)
{
+ YieldProcessorNormalizationInfo normalizationInfo;
for (int i = 0; i < iterations; i++)
- Thread::YieldProcessorNormalized();
+ YieldProcessorNormalized(normalizationInfo);
return;
}
@@ -1668,9 +1670,9 @@ FCIMPL1(void, ThreadNative::SpinWait, int iterations)
HELPER_METHOD_FRAME_BEGIN_NOPOLL();
GCX_PREEMP();
- Thread::EnsureYieldProcessorNormalizedInitialized();
+ YieldProcessorNormalizationInfo normalizationInfo;
for (int i = 0; i < iterations; i++)
- Thread::YieldProcessorNormalized();
+ YieldProcessorNormalized(normalizationInfo);
HELPER_METHOD_FRAME_END();
}
diff --git a/src/vm/comutilnative.cpp b/src/vm/comutilnative.cpp
index 766336ee7f..5c5a1e9eaa 100644
--- a/src/vm/comutilnative.cpp
+++ b/src/vm/comutilnative.cpp
@@ -44,20 +44,6 @@
#define STACK_OVERFLOW_MESSAGE W("StackOverflowException")
-//These are defined in System.ParseNumbers and should be kept in sync.
-#define PARSE_TREATASUNSIGNED 0x200
-#define PARSE_TREATASI1 0x400
-#define PARSE_TREATASI2 0x800
-#define PARSE_ISTIGHT 0x1000
-#define PARSE_NOSPACE 0x2000
-
-
-//
-//
-// PARSENUMBERS (and helper functions)
-//
-//
-
/*===================================IsDigit====================================
**Returns a bool indicating whether the character passed in represents a **
**digit.
@@ -119,638 +105,7 @@ INT32 wtoi(__in_ecount(length) WCHAR* wstr, DWORD length)
return result;
}
-INT32 ParseNumbers::GrabInts(const INT32 radix, __in_ecount(length) WCHAR *buffer, const int length, int *i, BOOL isUnsigned)
-{
- CONTRACTL
- {
- THROWS;
- GC_NOTRIGGER;
- MODE_COOPERATIVE;
- PRECONDITION(CheckPointer(buffer));
- PRECONDITION(CheckPointer(i));
- PRECONDITION(*i >= 0);
- PRECONDITION(length >= 0);
- PRECONDITION( radix==2 || radix==8 || radix==10 || radix==16 );
- }
- CONTRACTL_END;
-
- UINT32 result=0;
- int value;
- UINT32 maxVal;
-
- // Allow all non-decimal numbers to set the sign bit.
- if (radix==10 && !isUnsigned) {
- maxVal = (0x7FFFFFFF / 10);
-
- //Read all of the digits and convert to a number
- while (*i<length&&(IsDigit(buffer[*i],radix,&value))) {
- // Check for overflows - this is sufficient & correct.
- if (result > maxVal || ((INT32)result)<0)
- COMPlusThrow(kOverflowException, W("Overflow_Int32"));
- result = result*radix + value;
- (*i)++;
- }
- if ((INT32)result<0 && result!=0x80000000)
- COMPlusThrow(kOverflowException, W("Overflow_Int32"));
-
- }
- else {
- maxVal = ((UINT32) -1) / radix;
-
- //Read all of the digits and convert to a number
- while (*i<length&&(IsDigit(buffer[*i],radix,&value))) {
- // Check for overflows - this is sufficient & correct.
- if (result > maxVal)
- COMPlusThrow(kOverflowException, W("Overflow_UInt32"));
- // the above check won't cover 4294967296 to 4294967299
- UINT32 temp = result*radix + value;
- if( temp < result) { // this means overflow as well
- COMPlusThrow(kOverflowException, W("Overflow_UInt32"));
- }
-
- result = temp;
- (*i)++;
- }
- }
- return(INT32) result;
-}
-
-INT64 ParseNumbers::GrabLongs(const INT32 radix, __in_ecount(length) WCHAR *buffer, const int length, int *i, BOOL isUnsigned)
-{
- CONTRACTL
- {
- THROWS;
- GC_NOTRIGGER;
- MODE_COOPERATIVE;
- PRECONDITION(CheckPointer(buffer));
- PRECONDITION(CheckPointer(i));
- PRECONDITION(*i >= 0);
- PRECONDITION(length >= 0);
- }
- CONTRACTL_END;
-
- UINT64 result=0;
- int value;
- UINT64 maxVal;
-
- // Allow all non-decimal numbers to set the sign bit.
- if (radix==10 && !isUnsigned) {
- maxVal = (UI64(0x7FFFFFFFFFFFFFFF) / 10);
-
- //Read all of the digits and convert to a number
- while (*i<length&&(IsDigit(buffer[*i],radix,&value))) {
- // Check for overflows - this is sufficient & correct.
- if (result > maxVal || ((INT64)result)<0)
- COMPlusThrow(kOverflowException, W("Overflow_Int64"));
- result = result*radix + value;
- (*i)++;
- }
- if ((INT64)result<0 && result!=UI64(0x8000000000000000))
- COMPlusThrow(kOverflowException, W("Overflow_Int64"));
-
- }
- else {
- maxVal = ((UINT64) -1L) / radix;
-
- //Read all of the digits and convert to a number
- while (*i<length&&(IsDigit(buffer[*i],radix,&value))) {
- // Check for overflows - this is sufficient & correct.
- if (result > maxVal)
- COMPlusThrow(kOverflowException, W("Overflow_UInt64"));
-
- UINT64 temp = result*radix + value;
- if( temp < result) { // this means overflow as well
- COMPlusThrow(kOverflowException, W("Overflow_UInt64"));
- }
- result = temp;
-
- (*i)++;
- }
- }
- return(INT64) result;
-}
-
-void EatWhiteSpace(__in_ecount(length) WCHAR *buffer, int length, int *i)
-{
- CONTRACTL
- {
- NOTHROW;
- GC_NOTRIGGER;
- MODE_ANY;
- PRECONDITION(CheckPointer(buffer));
- PRECONDITION(CheckPointer(i));
- PRECONDITION(length >= 0);
- }
- CONTRACTL_END;
-
- for (; *i<length && COMCharacter::nativeIsWhiteSpace(buffer[*i]); (*i)++);
-}
-
-FCIMPL5_VII(LPVOID, ParseNumbers::LongToString, INT64 n, INT32 radix, INT32 width, CLR_CHAR paddingChar, INT32 flags)
-{
- FCALL_CONTRACT;
-
- LPVOID rv = NULL;
-
- HELPER_METHOD_FRAME_BEGIN_RET_0();
-
- bool isNegative = false;
- int index=0;
- int charVal;
- UINT64 l;
- INT32 i;
- INT32 buffLength=0;
- WCHAR buffer[67];//Longest possible string length for an integer in binary notation with prefix
-
- if (radix<MinRadix || radix>MaxRadix)
- COMPlusThrowArgumentException(W("radix"), W("Arg_InvalidBase"));
-
- //If the number is negative, make it positive and remember the sign.
- if (n<0) {
- isNegative=true;
-
- // For base 10, write out -num, but other bases write out the
- // 2's complement bit pattern
- if (10==radix)
- l = (UINT64)(-n);
- else
- l = (UINT64)n;
- }
- else {
- l=(UINT64)n;
- }
-
- if (flags&PrintAsI1)
- l = l&0xFF;
- else if (flags&PrintAsI2)
- l = l&0xFFFF;
- else if (flags&PrintAsI4)
- l=l&0xFFFFFFFF;
-
- //Special case the 0.
- if (0==l) {
- buffer[0]='0';
- index=1;
- }
- else {
- //Pull apart the number and put the digits (in reverse order) into the buffer.
- for (index=0; l>0; l=l/radix, index++) {
- if ((charVal=(int)(l%radix))<10)
- buffer[index] = (WCHAR)(charVal + '0');
- else
- buffer[index] = (WCHAR)(charVal + 'a' - 10);
- }
- }
-
- //If they want the base, append that to the string (in reverse order)
- if (radix!=10 && ((flags&PrintBase)!=0)) {
- if (16==radix) {
- buffer[index++]='x';
- buffer[index++]='0';
- }
- else if (8==radix) {
- buffer[index++]='0';
- }
- else if ((flags&PrintRadixBase)!=0) {
- buffer[index++]='#';
- buffer[index++]=((radix%10)+'0');
- buffer[index++]=((static_cast<char>(radix)/10)+'0');
- }
- }
-
- if (10==radix) {
- //If it was negative, append the sign.
- if (isNegative) {
- buffer[index++]='-';
- }
-
- //else if they requested, add the '+';
- else if ((flags&PrintSign)!=0) {
- buffer[index++]='+';
- }
-
- //If they requested a leading space, put it on.
- else if ((flags&PrefixSpace)!=0) {
- buffer[index++]=' ';
- }
- }
-
- //Figure out the size of our string.
- if (width<=index)
- buffLength=index;
- else
- buffLength=width;
-
- STRINGREF Local = StringObject::NewString(buffLength);
- WCHAR *LocalBuffer = Local->GetBuffer();
-
- //Put the characters into the String in reverse order
- //Fill the remaining space -- if there is any --
- //with the correct padding character.
- if ((flags&LeftAlign)!=0) {
- for (i=0; i<index; i++) {
- LocalBuffer[i]=buffer[index-i-1];
- }
- for (;i<buffLength; i++) {
- LocalBuffer[i]=paddingChar;
- }
- }
- else {
- for (i=0; i<index; i++) {
- LocalBuffer[buffLength-i-1]=buffer[i];
- }
- for (int j=buffLength-i-1; j>=0; j--) {
- LocalBuffer[j]=paddingChar;
- }
- }
-
- *((STRINGREF *)&rv)=Local;
-
- HELPER_METHOD_FRAME_END();
-
- return rv;
-}
-FCIMPLEND
-
-
-FCIMPL5(LPVOID, ParseNumbers::IntToString, INT32 n, INT32 radix, INT32 width, CLR_CHAR paddingChar, INT32 flags)
-{
- FCALL_CONTRACT;
-
- LPVOID rv = NULL;
-
- HELPER_METHOD_FRAME_BEGIN_RET_0();
-
- bool isNegative = false;
- int index=0;
- int charVal;
- int buffLength;
- int i;
- UINT32 l;
- WCHAR buffer[66]; //Longest possible string length for an integer in binary notation with prefix
-
- if (radix<MinRadix || radix>MaxRadix)
- COMPlusThrowArgumentException(W("radix"), W("Arg_InvalidBase"));
-
- //If the number is negative, make it positive and remember the sign.
- //If the number is MIN_VALUE, this will still be negative, so we'll have to
- //special case this later.
- if (n<0) {
- isNegative=true;
- // For base 10, write out -num, but other bases write out the
- // 2's complement bit pattern
- if (10==radix)
- l = (UINT32)(-n);
- else
- l = (UINT32)n;
- }
- else {
- l=(UINT32)n;
- }
-
- //The conversion to a UINT will sign extend the number. In order to ensure
- //that we only get as many bits as we expect, we chop the number.
- if (flags&PrintAsI1) {
- l = l&0xFF;
- }
- else if (flags&PrintAsI2) {
- l = l&0xFFFF;
- }
- else if (flags&PrintAsI4) {
- l=l&0xFFFFFFFF;
- }
-
- //Special case the 0.
- if (0==l) {
- buffer[0]='0';
- index=1;
- }
- else {
- do {
- charVal = l%radix;
- l=l/radix;
- if (charVal<10) {
- buffer[index++] = (WCHAR)(charVal + '0');
- }
- else {
- buffer[index++] = (WCHAR)(charVal + 'a' - 10);
- }
- }
- while (l!=0);
- }
-
- //If they want the base, append that to the string (in reverse order)
- if (radix!=10 && ((flags&PrintBase)!=0)) {
- if (16==radix) {
- buffer[index++]='x';
- buffer[index++]='0';
- }
- else if (8==radix) {
- buffer[index++]='0';
- }
- }
-
- if (10==radix) {
- //If it was negative, append the sign.
- if (isNegative) {
- buffer[index++]='-';
- }
-
- //else if they requested, add the '+';
- else if ((flags&PrintSign)!=0) {
- buffer[index++]='+';
- }
-
- //If they requested a leading space, put it on.
- else if ((flags&PrefixSpace)!=0) {
- buffer[index++]=' ';
- }
- }
-
- //Figure out the size of our string.
- if (width<=index) {
- buffLength=index;
- }
- else {
- buffLength=width;
- }
-
- STRINGREF Local = StringObject::NewString(buffLength);
- WCHAR *LocalBuffer = Local->GetBuffer();
-
- //Put the characters into the String in reverse order
- //Fill the remaining space -- if there is any --
- //with the correct padding character.
- if ((flags&LeftAlign)!=0) {
- for (i=0; i<index; i++) {
- LocalBuffer[i]=buffer[index-i-1];
- }
- for (;i<buffLength; i++) {
- LocalBuffer[i]=paddingChar;
- }
- }
- else {
- for (i=0; i<index; i++) {
- LocalBuffer[buffLength-i-1]=buffer[i];
- }
- for (int j=buffLength-i-1; j>=0; j--) {
- LocalBuffer[j]=paddingChar;
- }
- }
-
- *((STRINGREF *)&rv)=Local;
-
- HELPER_METHOD_FRAME_END();
-
- return rv;
-}
-FCIMPLEND
-
-
-/*===================================FixRadix===================================
-**It's possible that we parsed the radix in a base other than 10 by accident.
-**This method will take that number, verify that it only contained valid base 10
-**digits, and then do the conversion to base 10. If it contained invalid digits,
-**they tried to pass us a radix such as 1A, so we throw a FormatException.
-**
-**Args: oldVal: The value that we had actually parsed in some arbitrary base.
-** oldBase: The base in which we actually did the parsing.
-**
-**Returns: oldVal as if it had been parsed as a base-10 number.
-**Exceptions: FormatException if either of the digits in the radix aren't
-** valid base-10 numbers.
-==============================================================================*/
-int FixRadix(int oldVal, int oldBase)
-{
- CONTRACTL
- {
- THROWS;
- GC_NOTRIGGER;
- MODE_COOPERATIVE;
- }
- CONTRACTL_END;
-
- int firstDigit = (oldVal/oldBase);
- int secondDigit = (oldVal%oldBase);
-
- if ((firstDigit>=10) || (secondDigit>=10))
- COMPlusThrow(kFormatException, W("Format_BadBase"));
-
- return(firstDigit*10)+secondDigit;
-}
-
-/*=================================StringToLong=================================
-**Action:
-**Returns:
-**Exceptions:
-==============================================================================*/
-FCIMPL4(INT64, ParseNumbers::StringToLong, StringObject * s, INT32 radix, INT32 flags, INT32 *currPos)
-{
- FCALL_CONTRACT;
-
- INT64 result = 0;
-
- HELPER_METHOD_FRAME_BEGIN_RET_1(s);
-
- int sign = 1;
- WCHAR *input;
- int length;
- int i;
- int grabNumbersStart=0;
- INT32 r;
-
- _ASSERTE((flags & PARSE_TREATASI1) == 0 && (flags & PARSE_TREATASI2) == 0);
-
- if (s) {
- i = currPos ? *currPos : 0;
-
- //Do some radix checking.
- //A radix of -1 says to use whatever base is spec'd on the number.
- //Parse in Base10 until we figure out what the base actually is.
- r = (-1==radix)?10:radix;
-
- if (r!=2 && r!=10 && r!=8 && r!=16)
- COMPlusThrow(kArgumentException, W("Arg_InvalidBase"));
-
- s->RefInterpretGetStringValuesDangerousForGC(&input, &length);
-
- if (i<0 || i>=length)
- COMPlusThrowArgumentOutOfRange(W("startIndex"), W("ArgumentOutOfRange_Index"));
-
- //Get rid of the whitespace and then check that we've still got some digits to parse.
- if (!(flags & PARSE_ISTIGHT) && !(flags & PARSE_NOSPACE)) {
- EatWhiteSpace(input,length,&i);
- if (i==length)
- COMPlusThrow(kFormatException, W("Format_EmptyInputString"));
- }
-
- //Check for a sign
- if (input[i]=='-') {
- if (r != 10)
- COMPlusThrow(kArgumentException, W("Arg_CannotHaveNegativeValue"));
-
- if (flags & PARSE_TREATASUNSIGNED)
- COMPlusThrow(kOverflowException, W("Overflow_NegativeUnsigned"));
-
- sign = -1;
- i++;
- }
- else if (input[i]=='+') {
- i++;
- }
-
- if ((radix==-1 || radix==16) && (i+1<length) && input[i]=='0') {
- if (input[i+1]=='x' || input [i+1]=='X') {
- r=16;
- i+=2;
- }
- }
-
- grabNumbersStart=i;
- result = GrabLongs(r,input,length,&i, (flags & PARSE_TREATASUNSIGNED));
-
- //Check if they passed us a string with no parsable digits.
- if (i==grabNumbersStart)
- COMPlusThrow(kFormatException, W("Format_NoParsibleDigits"));
-
- if (flags & PARSE_ISTIGHT) {
- //If we've got effluvia left at the end of the string, complain.
- if (i<length)
- COMPlusThrow(kFormatException, W("Format_ExtraJunkAtEnd"));
- }
-
- //Put the current index back into the correct place.
- if (currPos != NULL) *currPos = i;
-
- //Return the value properly signed.
- if ((UINT64) result==UI64(0x8000000000000000) && sign==1 && r==10 && !(flags & PARSE_TREATASUNSIGNED))
- COMPlusThrow(kOverflowException, W("Overflow_Int64"));
-
- if (r == 10)
- result *= sign;
- }
- else {
- result = 0;
- }
-
- HELPER_METHOD_FRAME_END();
-
- return result;
-}
-FCIMPLEND
-
-FCIMPL4(INT32, ParseNumbers::StringToInt, StringObject * s, INT32 radix, INT32 flags, INT32* currPos)
-{
- FCALL_CONTRACT;
-
- INT32 result = 0;
-
- HELPER_METHOD_FRAME_BEGIN_RET_1(s);
-
- int sign = 1;
- WCHAR *input;
- int length;
- int i;
- int grabNumbersStart=0;
- INT32 r;
-
- // TreatAsI1 and TreatAsI2 are mutually exclusive.
- _ASSERTE(!((flags & PARSE_TREATASI1) != 0 && (flags & PARSE_TREATASI2) != 0));
-
- if (s) {
- //They're requied to tell me where to start parsing.
- i = currPos ? (*currPos) : 0;
-
- //Do some radix checking.
- //A radix of -1 says to use whatever base is spec'd on the number.
- //Parse in Base10 until we figure out what the base actually is.
- r = (-1==radix)?10:radix;
- if (r!=2 && r!=10 && r!=8 && r!=16)
- COMPlusThrow(kArgumentException, W("Arg_InvalidBase"));
-
- s->RefInterpretGetStringValuesDangerousForGC(&input, &length);
-
- if (i<0 || i>=length)
- COMPlusThrowArgumentOutOfRange(W("startIndex"), W("ArgumentOutOfRange_Index"));
-
- //Get rid of the whitespace and then check that we've still got some digits to parse.
- if (!(flags & PARSE_ISTIGHT) && !(flags & PARSE_NOSPACE)) {
- EatWhiteSpace(input,length,&i);
- if (i==length)
- COMPlusThrow(kFormatException, W("Format_EmptyInputString"));
- }
-
- //Check for a sign
- if (input[i]=='-') {
- if (r != 10)
- COMPlusThrow(kArgumentException, W("Arg_CannotHaveNegativeValue"));
-
- if (flags & PARSE_TREATASUNSIGNED)
- COMPlusThrow(kOverflowException, W("Overflow_NegativeUnsigned"));
-
- sign = -1;
- i++;
- }
- else if (input[i]=='+') {
- i++;
- }
-
- //Consume the 0x if we're in an unknown base or in base-16.
- if ((radix==-1||radix==16) && (i+1<length) && input[i]=='0') {
- if (input[i+1]=='x' || input [i+1]=='X') {
- r=16;
- i+=2;
- }
- }
-
- grabNumbersStart=i;
- result = GrabInts(r,input,length,&i, (flags & PARSE_TREATASUNSIGNED));
-
- //Check if they passed us a string with no parsable digits.
- if (i==grabNumbersStart)
- COMPlusThrow(kFormatException, W("Format_NoParsibleDigits"));
-
- if (flags & PARSE_ISTIGHT) {
- //If we've got effluvia left at the end of the string, complain.
- if (i<(length))
- COMPlusThrow(kFormatException, W("Format_ExtraJunkAtEnd"));
- }
-
- //Put the current index back into the correct place.
- if (currPos != NULL) *currPos = i;
-
- //Return the value properly signed.
- if (flags & PARSE_TREATASI1) {
- if ((UINT32)result > 0xFF)
- COMPlusThrow(kOverflowException, W("Overflow_SByte"));
-
- // result looks positive when parsed as an I4
- _ASSERTE(sign==1 || r==10);
- }
- else if (flags & PARSE_TREATASI2) {
- if ((UINT32)result > 0xFFFF)
- COMPlusThrow(kOverflowException, W("Overflow_Int16"));
-
- // result looks positive when parsed as an I4
- _ASSERTE(sign==1 || r==10);
- }
- else if ((UINT32) result==0x80000000U && sign==1 && r==10 && !(flags & PARSE_TREATASUNSIGNED)) {
- COMPlusThrow(kOverflowException, W("Overflow_Int32"));
- }
-
- if (r == 10)
- result *= sign;
- }
- else {
- result = 0;
- }
-
- HELPER_METHOD_FRAME_END();
-
- return result;
-}
-FCIMPLEND
//
//
diff --git a/src/vm/comutilnative.h b/src/vm/comutilnative.h
index 831e1c071e..07c57c1312 100644
--- a/src/vm/comutilnative.h
+++ b/src/vm/comutilnative.h
@@ -37,42 +37,6 @@
//
//
-// PARSE NUMBERS
-//
-//
-
-#define MinRadix 2
-#define MaxRadix 36
-
-class ParseNumbers {
-
- enum FmtFlags {
- LeftAlign = 0x1, //Ensure that these conform to the values specified in the managed files.
- CenterAlign = 0x2,
- RightAlign = 0x4,
- PrefixSpace = 0x8,
- PrintSign = 0x10,
- PrintBase = 0x20,
- TreatAsUnsigned = 0x10,
- PrintAsI1 = 0x40,
- PrintAsI2 = 0x80,
- PrintAsI4 = 0x100,
- PrintRadixBase = 0x200,
- AlternateForm = 0x400};
-
-public:
-
- static INT32 GrabInts(const INT32 radix, __in_ecount(length) WCHAR *buffer, const int length, int *i, BOOL isUnsigned);
- static INT64 GrabLongs(const INT32 radix, __in_ecount(length) WCHAR *buffer, const int length, int *i, BOOL isUnsigned);
-
- static FCDECL5(LPVOID, IntToString, INT32 l, INT32 radix, INT32 width, CLR_CHAR paddingChar, INT32 flags);
- static FCDECL5_VII(LPVOID, LongToString, INT64 l, INT32 radix, INT32 width, CLR_CHAR paddingChar, INT32 flags);
- static FCDECL4(INT32, StringToInt, StringObject * s, INT32 radix, INT32 flags, INT32* currPos);
- static FCDECL4(INT64, StringToLong, StringObject * s, INT32 radix, INT32 flags, INT32* currPos);
-};
-
-//
-//
// EXCEPTION NATIVE
//
//
diff --git a/src/vm/ecalllist.h b/src/vm/ecalllist.h
index 76be0b172c..4720b5a11f 100644
--- a/src/vm/ecalllist.h
+++ b/src/vm/ecalllist.h
@@ -89,13 +89,6 @@ FCFuncStart(gSymWrapperCodePunkSafeHandleFuncs)
FCFuncElement("nGetDReleaseTarget", COMPunkSafeHandle::nGetDReleaseTarget)
FCFuncEnd()
-FCFuncStart(gParseNumbersFuncs)
- FCFuncElement("IntToString", ParseNumbers::IntToString)
- FCFuncElement("LongToString", ParseNumbers::LongToString)
- FCFuncElement("StringToInt", ParseNumbers::StringToInt)
- FCFuncElement("StringToLong", ParseNumbers::StringToLong)
-FCFuncEnd()
-
FCFuncStart(gObjectFuncs)
FCIntrinsic("GetType", ObjectNative::GetClass, CORINFO_INTRINSIC_Object_GetType)
@@ -659,13 +652,13 @@ FCFuncStart(gMathFuncs)
FCIntrinsic("Cosh", COMDouble::Cosh, CORINFO_INTRINSIC_Cosh)
FCIntrinsic("Exp", COMDouble::Exp, CORINFO_INTRINSIC_Exp)
FCIntrinsic("Floor", COMDouble::Floor, CORINFO_INTRINSIC_Floor)
+ FCFuncElement("FMod", COMDouble::FMod)
FCFuncElement("Log", COMDouble::Log)
FCIntrinsic("Log10", COMDouble::Log10, CORINFO_INTRINSIC_Log10)
+ FCFuncElement("ModF", COMDouble::ModF)
FCIntrinsic("Pow", COMDouble::Pow, CORINFO_INTRINSIC_Pow)
- FCIntrinsic("Round", COMDouble::Round, CORINFO_INTRINSIC_Round)
FCIntrinsic("Sin", COMDouble::Sin, CORINFO_INTRINSIC_Sin)
FCIntrinsic("Sinh", COMDouble::Sinh, CORINFO_INTRINSIC_Sinh)
- FCFuncElement("SplitFractionDouble", COMDouble::ModF)
FCIntrinsic("Sqrt", COMDouble::Sqrt, CORINFO_INTRINSIC_Sqrt)
FCIntrinsic("Tan", COMDouble::Tan, CORINFO_INTRINSIC_Tan)
FCIntrinsic("Tanh", COMDouble::Tanh, CORINFO_INTRINSIC_Tanh)
@@ -681,13 +674,13 @@ FCFuncStart(gMathFFuncs)
FCIntrinsic("Cosh", COMSingle::Cosh, CORINFO_INTRINSIC_Cosh)
FCIntrinsic("Exp", COMSingle::Exp, CORINFO_INTRINSIC_Exp)
FCIntrinsic("Floor", COMSingle::Floor, CORINFO_INTRINSIC_Floor)
+ FCFuncElement("FMod", COMSingle::FMod)
FCFuncElement("Log", COMSingle::Log)
FCIntrinsic("Log10", COMSingle::Log10, CORINFO_INTRINSIC_Log10)
+ FCFuncElement("ModF", COMSingle::ModF)
FCIntrinsic("Pow", COMSingle::Pow, CORINFO_INTRINSIC_Pow)
- FCIntrinsic("Round", COMSingle::Round, CORINFO_INTRINSIC_Round)
FCIntrinsic("Sin", COMSingle::Sin, CORINFO_INTRINSIC_Sin)
FCIntrinsic("Sinh", COMSingle::Sinh, CORINFO_INTRINSIC_Sinh)
- FCFuncElement("SplitFractionSingle", COMSingle::ModF)
FCIntrinsic("Sqrt", COMSingle::Sqrt, CORINFO_INTRINSIC_Sqrt)
FCIntrinsic("Tan", COMSingle::Tan, CORINFO_INTRINSIC_Tan)
FCIntrinsic("Tanh", COMSingle::Tanh, CORINFO_INTRINSIC_Tanh)
@@ -1400,7 +1393,6 @@ FCClassElement("Object", "System", gObjectFuncs)
FCClassElement("ObjectMarshaler", "System.StubHelpers", gObjectMarshalerFuncs)
#endif
FCClassElement("OverlappedData", "System.Threading", gOverlappedFuncs)
-FCClassElement("ParseNumbers", "System", gParseNumbersFuncs)
FCClassElement("PunkSafeHandle", "System.Reflection.Emit", gSymWrapperCodePunkSafeHandleFuncs)
diff --git a/src/vm/eventpipe.cpp b/src/vm/eventpipe.cpp
index eebd2744a4..8f2e8ff937 100644
--- a/src/vm/eventpipe.cpp
+++ b/src/vm/eventpipe.cpp
@@ -390,7 +390,14 @@ EventPipeProvider* EventPipe::CreateProvider(const SString &providerName, EventP
}
CONTRACTL_END;
- return new EventPipeProvider(providerName, pCallbackFunction, pCallbackData);
+ EventPipeProvider *pProvider = NULL;
+ if (s_pConfig != NULL)
+ {
+ pProvider = s_pConfig->CreateProvider(providerName, pCallbackFunction, pCallbackData);
+ }
+
+ return pProvider;
+
}
void EventPipe::DeleteProvider(EventPipeProvider *pProvider)
@@ -418,8 +425,10 @@ void EventPipe::DeleteProvider(EventPipeProvider *pProvider)
else
{
// Delete the provider now.
- // NOTE: This will remove it from all of the EventPipe data structures.
- delete(pProvider);
+ if (s_pConfig != NULL)
+ {
+ s_pConfig->DeleteProvider(pProvider);
+ }
}
}
}
diff --git a/src/vm/eventpipeconfiguration.cpp b/src/vm/eventpipeconfiguration.cpp
index 8b703718b2..ae1dd4e099 100644
--- a/src/vm/eventpipeconfiguration.cpp
+++ b/src/vm/eventpipeconfiguration.cpp
@@ -75,7 +75,7 @@ void EventPipeConfiguration::Initialize()
CONTRACTL_END;
// Create the configuration provider.
- m_pConfigProvider = EventPipe::CreateProvider(SL(s_configurationProviderName));
+ m_pConfigProvider = CreateProvider(SL(s_configurationProviderName), NULL, NULL);
// Create the metadata event.
m_pMetadataEvent = m_pConfigProvider->AddEvent(
@@ -86,6 +86,49 @@ void EventPipeConfiguration::Initialize()
false); /* needStack */
}
+EventPipeProvider* EventPipeConfiguration::CreateProvider(const SString &providerName, EventPipeCallback pCallbackFunction, void *pCallbackData)
+{
+ CONTRACTL
+ {
+ THROWS;
+ GC_NOTRIGGER;
+ MODE_ANY;
+ }
+ CONTRACTL_END;
+
+ // Allocate a new provider.
+ EventPipeProvider *pProvider = new EventPipeProvider(this, providerName, pCallbackFunction, pCallbackData);
+
+ // Register the provider with the configuration system.
+ RegisterProvider(*pProvider);
+
+ return pProvider;
+}
+
+void EventPipeConfiguration::DeleteProvider(EventPipeProvider *pProvider)
+{
+ CONTRACTL
+ {
+ THROWS;
+ GC_NOTRIGGER;
+ MODE_ANY;
+ PRECONDITION(pProvider != NULL);
+ }
+ CONTRACTL_END;
+
+ if (pProvider == NULL)
+ {
+ return;
+ }
+
+ // Unregister the provider.
+ UnregisterProvider(*pProvider);
+
+ // Free the provider itself.
+ delete(pProvider);
+}
+
+
bool EventPipeConfiguration::RegisterProvider(EventPipeProvider &provider)
{
CONTRACTL
diff --git a/src/vm/eventpipeconfiguration.h b/src/vm/eventpipeconfiguration.h
index 1d161367b2..baca06920a 100644
--- a/src/vm/eventpipeconfiguration.h
+++ b/src/vm/eventpipeconfiguration.h
@@ -35,6 +35,12 @@ public:
// Perform initialization that cannot be performed in the constructor.
void Initialize();
+ // Create a new provider.
+ EventPipeProvider* CreateProvider(const SString &providerName, EventPipeCallback pCallbackFunction, void *pCallbackData);
+
+ // Delete a provider.
+ void DeleteProvider(EventPipeProvider *pProvider);
+
// Register a provider.
bool RegisterProvider(EventPipeProvider &provider);
diff --git a/src/vm/eventpipeprovider.cpp b/src/vm/eventpipeprovider.cpp
index 7361541e77..c10dd33638 100644
--- a/src/vm/eventpipeprovider.cpp
+++ b/src/vm/eventpipeprovider.cpp
@@ -11,13 +11,14 @@
#ifdef FEATURE_PERFTRACING
-EventPipeProvider::EventPipeProvider(const SString &providerName, EventPipeCallback pCallbackFunction, void *pCallbackData)
+EventPipeProvider::EventPipeProvider(EventPipeConfiguration *pConfig, const SString &providerName, EventPipeCallback pCallbackFunction, void *pCallbackData)
{
CONTRACTL
{
THROWS;
GC_NOTRIGGER;
MODE_ANY;
+ PRECONDITION(pConfig != NULL);
}
CONTRACTL_END;
@@ -28,11 +29,7 @@ EventPipeProvider::EventPipeProvider(const SString &providerName, EventPipeCallb
m_pEventList = new SList<SListElem<EventPipeEvent*>>();
m_pCallbackFunction = pCallbackFunction;
m_pCallbackData = pCallbackData;
- m_pConfig = EventPipe::GetConfiguration();
- _ASSERTE(m_pConfig != NULL);
-
- // Register the provider.
- m_pConfig->RegisterProvider(*this);
+ m_pConfig = pConfig;
}
EventPipeProvider::~EventPipeProvider()
@@ -45,15 +42,6 @@ EventPipeProvider::~EventPipeProvider()
}
CONTRACTL_END;
- // Unregister the provider.
- // This call is re-entrant.
- // NOTE: We don't use the cached event pipe configuration pointer
- // in case this runs during shutdown and the configuration has already
- // been freed.
- EventPipeConfiguration* pConfig = EventPipe::GetConfiguration();
- _ASSERTE(pConfig != NULL);
- pConfig->UnregisterProvider(*this);
-
// Free all of the events.
if(m_pEventList != NULL)
{
diff --git a/src/vm/eventpipeprovider.h b/src/vm/eventpipeprovider.h
index 7b92faca72..405ce32154 100644
--- a/src/vm/eventpipeprovider.h
+++ b/src/vm/eventpipeprovider.h
@@ -64,7 +64,7 @@ private:
bool m_deleteDeferred;
// Private constructor because all providers are created through EventPipe::CreateProvider.
- EventPipeProvider(const SString &providerName, EventPipeCallback pCallbackFunction = NULL, void *pCallbackData = NULL);
+ EventPipeProvider(EventPipeConfiguration *pConfig, const SString &providerName, EventPipeCallback pCallbackFunction = NULL, void *pCallbackData = NULL);
public:
diff --git a/src/vm/exceptionhandling.cpp b/src/vm/exceptionhandling.cpp
index a52ccd7c2a..811237981c 100644
--- a/src/vm/exceptionhandling.cpp
+++ b/src/vm/exceptionhandling.cpp
@@ -5156,7 +5156,7 @@ static BOOL IsIPinVirtualStub(PCODE f_IP)
}
VirtualCallStubManager::StubKind sk;
- VirtualCallStubManager::FindStubManager(f_IP, &sk);
+ VirtualCallStubManager::FindStubManager(f_IP, &sk, FALSE /* usePredictStubKind */);
if (sk == VirtualCallStubManager::SK_DISPATCH)
{
diff --git a/src/vm/finalizerthread.cpp b/src/vm/finalizerthread.cpp
index 3ba3468407..2955decbd7 100644
--- a/src/vm/finalizerthread.cpp
+++ b/src/vm/finalizerthread.cpp
@@ -744,6 +744,8 @@ DWORD WINAPI FinalizerThread::FinalizerThreadStart(void *args)
#endif
GetFinalizerThread()->SetBackground(TRUE);
+ EnsureYieldProcessorNormalizedInitialized();
+
#ifdef FEATURE_PROFAPI_ATTACH_DETACH
// Add the Profiler Attach Event to the array of event handles that the
// finalizer thread waits on. If the process is not enabled for profiler
diff --git a/src/vm/gcenv.os.cpp b/src/vm/gcenv.os.cpp
index 22c8a97176..b1b9c32635 100644
--- a/src/vm/gcenv.os.cpp
+++ b/src/vm/gcenv.os.cpp
@@ -83,7 +83,7 @@ bool GCToOSInterface::SetCurrentThreadIdealAffinity(GCThreadAffinity* affinity)
#if !defined(FEATURE_CORESYSTEM)
SetThreadIdealProcessor(GetCurrentThread(), (DWORD)affinity->Processor);
-#elif !defined(FEATURE_PAL)
+#else
PROCESSOR_NUMBER proc;
if (affinity->Group != -1)
@@ -94,6 +94,7 @@ bool GCToOSInterface::SetCurrentThreadIdealAffinity(GCThreadAffinity* affinity)
success = !!SetThreadIdealProcessorEx(GetCurrentThread(), &proc, NULL);
}
+#if !defined(FEATURE_PAL)
else
{
if (GetThreadIdealProcessorEx(GetCurrentThread(), &proc))
@@ -102,6 +103,7 @@ bool GCToOSInterface::SetCurrentThreadIdealAffinity(GCThreadAffinity* affinity)
success = !!SetThreadIdealProcessorEx(GetCurrentThread(), &proc, &proc);
}
}
+#endif // !defined(FEATURE_PAL)
#endif
return success;
diff --git a/src/vm/gdbjit.cpp b/src/vm/gdbjit.cpp
index 9557b0bf3e..9dbf9df1a2 100644
--- a/src/vm/gdbjit.cpp
+++ b/src/vm/gdbjit.cpp
@@ -674,7 +674,7 @@ const int DebugStringCount = sizeof(DebugStrings) / sizeof(DebugStrings[0]);
/* Static data for .debug_abbrev */
const unsigned char AbbrevTable[] = {
1, DW_TAG_compile_unit, DW_CHILDREN_yes,
- DW_AT_producer, DW_FORM_strp, DW_AT_language, DW_FORM_data2, DW_AT_name, DW_FORM_strp,
+ DW_AT_producer, DW_FORM_strp, DW_AT_language, DW_FORM_data2, DW_AT_name, DW_FORM_strp, DW_AT_comp_dir, DW_FORM_strp,
DW_AT_stmt_list, DW_FORM_sec_offset, 0, 0,
2, DW_TAG_base_type, DW_CHILDREN_no,
@@ -772,6 +772,7 @@ struct __attribute__((packed)) DebugInfoCU
uint32_t m_prod_off;
uint16_t m_lang;
uint32_t m_cu_name;
+ uint32_t m_cu_dir;
uint32_t m_line_num;
} debugInfoCU = {
#ifdef FEATURE_GDBJIT_LANGID_CS
@@ -2479,9 +2480,7 @@ void NotifyGdb::OnMethodPrepared(MethodDesc* methodDescPtr)
SString modName = mod->GetFile()->GetPath();
StackScratchBuffer scratch;
const char* szModName = modName.GetUTF8(scratch);
- const char *szModulePath, *szModuleFile;
- SplitPathname(szModName, szModulePath, szModuleFile);
-
+ const char* szModuleFile = SplitFilename(szModName);
int length = MultiByteToWideChar(CP_UTF8, 0, szModuleFile, -1, NULL, 0);
if (length == 0)
@@ -2508,7 +2507,7 @@ void NotifyGdb::OnMethodPrepared(MethodDesc* methodDescPtr)
if (isListedModule(wszModuleFile))
{
- bool bEmitted = EmitDebugInfo(elfBuilder, methodDescPtr, pCode, codeSize, szModuleFile);
+ bool bEmitted = EmitDebugInfo(elfBuilder, methodDescPtr, pCode, codeSize);
bNotify = bNotify || bEmitted;
}
#ifdef FEATURE_GDBJIT_SYMTAB
@@ -2661,7 +2660,7 @@ bool NotifyGdb::EmitSymtab(Elf_Builder &elfBuilder, MethodDesc* methodDescPtr, P
}
#endif // FEATURE_GDBJIT_SYMTAB
-bool NotifyGdb::EmitDebugInfo(Elf_Builder &elfBuilder, MethodDesc* methodDescPtr, PCODE pCode, TADDR codeSize, const char *szModuleFile)
+bool NotifyGdb::EmitDebugInfo(Elf_Builder &elfBuilder, MethodDesc* methodDescPtr, PCODE pCode, TADDR codeSize)
{
unsigned int thunkIndexBase = elfBuilder.GetSectionCount();
@@ -2750,13 +2749,26 @@ bool NotifyGdb::EmitDebugInfo(Elf_Builder &elfBuilder, MethodDesc* methodDescPtr
return false;
}
+ const char *cuPath = "";
+
/* Build .debug_line section */
- if (!BuildLineTable(dbgLine, pCode, codeSize, symInfo, symInfoLen))
+ if (!BuildLineTable(dbgLine, pCode, codeSize, symInfo, symInfoLen, cuPath))
{
return false;
}
- DebugStrings[1] = szModuleFile;
+ // Split full path to compile unit into file name and directory path
+ const char *fileName = SplitFilename(cuPath);
+ int dirLen = fileName - cuPath;
+ NewArrayHolder<char> dirPath;
+ if (dirLen != 0)
+ {
+ dirPath = new char[dirLen];
+ memcpy(dirPath, DebugStrings[1], dirLen - 1);
+ dirPath[dirLen - 1] = '\0';
+ }
+ DebugStrings[1] = fileName;
+ DebugStrings[2] = dirPath ? (const char *)dirPath : "";
/* Build .debug_str section */
if (!BuildDebugStrings(dbgStr, pTypeMap, method))
@@ -2770,6 +2782,9 @@ bool NotifyGdb::EmitDebugInfo(Elf_Builder &elfBuilder, MethodDesc* methodDescPtr
return false;
}
+ DebugStrings[1] = "";
+ DebugStrings[2] = "";
+
for (int i = 0; i < method.GetCount(); ++i)
{
method[i]->lines = nullptr;
@@ -2893,12 +2908,13 @@ void NotifyGdb::MethodPitched(MethodDesc* methodDescPtr)
}
/* Build the DWARF .debug_line section */
-bool NotifyGdb::BuildLineTable(MemBuf& buf, PCODE startAddr, TADDR codeSize, SymbolsInfo* lines, unsigned nlines)
+bool NotifyGdb::BuildLineTable(MemBuf& buf, PCODE startAddr, TADDR codeSize, SymbolsInfo* lines, unsigned nlines,
+ const char * &cuPath)
{
MemBuf fileTable, lineProg;
/* Build file table */
- if (!BuildFileTable(fileTable, lines, nlines))
+ if (!BuildFileTable(fileTable, lines, nlines, cuPath))
return false;
/* Build line info program */
if (!BuildLineProg(lineProg, startAddr, codeSize, lines, nlines))
@@ -2906,85 +2922,193 @@ bool NotifyGdb::BuildLineTable(MemBuf& buf, PCODE startAddr, TADDR codeSize, Sym
return false;
}
- buf.MemSize = sizeof(DwarfLineNumHeader) + 1 + fileTable.MemSize + lineProg.MemSize;
+ buf.MemSize = sizeof(DwarfLineNumHeader) + fileTable.MemSize + lineProg.MemSize;
buf.MemPtr = new char[buf.MemSize];
/* Fill the line info header */
DwarfLineNumHeader* header = reinterpret_cast<DwarfLineNumHeader*>(buf.MemPtr.GetValue());
memcpy(buf.MemPtr, &LineNumHeader, sizeof(DwarfLineNumHeader));
- header->m_length = buf.MemSize - sizeof(uint32_t);
- header->m_hdr_length = sizeof(DwarfLineNumHeader) + 1 + fileTable.MemSize - 2 * sizeof(uint32_t) - sizeof(uint16_t);
- buf.MemPtr[sizeof(DwarfLineNumHeader)] = 0; // this is for missing directory table
+ header->m_length = buf.MemSize - sizeof(header->m_length);
+
+ // Set m_hdr_field to the number of bytes following the m_hdr_field field to the beginning of the first byte of
+ // the line number program itself.
+ header->m_hdr_length = sizeof(DwarfLineNumHeader)
+ - sizeof(header->m_length)
+ - sizeof(header->m_version)
+ - sizeof(header->m_hdr_length)
+ + fileTable.MemSize;
+
/* copy file table */
- memcpy(buf.MemPtr + sizeof(DwarfLineNumHeader) + 1, fileTable.MemPtr, fileTable.MemSize);
+ memcpy(buf.MemPtr + sizeof(DwarfLineNumHeader), fileTable.MemPtr, fileTable.MemSize);
/* copy line program */
- memcpy(buf.MemPtr + sizeof(DwarfLineNumHeader) + 1 + fileTable.MemSize, lineProg.MemPtr, lineProg.MemSize);
+ memcpy(buf.MemPtr + sizeof(DwarfLineNumHeader) + fileTable.MemSize, lineProg.MemPtr, lineProg.MemSize);
return true;
}
-/* Buid the source files table for DWARF source line info */
-bool NotifyGdb::BuildFileTable(MemBuf& buf, SymbolsInfo* lines, unsigned nlines)
+// A class for building Directory Table and File Table (in .debug_line section) from a list of files
+class NotifyGdb::FileTableBuilder
{
- NewArrayHolder<const char*> files = nullptr;
- unsigned nfiles = 0;
+ int m_capacity;
- /* GetValue file names and replace them with indices in file table */
- files = new const char*[nlines];
- if (files == nullptr)
- return false;
- for (unsigned i = 0; i < nlines; ++i)
- {
- if (lines[i].fileName[0] == 0)
- continue;
- const char *filePath, *fileName;
- SplitPathname(lines[i].fileName, filePath, fileName);
+ NewArrayHolder< NewArrayHolder<char> > m_dirs;
+ int m_dirs_count;
- /* if this isn't first then we already added file, so adjust index */
- lines[i].fileIndex = (nfiles) ? (nfiles - 1) : (nfiles);
+ struct FileEntry
+ {
+ const char* path;
+ const char* name;
+ int dir;
+ };
+ NewArrayHolder<FileEntry> m_files;
+ int m_files_count;
- bool found = false;
- for (int j = 0; j < nfiles; ++j)
+ int FindDir(const char *name) const
+ {
+ for (int i = 0; i < m_dirs_count; ++i)
{
- if (strcmp(fileName, files[j]) == 0)
- {
- found = true;
- break;
- }
+ if (strcmp(m_dirs[i], name) == 0)
+ return i;
}
+ return -1;
+ }
- /* add new source file */
- if (!found)
+ int FindFile(const char *path) const
+ {
+ for (int i = 0; i < m_files_count; ++i)
{
- files[nfiles++] = fileName;
+ if (strcmp(m_files[i].path, path) == 0)
+ return i;
}
+ return -1;
}
- /* build file table */
- unsigned totalSize = 0;
+public:
- for (unsigned i = 0; i < nfiles; ++i)
+ FileTableBuilder(int capacity) :
+ m_capacity(capacity),
+ m_dirs(new NewArrayHolder<char>[capacity]),
+ m_dirs_count(0),
+ m_files(new FileEntry[capacity]),
+ m_files_count(0)
{
- totalSize += strlen(files[i]) + 1 + 3;
}
- totalSize += 1;
- buf.MemSize = totalSize;
- buf.MemPtr = new char[buf.MemSize];
+ int Add(const char *path)
+ {
+ // Already exists?
+ int i = FindFile(path);
+ if (i != -1)
+ return i;
+
+ if (m_files_count >= m_capacity)
+ return -1;
+
+ // Add new file entry
+ m_files[m_files_count].path = path;
+ const char *filename = SplitFilename(path);
+ m_files[m_files_count].name = filename;
+ int dirLen = filename - path;
+ if (dirLen == 0)
+ {
+ m_files[m_files_count].dir = 0;
+ return m_files_count++;
+ }
+
+ // Construct directory path
+ NewArrayHolder<char> dirName = new char[dirLen + 1];
+ int delimiterDelta = dirLen == 1 ? 0 : 1; // Avoid empty dir entry when file is at Unix root /
+ memcpy(dirName, path, dirLen - delimiterDelta);
+ dirName[dirLen - delimiterDelta] = '\0';
+
+ // Try to find existing directory entry
+ i = FindDir(dirName);
+ if (i != -1)
+ {
+ m_files[m_files_count].dir = i + 1;
+ return m_files_count++;
+ }
+
+ // Create new directory entry
+ if (m_dirs_count >= m_capacity)
+ return -1;
+
+ m_dirs[m_dirs_count++] = dirName.Extract();
+
+ m_files[m_files_count].dir = m_dirs_count;
+ return m_files_count++;
+ }
- /* copy collected file names */
- char *ptr = buf.MemPtr;
- for (unsigned i = 0; i < nfiles; ++i)
+ void Build(MemBuf& buf)
{
- strcpy(ptr, files[i]);
- ptr += strlen(files[i]) + 1;
- // three LEB128 entries which we don't care
- *ptr++ = 0;
- *ptr++ = 0;
+ unsigned totalSize = 0;
+
+ // Compute buffer size
+ for (unsigned i = 0; i < m_dirs_count; ++i)
+ totalSize += strlen(m_dirs[i]) + 1;
+ totalSize += 1;
+
+ char cnv_buf[16];
+ for (unsigned i = 0; i < m_files_count; ++i)
+ {
+ int len = Leb128Encode(static_cast<uint32_t>(m_files[i].dir), cnv_buf, sizeof(cnv_buf));
+ totalSize += strlen(m_files[i].name) + 1 + len + 2;
+ }
+ totalSize += 1;
+
+ // Fill the buffer
+ buf.MemSize = totalSize;
+ buf.MemPtr = new char[buf.MemSize];
+
+ char *ptr = buf.MemPtr;
+
+ for (unsigned i = 0; i < m_dirs_count; ++i)
+ {
+ strcpy(ptr, m_dirs[i]);
+ ptr += strlen(m_dirs[i]) + 1;
+ }
+ // final zero byte for directory table
*ptr++ = 0;
+
+ for (unsigned i = 0; i < m_files_count; ++i)
+ {
+ strcpy(ptr, m_files[i].name);
+ ptr += strlen(m_files[i].name) + 1;
+
+ // Index in directory table
+ int len = Leb128Encode(static_cast<uint32_t>(m_files[i].dir), cnv_buf, sizeof(cnv_buf));
+ memcpy(ptr, cnv_buf, len);
+ ptr += len;
+
+ // Two LEB128 entries which we don't care
+ *ptr++ = 0;
+ *ptr++ = 0;
+ }
+ // final zero byte
+ *ptr = 0;
}
- // final zero byte
- *ptr = 0;
+};
+
+/* Buid the source files table for DWARF source line info */
+bool NotifyGdb::BuildFileTable(MemBuf& buf, SymbolsInfo* lines, unsigned nlines, const char * &cuPath)
+{
+ FileTableBuilder fileTable(nlines);
+
+ cuPath = "";
+ for (unsigned i = 0; i < nlines; ++i)
+ {
+ const char* fileName = lines[i].fileName;
+
+ if (fileName[0] == '\0')
+ continue;
+
+ if (*cuPath == '\0') // Use first non-empty filename as compile unit
+ cuPath = fileName;
+
+ lines[i].fileIndex = fileTable.Add(fileName);
+ }
+
+ fileTable.Build(buf);
return true;
}
@@ -3244,6 +3368,7 @@ bool NotifyGdb::BuildDebugInfo(MemBuf& buf, PTK_TypeInfoMap pTypeMap, FunctionMe
offset += sizeof(DebugInfoCU);
diCU->m_prod_off = 0;
diCU->m_cu_name = strlen(DebugStrings[0]) + 1;
+ diCU->m_cu_dir = diCU->m_cu_name + strlen(DebugStrings[1]) + 1;
{
auto iter = pTypeMap->Begin();
while (iter != pTypeMap->End())
@@ -3404,22 +3529,18 @@ bool NotifyGdb::BuildSymbolTableSection(MemBuf& buf, PCODE addr, TADDR codeSize,
return true;
}
-/* Split full path name into directory & file names */
-void NotifyGdb::SplitPathname(const char* path, const char*& pathName, const char*& fileName)
+/* Split file name part from the full path */
+const char * NotifyGdb::SplitFilename(const char* path)
{
- char* pSlash = strrchr(path, '/');
-
- if (pSlash != nullptr)
+ // Search for the last directory delimiter (Windows or Unix)
+ const char *pSlash = nullptr;
+ for (const char *p = path; *p != '\0'; p++)
{
- *pSlash = 0;
- fileName = ++pSlash;
- pathName = path;
- }
- else
- {
- fileName = path;
- pathName = nullptr;
+ if (*p == '/' || *p == '\\')
+ pSlash = p;
}
+
+ return pSlash ? pSlash + 1 : path;
}
/* ELF 32bit header */
diff --git a/src/vm/gdbjit.h b/src/vm/gdbjit.h
index f7267ad2a1..6cfe52c36d 100644
--- a/src/vm/gdbjit.h
+++ b/src/vm/gdbjit.h
@@ -340,6 +340,7 @@ class Elf_Builder;
class NotifyGdb
{
public:
+ class FileTableBuilder;
static void MethodPrepared(MethodDesc* methodDescPtr);
static void MethodPitched(MethodDesc* methodDescPtr);
template <typename PARENT_TRAITS>
@@ -422,7 +423,7 @@ private:
#ifdef FEATURE_GDBJIT_SYMTAB
static bool EmitSymtab(Elf_Builder &, MethodDesc* methodDescPtr, PCODE pCode, TADDR codeSize);
#endif // FEATURE_GDBJIT_SYMTAB
- static bool EmitDebugInfo(Elf_Builder &, MethodDesc* methodDescPtr, PCODE pCode, TADDR codeSize, const char *szModuleFile);
+ static bool EmitDebugInfo(Elf_Builder &, MethodDesc* methodDescPtr, PCODE pCode, TADDR codeSize);
static bool BuildSymbolTableSection(MemBuf& buf, PCODE addr, TADDR codeSize, int methodCount,
NewArrayHolder<Elf_Symbol> &symbolNames, int symbolCount,
@@ -432,14 +433,15 @@ private:
static bool BuildDebugAbbrev(MemBuf& buf);
static bool BuildDebugInfo(MemBuf& buf, PTK_TypeInfoMap pTypeMap, FunctionMemberPtrArrayHolder &method);
static bool BuildDebugPub(MemBuf& buf, const char* name, uint32_t size, uint32_t dieOffset);
- static bool BuildLineTable(MemBuf& buf, PCODE startAddr, TADDR codeSize, SymbolsInfo* lines, unsigned nlines);
- static bool BuildFileTable(MemBuf& buf, SymbolsInfo* lines, unsigned nlines);
+ static bool BuildLineTable(MemBuf& buf, PCODE startAddr, TADDR codeSize, SymbolsInfo* lines, unsigned nlines,
+ const char * &cuPath);
+ static bool BuildFileTable(MemBuf& buf, SymbolsInfo* lines, unsigned nlines, const char * &cuPath);
static bool BuildLineProg(MemBuf& buf, PCODE startAddr, TADDR codeSize, SymbolsInfo* lines, unsigned nlines);
static void IssueSetAddress(char*& ptr, PCODE addr);
static void IssueEndOfSequence(char*& ptr);
static void IssueSimpleCommand(char*& ptr, uint8_t command);
static void IssueParamCommand(char*& ptr, uint8_t command, char* param, int param_len);
- static void SplitPathname(const char* path, const char*& pathName, const char*& fileName);
+ static const char* SplitFilename(const char* path);
static bool CollectCalledMethods(CalledMethod* pCM, TADDR nativeCode, FunctionMemberPtrArrayHolder &method,
NewArrayHolder<Elf_Symbol> &symbolNames, int &symbolCount);
};
diff --git a/src/vm/i386/asmconstants.h b/src/vm/i386/asmconstants.h
index 0a581cffe0..f7d5f709dc 100644
--- a/src/vm/i386/asmconstants.h
+++ b/src/vm/i386/asmconstants.h
@@ -176,9 +176,6 @@ ASMCONSTANTS_C_ASSERT(CORINFO_IndexOutOfRangeException_ASM == CORINFO_IndexOutOf
#define CORINFO_OverflowException_ASM 4
ASMCONSTANTS_C_ASSERT(CORINFO_OverflowException_ASM == CORINFO_OverflowException)
-#define CORINFO_SynchronizationLockException_ASM 5
-ASMCONSTANTS_C_ASSERT(CORINFO_SynchronizationLockException_ASM == CORINFO_SynchronizationLockException)
-
#define CORINFO_ArrayTypeMismatchException_ASM 6
ASMCONSTANTS_C_ASSERT(CORINFO_ArrayTypeMismatchException_ASM == CORINFO_ArrayTypeMismatchException)
@@ -232,79 +229,6 @@ ASMCONSTANTS_C_ASSERT(Thread::TS_Hijacked == TS_Hijacked_ASM)
#define AppDomain__m_dwId 0x4
ASMCONSTANTS_C_ASSERT(AppDomain__m_dwId == offsetof(AppDomain, m_dwId));
-// from clr/src/vm/ceeload.cpp
-
-// from clr/src/vm/syncblk.h
-#define SizeOfSyncTableEntry_ASM 8
-ASMCONSTANTS_C_ASSERT(sizeof(SyncTableEntry) == SizeOfSyncTableEntry_ASM)
-
-#define SyncBlockIndexOffset_ASM 4
-ASMCONSTANTS_C_ASSERT(sizeof(ObjHeader) - offsetof(ObjHeader, m_SyncBlockValue) == SyncBlockIndexOffset_ASM)
-
-#ifndef __GNUC__
-#define SyncTableEntry_m_SyncBlock 0
-ASMCONSTANTS_C_ASSERT(offsetof(SyncTableEntry, m_SyncBlock) == SyncTableEntry_m_SyncBlock)
-
-#define SyncBlock_m_Monitor 0
-ASMCONSTANTS_C_ASSERT(offsetof(SyncBlock, m_Monitor) == SyncBlock_m_Monitor)
-
-#define AwareLock_m_MonitorHeld 0
-ASMCONSTANTS_C_ASSERT(offsetof(AwareLock, m_MonitorHeld) == AwareLock_m_MonitorHeld)
-#else
-// The following 3 offsets have value of 0, and must be
-// defined to be an empty string. Otherwise, gas may generate assembly
-// code with 0 displacement if 0 is left in the displacement field
-// of an instruction.
-#define SyncTableEntry_m_SyncBlock // 0
-ASMCONSTANTS_C_ASSERT(offsetof(SyncTableEntry, m_SyncBlock) == 0)
-
-#define SyncBlock_m_Monitor // 0
-ASMCONSTANTS_C_ASSERT(offsetof(SyncBlock, m_Monitor) == 0)
-
-#define AwareLock_m_MonitorHeld // 0
-ASMCONSTANTS_C_ASSERT(offsetof(AwareLock, m_MonitorHeld) == 0)
-#endif // !__GNUC__
-
-#define AwareLock_m_HoldingThread 8
-ASMCONSTANTS_C_ASSERT(offsetof(AwareLock, m_HoldingThread) == AwareLock_m_HoldingThread)
-
-#define AwareLock_m_Recursion 4
-ASMCONSTANTS_C_ASSERT(offsetof(AwareLock, m_Recursion) == AwareLock_m_Recursion)
-
-#define BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX_ASM 0x08000000
-ASMCONSTANTS_C_ASSERT(BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX_ASM == BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX)
-
-#define BIT_SBLK_SPIN_LOCK_ASM 0x10000000
-ASMCONSTANTS_C_ASSERT(BIT_SBLK_SPIN_LOCK_ASM == BIT_SBLK_SPIN_LOCK)
-
-#define SBLK_MASK_LOCK_THREADID_ASM 0x000003FF // special value of 0 + 1023 thread ids
-ASMCONSTANTS_C_ASSERT(SBLK_MASK_LOCK_THREADID_ASM == SBLK_MASK_LOCK_THREADID)
-
-#define SBLK_MASK_LOCK_RECLEVEL_ASM 0x0000FC00 // 64 recursion levels
-ASMCONSTANTS_C_ASSERT(SBLK_MASK_LOCK_RECLEVEL_ASM == SBLK_MASK_LOCK_RECLEVEL)
-
-#define SBLK_LOCK_RECLEVEL_INC_ASM 0x00000400 // each level is this much higher than the previous one
-ASMCONSTANTS_C_ASSERT(SBLK_LOCK_RECLEVEL_INC_ASM == SBLK_LOCK_RECLEVEL_INC)
-
-#define BIT_SBLK_IS_HASHCODE_ASM 0x04000000
-ASMCONSTANTS_C_ASSERT(BIT_SBLK_IS_HASHCODE_ASM == BIT_SBLK_IS_HASHCODE)
-
-#define MASK_SYNCBLOCKINDEX_ASM 0x03ffffff // ((1<<SYNCBLOCKINDEX_BITS)-1)
-ASMCONSTANTS_C_ASSERT(MASK_SYNCBLOCKINDEX_ASM == MASK_SYNCBLOCKINDEX)
-
-// BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX_ASM + BIT_SBLK_SPIN_LOCK_ASM +
-// SBLK_MASK_LOCK_THREADID_ASM + SBLK_MASK_LOCK_RECLEVEL_ASM
-#define SBLK_COMBINED_MASK_ASM 0x1800ffff
-ASMCONSTANTS_C_ASSERT(SBLK_COMBINED_MASK_ASM == (BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX + BIT_SBLK_SPIN_LOCK + SBLK_MASK_LOCK_THREADID + SBLK_MASK_LOCK_RECLEVEL))
-
-// BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX_ASM + BIT_SBLK_SPIN_LOCK_ASM
-#define BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX_SPIN_LOCK_ASM 0x18000000
-ASMCONSTANTS_C_ASSERT(BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX_SPIN_LOCK_ASM == (BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX + BIT_SBLK_SPIN_LOCK))
-
-// BIT_SBLK_IS_HASHCODE + BIT_SBLK_SPIN_LOCK
-#define BIT_SBLK_IS_HASHCODE_OR_SPIN_LOCK_ASM 0x14000000
-ASMCONSTANTS_C_ASSERT(BIT_SBLK_IS_HASHCODE_OR_SPIN_LOCK_ASM == (BIT_SBLK_IS_HASHCODE + BIT_SBLK_SPIN_LOCK))
-
// This is the offset from EBP at which the original CONTEXT is stored in one of the
// RedirectedHandledJITCase*_Stub functions.
#define REDIRECTSTUB_EBP_OFFSET_CONTEXT (-4)
diff --git a/src/vm/i386/asmhelpers.S b/src/vm/i386/asmhelpers.S
index 75f4a26a80..480eb2dc21 100644
--- a/src/vm/i386/asmhelpers.S
+++ b/src/vm/i386/asmhelpers.S
@@ -757,13 +757,16 @@ NESTED_ENTRY StubDispatchFixupStub, _TEXT, NoHandler
.att_syntax
pushl $0
pushl $0
+ pushl $0
.intel_syntax noprefix
push eax // siteAddrForRegisterIndirect (for tailcalls)
push esi // pTransitionBlock
+ CHECK_STACK_ALIGNMENT
call C_FUNC(StubDispatchFixupWorker)
+ mov esp, esi
STUB_EPILOG
PATCH_LABEL StubDispatchFixupPatchLabel
diff --git a/src/vm/i386/cgencpu.h b/src/vm/i386/cgencpu.h
index e4a623b715..5360b3eb0e 100644
--- a/src/vm/i386/cgencpu.h
+++ b/src/vm/i386/cgencpu.h
@@ -558,24 +558,6 @@ inline BOOL ClrFlushInstructionCache(LPCVOID pCodeAddr, size_t sizeOfCode)
return TRUE;
}
-#ifndef FEATURE_IMPLICIT_TLS
-//
-// JIT HELPER ALIASING FOR PORTABILITY.
-//
-// Create alias for optimized implementations of helpers provided on this platform
-//
-
-#define JIT_MonEnter JIT_MonEnterWorker
-#define JIT_MonEnterWorker JIT_MonEnterWorker
-#define JIT_MonReliableEnter JIT_MonReliableEnter
-#define JIT_MonTryEnter JIT_MonTryEnter
-#define JIT_MonExit JIT_MonExitWorker
-#define JIT_MonExitWorker JIT_MonExitWorker
-#define JIT_MonEnterStatic JIT_MonEnterStatic
-#define JIT_MonExitStatic JIT_MonExitStatic
-
-#endif
-
// optimized static helpers generated dynamically at runtime
// #define JIT_GetSharedGCStaticBase
// #define JIT_GetSharedNonGCStaticBase
diff --git a/src/vm/i386/cgenx86.cpp b/src/vm/i386/cgenx86.cpp
index 9b8960a6eb..3b523c9c28 100644
--- a/src/vm/i386/cgenx86.cpp
+++ b/src/vm/i386/cgenx86.cpp
@@ -378,7 +378,30 @@ void HelperMethodFrame::UpdateRegDisplay(const PREGDISPLAY pRD)
pRD->IsCallerSPValid = FALSE; // Don't add usage of this field. This is only temporary.
#ifdef DACCESS_COMPILE
- PORTABILITY_ASSERT("HelperMethodFrame::UpdateRegDisplay");
+ // For DAC, we may get here when the HMF is still uninitialized.
+ // So we may need to unwind here.
+ if (!m_MachState.isValid())
+ {
+ // This allocation throws on OOM.
+ MachState* pUnwoundState = (MachState*)DacAllocHostOnlyInstance(sizeof(*pUnwoundState), true);
+
+ InsureInit(false, pUnwoundState);
+
+ pRD->pCurrentContext->Eip = pRD->ControlPC = pUnwoundState->GetRetAddr();
+ pRD->pCurrentContext->Esp = pRD->SP = pUnwoundState->esp();
+
+#define CALLEE_SAVED_REGISTER(regname) pRD->pCurrentContext->regname = *((DWORD*) pUnwoundState->p##regname());
+ ENUM_CALLEE_SAVED_REGISTERS();
+#undef CALLEE_SAVED_REGISTER
+
+#define CALLEE_SAVED_REGISTER(regname) pRD->pCurrentContextPointers->regname = (DWORD*) pUnwoundState->p##regname();
+ ENUM_CALLEE_SAVED_REGISTERS();
+#undef CALLEE_SAVED_REGISTER
+
+ ClearRegDisplayArgumentAndScratchRegisters(pRD);
+
+ return;
+ }
#endif // DACCESS_COMPILE
pRD->pCurrentContext->Eip = pRD->ControlPC = m_MachState.GetRetAddr();
diff --git a/src/vm/i386/jithelp.asm b/src/vm/i386/jithelp.asm
index e8d2f121e0..85e824040a 100644
--- a/src/vm/i386/jithelp.asm
+++ b/src/vm/i386/jithelp.asm
@@ -1240,1058 +1240,6 @@ fremloopd:
;------------------------------------------------------------------------------
-g_SystemInfo TEXTEQU <?g_SystemInfo@@3U_SYSTEM_INFO@@A>
-g_SpinConstants TEXTEQU <?g_SpinConstants@@3USpinConstants@@A>
-g_pSyncTable TEXTEQU <?g_pSyncTable@@3PAVSyncTableEntry@@A>
-JITutil_MonEnterWorker TEXTEQU <@JITutil_MonEnterWorker@4>
-JITutil_MonReliableEnter TEXTEQU <@JITutil_MonReliableEnter@8>
-JITutil_MonTryEnter TEXTEQU <@JITutil_MonTryEnter@12>
-JITutil_MonExitWorker TEXTEQU <@JITutil_MonExitWorker@4>
-JITutil_MonContention TEXTEQU <@JITutil_MonContention@4>
-JITutil_MonReliableContention TEXTEQU <@JITutil_MonReliableContention@8>
-JITutil_MonSignal TEXTEQU <@JITutil_MonSignal@4>
-JIT_InternalThrow TEXTEQU <@JIT_InternalThrow@4>
-EXTRN g_SystemInfo:BYTE
-EXTRN g_SpinConstants:BYTE
-EXTRN g_pSyncTable:DWORD
-EXTRN JITutil_MonEnterWorker:PROC
-EXTRN JITutil_MonReliableEnter:PROC
-EXTRN JITutil_MonTryEnter:PROC
-EXTRN JITutil_MonExitWorker:PROC
-EXTRN JITutil_MonContention:PROC
-EXTRN JITutil_MonReliableContention:PROC
-EXTRN JITutil_MonSignal:PROC
-EXTRN JIT_InternalThrow:PROC
-
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
-EnterSyncHelper TEXTEQU <_EnterSyncHelper@8>
-LeaveSyncHelper TEXTEQU <_LeaveSyncHelper@8>
-EXTRN EnterSyncHelper:PROC
-EXTRN LeaveSyncHelper:PROC
-endif ;TRACK_SYNC
-endif ;MON_DEBUG
-
-; The following macro is needed because MASM returns
-; "instruction prefix not allowed" error message for
-; rep nop mnemonic
-$repnop MACRO
- db 0F3h
- db 090h
-ENDM
-
-; Safe ThreadAbort does not abort a thread if it is running finally or has lock counts.
-; At the time we call Monitor.Enter, we initiate the abort if we can.
-; We do not need to do the same for Monitor.Leave, since most of time, Monitor.Leave is called
-; during finally.
-
-;**********************************************************************
-; This is a frameless helper for entering a monitor on a object.
-; The object is in ARGUMENT_REG1. This tries the normal case (no
-; blocking or object allocation) in line and calls a framed helper
-; for the other cases.
-; ***** NOTE: if you make any changes to this routine, build with MON_DEBUG undefined
-; to make sure you don't break the non-debug build. This is very fragile code.
-; Also, propagate the changes to jithelp.s which contains the same helper and assembly code
-; (in AT&T syntax) for gnu assembler.
-@JIT_MonEnterWorker@4 proc public
- ; Initialize delay value for retry with exponential backoff
- push ebx
- mov ebx, dword ptr g_SpinConstants+SpinConstants_dwInitialDuration
-
- ; We need yet another register to avoid refetching the thread object
- push esi
-
- ; Check if the instance is NULL.
- test ARGUMENT_REG1, ARGUMENT_REG1
- jz MonEnterFramedLockHelper
-
- call _GetThread@0
- mov esi,eax
-
- ; Check if we can abort here
- mov eax, [esi+Thread_m_State]
- and eax, TS_CatchAtSafePoint_ASM
- jz MonEnterRetryThinLock
- ; go through the slow code path to initiate ThreadAbort.
- jmp MonEnterFramedLockHelper
-
-MonEnterRetryThinLock:
- ; Fetch the object header dword
- mov eax, [ARGUMENT_REG1-SyncBlockIndexOffset_ASM]
-
- ; Check whether we have the "thin lock" layout, the lock is free and the spin lock bit not set
- ; SBLK_COMBINED_MASK_ASM = BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX + BIT_SBLK_SPIN_LOCK + SBLK_MASK_LOCK_THREADID + SBLK_MASK_LOCK_RECLEVEL
- test eax, SBLK_COMBINED_MASK_ASM
- jnz MonEnterNeedMoreTests
-
- ; Everything is fine - get the thread id to store in the lock
- mov edx, [esi+Thread_m_ThreadId]
-
- ; If the thread id is too large, we need a syncblock for sure
- cmp edx, SBLK_MASK_LOCK_THREADID_ASM
- ja MonEnterFramedLockHelper
-
- ; We want to store a new value with the current thread id set in the low 10 bits
- or edx,eax
- lock cmpxchg dword ptr [ARGUMENT_REG1-SyncBlockIndexOffset_ASM], edx
- jnz MonEnterPrepareToWaitThinLock
-
- ; Everything went fine and we're done
- add [esi+Thread_m_dwLockCount],1
- pop esi
- pop ebx
- ret
-
-MonEnterNeedMoreTests:
- ; Ok, it's not the simple case - find out which case it is
- test eax, BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX_ASM
- jnz MonEnterHaveHashOrSyncBlockIndex
-
- ; The header is transitioning or the lock - treat this as if the lock was taken
- test eax, BIT_SBLK_SPIN_LOCK_ASM
- jnz MonEnterPrepareToWaitThinLock
-
- ; Here we know we have the "thin lock" layout, but the lock is not free.
- ; It could still be the recursion case - compare the thread id to check
- mov edx,eax
- and edx, SBLK_MASK_LOCK_THREADID_ASM
- cmp edx, [esi+Thread_m_ThreadId]
- jne MonEnterPrepareToWaitThinLock
-
- ; Ok, the thread id matches, it's the recursion case.
- ; Bump up the recursion level and check for overflow
- lea edx, [eax+SBLK_LOCK_RECLEVEL_INC_ASM]
- test edx, SBLK_MASK_LOCK_RECLEVEL_ASM
- jz MonEnterFramedLockHelper
-
- ; Try to put the new recursion level back. If the header was changed in the meantime,
- ; we need a full retry, because the layout could have changed.
- lock cmpxchg [ARGUMENT_REG1-SyncBlockIndexOffset_ASM], edx
- jnz MonEnterRetryHelperThinLock
-
- ; Everything went fine and we're done
- pop esi
- pop ebx
- ret
-
-MonEnterPrepareToWaitThinLock:
- ; If we are on an MP system, we try spinning for a certain number of iterations
- cmp dword ptr g_SystemInfo+SYSTEM_INFO_dwNumberOfProcessors,1
- jle MonEnterFramedLockHelper
-
- ; exponential backoff: delay by approximately 2*ebx clock cycles (on a PIII)
- mov eax, ebx
-MonEnterdelayLoopThinLock:
- $repnop ; indicate to the CPU that we are spin waiting (useful for some Intel P4 multiprocs)
- dec eax
- jnz MonEnterdelayLoopThinLock
-
- ; next time, wait a factor longer
- imul ebx, dword ptr g_SpinConstants+SpinConstants_dwBackoffFactor
-
- cmp ebx, dword ptr g_SpinConstants+SpinConstants_dwMaximumDuration
- jle MonEnterRetryHelperThinLock
-
- jmp MonEnterFramedLockHelper
-
-MonEnterRetryHelperThinLock:
- jmp MonEnterRetryThinLock
-
-MonEnterHaveHashOrSyncBlockIndex:
- ; If we have a hash code already, we need to create a sync block
- test eax, BIT_SBLK_IS_HASHCODE_ASM
- jnz MonEnterFramedLockHelper
-
- ; Ok, we have a sync block index - just and out the top bits and grab the syncblock index
- and eax, MASK_SYNCBLOCKINDEX_ASM
-
- ; Get the sync block pointer.
- mov ARGUMENT_REG2, dword ptr g_pSyncTable
- mov ARGUMENT_REG2, [ARGUMENT_REG2+eax*SizeOfSyncTableEntry_ASM+SyncTableEntry_m_SyncBlock]
-
- ; Check if the sync block has been allocated.
- test ARGUMENT_REG2, ARGUMENT_REG2
- jz MonEnterFramedLockHelper
-
- ; Get a pointer to the lock object.
- lea ARGUMENT_REG2, [ARGUMENT_REG2+SyncBlock_m_Monitor]
-
- ; Attempt to acquire the lock.
-MonEnterRetrySyncBlock:
- mov eax, [ARGUMENT_REG2+AwareLock_m_MonitorHeld]
- test eax,eax
- jne MonEnterHaveWaiters
-
- ; Common case, lock isn't held and there are no waiters. Attempt to
- ; gain ownership ourselves.
- mov ARGUMENT_REG1,1
- lock cmpxchg [ARGUMENT_REG2+AwareLock_m_MonitorHeld], ARGUMENT_REG1
- jnz MonEnterRetryHelperSyncBlock
-
- ; Success. Save the thread object in the lock and increment the use count.
- mov dword ptr [ARGUMENT_REG2+AwareLock_m_HoldingThread],esi
- inc dword ptr [esi+Thread_m_dwLockCount]
- inc dword ptr [ARGUMENT_REG2+AwareLock_m_Recursion]
-
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- push ARGUMENT_REG2 ; AwareLock
- push [esp+4] ; return address
- call EnterSyncHelper
-endif ;TRACK_SYNC
-endif ;MON_DEBUG
- pop esi
- pop ebx
- ret
-
- ; It's possible to get here with waiters but no lock held, but in this
- ; case a signal is about to be fired which will wake up a waiter. So
- ; for fairness sake we should wait too.
- ; Check first for recursive lock attempts on the same thread.
-MonEnterHaveWaiters:
- ; Is mutex already owned by current thread?
- cmp [ARGUMENT_REG2+AwareLock_m_HoldingThread],esi
- jne MonEnterPrepareToWait
-
- ; Yes, bump our use count.
- inc dword ptr [ARGUMENT_REG2+AwareLock_m_Recursion]
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- push ARGUMENT_REG2 ; AwareLock
- push [esp+4] ; return address
- call EnterSyncHelper
-endif ;TRACK_SYNC
-endif ;MON_DEBUG
- pop esi
- pop ebx
- ret
-
-MonEnterPrepareToWait:
- ; If we are on an MP system, we try spinning for a certain number of iterations
- cmp dword ptr g_SystemInfo+SYSTEM_INFO_dwNumberOfProcessors,1
- jle MonEnterHaveWaiters1
-
- ; exponential backoff: delay by approximately 2*ebx clock cycles (on a PIII)
- mov eax,ebx
-MonEnterdelayLoop:
- $repnop ; indicate to the CPU that we are spin waiting (useful for some Intel P4 multiprocs)
- dec eax
- jnz MonEnterdelayLoop
-
- ; next time, wait a factor longer
- imul ebx, dword ptr g_SpinConstants+SpinConstants_dwBackoffFactor
-
- cmp ebx, dword ptr g_SpinConstants+SpinConstants_dwMaximumDuration
- jle MonEnterRetrySyncBlock
-
-MonEnterHaveWaiters1:
-
- pop esi
- pop ebx
-
- ; Place AwareLock in arg1 then call contention helper.
- mov ARGUMENT_REG1, ARGUMENT_REG2
- jmp JITutil_MonContention
-
-MonEnterRetryHelperSyncBlock:
- jmp MonEnterRetrySyncBlock
-
- ; ECX has the object to synchronize on
-MonEnterFramedLockHelper:
- pop esi
- pop ebx
- jmp JITutil_MonEnterWorker
-
-@JIT_MonEnterWorker@4 endp
-
-;**********************************************************************
-; This is a frameless helper for entering a monitor on a object, and
-; setting a flag to indicate that the lock was taken.
-; The object is in ARGUMENT_REG1. The flag is in ARGUMENT_REG2.
-; This tries the normal case (no blocking or object allocation) in line
-; and calls a framed helper for the other cases.
-; ***** NOTE: if you make any changes to this routine, build with MON_DEBUG undefined
-; to make sure you don't break the non-debug build. This is very fragile code.
-; Also, propagate the changes to jithelp.s which contains the same helper and assembly code
-; (in AT&T syntax) for gnu assembler.
-@JIT_MonReliableEnter@8 proc public
- ; Initialize delay value for retry with exponential backoff
- push ebx
- mov ebx, dword ptr g_SpinConstants+SpinConstants_dwInitialDuration
-
- ; Put pbLockTaken in edi
- push edi
- mov edi, ARGUMENT_REG2
-
- ; We need yet another register to avoid refetching the thread object
- push esi
-
- ; Check if the instance is NULL.
- test ARGUMENT_REG1, ARGUMENT_REG1
- jz MonReliableEnterFramedLockHelper
-
- call _GetThread@0
- mov esi,eax
-
- ; Check if we can abort here
- mov eax, [esi+Thread_m_State]
- and eax, TS_CatchAtSafePoint_ASM
- jz MonReliableEnterRetryThinLock
- ; go through the slow code path to initiate ThreadAbort.
- jmp MonReliableEnterFramedLockHelper
-
-MonReliableEnterRetryThinLock:
- ; Fetch the object header dword
- mov eax, [ARGUMENT_REG1-SyncBlockIndexOffset_ASM]
-
- ; Check whether we have the "thin lock" layout, the lock is free and the spin lock bit not set
- ; SBLK_COMBINED_MASK_ASM = BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX + BIT_SBLK_SPIN_LOCK + SBLK_MASK_LOCK_THREADID + SBLK_MASK_LOCK_RECLEVEL
- test eax, SBLK_COMBINED_MASK_ASM
- jnz MonReliableEnterNeedMoreTests
-
- ; Everything is fine - get the thread id to store in the lock
- mov edx, [esi+Thread_m_ThreadId]
-
- ; If the thread id is too large, we need a syncblock for sure
- cmp edx, SBLK_MASK_LOCK_THREADID_ASM
- ja MonReliableEnterFramedLockHelper
-
- ; We want to store a new value with the current thread id set in the low 10 bits
- or edx,eax
- lock cmpxchg dword ptr [ARGUMENT_REG1-SyncBlockIndexOffset_ASM], edx
- jnz MonReliableEnterPrepareToWaitThinLock
-
- ; Everything went fine and we're done
- add [esi+Thread_m_dwLockCount],1
- ; Set *pbLockTaken=true
- mov byte ptr [edi],1
- pop esi
- pop edi
- pop ebx
- ret
-
-MonReliableEnterNeedMoreTests:
- ; Ok, it's not the simple case - find out which case it is
- test eax, BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX_ASM
- jnz MonReliableEnterHaveHashOrSyncBlockIndex
-
- ; The header is transitioning or the lock - treat this as if the lock was taken
- test eax, BIT_SBLK_SPIN_LOCK_ASM
- jnz MonReliableEnterPrepareToWaitThinLock
-
- ; Here we know we have the "thin lock" layout, but the lock is not free.
- ; It could still be the recursion case - compare the thread id to check
- mov edx,eax
- and edx, SBLK_MASK_LOCK_THREADID_ASM
- cmp edx, [esi+Thread_m_ThreadId]
- jne MonReliableEnterPrepareToWaitThinLock
-
- ; Ok, the thread id matches, it's the recursion case.
- ; Bump up the recursion level and check for overflow
- lea edx, [eax+SBLK_LOCK_RECLEVEL_INC_ASM]
- test edx, SBLK_MASK_LOCK_RECLEVEL_ASM
- jz MonReliableEnterFramedLockHelper
-
- ; Try to put the new recursion level back. If the header was changed in the meantime,
- ; we need a full retry, because the layout could have changed.
- lock cmpxchg [ARGUMENT_REG1-SyncBlockIndexOffset_ASM], edx
- jnz MonReliableEnterRetryHelperThinLock
-
- ; Everything went fine and we're done
- ; Set *pbLockTaken=true
- mov byte ptr [edi],1
- pop esi
- pop edi
- pop ebx
- ret
-
-MonReliableEnterPrepareToWaitThinLock:
- ; If we are on an MP system, we try spinning for a certain number of iterations
- cmp dword ptr g_SystemInfo+SYSTEM_INFO_dwNumberOfProcessors,1
- jle MonReliableEnterFramedLockHelper
-
- ; exponential backoff: delay by approximately 2*ebx clock cycles (on a PIII)
- mov eax, ebx
-MonReliableEnterdelayLoopThinLock:
- $repnop ; indicate to the CPU that we are spin waiting (useful for some Intel P4 multiprocs)
- dec eax
- jnz MonReliableEnterdelayLoopThinLock
-
- ; next time, wait a factor longer
- imul ebx, dword ptr g_SpinConstants+SpinConstants_dwBackoffFactor
-
- cmp ebx, dword ptr g_SpinConstants+SpinConstants_dwMaximumDuration
- jle MonReliableEnterRetryHelperThinLock
-
- jmp MonReliableEnterFramedLockHelper
-
-MonReliableEnterRetryHelperThinLock:
- jmp MonReliableEnterRetryThinLock
-
-MonReliableEnterHaveHashOrSyncBlockIndex:
- ; If we have a hash code already, we need to create a sync block
- test eax, BIT_SBLK_IS_HASHCODE_ASM
- jnz MonReliableEnterFramedLockHelper
-
- ; Ok, we have a sync block index - just and out the top bits and grab the syncblock index
- and eax, MASK_SYNCBLOCKINDEX_ASM
-
- ; Get the sync block pointer.
- mov ARGUMENT_REG2, dword ptr g_pSyncTable
- mov ARGUMENT_REG2, [ARGUMENT_REG2+eax*SizeOfSyncTableEntry_ASM+SyncTableEntry_m_SyncBlock]
-
- ; Check if the sync block has been allocated.
- test ARGUMENT_REG2, ARGUMENT_REG2
- jz MonReliableEnterFramedLockHelper
-
- ; Get a pointer to the lock object.
- lea ARGUMENT_REG2, [ARGUMENT_REG2+SyncBlock_m_Monitor]
-
- ; Attempt to acquire the lock.
-MonReliableEnterRetrySyncBlock:
- mov eax, [ARGUMENT_REG2+AwareLock_m_MonitorHeld]
- test eax,eax
- jne MonReliableEnterHaveWaiters
-
- ; Common case, lock isn't held and there are no waiters. Attempt to
- ; gain ownership ourselves.
- mov ARGUMENT_REG1,1
- lock cmpxchg [ARGUMENT_REG2+AwareLock_m_MonitorHeld], ARGUMENT_REG1
- jnz MonReliableEnterRetryHelperSyncBlock
-
- ; Success. Save the thread object in the lock and increment the use count.
- mov dword ptr [ARGUMENT_REG2+AwareLock_m_HoldingThread],esi
- inc dword ptr [esi+Thread_m_dwLockCount]
- inc dword ptr [ARGUMENT_REG2+AwareLock_m_Recursion]
- ; Set *pbLockTaken=true
- mov byte ptr [edi],1
-
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- push ARGUMENT_REG2 ; AwareLock
- push [esp+4] ; return address
- call EnterSyncHelper
-endif ;TRACK_SYNC
-endif ;MON_DEBUG
- pop esi
- pop edi
- pop ebx
- ret
-
- ; It's possible to get here with waiters but no lock held, but in this
- ; case a signal is about to be fired which will wake up a waiter. So
- ; for fairness sake we should wait too.
- ; Check first for recursive lock attempts on the same thread.
-MonReliableEnterHaveWaiters:
- ; Is mutex already owned by current thread?
- cmp [ARGUMENT_REG2+AwareLock_m_HoldingThread],esi
- jne MonReliableEnterPrepareToWait
-
- ; Yes, bump our use count.
- inc dword ptr [ARGUMENT_REG2+AwareLock_m_Recursion]
- ; Set *pbLockTaken=true
- mov byte ptr [edi],1
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- push ARGUMENT_REG2 ; AwareLock
- push [esp+4] ; return address
- call EnterSyncHelper
-endif ;TRACK_SYNC
-endif ;MON_DEBUG
- pop esi
- pop edi
- pop ebx
- ret
-
-MonReliableEnterPrepareToWait:
- ; If we are on an MP system, we try spinning for a certain number of iterations
- cmp dword ptr g_SystemInfo+SYSTEM_INFO_dwNumberOfProcessors,1
- jle MonReliableEnterHaveWaiters1
-
- ; exponential backoff: delay by approximately 2*ebx clock cycles (on a PIII)
- mov eax,ebx
-MonReliableEnterdelayLoop:
- $repnop ; indicate to the CPU that we are spin waiting (useful for some Intel P4 multiprocs)
- dec eax
- jnz MonReliableEnterdelayLoop
-
- ; next time, wait a factor longer
- imul ebx, dword ptr g_SpinConstants+SpinConstants_dwBackoffFactor
-
- cmp ebx, dword ptr g_SpinConstants+SpinConstants_dwMaximumDuration
- jle MonReliableEnterRetrySyncBlock
-
-MonReliableEnterHaveWaiters1:
-
- ; Place AwareLock in arg1, pbLockTaken in arg2, then call contention helper.
- mov ARGUMENT_REG1, ARGUMENT_REG2
- mov ARGUMENT_REG2, edi
-
- pop esi
- pop edi
- pop ebx
-
- jmp JITutil_MonReliableContention
-
-MonReliableEnterRetryHelperSyncBlock:
- jmp MonReliableEnterRetrySyncBlock
-
- ; ECX has the object to synchronize on
-MonReliableEnterFramedLockHelper:
- mov ARGUMENT_REG2, edi
- pop esi
- pop edi
- pop ebx
- jmp JITutil_MonReliableEnter
-
-@JIT_MonReliableEnter@8 endp
-
-;************************************************************************
-; This is a frameless helper for trying to enter a monitor on a object.
-; The object is in ARGUMENT_REG1 and a timeout in ARGUMENT_REG2. This tries the
-; normal case (no object allocation) in line and calls a framed helper for the
-; other cases.
-; ***** NOTE: if you make any changes to this routine, build with MON_DEBUG undefined
-; to make sure you don't break the non-debug build. This is very fragile code.
-; Also, propagate the changes to jithelp.s which contains the same helper and assembly code
-; (in AT&T syntax) for gnu assembler.
-@JIT_MonTryEnter@12 proc public
- ; Save the timeout parameter.
- push ARGUMENT_REG2
-
- ; Initialize delay value for retry with exponential backoff
- push ebx
- mov ebx, dword ptr g_SpinConstants+SpinConstants_dwInitialDuration
-
- ; The thin lock logic needs another register to store the thread
- push esi
-
- ; Check if the instance is NULL.
- test ARGUMENT_REG1, ARGUMENT_REG1
- jz MonTryEnterFramedLockHelper
-
- ; Check if the timeout looks valid
- cmp ARGUMENT_REG2,-1
- jl MonTryEnterFramedLockHelper
-
- ; Get the thread right away, we'll need it in any case
- call _GetThread@0
- mov esi,eax
-
- ; Check if we can abort here
- mov eax, [esi+Thread_m_State]
- and eax, TS_CatchAtSafePoint_ASM
- jz MonTryEnterRetryThinLock
- ; go through the slow code path to initiate ThreadAbort.
- jmp MonTryEnterFramedLockHelper
-
-MonTryEnterRetryThinLock:
- ; Get the header dword and check its layout
- mov eax, [ARGUMENT_REG1-SyncBlockIndexOffset_ASM]
-
- ; Check whether we have the "thin lock" layout, the lock is free and the spin lock bit not set
- ; SBLK_COMBINED_MASK_ASM = BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX + BIT_SBLK_SPIN_LOCK + SBLK_MASK_LOCK_THREADID + SBLK_MASK_LOCK_RECLEVEL
- test eax, SBLK_COMBINED_MASK_ASM
- jnz MonTryEnterNeedMoreTests
-
- ; Ok, everything is fine. Fetch the thread id and make sure it's small enough for thin locks
- mov edx, [esi+Thread_m_ThreadId]
- cmp edx, SBLK_MASK_LOCK_THREADID_ASM
- ja MonTryEnterFramedLockHelper
-
- ; Try to put our thread id in there
- or edx,eax
- lock cmpxchg [ARGUMENT_REG1-SyncBlockIndexOffset_ASM],edx
- jnz MonTryEnterRetryHelperThinLock
-
- ; Got the lock - everything is fine"
- add [esi+Thread_m_dwLockCount],1
- pop esi
-
- ; Delay value no longer needed
- pop ebx
-
- ; Timeout parameter not needed, ditch it from the stack.
- add esp,4
-
- mov eax, [esp+4]
- mov byte ptr [eax], 1
- ret 4
-
-MonTryEnterNeedMoreTests:
- ; Ok, it's not the simple case - find out which case it is
- test eax, BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX_ASM
- jnz MonTryEnterHaveSyncBlockIndexOrHash
-
- ; The header is transitioning or the lock is taken
- test eax, BIT_SBLK_SPIN_LOCK_ASM
- jnz MonTryEnterRetryHelperThinLock
-
- mov edx, eax
- and edx, SBLK_MASK_LOCK_THREADID_ASM
- cmp edx, [esi+Thread_m_ThreadId]
- jne MonTryEnterPrepareToWaitThinLock
-
- ; Ok, the thread id matches, it's the recursion case.
- ; Bump up the recursion level and check for overflow
- lea edx, [eax+SBLK_LOCK_RECLEVEL_INC_ASM]
- test edx, SBLK_MASK_LOCK_RECLEVEL_ASM
- jz MonTryEnterFramedLockHelper
-
- ; Try to put the new recursion level back. If the header was changed in the meantime,
- ; we need a full retry, because the layout could have changed.
- lock cmpxchg [ARGUMENT_REG1-SyncBlockIndexOffset_ASM],edx
- jnz MonTryEnterRetryHelperThinLock
-
- ; Everything went fine and we're done
- pop esi
- pop ebx
-
- ; Timeout parameter not needed, ditch it from the stack.
- add esp, 4
- mov eax, [esp+4]
- mov byte ptr [eax], 1
- ret 4
-
-MonTryEnterPrepareToWaitThinLock:
- ; If we are on an MP system, we try spinning for a certain number of iterations
- cmp dword ptr g_SystemInfo+SYSTEM_INFO_dwNumberOfProcessors,1
- jle MonTryEnterFramedLockHelper
-
- ; exponential backoff: delay by approximately 2*ebx clock cycles (on a PIII)
- mov eax, ebx
-MonTryEnterdelayLoopThinLock:
- $repnop ; indicate to the CPU that we are spin waiting (useful for some Intel P4 multiprocs)
- dec eax
- jnz MonTryEnterdelayLoopThinLock
-
- ; next time, wait a factor longer
- imul ebx, dword ptr g_SpinConstants+SpinConstants_dwBackoffFactor
-
- cmp ebx, dword ptr g_SpinConstants+SpinConstants_dwMaximumDuration
- jle MonTryEnterRetryHelperThinLock
-
- jmp MonTryEnterWouldBlock
-
-MonTryEnterRetryHelperThinLock:
- jmp MonTryEnterRetryThinLock
-
-
-MonTryEnterHaveSyncBlockIndexOrHash:
- ; If we have a hash code already, we need to create a sync block
- test eax, BIT_SBLK_IS_HASHCODE_ASM
- jnz MonTryEnterFramedLockHelper
-
- ; Just and out the top bits and grab the syncblock index
- and eax, MASK_SYNCBLOCKINDEX_ASM
-
- ; Get the sync block pointer.
- mov ARGUMENT_REG2, dword ptr g_pSyncTable
- mov ARGUMENT_REG2, [ARGUMENT_REG2+eax*SizeOfSyncTableEntry_ASM+SyncTableEntry_m_SyncBlock]
-
- ; Check if the sync block has been allocated.
- test ARGUMENT_REG2, ARGUMENT_REG2
- jz MonTryEnterFramedLockHelper
-
- ; Get a pointer to the lock object.
- lea ARGUMENT_REG2, [ARGUMENT_REG2+SyncBlock_m_Monitor]
-
-MonTryEnterRetrySyncBlock:
- ; Attempt to acquire the lock.
- mov eax, [ARGUMENT_REG2+AwareLock_m_MonitorHeld]
- test eax,eax
- jne MonTryEnterHaveWaiters
-
- ; We need another scratch register for what follows, so save EBX now so"
- ; we can use it for that purpose."
- push ebx
-
- ; Common case, lock isn't held and there are no waiters. Attempt to
- ; gain ownership ourselves.
- mov ebx,1
- lock cmpxchg [ARGUMENT_REG2+AwareLock_m_MonitorHeld],ebx
-
- pop ebx
-
- jnz MonTryEnterRetryHelperSyncBlock
-
- ; Success. Save the thread object in the lock and increment the use count.
- mov dword ptr [ARGUMENT_REG2+AwareLock_m_HoldingThread],esi
- inc dword ptr [ARGUMENT_REG2+AwareLock_m_Recursion]
- inc dword ptr [esi+Thread_m_dwLockCount]
-
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- push ARGUMENT_REG2 ; AwareLock
- push [esp+4] ; return address
- call EnterSyncHelper
-endif ;TRACK_SYNC
-endif ;MON_DEBUG
-
- pop esi
- pop ebx
-
- ; Timeout parameter not needed, ditch it from the stack."
- add esp,4
-
- mov eax, [esp+4]
- mov byte ptr [eax], 1
- ret 4
-
- ; It's possible to get here with waiters but no lock held, but in this
- ; case a signal is about to be fired which will wake up a waiter. So
- ; for fairness sake we should wait too.
- ; Check first for recursive lock attempts on the same thread.
-MonTryEnterHaveWaiters:
- ; Is mutex already owned by current thread?
- cmp [ARGUMENT_REG2+AwareLock_m_HoldingThread],esi
- jne MonTryEnterPrepareToWait
-
- ; Yes, bump our use count.
- inc dword ptr [ARGUMENT_REG2+AwareLock_m_Recursion]
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- push ARGUMENT_REG2 ; AwareLock
- push [esp+4] ; return address
- call EnterSyncHelper
-endif ;TRACK_SYNC
-endif ;MON_DEBUG
- pop esi
- pop ebx
-
- ; Timeout parameter not needed, ditch it from the stack.
- add esp,4
-
- mov eax, [esp+4]
- mov byte ptr [eax], 1
- ret 4
-
-MonTryEnterPrepareToWait:
- ; If we are on an MP system, we try spinning for a certain number of iterations
- cmp dword ptr g_SystemInfo+SYSTEM_INFO_dwNumberOfProcessors,1
- jle MonTryEnterWouldBlock
-
- ; exponential backoff: delay by approximately 2*ebx clock cycles (on a PIII)
- mov eax, ebx
-MonTryEnterdelayLoop:
- $repnop ; indicate to the CPU that we are spin waiting (useful for some Intel P4 multiprocs)
- dec eax
- jnz MonTryEnterdelayLoop
-
- ; next time, wait a factor longer
- imul ebx, dword ptr g_SpinConstants+SpinConstants_dwBackoffFactor
-
- cmp ebx, dword ptr g_SpinConstants+SpinConstants_dwMaximumDuration
- jle MonTryEnterRetrySyncBlock
-
- ; We would need to block to enter the section. Return failure if
- ; timeout is zero, else call the framed helper to do the blocking
- ; form of TryEnter."
-MonTryEnterWouldBlock:
- pop esi
- pop ebx
- pop ARGUMENT_REG2
- test ARGUMENT_REG2, ARGUMENT_REG2
- jnz MonTryEnterBlock
- mov eax, [esp+4]
- mov byte ptr [eax], 0
- ret 4
-
-MonTryEnterRetryHelperSyncBlock:
- jmp MonTryEnterRetrySyncBlock
-
-MonTryEnterFramedLockHelper:
- ; ARGUMENT_REG1 has the object to synchronize on, must retrieve the
- ; timeout parameter from the stack.
- pop esi
- pop ebx
- pop ARGUMENT_REG2
-MonTryEnterBlock:
- jmp JITutil_MonTryEnter
-
-@JIT_MonTryEnter@12 endp
-
-;**********************************************************************
-; This is a frameless helper for exiting a monitor on a object.
-; The object is in ARGUMENT_REG1. This tries the normal case (no
-; blocking or object allocation) in line and calls a framed helper
-; for the other cases.
-; ***** NOTE: if you make any changes to this routine, build with MON_DEBUG undefined
-; to make sure you don't break the non-debug build. This is very fragile code.
-; Also, propagate the changes to jithelp.s which contains the same helper and assembly code
-; (in AT&T syntax) for gnu assembler.
-@JIT_MonExitWorker@4 proc public
- ; The thin lock logic needs an additional register to hold the thread, unfortunately
- push esi
-
- ; Check if the instance is NULL.
- test ARGUMENT_REG1, ARGUMENT_REG1
- jz MonExitFramedLockHelper
-
- call _GetThread@0
- mov esi,eax
-
-MonExitRetryThinLock:
- ; Fetch the header dword and check its layout and the spin lock bit
- mov eax, [ARGUMENT_REG1-SyncBlockIndexOffset_ASM]
- ;BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX_SPIN_LOCK_ASM = BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX + BIT_SBLK_SPIN_LOCK
- test eax, BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX_SPIN_LOCK_ASM
- jnz MonExitNeedMoreTests
-
- ; Ok, we have a "thin lock" layout - check whether the thread id matches
- mov edx,eax
- and edx, SBLK_MASK_LOCK_THREADID_ASM
- cmp edx, [esi+Thread_m_ThreadId]
- jne MonExitFramedLockHelper
-
- ; Check the recursion level
- test eax, SBLK_MASK_LOCK_RECLEVEL_ASM
- jne MonExitDecRecursionLevel
-
- ; It's zero - we're leaving the lock.
- ; So try to put back a zero thread id.
- ; edx and eax match in the thread id bits, and edx is zero elsewhere, so the xor is sufficient
- xor edx,eax
- lock cmpxchg [ARGUMENT_REG1-SyncBlockIndexOffset_ASM],edx
- jnz MonExitRetryHelperThinLock
-
- ; We're done
- sub [esi+Thread_m_dwLockCount],1
- pop esi
- ret
-
-MonExitDecRecursionLevel:
- lea edx, [eax-SBLK_LOCK_RECLEVEL_INC_ASM]
- lock cmpxchg [ARGUMENT_REG1-SyncBlockIndexOffset_ASM],edx
- jnz MonExitRetryHelperThinLock
-
- ; We're done
- pop esi
- ret
-
-MonExitNeedMoreTests:
- ;Forward all special cases to the slow helper
- ;BIT_SBLK_IS_HASHCODE_OR_SPIN_LOCK_ASM = BIT_SBLK_IS_HASHCODE + BIT_SBLK_SPIN_LOCK
- test eax, BIT_SBLK_IS_HASHCODE_OR_SPIN_LOCK_ASM
- jnz MonExitFramedLockHelper
-
- ; Get the sync block index and use it to compute the sync block pointer
- mov ARGUMENT_REG2, dword ptr g_pSyncTable
- and eax, MASK_SYNCBLOCKINDEX_ASM
- mov ARGUMENT_REG2, [ARGUMENT_REG2+eax*SizeOfSyncTableEntry_ASM+SyncTableEntry_m_SyncBlock]
-
- ; was there a sync block?
- test ARGUMENT_REG2, ARGUMENT_REG2
- jz MonExitFramedLockHelper
-
- ; Get a pointer to the lock object.
- lea ARGUMENT_REG2, [ARGUMENT_REG2+SyncBlock_m_Monitor]
-
- ; Check if lock is held.
- cmp [ARGUMENT_REG2+AwareLock_m_HoldingThread],esi
- jne MonExitFramedLockHelper
-
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- push ARGUMENT_REG1 ; preserve regs
- push ARGUMENT_REG2
-
- push ARGUMENT_REG2 ; AwareLock
- push [esp+8] ; return address
- call LeaveSyncHelper
-
- pop ARGUMENT_REG2 ; restore regs
- pop ARGUMENT_REG1
-endif ;TRACK_SYNC
-endif ;MON_DEBUG
- ; Reduce our recursion count.
- dec dword ptr [ARGUMENT_REG2+AwareLock_m_Recursion]
- jz MonExitLastRecursion
-
- pop esi
- ret
-
-MonExitRetryHelperThinLock:
- jmp MonExitRetryThinLock
-
-MonExitFramedLockHelper:
- pop esi
- jmp JITutil_MonExitWorker
-
- ; This is the last count we held on this lock, so release the lock.
-MonExitLastRecursion:
- dec dword ptr [esi+Thread_m_dwLockCount]
- mov dword ptr [ARGUMENT_REG2+AwareLock_m_HoldingThread],0
-
-MonExitRetry:
- mov eax, [ARGUMENT_REG2+AwareLock_m_MonitorHeld]
- lea esi, [eax-1]
- lock cmpxchg [ARGUMENT_REG2+AwareLock_m_MonitorHeld], esi
- jne MonExitRetryHelper
- pop esi
- test eax,0FFFFFFFEh
- jne MonExitMustSignal
-
- ret
-
-MonExitMustSignal:
- mov ARGUMENT_REG1, ARGUMENT_REG2
- jmp JITutil_MonSignal
-
-MonExitRetryHelper:
- jmp MonExitRetry
-
-@JIT_MonExitWorker@4 endp
-
-;**********************************************************************
-; This is a frameless helper for entering a static monitor on a class.
-; The methoddesc is in ARGUMENT_REG1. This tries the normal case (no
-; blocking or object allocation) in line and calls a framed helper
-; for the other cases.
-; Note we are changing the methoddesc parameter to a pointer to the
-; AwareLock.
-; ***** NOTE: if you make any changes to this routine, build with MON_DEBUG undefined
-; to make sure you don't break the non-debug build. This is very fragile code.
-; Also, propagate the changes to jithelp.s which contains the same helper and assembly code
-; (in AT&T syntax) for gnu assembler.
-@JIT_MonEnterStatic@4 proc public
- ; We need another scratch register for what follows, so save EBX now so
- ; we can use it for that purpose.
- push ebx
-
- ; Attempt to acquire the lock
-MonEnterStaticRetry:
- mov eax, [ARGUMENT_REG1+AwareLock_m_MonitorHeld]
- test eax,eax
- jne MonEnterStaticHaveWaiters
-
- ; Common case, lock isn't held and there are no waiters. Attempt to
- ; gain ownership ourselves.
- mov ebx,1
- lock cmpxchg [ARGUMENT_REG1+AwareLock_m_MonitorHeld],ebx
- jnz MonEnterStaticRetryHelper
-
- pop ebx
-
- ; Success. Save the thread object in the lock and increment the use count.
- call _GetThread@0
- mov [ARGUMENT_REG1+AwareLock_m_HoldingThread], eax
- inc dword ptr [ARGUMENT_REG1+AwareLock_m_Recursion]
- inc dword ptr [eax+Thread_m_dwLockCount]
-
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- push ARGUMENT_REG1 ; AwareLock
- push [esp+4] ; return address
- call EnterSyncHelper
-endif ;TRACK_SYNC
-endif ;MON_DEBUG
- ret
-
- ; It's possible to get here with waiters but no lock held, but in this
- ; case a signal is about to be fired which will wake up a waiter. So
- ; for fairness sake we should wait too.
- ; Check first for recursive lock attempts on the same thread.
-MonEnterStaticHaveWaiters:
- ; Get thread but preserve EAX (contains cached contents of m_MonitorHeld).
- push eax
- call _GetThread@0
- mov ebx,eax
- pop eax
-
- ; Is mutex already owned by current thread?
- cmp [ARGUMENT_REG1+AwareLock_m_HoldingThread],ebx
- jne MonEnterStaticPrepareToWait
-
- ; Yes, bump our use count.
- inc dword ptr [ARGUMENT_REG1+AwareLock_m_Recursion]
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- push ARGUMENT_REG1 ; AwareLock
- push [esp+4] ; return address
- call EnterSyncHelper
-endif ;TRACK_SYNC
-endif ;MON_DEBUG
- pop ebx
- ret
-
-MonEnterStaticPrepareToWait:
- pop ebx
-
- ; ARGUMENT_REG1 should have AwareLock. Call contention helper.
- jmp JITutil_MonContention
-
-MonEnterStaticRetryHelper:
- jmp MonEnterStaticRetry
-@JIT_MonEnterStatic@4 endp
-
-;**********************************************************************
-; A frameless helper for exiting a static monitor on a class.
-; The methoddesc is in ARGUMENT_REG1. This tries the normal case (no
-; blocking or object allocation) in line and calls a framed helper
-; for the other cases.
-; Note we are changing the methoddesc parameter to a pointer to the
-; AwareLock.
-; ***** NOTE: if you make any changes to this routine, build with MON_DEBUG undefined
-; to make sure you don't break the non-debug build. This is very fragile code.
-; Also, propagate the changes to jithelp.s which contains the same helper and assembly code
-; (in AT&T syntax) for gnu assembler.
-@JIT_MonExitStatic@4 proc public
-
-ifdef MON_DEBUG
-ifdef TRACK_SYNC
- push ARGUMENT_REG1 ; preserve regs
-
- push ARGUMENT_REG1 ; AwareLock
- push [esp+8] ; return address
- call LeaveSyncHelper
-
- pop [ARGUMENT_REG1] ; restore regs
-endif ;TRACK_SYNC
-endif ;MON_DEBUG
-
- ; Check if lock is held.
- call _GetThread@0
- cmp [ARGUMENT_REG1+AwareLock_m_HoldingThread],eax
- jne MonExitStaticLockError
-
- ; Reduce our recursion count.
- dec dword ptr [ARGUMENT_REG1+AwareLock_m_Recursion]
- jz MonExitStaticLastRecursion
-
- ret
-
- ; This is the last count we held on this lock, so release the lock.
-MonExitStaticLastRecursion:
- ; eax must have the thread object
- dec dword ptr [eax+Thread_m_dwLockCount]
- mov dword ptr [ARGUMENT_REG1+AwareLock_m_HoldingThread],0
- push ebx
-
-MonExitStaticRetry:
- mov eax, [ARGUMENT_REG1+AwareLock_m_MonitorHeld]
- lea ebx, [eax-1]
- lock cmpxchg [ARGUMENT_REG1+AwareLock_m_MonitorHeld],ebx
- jne MonExitStaticRetryHelper
- pop ebx
- test eax,0FFFFFFFEh
- jne MonExitStaticMustSignal
-
- ret
-
-MonExitStaticMustSignal:
- jmp JITutil_MonSignal
-
-MonExitStaticRetryHelper:
- jmp MonExitStaticRetry
- ; Throw a synchronization lock exception.
-MonExitStaticLockError:
- mov ARGUMENT_REG1, CORINFO_SynchronizationLockException_ASM
- jmp JIT_InternalThrow
-
-@JIT_MonExitStatic@4 endp
-
; PatchedCodeStart and PatchedCodeEnd are used to determine bounds of patched code.
;
diff --git a/src/vm/jithelpers.cpp b/src/vm/jithelpers.cpp
index 32be77823c..8cff03ae60 100644
--- a/src/vm/jithelpers.cpp
+++ b/src/vm/jithelpers.cpp
@@ -4472,19 +4472,18 @@ HCIMPL_MONHELPER(JIT_MonEnterWorker_Portable, Object* obj)
result = obj->EnterObjMonitorHelper(pCurThread);
if (result == AwareLock::EnterHelperResult_Entered)
{
- MONHELPER_STATE(*pbLockTaken = 1;)
+ MONHELPER_STATE(*pbLockTaken = 1);
return;
}
- else
if (result == AwareLock::EnterHelperResult_Contention)
{
- AwareLock::EnterHelperResult resultSpin = obj->EnterObjMonitorHelperSpin(pCurThread);
- if (resultSpin == AwareLock::EnterHelperResult_Entered)
+ result = obj->EnterObjMonitorHelperSpin(pCurThread);
+ if (result == AwareLock::EnterHelperResult_Entered)
{
- MONHELPER_STATE(*pbLockTaken = 1;)
+ MONHELPER_STATE(*pbLockTaken = 1);
return;
}
- if (resultSpin == AwareLock::EnterHelperResult_Contention)
+ if (result == AwareLock::EnterHelperResult_Contention)
{
FC_INNER_RETURN_VOID(JIT_MonContention_Helper(obj, MONHELPER_ARG, GetEEFuncEntryPointMacro(JIT_MonEnter)));
}
@@ -4519,15 +4518,14 @@ HCIMPL1(void, JIT_MonEnter_Portable, Object* obj)
{
return;
}
- else
if (result == AwareLock::EnterHelperResult_Contention)
{
- AwareLock::EnterHelperResult resultSpin = obj->EnterObjMonitorHelperSpin(pCurThread);
- if (resultSpin == AwareLock::EnterHelperResult_Entered)
+ result = obj->EnterObjMonitorHelperSpin(pCurThread);
+ if (result == AwareLock::EnterHelperResult_Entered)
{
return;
}
- if (resultSpin == AwareLock::EnterHelperResult_Contention)
+ if (result == AwareLock::EnterHelperResult_Contention)
{
FC_INNER_RETURN_VOID(JIT_MonContention_Helper(obj, NULL, GetEEFuncEntryPointMacro(JIT_MonEnter)));
}
@@ -4563,16 +4561,15 @@ HCIMPL2(void, JIT_MonReliableEnter_Portable, Object* obj, BYTE* pbLockTaken)
*pbLockTaken = 1;
return;
}
- else
if (result == AwareLock::EnterHelperResult_Contention)
{
- AwareLock::EnterHelperResult resultSpin = obj->EnterObjMonitorHelperSpin(pCurThread);
- if (resultSpin == AwareLock::EnterHelperResult_Entered)
+ result = obj->EnterObjMonitorHelperSpin(pCurThread);
+ if (result == AwareLock::EnterHelperResult_Entered)
{
*pbLockTaken = 1;
return;
}
- if (resultSpin == AwareLock::EnterHelperResult_Contention)
+ if (result == AwareLock::EnterHelperResult_Contention)
{
FC_INNER_RETURN_VOID(JIT_MonContention_Helper(obj, pbLockTaken, GetEEFuncEntryPointMacro(JIT_MonReliableEnter)));
}
@@ -4649,14 +4646,15 @@ HCIMPL3(void, JIT_MonTryEnter_Portable, Object* obj, INT32 timeOut, BYTE* pbLock
*pbLockTaken = 1;
return;
}
- else
if (result == AwareLock::EnterHelperResult_Contention)
{
if (timeOut == 0)
+ {
return;
+ }
- AwareLock::EnterHelperResult resultSpin = obj->EnterObjMonitorHelperSpin(pCurThread);
- if (resultSpin == AwareLock::EnterHelperResult_Entered)
+ result = obj->EnterObjMonitorHelperSpin(pCurThread);
+ if (result == AwareLock::EnterHelperResult_Entered)
{
*pbLockTaken = 1;
return;
@@ -4741,7 +4739,6 @@ FCIMPL1(void, JIT_MonExit_Portable, Object* obj)
{
return;
}
- else
if (action == AwareLock::LeaveHelperAction_Signal)
{
FC_INNER_RETURN_VOID(JIT_MonExit_Signal(obj));
@@ -4773,7 +4770,6 @@ HCIMPL_MONHELPER(JIT_MonExitWorker_Portable, Object* obj)
MONHELPER_STATE(*pbLockTaken = 0;)
return;
}
- else
if (action == AwareLock::LeaveHelperAction_Signal)
{
MONHELPER_STATE(*pbLockTaken = 0;)
@@ -4821,7 +4817,7 @@ HCIMPL_MONHELPER(JIT_MonEnterStatic_Portable, AwareLock *lock)
goto FramedLockHelper;
}
- if (lock->EnterHelper(pCurThread) == AwareLock::EnterHelperResult_Entered)
+ if (lock->EnterHelper(pCurThread, true /* checkRecursiveCase */))
{
#if defined(_DEBUG) && defined(TRACK_SYNC)
// The best place to grab this is from the ECall frame
@@ -4909,289 +4905,6 @@ HCIMPL_MONHELPER(JIT_MonExitStatic_Portable, AwareLock *lock)
HCIMPLEND
#include <optdefault.h>
-/*********************************************************************/
-// JITutil_Mon* are helpers than handle slow paths for JIT_Mon* methods
-// implemented in assembly. They are not doing any spinning compared
-// to the full fledged portable implementations above.
-/*********************************************************************/
-
-/*********************************************************************/
-HCIMPL_MONHELPER(JITutil_MonEnterWorker, Object* obj)
-{
- CONTRACTL
- {
- FCALL_CHECK;
- }
- CONTRACTL_END;
-
- OBJECTREF objRef = ObjectToOBJECTREF(obj);
-
- // The following makes sure that Monitor.Enter shows up on thread abort
- // stack walks (otherwise Monitor.Enter called within a CER can block a
- // thread abort indefinitely). Setting the __me internal variable (normally
- // only set for fcalls) will cause the helper frame below to be able to
- // backtranslate into the method desc for the Monitor.Enter fcall.
- //
- // Note that we need explicitly initialize Monitor.Enter fcall in
- // code:SystemDomain::LoadBaseSystemClasses to make this work in the case
- // where the first call ever to Monitor.Enter is done as JIT helper
- // for synchronized method.
- __me = GetEEFuncEntryPointMacro(JIT_MonEnter);
-
- // Monitor helpers are used as both hcalls and fcalls, thus we need exact depth.
- HELPER_METHOD_FRAME_BEGIN_ATTRIB_1(Frame::FRAME_ATTR_EXACT_DEPTH, objRef);
-
- if (objRef == NULL)
- COMPlusThrow(kArgumentNullException);
-
- MONHELPER_STATE(GCPROTECT_BEGININTERIOR(pbLockTaken);)
-
-#ifdef _DEBUG
- Thread *pThread = GetThread();
- DWORD lockCount = pThread->m_dwLockCount;
-#endif
- if (GET_THREAD()->CatchAtSafePointOpportunistic())
- {
- GET_THREAD()->PulseGCMode();
- }
- objRef->EnterObjMonitor();
- _ASSERTE ((objRef->GetSyncBlock()->GetMonitor()->m_Recursion == 1 && pThread->m_dwLockCount == lockCount + 1) ||
- pThread->m_dwLockCount == lockCount);
- MONHELPER_STATE(if (pbLockTaken != 0) *pbLockTaken = 1;)
-
- MONHELPER_STATE(GCPROTECT_END();)
- HELPER_METHOD_FRAME_END();
-}
-HCIMPLEND
-
-/*********************************************************************/
-
-// This helper is only ever used as part of FCall, but it is implemented using HCIMPL macro
-// so that it can be tail called from assembly helper without triggering asserts in debug.
-HCIMPL2(void, JITutil_MonReliableEnter, Object* obj, BYTE* pbLockTaken)
-{
- CONTRACTL
- {
- FCALL_CHECK;
- }
- CONTRACTL_END;
-
- OBJECTREF objRef = ObjectToOBJECTREF(obj);
-
- // The following makes sure that Monitor.Enter shows up on thread abort
- // stack walks (otherwise Monitor.Enter called within a CER can block a
- // thread abort indefinitely). Setting the __me internal variable (normally
- // only set for fcalls) will cause the helper frame below to be able to
- // backtranslate into the method desc for the Monitor.Enter fcall.
- __me = GetEEFuncEntryPointMacro(JIT_MonReliableEnter);
-
- // Monitor helpers are used as both hcalls and fcalls, thus we need exact depth.
- HELPER_METHOD_FRAME_BEGIN_ATTRIB_1(Frame::FRAME_ATTR_EXACT_DEPTH, objRef);
-
- if (objRef == NULL)
- COMPlusThrow(kArgumentNullException);
-
- GCPROTECT_BEGININTERIOR(pbLockTaken);
-
-#ifdef _DEBUG
- Thread *pThread = GetThread();
- DWORD lockCount = pThread->m_dwLockCount;
-#endif
- if (GET_THREAD()->CatchAtSafePointOpportunistic())
- {
- GET_THREAD()->PulseGCMode();
- }
- objRef->EnterObjMonitor();
- _ASSERTE ((objRef->GetSyncBlock()->GetMonitor()->m_Recursion == 1 && pThread->m_dwLockCount == lockCount + 1) ||
- pThread->m_dwLockCount == lockCount);
- *pbLockTaken = 1;
-
- GCPROTECT_END();
- HELPER_METHOD_FRAME_END();
-}
-HCIMPLEND
-
-
-/*********************************************************************/
-
-// This helper is only ever used as part of FCall, but it is implemented using HCIMPL macro
-// so that it can be tail called from assembly helper without triggering asserts in debug.
-HCIMPL3(void, JITutil_MonTryEnter, Object* obj, INT32 timeOut, BYTE* pbLockTaken)
-{
- CONTRACTL
- {
- FCALL_CHECK;
- }
- CONTRACTL_END;
-
- BOOL result = FALSE;
-
- OBJECTREF objRef = ObjectToOBJECTREF(obj);
-
- // The following makes sure that Monitor.TryEnter shows up on thread
- // abort stack walks (otherwise Monitor.TryEnter called within a CER can
- // block a thread abort for long periods of time). Setting the __me internal
- // variable (normally only set for fcalls) will cause the helper frame below
- // to be able to backtranslate into the method desc for the Monitor.TryEnter
- // fcall.
- __me = GetEEFuncEntryPointMacro(JIT_MonTryEnter);
-
- // Monitor helpers are used as both hcalls and fcalls, thus we need exact depth.
- HELPER_METHOD_FRAME_BEGIN_ATTRIB_1(Frame::FRAME_ATTR_EXACT_DEPTH, objRef);
-
- if (objRef == NULL)
- COMPlusThrow(kArgumentNullException);
-
- if (timeOut < -1)
- COMPlusThrow(kArgumentOutOfRangeException);
-
- GCPROTECT_BEGININTERIOR(pbLockTaken);
-
- if (GET_THREAD()->CatchAtSafePointOpportunistic())
- {
- GET_THREAD()->PulseGCMode();
- }
-
- result = objRef->TryEnterObjMonitor(timeOut);
- *pbLockTaken = result != FALSE;
-
- GCPROTECT_END();
- HELPER_METHOD_FRAME_END();
-}
-HCIMPLEND
-
-/*********************************************************************/
-HCIMPL_MONHELPER(JITutil_MonExitWorker, Object* obj)
-{
- CONTRACTL
- {
- FCALL_CHECK;
- }
- CONTRACTL_END;
-
- MONHELPER_STATE(if (pbLockTaken != NULL && *pbLockTaken == 0) return;)
-
- OBJECTREF objRef = ObjectToOBJECTREF(obj);
-
- // Monitor helpers are used as both hcalls and fcalls, thus we need exact depth.
- HELPER_METHOD_FRAME_BEGIN_ATTRIB_1(Frame::FRAME_ATTR_NO_THREAD_ABORT|Frame::FRAME_ATTR_EXACT_DEPTH, objRef);
-
- if (objRef == NULL)
- COMPlusThrow(kArgumentNullException);
-
- if (!objRef->LeaveObjMonitor())
- COMPlusThrow(kSynchronizationLockException);
-
- MONHELPER_STATE(if (pbLockTaken != 0) *pbLockTaken = 0;)
-
- TESTHOOKCALL(AppDomainCanBeUnloaded(GET_THREAD()->GetDomain()->GetId().m_dwId,FALSE));
-
- if (GET_THREAD()->IsAbortRequested()) {
- GET_THREAD()->HandleThreadAbort();
- }
-
- HELPER_METHOD_FRAME_END();
-}
-HCIMPLEND
-
-/*********************************************************************/
-// A helper for JIT_MonEnter that is on the callee side of an ecall
-// frame and handles the contention case.
-
-HCIMPL_MONHELPER(JITutil_MonContention, AwareLock* lock)
-{
- CONTRACTL
- {
- FCALL_CHECK;
- }
- CONTRACTL_END;
-
- // The following makes sure that Monitor.Enter shows up on thread abort
- // stack walks (otherwise Monitor.Enter called within a CER can block a
- // thread abort indefinitely). Setting the __me internal variable (normally
- // only set for fcalls) will cause the helper frame below to be able to
- // backtranslate into the method desc for the Monitor.Enter fcall.
- __me = GetEEFuncEntryPointMacro(JIT_MonEnter);
-
- // Monitor helpers are used as both hcalls and fcalls, thus we need exact depth.
- HELPER_METHOD_FRAME_BEGIN_ATTRIB(Frame::FRAME_ATTR_EXACT_DEPTH);
- MONHELPER_STATE(GCPROTECT_BEGININTERIOR(pbLockTaken);)
-
-#ifdef _DEBUG
- Thread *pThread = GetThread();
- DWORD lockCount = pThread->m_dwLockCount;
-#endif
- lock->Contention();
- _ASSERTE (pThread->m_dwLockCount == lockCount + 1);
- MONHELPER_STATE(if (pbLockTaken != 0) *pbLockTaken = 1;)
-
- MONHELPER_STATE(GCPROTECT_END();)
- HELPER_METHOD_FRAME_END();
-}
-HCIMPLEND
-
-// This helper is only ever used as part of FCall, but it is implemented using HCIMPL macro
-// so that it can be tail called from assembly helper without triggering asserts in debug.
-HCIMPL2(void, JITutil_MonReliableContention, AwareLock* lock, BYTE* pbLockTaken)
-{
- CONTRACTL
- {
- FCALL_CHECK;
- }
- CONTRACTL_END;
-
- // The following makes sure that Monitor.Enter shows up on thread abort
- // stack walks (otherwise Monitor.Enter called within a CER can block a
- // thread abort indefinitely). Setting the __me internal variable (normally
- // only set for fcalls) will cause the helper frame below to be able to
- // backtranslate into the method desc for the Monitor.Enter fcall.
- __me = GetEEFuncEntryPointMacro(JIT_MonReliableEnter);
-
- // Monitor helpers are used as both hcalls and fcalls, thus we need exact depth.
- HELPER_METHOD_FRAME_BEGIN_ATTRIB(Frame::FRAME_ATTR_EXACT_DEPTH);
- GCPROTECT_BEGININTERIOR(pbLockTaken);
-
-#ifdef _DEBUG
- Thread *pThread = GetThread();
- DWORD lockCount = pThread->m_dwLockCount;
-#endif
- lock->Contention();
- _ASSERTE (pThread->m_dwLockCount == lockCount + 1);
- *pbLockTaken = 1;
-
- GCPROTECT_END();
- HELPER_METHOD_FRAME_END();
-}
-HCIMPLEND
-
-/*********************************************************************/
-// A helper for JIT_MonExit and JIT_MonExitStatic that is on the
-// callee side of an ecall frame and handles cases that might allocate,
-// throw or block.
-HCIMPL_MONHELPER(JITutil_MonSignal, AwareLock* lock)
-{
- CONTRACTL
- {
- FCALL_CHECK;
- }
- CONTRACTL_END;
-
- // Monitor helpers are used as both hcalls and fcalls, thus we need exact depth.
- HELPER_METHOD_FRAME_BEGIN_ATTRIB(Frame::FRAME_ATTR_EXACT_DEPTH | Frame::FRAME_ATTR_NO_THREAD_ABORT);
-
- lock->Signal();
- MONHELPER_STATE(if (pbLockTaken != 0) *pbLockTaken = 0;)
-
- TESTHOOKCALL(AppDomainCanBeUnloaded(GET_THREAD()->GetDomain()->GetId().m_dwId,FALSE));
-
- if (GET_THREAD()->IsAbortRequested()) {
- GET_THREAD()->HandleThreadAbort();
- }
-
- HELPER_METHOD_FRAME_END();
-}
-HCIMPLEND
-
HCIMPL1(void *, JIT_GetSyncFromClassHandle, CORINFO_CLASS_HANDLE typeHnd_)
CONTRACTL {
FCALL_CHECK;
diff --git a/src/vm/jitinterface.cpp b/src/vm/jitinterface.cpp
index 8865525e06..2a8fa908e9 100644
--- a/src/vm/jitinterface.cpp
+++ b/src/vm/jitinterface.cpp
@@ -8692,6 +8692,123 @@ void CEEInfo::expandRawHandleIntrinsic(
}
/*********************************************************************/
+CORINFO_CLASS_HANDLE CEEInfo::getDefaultEqualityComparerClass(CORINFO_CLASS_HANDLE elemType)
+{
+ CONTRACTL {
+ SO_TOLERANT;
+ THROWS;
+ GC_TRIGGERS;
+ MODE_PREEMPTIVE;
+ } CONTRACTL_END;
+
+ CORINFO_CLASS_HANDLE result = NULL;
+
+ JIT_TO_EE_TRANSITION();
+
+ result = getDefaultEqualityComparerClassHelper(elemType);
+
+ EE_TO_JIT_TRANSITION();
+
+ return result;
+}
+
+CORINFO_CLASS_HANDLE CEEInfo::getDefaultEqualityComparerClassHelper(CORINFO_CLASS_HANDLE elemType)
+{
+ CONTRACTL {
+ SO_TOLERANT;
+ THROWS;
+ GC_TRIGGERS;
+ MODE_PREEMPTIVE;
+ } CONTRACTL_END;
+
+ // Mirrors the logic in BCL's CompareHelpers.CreateDefaultEqualityComparer
+ // And in compile.cpp's SpecializeEqualityComparer
+ TypeHandle elemTypeHnd(elemType);
+
+ // Special case for byte
+ if (elemTypeHnd.AsMethodTable()->HasSameTypeDefAs(MscorlibBinder::GetClass(CLASS__ELEMENT_TYPE_U1)))
+ {
+ return CORINFO_CLASS_HANDLE(MscorlibBinder::GetClass(CLASS__BYTE_EQUALITYCOMPARER));
+ }
+
+ // Else we'll need to find the appropriate instantation
+ Instantiation inst(&elemTypeHnd, 1);
+
+ // If T implements IEquatable<T>
+ if (elemTypeHnd.CanCastTo(TypeHandle(MscorlibBinder::GetClass(CLASS__IEQUATABLEGENERIC)).Instantiate(inst)))
+ {
+ TypeHandle resultTh = ((TypeHandle)MscorlibBinder::GetClass(CLASS__GENERIC_EQUALITYCOMPARER)).Instantiate(inst);
+ return CORINFO_CLASS_HANDLE(resultTh.GetMethodTable());
+ }
+
+ // Nullable<T>
+ if (Nullable::IsNullableType(elemTypeHnd))
+ {
+ Instantiation nullableInst = elemTypeHnd.AsMethodTable()->GetInstantiation();
+ TypeHandle nullableComparer = TypeHandle(MscorlibBinder::GetClass(CLASS__IEQUATABLEGENERIC)).Instantiate(nullableInst);
+ if (nullableInst[0].CanCastTo(nullableComparer))
+ {
+ return CORINFO_CLASS_HANDLE(nullableComparer.GetMethodTable());
+ }
+ }
+
+ // Enum
+ //
+ // We need to special case the Enum comparers based on their underlying type,
+ // to avoid boxing and call the correct versions of GetHashCode.
+ if (elemTypeHnd.IsEnum())
+ {
+ MethodTable* targetClass = NULL;
+ CorElementType normType = elemTypeHnd.GetVerifierCorElementType();
+
+ switch(normType)
+ {
+ case ELEMENT_TYPE_I1:
+ {
+ targetClass = MscorlibBinder::GetClass(CLASS__SBYTE_ENUM_EQUALITYCOMPARER);
+ break;
+ }
+
+ case ELEMENT_TYPE_I2:
+ {
+ targetClass = MscorlibBinder::GetClass(CLASS__SHORT_ENUM_EQUALITYCOMPARER);
+ break;
+ }
+
+ case ELEMENT_TYPE_U1:
+ case ELEMENT_TYPE_U2:
+ case ELEMENT_TYPE_I4:
+ case ELEMENT_TYPE_U4:
+ {
+ targetClass = MscorlibBinder::GetClass(CLASS__ENUM_EQUALITYCOMPARER);
+ break;
+ }
+
+ case ELEMENT_TYPE_I8:
+ case ELEMENT_TYPE_U8:
+ {
+ targetClass = MscorlibBinder::GetClass(CLASS__LONG_ENUM_EQUALITYCOMPARER);
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ if (targetClass != NULL)
+ {
+ TypeHandle resultTh = ((TypeHandle)targetClass->GetCanonicalMethodTable()).Instantiate(inst);
+ return CORINFO_CLASS_HANDLE(resultTh.GetMethodTable());
+ }
+ }
+
+ // Default case
+ TypeHandle resultTh = ((TypeHandle)MscorlibBinder::GetClass(CLASS__OBJECT_EQUALITYCOMPARER)).Instantiate(inst);
+
+ return CORINFO_CLASS_HANDLE(resultTh.GetMethodTable());
+}
+
+/*********************************************************************/
void CEEInfo::getFunctionEntryPoint(CORINFO_METHOD_HANDLE ftnHnd,
CORINFO_CONST_LOOKUP * pResult,
CORINFO_ACCESS_FLAGS accessFlags)
diff --git a/src/vm/jitinterface.h b/src/vm/jitinterface.h
index 93470ecbac..b6d846ee7f 100644
--- a/src/vm/jitinterface.h
+++ b/src/vm/jitinterface.h
@@ -744,6 +744,14 @@ public:
CORINFO_CONTEXT_HANDLE ownerType
);
+ CORINFO_CLASS_HANDLE getDefaultEqualityComparerClass(
+ CORINFO_CLASS_HANDLE elemType
+ );
+
+ CORINFO_CLASS_HANDLE getDefaultEqualityComparerClassHelper(
+ CORINFO_CLASS_HANDLE elemType
+ );
+
void expandRawHandleIntrinsic(
CORINFO_RESOLVED_TOKEN * pResolvedToken,
CORINFO_GENERICHANDLE_RESULT * pResult);
diff --git a/src/vm/jitinterfacegen.cpp b/src/vm/jitinterfacegen.cpp
index 26387405b7..38f1a7436a 100644
--- a/src/vm/jitinterfacegen.cpp
+++ b/src/vm/jitinterfacegen.cpp
@@ -47,15 +47,6 @@ EXTERN_C Object* JIT_NewArr1OBJ_UP (CORINFO_CLASS_HANDLE arrayMT, INT_PTR size);
EXTERN_C Object* JIT_NewArr1VC_MP (CORINFO_CLASS_HANDLE arrayMT, INT_PTR size);
EXTERN_C Object* JIT_NewArr1VC_UP (CORINFO_CLASS_HANDLE arrayMT, INT_PTR size);
-//For the optimized JIT_Mon helpers
-#if defined(_TARGET_AMD64_)
-EXTERN_C void JIT_MonEnterWorker_Slow(Object* obj, BYTE* pbLockTaken);
-EXTERN_C void JIT_MonExitWorker_Slow(Object* obj, BYTE* pbLockTaken);
-EXTERN_C void JIT_MonTryEnter_Slow(Object* obj, INT32 timeOut, BYTE* pbLockTaken);
-EXTERN_C void JIT_MonEnterStatic_Slow(AwareLock* lock, BYTE* pbLockTaken);
-EXTERN_C void JIT_MonExitStatic_Slow(AwareLock* lock, BYTE* pbLockTaken);
-#endif // _TARGET_AMD64_
-
extern "C" void* JIT_GetSharedNonGCStaticBase_Slow(SIZE_T moduleDomainID, DWORD dwModuleClassID);
extern "C" void* JIT_GetSharedNonGCStaticBaseNoCtor_Slow(SIZE_T moduleDomainID, DWORD dwModuleClassID);
extern "C" void* JIT_GetSharedGCStaticBase_Slow(SIZE_T moduleDomainID, DWORD dwModuleClassID);
@@ -114,12 +105,6 @@ EXTERN_C void JIT_BoxFastMPIGT__PatchTLSLabel();
EXTERN_C void AllocateStringFastMP_InlineGetThread__PatchTLSOffset();
EXTERN_C void JIT_NewArr1VC_MP_InlineGetThread__PatchTLSOffset();
EXTERN_C void JIT_NewArr1OBJ_MP_InlineGetThread__PatchTLSOffset();
-EXTERN_C void JIT_MonEnterWorker_InlineGetThread_GetThread_PatchLabel();
-EXTERN_C void JIT_MonExitWorker_InlineGetThread_GetThread_PatchLabel();
-EXTERN_C void JIT_MonTryEnter_GetThread_PatchLabel();
-EXTERN_C void JIT_MonEnterStaticWorker_InlineGetThread_GetThread_PatchLabel_1();
-EXTERN_C void JIT_MonEnterStaticWorker_InlineGetThread_GetThread_PatchLabel_2();
-EXTERN_C void JIT_MonExitStaticWorker_InlineGetThread_GetThread_PatchLabel();
static const LPVOID InlineGetThreadLocations[] = {
@@ -128,12 +113,6 @@ static const LPVOID InlineGetThreadLocations[] = {
(PVOID)AllocateStringFastMP_InlineGetThread__PatchTLSOffset,
(PVOID)JIT_NewArr1VC_MP_InlineGetThread__PatchTLSOffset,
(PVOID)JIT_NewArr1OBJ_MP_InlineGetThread__PatchTLSOffset,
- (PVOID)JIT_MonEnterWorker_InlineGetThread_GetThread_PatchLabel,
- (PVOID)JIT_MonExitWorker_InlineGetThread_GetThread_PatchLabel,
- (PVOID)JIT_MonTryEnter_GetThread_PatchLabel,
- (PVOID)JIT_MonEnterStaticWorker_InlineGetThread_GetThread_PatchLabel_1,
- (PVOID)JIT_MonEnterStaticWorker_InlineGetThread_GetThread_PatchLabel_2,
- (PVOID)JIT_MonExitStaticWorker_InlineGetThread_GetThread_PatchLabel,
};
EXTERN_C void JIT_GetSharedNonGCStaticBase__PatchTLSLabel();
@@ -187,11 +166,6 @@ void FixupInlineGetters(DWORD tlsSlot, const LPVOID * pLocations, int nLocations
}
#endif // defined(_WIN64) && !defined(FEATURE_IMPLICIT_TLS)
-#if defined(_TARGET_AMD64_)
-EXTERN_C void JIT_MonEnterStaticWorker();
-EXTERN_C void JIT_MonExitStaticWorker();
-#endif
-
void InitJITHelpers1()
{
STANDARD_VM_CONTRACT;
@@ -274,22 +248,6 @@ void InitJITHelpers1()
}
}
-#ifndef FEATURE_IMPLICIT_TLS
- if (gThreadTLSIndex >= TLS_MINIMUM_AVAILABLE)
- {
- // We need to patch the helpers for FCalls
- MakeIntoJumpStub(JIT_MonEnterWorker_InlineGetThread, JIT_MonEnterWorker_Slow);
- MakeIntoJumpStub(JIT_MonExitWorker_InlineGetThread, JIT_MonExitWorker_Slow);
- MakeIntoJumpStub(JIT_MonTryEnter_InlineGetThread, JIT_MonTryEnter_Slow);
-
- SetJitHelperFunction(CORINFO_HELP_MON_ENTER, JIT_MonEnterWorker_Slow);
- SetJitHelperFunction(CORINFO_HELP_MON_EXIT, JIT_MonExitWorker_Slow);
-
- SetJitHelperFunction(CORINFO_HELP_MON_ENTER_STATIC, JIT_MonEnterStatic_Slow);
- SetJitHelperFunction(CORINFO_HELP_MON_EXIT_STATIC, JIT_MonExitStatic_Slow);
- }
-#endif
-
if(IsSingleAppDomain())
{
SetJitHelperFunction(CORINFO_HELP_GETSHARED_GCSTATIC_BASE, JIT_GetSharedGCStaticBase_SingleAppDomain);
diff --git a/src/vm/method.hpp b/src/vm/method.hpp
index 08318ec5b5..5f860be1e7 100644
--- a/src/vm/method.hpp
+++ b/src/vm/method.hpp
@@ -1251,7 +1251,8 @@ public:
!IsEnCMethod() &&
HasNativeCodeSlot() &&
!IsUnboxingStub() &&
- !IsInstantiatingStub();
+ !IsInstantiatingStub() &&
+ !IsDynamicMethod();
// We should add an exclusion for modules with debuggable code gen flags
diff --git a/src/vm/mscorlib.h b/src/vm/mscorlib.h
index b86930693d..4942e0d8a9 100644
--- a/src/vm/mscorlib.h
+++ b/src/vm/mscorlib.h
@@ -1449,6 +1449,17 @@ DEFINE_CLASS(UTF8BUFFERMARSHALER, StubHelpers, UTF8BufferMarshaler)
DEFINE_METHOD(UTF8BUFFERMARSHALER, CONVERT_TO_NATIVE, ConvertToNative, NoSig)
DEFINE_METHOD(UTF8BUFFERMARSHALER, CONVERT_TO_MANAGED, ConvertToManaged, NoSig)
+// Classes referenced in EqualityComparer<T>.Default optimization
+
+DEFINE_CLASS(BYTE_EQUALITYCOMPARER, CollectionsGeneric, ByteEqualityComparer)
+DEFINE_CLASS(SHORT_ENUM_EQUALITYCOMPARER, CollectionsGeneric, ShortEnumEqualityComparer`1)
+DEFINE_CLASS(SBYTE_ENUM_EQUALITYCOMPARER, CollectionsGeneric, SByteEnumEqualityComparer`1)
+DEFINE_CLASS(ENUM_EQUALITYCOMPARER, CollectionsGeneric, EnumEqualityComparer`1)
+DEFINE_CLASS(LONG_ENUM_EQUALITYCOMPARER, CollectionsGeneric, LongEnumEqualityComparer`1)
+DEFINE_CLASS(NULLABLE_EQUALITYCOMPARER, CollectionsGeneric, NullableEqualityComparer`1)
+DEFINE_CLASS(GENERIC_EQUALITYCOMPARER, CollectionsGeneric, GenericEqualityComparer`1)
+DEFINE_CLASS(OBJECT_EQUALITYCOMPARER, CollectionsGeneric, ObjectEqualityComparer`1)
+
#undef DEFINE_CLASS
#undef DEFINE_METHOD
#undef DEFINE_FIELD
diff --git a/src/vm/prestub.cpp b/src/vm/prestub.cpp
index f96135008d..d2f24bde29 100644
--- a/src/vm/prestub.cpp
+++ b/src/vm/prestub.cpp
@@ -205,7 +205,7 @@ PCODE MethodDesc::DoBackpatch(MethodTable * pMT, MethodTable *pDispatchingMT, BO
#pragma optimize("", off)
#endif
-void DACNotifyCompilationFinished(MethodDesc *methodDesc)
+void DACNotifyCompilationFinished(MethodDesc *methodDesc, PCODE pCode)
{
CONTRACTL
{
@@ -231,7 +231,7 @@ void DACNotifyCompilationFinished(MethodDesc *methodDesc)
if (jnt & CLRDATA_METHNOTIFY_GENERATED)
{
// If so, throw an exception!
- DACNotify::DoJITNotification(methodDesc);
+ DACNotify::DoJITNotification(methodDesc, (TADDR)pCode);
}
}
}
@@ -813,7 +813,7 @@ PCODE MethodDesc::JitCompileCodeLockedEventWrapper(PrepareCodeConfig* pConfig, J
#endif
{
// The notification will only occur if someone has registered for this method.
- DACNotifyCompilationFinished(this);
+ DACNotifyCompilationFinished(this, pCode);
}
return pCode;
diff --git a/src/vm/readytoruninfo.cpp b/src/vm/readytoruninfo.cpp
index 996a862431..5ac1eb114d 100644
--- a/src/vm/readytoruninfo.cpp
+++ b/src/vm/readytoruninfo.cpp
@@ -495,12 +495,6 @@ PTR_ReadyToRunInfo ReadyToRunInfo::Initialize(Module * pModule, AllocMemTracker
return NULL;
}
- if (!pLayout->IsNativeMachineFormat())
- {
- // For CoreCLR, be strict about disallowing machine mismatches.
- COMPlusThrowHR(COR_E_BADIMAGEFORMAT);
- }
-
#ifdef FEATURE_NATIVE_IMAGE_GENERATION
// Ignore ReadyToRun during NGen
if (IsCompilationProcess() && !IsNgenPDBCompilationProcess())
@@ -510,6 +504,12 @@ PTR_ReadyToRunInfo ReadyToRunInfo::Initialize(Module * pModule, AllocMemTracker
}
#endif
+ if (!pLayout->IsNativeMachineFormat())
+ {
+ // For CoreCLR, be strict about disallowing machine mismatches.
+ COMPlusThrowHR(COR_E_BADIMAGEFORMAT);
+ }
+
#ifndef CROSSGEN_COMPILE
// The file must have been loaded using LoadLibrary
if (!pLayout->IsRelocated())
diff --git a/src/vm/syncblk.cpp b/src/vm/syncblk.cpp
index 50eec9b068..9c512675b6 100644
--- a/src/vm/syncblk.cpp
+++ b/src/vm/syncblk.cpp
@@ -1901,6 +1901,90 @@ BOOL ObjHeader::TryEnterObjMonitor(INT32 timeOut)
return GetSyncBlock()->TryEnterMonitor(timeOut);
}
+AwareLock::EnterHelperResult ObjHeader::EnterObjMonitorHelperSpin(Thread* pCurThread)
+{
+ CONTRACTL{
+ SO_TOLERANT;
+ NOTHROW;
+ GC_NOTRIGGER;
+ MODE_COOPERATIVE;
+ } CONTRACTL_END;
+
+ // Note: EnterObjMonitorHelper must be called before this function (see below)
+
+ if (g_SystemInfo.dwNumberOfProcessors == 1)
+ {
+ return AwareLock::EnterHelperResult_Contention;
+ }
+
+ for (DWORD spinCount = g_SpinConstants.dwInitialDuration; AwareLock::SpinWaitAndBackOffBeforeOperation(&spinCount);)
+ {
+ LONG oldValue = m_SyncBlockValue.LoadWithoutBarrier();
+
+ // Since spinning has begun, chances are good that the monitor has already switched to AwareLock mode, so check for that
+ // case first
+ if (oldValue & BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX)
+ {
+ // If we have a hash code already, we need to create a sync block
+ if (oldValue & BIT_SBLK_IS_HASHCODE)
+ {
+ return AwareLock::EnterHelperResult_UseSlowPath;
+ }
+
+ // Check the recursive case once before the spin loop. If it's not the recursive case in the beginning, it will not
+ // be in the future, so the spin loop can avoid checking the recursive case.
+ SyncBlock *syncBlock = g_pSyncTable[oldValue & MASK_SYNCBLOCKINDEX].m_SyncBlock;
+ _ASSERTE(syncBlock != NULL);
+ AwareLock *awareLock = &syncBlock->m_Monitor;
+ if (awareLock->EnterHelper(pCurThread, true /* checkRecursiveCase */))
+ {
+ return AwareLock::EnterHelperResult_Entered;
+ }
+ while (AwareLock::SpinWaitAndBackOffBeforeOperation(&spinCount))
+ {
+ if (awareLock->EnterHelper(pCurThread, false /* checkRecursiveCase */))
+ {
+ return AwareLock::EnterHelperResult_Entered;
+ }
+ }
+ break;
+ }
+
+ DWORD tid = pCurThread->GetThreadId();
+ if ((oldValue & (BIT_SBLK_SPIN_LOCK +
+ SBLK_MASK_LOCK_THREADID +
+ SBLK_MASK_LOCK_RECLEVEL)) == 0)
+ {
+ if (tid > SBLK_MASK_LOCK_THREADID)
+ {
+ return AwareLock::EnterHelperResult_UseSlowPath;
+ }
+
+ LONG newValue = oldValue | tid;
+ if (InterlockedCompareExchangeAcquire((LONG*)&m_SyncBlockValue, newValue, oldValue) == oldValue)
+ {
+ pCurThread->IncLockCount();
+ return AwareLock::EnterHelperResult_Entered;
+ }
+
+ continue;
+ }
+
+ // EnterObjMonitorHelper handles the thin lock recursion case. If it's not that case, it won't become that case. If
+ // EnterObjMonitorHelper failed to increment the recursion level, it will go down the slow path and won't come here. So,
+ // no need to check the recursion case here.
+ _ASSERTE(
+ // The header is transitioning - treat this as if the lock was taken
+ oldValue & BIT_SBLK_SPIN_LOCK ||
+ // Here we know we have the "thin lock" layout, but the lock is not free.
+ // It can't be the recursion case though, because the call to EnterObjMonitorHelper prior to this would have taken
+ // the slow path in the recursive case.
+ tid != (DWORD)(oldValue & SBLK_MASK_LOCK_THREADID));
+ }
+
+ return AwareLock::EnterHelperResult_Contention;
+}
+
BOOL ObjHeader::LeaveObjMonitor()
{
CONTRACTL
diff --git a/src/vm/syncblk.h b/src/vm/syncblk.h
index c6c63aefc7..9dcd57c497 100644
--- a/src/vm/syncblk.h
+++ b/src/vm/syncblk.h
@@ -251,9 +251,10 @@ public:
LeaveHelperAction_Error,
};
+ static bool SpinWaitAndBackOffBeforeOperation(DWORD *spinCountRef);
+
// Helper encapsulating the fast path entering monitor. Returns what kind of result was achieved.
- AwareLock::EnterHelperResult EnterHelper(Thread* pCurThread);
- AwareLock::EnterHelperResult EnterHelperSpin(Thread* pCurThread, INT32 timeOut = -1);
+ bool EnterHelper(Thread* pCurThread, bool checkRecursiveCase);
// Helper encapsulating the core logic for leaving monitor. Returns what kind of
// follow up action is necessary
@@ -1265,8 +1266,11 @@ class ObjHeader
// non-blocking version of above
BOOL TryEnterObjMonitor(INT32 timeOut = 0);
- // Inlineable fast path of EnterObjMonitor/TryEnterObjMonitor
+ // Inlineable fast path of EnterObjMonitor/TryEnterObjMonitor. Must be called before EnterObjMonitorHelperSpin.
AwareLock::EnterHelperResult EnterObjMonitorHelper(Thread* pCurThread);
+
+ // Typically non-inlined spin loop for some fast paths of EnterObjMonitor/TryEnterObjMonitor. EnterObjMonitorHelper must be
+ // called before this function.
AwareLock::EnterHelperResult EnterObjMonitorHelperSpin(Thread* pCurThread);
// leaves the monitor of an object
diff --git a/src/vm/syncblk.inl b/src/vm/syncblk.inl
index cb6b280228..376cd4c2e7 100644
--- a/src/vm/syncblk.inl
+++ b/src/vm/syncblk.inl
@@ -8,157 +8,141 @@
#ifndef DACCESS_COMPILE
-FORCEINLINE AwareLock::EnterHelperResult AwareLock::EnterHelper(Thread* pCurThread)
+FORCEINLINE bool AwareLock::SpinWaitAndBackOffBeforeOperation(DWORD *spinCountRef)
{
- CONTRACTL {
+ CONTRACTL{
SO_TOLERANT;
NOTHROW;
GC_NOTRIGGER;
- MODE_ANY;
+ MODE_COOPERATIVE;
} CONTRACTL_END;
- for (;;)
+ _ASSERTE(spinCountRef != nullptr);
+ DWORD &spinCount = *spinCountRef;
+ _ASSERTE(g_SystemInfo.dwNumberOfProcessors != 1);
+
+ if (spinCount > g_SpinConstants.dwMaximumDuration)
{
- LONG state = m_MonitorHeld.LoadWithoutBarrier();
+ return false;
+ }
- if (state == 0)
- {
- if (InterlockedCompareExchangeAcquire((LONG*)&m_MonitorHeld, 1, 0) == 0)
- {
- m_HoldingThread = pCurThread;
- m_Recursion = 1;
- pCurThread->IncLockCount();
- return AwareLock::EnterHelperResult_Entered;
- }
- }
- else
- {
- if (GetOwningThread() == pCurThread) /* monitor is held, but it could be a recursive case */
- {
- m_Recursion++;
- return AwareLock::EnterHelperResult_Entered;
- }
+ for (DWORD i = 0; i < spinCount; i++)
+ {
+ YieldProcessor();
+ }
+
+ spinCount *= g_SpinConstants.dwBackoffFactor;
+ return true;
+}
+
+FORCEINLINE bool AwareLock::EnterHelper(Thread* pCurThread, bool checkRecursiveCase)
+{
+ CONTRACTL{
+ SO_TOLERANT;
+ NOTHROW;
+ GC_NOTRIGGER;
+ MODE_ANY;
+ } CONTRACTL_END;
- return AwareLock::EnterHelperResult_Contention;
+ LONG state = m_MonitorHeld.LoadWithoutBarrier();
+ if (state == 0)
+ {
+ if (InterlockedCompareExchangeAcquire((LONG*)&m_MonitorHeld, 1, 0) == 0)
+ {
+ m_HoldingThread = pCurThread;
+ m_Recursion = 1;
+ pCurThread->IncLockCount();
+ return true;
}
}
+ else if (checkRecursiveCase && GetOwningThread() == pCurThread) /* monitor is held, but it could be a recursive case */
+ {
+ m_Recursion++;
+ return true;
+ }
+ return false;
}
FORCEINLINE AwareLock::EnterHelperResult ObjHeader::EnterObjMonitorHelper(Thread* pCurThread)
{
- CONTRACTL {
+ CONTRACTL{
SO_TOLERANT;
NOTHROW;
GC_NOTRIGGER;
MODE_COOPERATIVE;
} CONTRACTL_END;
- DWORD tid = pCurThread->GetThreadId();
+ LONG oldValue = m_SyncBlockValue.LoadWithoutBarrier();
- LONG oldvalue = m_SyncBlockValue.LoadWithoutBarrier();
-
- if ((oldvalue & (BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX +
- BIT_SBLK_SPIN_LOCK +
- SBLK_MASK_LOCK_THREADID +
- SBLK_MASK_LOCK_RECLEVEL)) == 0)
+ if ((oldValue & (BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX +
+ BIT_SBLK_SPIN_LOCK +
+ SBLK_MASK_LOCK_THREADID +
+ SBLK_MASK_LOCK_RECLEVEL)) == 0)
{
+ DWORD tid = pCurThread->GetThreadId();
if (tid > SBLK_MASK_LOCK_THREADID)
{
return AwareLock::EnterHelperResult_UseSlowPath;
}
- LONG newvalue = oldvalue | tid;
- if (InterlockedCompareExchangeAcquire((LONG*)&m_SyncBlockValue, newvalue, oldvalue) == oldvalue)
+ LONG newValue = oldValue | tid;
+ if (InterlockedCompareExchangeAcquire((LONG*)&m_SyncBlockValue, newValue, oldValue) == oldValue)
{
pCurThread->IncLockCount();
return AwareLock::EnterHelperResult_Entered;
}
- }
- else
- if (oldvalue & BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX)
- {
- // If we have a hash code already, we need to create a sync block
- if (oldvalue & BIT_SBLK_IS_HASHCODE)
- {
- return AwareLock::EnterHelperResult_UseSlowPath;
- }
-
- SyncBlock *syncBlock = g_pSyncTable [oldvalue & MASK_SYNCBLOCKINDEX].m_SyncBlock;
- _ASSERTE(syncBlock != NULL);
- return syncBlock->m_Monitor.EnterHelper(pCurThread);
+ return AwareLock::EnterHelperResult_Contention;
}
- else
+
+ if (oldValue & BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX)
{
- // The header is transitioning - treat this as if the lock was taken
- if (oldvalue & BIT_SBLK_SPIN_LOCK)
+ // If we have a hash code already, we need to create a sync block
+ if (oldValue & BIT_SBLK_IS_HASHCODE)
{
- return AwareLock::EnterHelperResult_Contention;
+ return AwareLock::EnterHelperResult_UseSlowPath;
}
- // Here we know we have the "thin lock" layout, but the lock is not free.
- // It could still be the recursion case - compare the thread id to check
- if (tid == (DWORD) (oldvalue & SBLK_MASK_LOCK_THREADID))
+ SyncBlock *syncBlock = g_pSyncTable[oldValue & MASK_SYNCBLOCKINDEX].m_SyncBlock;
+ _ASSERTE(syncBlock != NULL);
+ if (syncBlock->m_Monitor.EnterHelper(pCurThread, true /* checkRecursiveCase */))
{
- // Ok, the thread id matches, it's the recursion case.
- // Bump up the recursion level and check for overflow
- LONG newvalue = oldvalue + SBLK_LOCK_RECLEVEL_INC;
-
- if ((newvalue & SBLK_MASK_LOCK_RECLEVEL) == 0)
- {
- return AwareLock::EnterHelperResult_UseSlowPath;
- }
-
- if (InterlockedCompareExchangeAcquire((LONG*)&m_SyncBlockValue, newvalue, oldvalue) == oldvalue)
- {
- return AwareLock::EnterHelperResult_Entered;
- }
+ return AwareLock::EnterHelperResult_Entered;
}
- }
- return AwareLock::EnterHelperResult_Contention;
-}
+ return AwareLock::EnterHelperResult_Contention;
+ }
-inline AwareLock::EnterHelperResult ObjHeader::EnterObjMonitorHelperSpin(Thread* pCurThread)
-{
- CONTRACTL {
- SO_TOLERANT;
- NOTHROW;
- GC_NOTRIGGER;
- MODE_COOPERATIVE;
- } CONTRACTL_END;
+ // The header is transitioning - treat this as if the lock was taken
+ if (oldValue & BIT_SBLK_SPIN_LOCK)
+ {
+ return AwareLock::EnterHelperResult_Contention;
+ }
- if (1 == g_SystemInfo.dwNumberOfProcessors)
+ // Here we know we have the "thin lock" layout, but the lock is not free.
+ // It could still be the recursion case - compare the thread id to check
+ if (pCurThread->GetThreadId() != (DWORD)(oldValue & SBLK_MASK_LOCK_THREADID))
{
return AwareLock::EnterHelperResult_Contention;
}
- DWORD spincount = g_SpinConstants.dwInitialDuration;
+ // Ok, the thread id matches, it's the recursion case.
+ // Bump up the recursion level and check for overflow
+ LONG newValue = oldValue + SBLK_LOCK_RECLEVEL_INC;
- for (;;)
+ if ((newValue & SBLK_MASK_LOCK_RECLEVEL) == 0)
{
- //
- // exponential backoff
- //
- for (DWORD i = 0; i < spincount; i++)
- {
- YieldProcessor();
- }
-
- AwareLock::EnterHelperResult result = EnterObjMonitorHelper(pCurThread);
- if (result != AwareLock::EnterHelperResult_Contention)
- {
- return result;
- }
+ return AwareLock::EnterHelperResult_UseSlowPath;
+ }
- spincount *= g_SpinConstants.dwBackoffFactor;
- if (spincount > g_SpinConstants.dwMaximumDuration)
- {
- break;
- }
+ if (InterlockedCompareExchangeAcquire((LONG*)&m_SyncBlockValue, newValue, oldValue) == oldValue)
+ {
+ return AwareLock::EnterHelperResult_Entered;
}
- return AwareLock::EnterHelperResult_Contention;
+ // Use the slow path instead of spinning. The compare-exchange above would not fail often, and it's not worth forcing the
+ // spin loop that typically follows the call to this function to check the recursive case, so just bail to the slow path.
+ return AwareLock::EnterHelperResult_UseSlowPath;
}
// Helper encapsulating the core logic for releasing monitor. Returns what kind of
@@ -185,31 +169,20 @@ FORCEINLINE AwareLock::LeaveHelperAction AwareLock::LeaveHelper(Thread* pCurThre
pCurThread->m_pTrackSync->LeaveSync(caller, this);
#endif
- if (--m_Recursion != 0)
- {
- return AwareLock::LeaveHelperAction_None;
- }
-
- m_HoldingThread->DecLockCount();
- m_HoldingThread = NULL;
-
- for (;;)
+ if (--m_Recursion == 0)
{
- // Read existing lock state
- LONG state = m_MonitorHeld.LoadWithoutBarrier();
+ m_HoldingThread->DecLockCount();
+ m_HoldingThread = NULL;
// Clear lock bit.
- if (InterlockedCompareExchangeRelease((LONG*)&m_MonitorHeld, state - 1, state) == state)
+ LONG state = InterlockedDecrementRelease((LONG*)&m_MonitorHeld);
+
+ // If wait count is non-zero on successful clear, we must signal the event.
+ if (state & ~1)
{
- // If wait count is non-zero on successful clear, we must signal the event.
- if (state & ~1)
- {
- return AwareLock::LeaveHelperAction_Signal;
- }
- break;
+ return AwareLock::LeaveHelperAction_Signal;
}
}
-
return AwareLock::LeaveHelperAction_None;
}
@@ -234,34 +207,34 @@ FORCEINLINE AwareLock::LeaveHelperAction ObjHeader::LeaveObjMonitorHelper(Thread
return AwareLock::LeaveHelperAction_Error;
}
- if (syncBlockValue & SBLK_MASK_LOCK_RECLEVEL)
+ if (!(syncBlockValue & SBLK_MASK_LOCK_RECLEVEL))
{
- // recursion and ThinLock
- DWORD newValue = syncBlockValue - SBLK_LOCK_RECLEVEL_INC;
+ // We are leaving the lock
+ DWORD newValue = (syncBlockValue & (~SBLK_MASK_LOCK_THREADID));
if (InterlockedCompareExchangeRelease((LONG*)&m_SyncBlockValue, newValue, syncBlockValue) != (LONG)syncBlockValue)
{
return AwareLock::LeaveHelperAction_Yield;
}
+ pCurThread->DecLockCount();
}
else
{
- // We are leaving the lock
- DWORD newValue = (syncBlockValue & (~SBLK_MASK_LOCK_THREADID));
+ // recursion and ThinLock
+ DWORD newValue = syncBlockValue - SBLK_LOCK_RECLEVEL_INC;
if (InterlockedCompareExchangeRelease((LONG*)&m_SyncBlockValue, newValue, syncBlockValue) != (LONG)syncBlockValue)
{
return AwareLock::LeaveHelperAction_Yield;
}
- pCurThread->DecLockCount();
}
return AwareLock::LeaveHelperAction_None;
}
- if ((syncBlockValue & (BIT_SBLK_SPIN_LOCK + BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX + BIT_SBLK_IS_HASHCODE)) == BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX)
+ if ((syncBlockValue & (BIT_SBLK_SPIN_LOCK + BIT_SBLK_IS_HASHCODE)) == 0)
{
- SyncBlock *syncBlock = g_pSyncTable [syncBlockValue & MASK_SYNCBLOCKINDEX].m_SyncBlock;
+ _ASSERTE((syncBlockValue & BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX) != 0);
+ SyncBlock *syncBlock = g_pSyncTable[syncBlockValue & MASK_SYNCBLOCKINDEX].m_SyncBlock;
_ASSERTE(syncBlock != NULL);
-
return syncBlock->m_Monitor.LeaveHelper(pCurThread);
}
diff --git a/src/vm/synch.cpp b/src/vm/synch.cpp
index e159b7813a..e4fae65855 100644
--- a/src/vm/synch.cpp
+++ b/src/vm/synch.cpp
@@ -590,6 +590,418 @@ DWORD CLRSemaphore::Wait(DWORD dwMilliseconds, BOOL alertable)
}
}
+void CLRLifoSemaphore::Create(INT32 initialSignalCount, INT32 maximumSignalCount)
+{
+ CONTRACTL
+ {
+ THROWS;
+ GC_NOTRIGGER;
+ SO_TOLERANT;
+ }
+ CONTRACTL_END;
+
+ _ASSERTE(maximumSignalCount > 0);
+ _ASSERTE(initialSignalCount <= maximumSignalCount);
+ _ASSERTE(m_handle == nullptr);
+
+#ifdef FEATURE_PAL
+ HANDLE h = UnsafeCreateSemaphore(nullptr, initialSignalCount, maximumSignalCount, nullptr);
+#else // !FEATURE_PAL
+ HANDLE h = CreateIoCompletionPort(INVALID_HANDLE_VALUE, nullptr, 0, maximumSignalCount);
+#endif // FEATURE_PAL
+ if (h == nullptr)
+ {
+ ThrowOutOfMemory();
+ }
+
+ m_handle = h;
+ m_counts.signalCount = initialSignalCount;
+ INDEBUG(m_maximumSignalCount = maximumSignalCount);
+}
+
+void CLRLifoSemaphore::Close()
+{
+ LIMITED_METHOD_CONTRACT;
+
+ if (m_handle == nullptr)
+ {
+ return;
+ }
+
+ CloseHandle(m_handle);
+ m_handle = nullptr;
+}
+
+bool CLRLifoSemaphore::WaitForSignal(DWORD timeoutMs)
+{
+ CONTRACTL
+ {
+ NOTHROW;
+ GC_NOTRIGGER;
+ SO_TOLERANT;
+ }
+ CONTRACTL_END;
+
+ _ASSERTE(timeoutMs != 0);
+ _ASSERTE(m_handle != nullptr);
+ _ASSERTE(m_counts.waiterCount != (UINT16)0);
+
+ while (true)
+ {
+ // Wait for a signal
+ BOOL waitSuccessful;
+ {
+#ifdef FEATURE_PAL
+ // Do a prioritized wait to get LIFO waiter release order
+ DWORD waitResult = PAL_WaitForSingleObjectPrioritized(m_handle, timeoutMs);
+ _ASSERTE(waitResult == WAIT_OBJECT_0 || waitResult == WAIT_TIMEOUT);
+ waitSuccessful = waitResult == WAIT_OBJECT_0;
+#else // !FEATURE_PAL
+ // I/O completion ports release waiters in LIFO order, see
+ // https://msdn.microsoft.com/en-us/library/windows/desktop/aa365198(v=vs.85).aspx
+ DWORD numberOfBytes;
+ ULONG_PTR completionKey;
+ LPOVERLAPPED overlapped;
+ waitSuccessful = GetQueuedCompletionStatus(m_handle, &numberOfBytes, &completionKey, &overlapped, timeoutMs);
+ _ASSERTE(waitSuccessful || GetLastError() == WAIT_TIMEOUT);
+ _ASSERTE(overlapped == nullptr);
+#endif // FEATURE_PAL
+ }
+
+ // Unregister the waiter if this thread will not be waiting anymore, and try to acquire the semaphore
+ Counts counts = m_counts.VolatileLoad();
+ while (true)
+ {
+ _ASSERTE(counts.waiterCount != (UINT16)0);
+ Counts newCounts = counts;
+ if (counts.signalCount != 0)
+ {
+ --newCounts.signalCount;
+ --newCounts.waiterCount;
+ }
+ else if (!waitSuccessful)
+ {
+ --newCounts.waiterCount;
+ }
+
+ // This waiter has woken up and this needs to be reflected in the count of waiters signaled to wake. Since we don't
+ // have thread-specific signal state, there is not enough information to tell whether this thread woke up because it
+ // was signaled. For instance, this thread may have timed out and then we don't know whether this thread also got
+ // signaled. So in any woken case, decrement the count if possible. As such, timeouts could cause more waiters to
+ // wake than necessary.
+ if (counts.countOfWaitersSignaledToWake != (UINT8)0)
+ {
+ --newCounts.countOfWaitersSignaledToWake;
+ }
+
+ Counts countsBeforeUpdate = m_counts.CompareExchange(newCounts, counts);
+ if (countsBeforeUpdate == counts)
+ {
+ if (counts.signalCount != 0)
+ {
+ return true;
+ }
+ break;
+ }
+
+ counts = countsBeforeUpdate;
+ }
+
+ if (!waitSuccessful)
+ {
+ return false;
+ }
+ }
+}
+
+bool CLRLifoSemaphore::Wait(DWORD timeoutMs)
+{
+ WRAPPER_NO_CONTRACT;
+
+ _ASSERTE(m_handle != nullptr);
+
+ // Acquire the semaphore or register as a waiter
+ Counts counts = m_counts.VolatileLoad();
+ while (true)
+ {
+ _ASSERTE(counts.signalCount <= m_maximumSignalCount);
+ Counts newCounts = counts;
+ if (counts.signalCount != 0)
+ {
+ --newCounts.signalCount;
+ }
+ else if (timeoutMs != 0)
+ {
+ ++newCounts.waiterCount;
+ _ASSERTE(newCounts.waiterCount != (UINT16)0); // overflow check, this many waiters is currently not supported
+ }
+
+ Counts countsBeforeUpdate = m_counts.CompareExchange(newCounts, counts);
+ if (countsBeforeUpdate == counts)
+ {
+ return counts.signalCount != 0 || (timeoutMs != 0 && WaitForSignal(timeoutMs));
+ }
+
+ counts = countsBeforeUpdate;
+ }
+}
+
+bool CLRLifoSemaphore::Wait(DWORD timeoutMs, UINT32 spinCount, UINT32 processorCount)
+{
+ CONTRACTL
+ {
+ NOTHROW;
+ GC_NOTRIGGER;
+ SO_TOLERANT;
+ }
+ CONTRACTL_END;
+
+ _ASSERTE(m_handle != nullptr);
+
+ if (timeoutMs == 0 || spinCount == 0)
+ {
+ return Wait(timeoutMs);
+ }
+
+ // Try to acquire the semaphore or register as a spinner
+ Counts counts = m_counts.VolatileLoad();
+ while (true)
+ {
+ Counts newCounts = counts;
+ if (counts.signalCount != 0)
+ {
+ --newCounts.signalCount;
+ }
+ else
+ {
+ ++newCounts.spinnerCount;
+ if (newCounts.spinnerCount == (UINT8)0)
+ {
+ // Maximum number of spinners reached, register as a waiter instead
+ --newCounts.spinnerCount;
+ ++newCounts.waiterCount;
+ _ASSERTE(newCounts.waiterCount != (UINT16)0); // overflow check, this many waiters is currently not supported
+ }
+ }
+
+ Counts countsBeforeUpdate = m_counts.CompareExchange(newCounts, counts);
+ if (countsBeforeUpdate == counts)
+ {
+ if (counts.signalCount != 0)
+ {
+ return true;
+ }
+ if (newCounts.waiterCount != counts.waiterCount)
+ {
+ return WaitForSignal(timeoutMs);
+ }
+ break;
+ }
+
+ counts = countsBeforeUpdate;
+ }
+
+#ifdef _TARGET_ARM64_
+ // For now, the spinning changes are disabled on ARM64. The spin loop below replicates how UnfairSemaphore used to spin.
+ // Once more tuning is done on ARM64, it should be possible to come up with a spinning scheme that works well everywhere.
+ int spinCountPerProcessor = spinCount;
+ for (UINT32 i = 1; ; ++i)
+ {
+ // Wait
+ ClrSleepEx(0, false);
+
+ // Try to acquire the semaphore and unregister as a spinner
+ counts = m_counts.VolatileLoad();
+ while (true)
+ {
+ _ASSERTE(counts.spinnerCount != (UINT8)0);
+ if (counts.signalCount == 0)
+ {
+ break;
+ }
+
+ Counts newCounts = counts;
+ --newCounts.signalCount;
+ --newCounts.spinnerCount;
+
+ Counts countsBeforeUpdate = m_counts.CompareExchange(newCounts, counts);
+ if (countsBeforeUpdate == counts)
+ {
+ return true;
+ }
+
+ counts = countsBeforeUpdate;
+ }
+
+ // Determine whether to spin further
+ double spinnersPerProcessor = (double)counts.spinnerCount / processorCount;
+ UINT32 spinLimit = (UINT32)(spinCountPerProcessor / spinnersPerProcessor + 0.5);
+ if (i >= spinLimit)
+ {
+ break;
+ }
+ }
+#else // !_TARGET_ARM64_
+ const UINT32 Sleep0Threshold = 10;
+ YieldProcessorWithBackOffNormalizationInfo normalizationInfo;
+#ifdef FEATURE_PAL
+ // The PAL's wait subsystem is quite slow, spin more to compensate for the more expensive wait
+ spinCount *= 2;
+#endif // FEATURE_PAL
+ for (UINT32 i = 0; i < spinCount; ++i)
+ {
+ // Wait
+ //
+ // (i - Sleep0Threshold) % 2 != 0: The purpose of this check is to interleave Thread.Yield/Sleep(0) with
+ // Thread.SpinWait. Otherwise, the following issues occur:
+ // - When there are no threads to switch to, Yield and Sleep(0) become no-op and it turns the spin loop into a
+ // busy-spin that may quickly reach the max spin count and cause the thread to enter a wait state. Completing the
+ // spin loop too early can cause excessive context switcing from the wait.
+ // - If there are multiple threads doing Yield and Sleep(0) (typically from the same spin loop due to contention),
+ // they may switch between one another, delaying work that can make progress.
+ if (i < Sleep0Threshold || (i - Sleep0Threshold) % 2 != 0)
+ {
+ YieldProcessorWithBackOffNormalized(normalizationInfo, i);
+ }
+ else
+ {
+ // Not doing SwitchToThread(), it does not seem to have any benefit over Sleep(0)
+ ClrSleepEx(0, false);
+ }
+
+ // Try to acquire the semaphore and unregister as a spinner
+ counts = m_counts.VolatileLoad();
+ while (true)
+ {
+ _ASSERTE(counts.spinnerCount != (UINT8)0);
+ if (counts.signalCount == 0)
+ {
+ break;
+ }
+
+ Counts newCounts = counts;
+ --newCounts.signalCount;
+ --newCounts.spinnerCount;
+
+ Counts countsBeforeUpdate = m_counts.CompareExchange(newCounts, counts);
+ if (countsBeforeUpdate == counts)
+ {
+ return true;
+ }
+
+ counts = countsBeforeUpdate;
+ }
+ }
+#endif // _TARGET_ARM64_
+
+ // Unregister as a spinner, and acquire the semaphore or register as a waiter
+ counts = m_counts.VolatileLoad();
+ while (true)
+ {
+ _ASSERTE(counts.spinnerCount != (UINT8)0);
+ Counts newCounts = counts;
+ --newCounts.spinnerCount;
+ if (counts.signalCount != 0)
+ {
+ --newCounts.signalCount;
+ }
+ else
+ {
+ ++newCounts.waiterCount;
+ _ASSERTE(newCounts.waiterCount != (UINT16)0); // overflow check, this many waiters is currently not supported
+ }
+
+ Counts countsBeforeUpdate = m_counts.CompareExchange(newCounts, counts);
+ if (countsBeforeUpdate == counts)
+ {
+ return counts.signalCount != 0 || WaitForSignal(timeoutMs);
+ }
+
+ counts = countsBeforeUpdate;
+ }
+}
+
+void CLRLifoSemaphore::Release(INT32 releaseCount)
+{
+ CONTRACTL
+ {
+ NOTHROW;
+ GC_NOTRIGGER;
+ SO_TOLERANT;
+ }
+ CONTRACTL_END;
+
+ _ASSERTE(releaseCount > 0);
+ _ASSERTE((UINT32)releaseCount <= m_maximumSignalCount);
+ _ASSERTE(m_handle != INVALID_HANDLE_VALUE);
+
+ INT32 countOfWaitersToWake;
+ Counts counts = m_counts.VolatileLoad();
+ while (true)
+ {
+ Counts newCounts = counts;
+
+ // Increase the signal count. The addition doesn't overflow because of the limit on the max signal count in Create.
+ newCounts.signalCount += releaseCount;
+ _ASSERTE(newCounts.signalCount > counts.signalCount);
+
+ // Determine how many waiters to wake, taking into account how many spinners and waiters there are and how many waiters
+ // have previously been signaled to wake but have not yet woken
+ countOfWaitersToWake =
+ (INT32)min(newCounts.signalCount, (UINT32)newCounts.waiterCount + newCounts.spinnerCount) -
+ newCounts.spinnerCount -
+ newCounts.countOfWaitersSignaledToWake;
+ if (countOfWaitersToWake > 0)
+ {
+ // Ideally, limiting to a maximum of releaseCount would not be necessary and could be an assert instead, but since
+ // WaitForSignal() does not have enough information to tell whether a woken thread was signaled, and due to the cap
+ // below, it's possible for countOfWaitersSignaledToWake to be less than the number of threads that have actually
+ // been signaled to wake.
+ if (countOfWaitersToWake > releaseCount)
+ {
+ countOfWaitersToWake = releaseCount;
+ }
+
+ // Cap countOfWaitersSignaledToWake to its max value. It's ok to ignore some woken threads in this count, it just
+ // means some more threads will be woken next time. Typically, it won't reach the max anyway.
+ newCounts.countOfWaitersSignaledToWake += (UINT8)min(countOfWaitersToWake, (INT32)UINT8_MAX);
+ if (newCounts.countOfWaitersSignaledToWake <= counts.countOfWaitersSignaledToWake)
+ {
+ newCounts.countOfWaitersSignaledToWake = UINT8_MAX;
+ }
+ }
+
+ Counts countsBeforeUpdate = m_counts.CompareExchange(newCounts, counts);
+ if (countsBeforeUpdate == counts)
+ {
+ _ASSERTE((UINT32)releaseCount <= m_maximumSignalCount - counts.signalCount);
+ _ASSERTE(newCounts.countOfWaitersSignaledToWake <= newCounts.waiterCount);
+ if (countOfWaitersToWake <= 0)
+ {
+ return;
+ }
+ break;
+ }
+
+ counts = countsBeforeUpdate;
+ }
+
+ // Wake waiters
+#ifdef FEATURE_PAL
+ BOOL released = UnsafeReleaseSemaphore(m_handle, countOfWaitersToWake, nullptr);
+ _ASSERTE(released);
+#else // !FEATURE_PAL
+ while (--countOfWaitersToWake >= 0)
+ {
+ while (!PostQueuedCompletionStatus(m_handle, 0, 0, nullptr))
+ {
+ // Probably out of memory. It's not valid to stop and throw here, so try again after a delay.
+ ClrSleepEx(1, false);
+ }
+ }
+#endif // FEATURE_PAL
+}
+
void CLRMutex::Create(LPSECURITY_ATTRIBUTES lpMutexAttributes, BOOL bInitialOwner, LPCTSTR lpName)
{
CONTRACTL
diff --git a/src/vm/synch.h b/src/vm/synch.h
index d88ec46342..c8e9baf481 100644
--- a/src/vm/synch.h
+++ b/src/vm/synch.h
@@ -177,6 +177,99 @@ private:
HANDLE m_handle;
};
+class CLRLifoSemaphore
+{
+private:
+ struct Counts
+ {
+ union
+ {
+ struct
+ {
+ UINT32 signalCount;
+ UINT16 waiterCount;
+ UINT8 spinnerCount;
+ UINT8 countOfWaitersSignaledToWake;
+ };
+ UINT64 data;
+ };
+
+ Counts(UINT64 data = 0) : data(data)
+ {
+ LIMITED_METHOD_CONTRACT;
+ }
+
+ operator UINT64() const
+ {
+ LIMITED_METHOD_CONTRACT;
+ return data;
+ }
+
+ Counts &operator =(UINT64 data)
+ {
+ LIMITED_METHOD_CONTRACT;
+
+ this->data = data;
+ return *this;
+ }
+
+ Counts VolatileLoad() const
+ {
+ LIMITED_METHOD_CONTRACT;
+ return ::VolatileLoad(&data);
+ }
+
+ Counts CompareExchange(Counts toCounts, Counts fromCounts)
+ {
+ LIMITED_METHOD_CONTRACT;
+ return (UINT64)InterlockedCompareExchange64((LONG64 *)&data, (LONG64)toCounts, (LONG64)fromCounts);
+ }
+ };
+
+public:
+ CLRLifoSemaphore() : m_handle(nullptr)
+ {
+ LIMITED_METHOD_CONTRACT;
+ }
+
+ ~CLRLifoSemaphore()
+ {
+ WRAPPER_NO_CONTRACT;
+ Close();
+ }
+
+public:
+ void Create(INT32 initialSignalCount, INT32 maximumSignalCount);
+ void Close();
+
+public:
+ BOOL IsValid() const
+ {
+ LIMITED_METHOD_CONTRACT;
+ return m_handle != nullptr;
+ }
+
+private:
+ bool WaitForSignal(DWORD timeoutMs);
+public:
+ bool Wait(DWORD timeoutMs);
+ bool Wait(DWORD timeoutMs, UINT32 spinCount, UINT32 processorCount);
+ void Release(INT32 releaseCount);
+
+private:
+ BYTE __padding1[MAX_CACHE_LINE_SIZE]; // padding to ensure that m_counts gets its own cache line
+ Counts m_counts;
+ BYTE __padding2[MAX_CACHE_LINE_SIZE]; // padding to ensure that m_counts gets its own cache line
+
+#if defined(DEBUG)
+ UINT32 m_maximumSignalCount;
+#endif // _DEBUG && !FEATURE_PAL
+
+ // When FEATURE_PAL is defined, this is a handle to an instance of the PAL's LIFO semaphore. When FEATURE_PAL is not
+ // defined, this is a handle to an I/O completion port.
+ HANDLE m_handle;
+};
+
class CLRMutex {
public:
CLRMutex()
diff --git a/src/vm/threads.cpp b/src/vm/threads.cpp
index 91373930e9..56bdffb1f1 100644
--- a/src/vm/threads.cpp
+++ b/src/vm/threads.cpp
@@ -63,6 +63,8 @@ SPTR_IMPL(ThreadStore, ThreadStore, s_pThreadStore);
CONTEXT *ThreadStore::s_pOSContext = NULL;
CLREvent *ThreadStore::s_pWaitForStackCrawlEvent;
+static CrstStatic s_initializeYieldProcessorNormalizedCrst;
+
#ifndef DACCESS_COMPILE
@@ -1363,7 +1365,7 @@ void InitThreadManager()
}
CONTRACTL_END;
- Thread::s_initializeYieldProcessorNormalizedCrst.Init(CrstLeafLock);
+ s_initializeYieldProcessorNormalizedCrst.Init(CrstLeafLock);
// All patched helpers should fit into one page.
// If you hit this assert on retail build, there is most likely problem with BBT script.
@@ -11747,25 +11749,29 @@ ULONGLONG Thread::QueryThreadProcessorUsage()
}
#endif // FEATURE_APPDOMAIN_RESOURCE_MONITORING
-CrstStatic Thread::s_initializeYieldProcessorNormalizedCrst;
-int Thread::s_yieldsPerNormalizedYield = 0;
-int Thread::s_optimalMaxNormalizedYieldsPerSpinIteration = 0;
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// YieldProcessorNormalized
+
+// Defaults are for when InitializeYieldProcessorNormalized has not yet been called or when no measurement is done, and are
+// tuned for Skylake processors
+int g_yieldsPerNormalizedYield = 1; // current value is for Skylake processors, this would be 9 for pre-Skylake
+int g_optimalMaxNormalizedYieldsPerSpinIteration = 7;
+
+static Volatile<bool> s_isYieldProcessorNormalizedInitialized = false;
-void Thread::InitializeYieldProcessorNormalized()
+void InitializeYieldProcessorNormalized()
{
LIMITED_METHOD_CONTRACT;
CrstHolder lock(&s_initializeYieldProcessorNormalizedCrst);
- if (IsYieldProcessorNormalizedInitialized())
+ if (s_isYieldProcessorNormalizedInitialized)
{
return;
}
// Intel pre-Skylake processor: measured typically 14-17 cycles per yield
// Intel post-Skylake processor: measured typically 125-150 cycles per yield
- const int DefaultYieldsPerNormalizedYield = 1; // defaults are for when no measurement is done
- const int DefaultOptimalMaxNormalizedYieldsPerSpinIteration = 64; // tuned for pre-Skylake processors, for post-Skylake it should be 7
const int MeasureDurationMs = 10;
const int MaxYieldsPerNormalizedYield = 10; // measured typically 8-9 on pre-Skylake
const int MinNsPerNormalizedYield = 37; // measured typically 37-46 on post-Skylake
@@ -11776,8 +11782,7 @@ void Thread::InitializeYieldProcessorNormalized()
if (!QueryPerformanceFrequency(&li) || (ULONGLONG)li.QuadPart < 1000 / MeasureDurationMs)
{
// High precision clock not available or clock resolution is too low, resort to defaults
- s_yieldsPerNormalizedYield = DefaultYieldsPerNormalizedYield;
- s_optimalMaxNormalizedYieldsPerSpinIteration = DefaultOptimalMaxNormalizedYieldsPerSpinIteration;
+ s_isYieldProcessorNormalizedInitialized = true;
return;
}
ULONGLONG ticksPerSecond = li.QuadPart;
@@ -11790,11 +11795,14 @@ void Thread::InitializeYieldProcessorNormalized()
ULONGLONG elapsedTicks;
do
{
- for (int i = 0; i < 10; ++i)
+ // On some systems, querying the high performance counter has relatively significant overhead. Do enough yields to mask
+ // the timing overhead. Assuming one yield has a delay of MinNsPerNormalizedYield, 1000 yields would have a delay in the
+ // low microsecond range.
+ for (int i = 0; i < 1000; ++i)
{
YieldProcessor();
}
- yieldCount += 10;
+ yieldCount += 1000;
QueryPerformanceCounter(&li);
ULONGLONG nowTicks = li.QuadPart;
@@ -11827,6 +11835,17 @@ void Thread::InitializeYieldProcessorNormalized()
optimalMaxNormalizedYieldsPerSpinIteration = 1;
}
- s_yieldsPerNormalizedYield = yieldsPerNormalizedYield;
- s_optimalMaxNormalizedYieldsPerSpinIteration = optimalMaxNormalizedYieldsPerSpinIteration;
+ g_yieldsPerNormalizedYield = yieldsPerNormalizedYield;
+ g_optimalMaxNormalizedYieldsPerSpinIteration = optimalMaxNormalizedYieldsPerSpinIteration;
+ s_isYieldProcessorNormalizedInitialized = true;
+}
+
+void EnsureYieldProcessorNormalizedInitialized()
+{
+ WRAPPER_NO_CONTRACT;
+
+ if (!s_isYieldProcessorNormalizedInitialized)
+ {
+ InitializeYieldProcessorNormalized();
+ }
}
diff --git a/src/vm/threads.h b/src/vm/threads.h
index 4000f216f4..17cc1f305d 100644
--- a/src/vm/threads.h
+++ b/src/vm/threads.h
@@ -5362,71 +5362,6 @@ public:
m_HijackReturnKind = returnKind;
}
#endif // FEATURE_HIJACK
-
-private:
- static CrstStatic s_initializeYieldProcessorNormalizedCrst;
- static int s_yieldsPerNormalizedYield;
- static int s_optimalMaxNormalizedYieldsPerSpinIteration;
-
-private:
- static void InitializeYieldProcessorNormalized();
-
-public:
- static bool IsYieldProcessorNormalizedInitialized()
- {
- LIMITED_METHOD_CONTRACT;
- return s_yieldsPerNormalizedYield != 0 && s_optimalMaxNormalizedYieldsPerSpinIteration != 0;
- }
-
-public:
- static void EnsureYieldProcessorNormalizedInitialized()
- {
- LIMITED_METHOD_CONTRACT;
-
- if (!IsYieldProcessorNormalizedInitialized())
- {
- InitializeYieldProcessorNormalized();
- }
- }
-
-public:
- static int GetOptimalMaxNormalizedYieldsPerSpinIteration()
- {
- WRAPPER_NO_CONTRACT;
- _ASSERTE(IsYieldProcessorNormalizedInitialized());
-
- return s_optimalMaxNormalizedYieldsPerSpinIteration;
- }
-
-public:
- static void YieldProcessorNormalized()
- {
- WRAPPER_NO_CONTRACT;
- _ASSERTE(IsYieldProcessorNormalizedInitialized());
-
- int n = s_yieldsPerNormalizedYield;
- while (--n >= 0)
- {
- YieldProcessor();
- }
- }
-
- static void YieldProcessorNormalizedWithBackOff(unsigned int spinIteration)
- {
- WRAPPER_NO_CONTRACT;
- _ASSERTE(IsYieldProcessorNormalizedInitialized());
-
- int n = s_optimalMaxNormalizedYieldsPerSpinIteration;
- if (spinIteration <= 30 && (1 << spinIteration) < n)
- {
- n = 1 << spinIteration;
- }
- n *= s_yieldsPerNormalizedYield;
- while (--n >= 0)
- {
- YieldProcessor();
- }
- }
};
// End of class Thread
@@ -7573,4 +7508,76 @@ private:
BOOL Debug_IsLockedViaThreadSuspension();
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// YieldProcessorNormalized
+
+extern int g_yieldsPerNormalizedYield;
+extern int g_optimalMaxNormalizedYieldsPerSpinIteration;
+
+void InitializeYieldProcessorNormalized();
+void EnsureYieldProcessorNormalizedInitialized();
+
+class YieldProcessorNormalizationInfo
+{
+private:
+ int yieldsPerNormalizedYield;
+
+public:
+ YieldProcessorNormalizationInfo() : yieldsPerNormalizedYield(g_yieldsPerNormalizedYield)
+ {
+ }
+
+ friend void YieldProcessorNormalized(const YieldProcessorNormalizationInfo &);
+};
+
+FORCEINLINE void YieldProcessorNormalized(const YieldProcessorNormalizationInfo &normalizationInfo)
+{
+ LIMITED_METHOD_CONTRACT;
+
+ int n = normalizationInfo.yieldsPerNormalizedYield;
+ while (--n >= 0)
+ {
+ YieldProcessor();
+ }
+}
+
+class YieldProcessorWithBackOffNormalizationInfo
+{
+private:
+ int yieldsPerNormalizedYield;
+ int optimalMaxNormalizedYieldsPerSpinIteration;
+ int optimalMaxYieldsPerSpinIteration;
+
+public:
+ YieldProcessorWithBackOffNormalizationInfo()
+ : yieldsPerNormalizedYield(g_yieldsPerNormalizedYield),
+ optimalMaxNormalizedYieldsPerSpinIteration(g_optimalMaxNormalizedYieldsPerSpinIteration),
+ optimalMaxYieldsPerSpinIteration(yieldsPerNormalizedYield * optimalMaxNormalizedYieldsPerSpinIteration)
+ {
+ }
+
+ friend void YieldProcessorWithBackOffNormalized(const YieldProcessorWithBackOffNormalizationInfo &, unsigned int);
+};
+
+FORCEINLINE void YieldProcessorWithBackOffNormalized(
+ const YieldProcessorWithBackOffNormalizationInfo &normalizationInfo,
+ unsigned int spinIteration)
+{
+ LIMITED_METHOD_CONTRACT;
+
+ int n;
+ if (spinIteration <= 30 && (1 << spinIteration) < normalizationInfo.optimalMaxNormalizedYieldsPerSpinIteration)
+ {
+ n = (1 << spinIteration) * normalizationInfo.yieldsPerNormalizedYield;
+ }
+ else
+ {
+ n = normalizationInfo.optimalMaxYieldsPerSpinIteration;
+ }
+ while (--n >= 0)
+ {
+ YieldProcessor();
+ }
+}
+
#endif //__threads_h__
diff --git a/src/vm/util.cpp b/src/vm/util.cpp
index 2c71289c8d..692b72fc39 100644
--- a/src/vm/util.cpp
+++ b/src/vm/util.cpp
@@ -2849,7 +2849,7 @@ void InitializeClrNotifications()
#endif // FEATURE_GDBJIT
// called from the runtime
-void DACNotify::DoJITNotification(MethodDesc *MethodDescPtr)
+void DACNotify::DoJITNotification(MethodDesc *MethodDescPtr, TADDR NativeCodeLocation)
{
CONTRACTL
{
@@ -2860,8 +2860,8 @@ void DACNotify::DoJITNotification(MethodDesc *MethodDescPtr)
}
CONTRACTL_END;
- TADDR Args[2] = { JIT_NOTIFICATION, (TADDR) MethodDescPtr };
- DACNotifyExceptionHelper(Args, 2);
+ TADDR Args[3] = { JIT_NOTIFICATION2, (TADDR) MethodDescPtr, NativeCodeLocation };
+ DACNotifyExceptionHelper(Args, 3);
}
void DACNotify::DoJITPitchingNotification(MethodDesc *MethodDescPtr)
@@ -2986,16 +2986,17 @@ int DACNotify::GetType(TADDR Args[])
// Type is an enum, and will thus fit into an int.
return static_cast<int>(Args[0]);
}
-
-BOOL DACNotify::ParseJITNotification(TADDR Args[], TADDR& MethodDescPtr)
+
+BOOL DACNotify::ParseJITNotification(TADDR Args[], TADDR& MethodDescPtr, TADDR& NativeCodeLocation)
{
- _ASSERTE(Args[0] == JIT_NOTIFICATION);
- if (Args[0] != JIT_NOTIFICATION)
+ _ASSERTE(Args[0] == JIT_NOTIFICATION2);
+ if (Args[0] != JIT_NOTIFICATION2)
{
return FALSE;
}
MethodDescPtr = Args[1];
+ NativeCodeLocation = Args[2];
return TRUE;
}
diff --git a/src/vm/util.hpp b/src/vm/util.hpp
index edfd9161e4..ad1261845f 100644
--- a/src/vm/util.hpp
+++ b/src/vm/util.hpp
@@ -1075,10 +1075,11 @@ public:
EXCEPTION_NOTIFICATION=5,
GC_NOTIFICATION= 6,
CATCH_ENTER_NOTIFICATION = 7,
+ JIT_NOTIFICATION2=8,
};
// called from the runtime
- static void DoJITNotification(MethodDesc *MethodDescPtr);
+ static void DoJITNotification(MethodDesc *MethodDescPtr, TADDR NativeCodeLocation);
static void DoJITPitchingNotification(MethodDesc *MethodDescPtr);
static void DoModuleLoadNotification(Module *Module);
static void DoModuleUnloadNotification(Module *Module);
@@ -1088,7 +1089,7 @@ public:
// called from the DAC
static int GetType(TADDR Args[]);
- static BOOL ParseJITNotification(TADDR Args[], TADDR& MethodDescPtr);
+ static BOOL ParseJITNotification(TADDR Args[], TADDR& MethodDescPtr, TADDR& NativeCodeLocation);
static BOOL ParseJITPitchingNotification(TADDR Args[], TADDR& MethodDescPtr);
static BOOL ParseModuleLoadNotification(TADDR Args[], TADDR& ModulePtr);
static BOOL ParseModuleUnloadNotification(TADDR Args[], TADDR& ModulePtr);
diff --git a/src/vm/virtualcallstub.cpp b/src/vm/virtualcallstub.cpp
index 2e94a16666..8040cbf8f2 100644
--- a/src/vm/virtualcallstub.cpp
+++ b/src/vm/virtualcallstub.cpp
@@ -974,7 +974,7 @@ void VirtualCallStubManager::Reclaim()
//----------------------------------------------------------------------------
/* static */
-VirtualCallStubManager *VirtualCallStubManager::FindStubManager(PCODE stubAddress, StubKind* wbStubKind)
+VirtualCallStubManager *VirtualCallStubManager::FindStubManager(PCODE stubAddress, StubKind* wbStubKind, BOOL usePredictStubKind)
{
CONTRACTL {
NOTHROW;
@@ -999,7 +999,7 @@ VirtualCallStubManager *VirtualCallStubManager::FindStubManager(PCODE stubAddres
// VirtualCallStubManager::isDispatchingStub
//
CONTRACT_VIOLATION(SOToleranceViolation);
- kind = pCur->getStubKind(stubAddress);
+ kind = pCur->getStubKind(stubAddress, usePredictStubKind);
if (kind != SK_UNKNOWN)
{
if (wbStubKind)
@@ -1011,7 +1011,7 @@ VirtualCallStubManager *VirtualCallStubManager::FindStubManager(PCODE stubAddres
// See if we are managed by the shared domain
//
pCur = SharedDomain::GetDomain()->GetLoaderAllocator()->GetVirtualCallStubManager();
- kind = pCur->getStubKind(stubAddress);
+ kind = pCur->getStubKind(stubAddress, usePredictStubKind);
if (kind != SK_UNKNOWN)
{
if (wbStubKind)
@@ -1026,7 +1026,7 @@ VirtualCallStubManager *VirtualCallStubManager::FindStubManager(PCODE stubAddres
{
_ASSERTE(pCur != NULL);
- kind = pCur->getStubKind(stubAddress);
+ kind = pCur->getStubKind(stubAddress, usePredictStubKind);
if (kind != SK_UNKNOWN)
{
if (wbStubKind)
diff --git a/src/vm/virtualcallstub.h b/src/vm/virtualcallstub.h
index 7b6fedf2b2..b8984eab3c 100644
--- a/src/vm/virtualcallstub.h
+++ b/src/vm/virtualcallstub.h
@@ -317,7 +317,7 @@ public:
/* know thine own stubs. It is possible that when multiple
virtualcallstub managers are built that these may need to become
non-static, and the callers modified accordingly */
- StubKind getStubKind(PCODE stubStartAddress)
+ StubKind getStubKind(PCODE stubStartAddress, BOOL usePredictStubKind = TRUE)
{
WRAPPER_NO_CONTRACT;
SUPPORTS_DAC;
@@ -329,7 +329,7 @@ public:
// Rather than calling IsInRange(stubStartAddress) for each possible stub kind
// we can peek at the assembly code and predict which kind of a stub we have
- StubKind predictedKind = predictStubKind(stubStartAddress);
+ StubKind predictedKind = (usePredictStubKind) ? predictStubKind(stubStartAddress) : SK_UNKNOWN;
if (predictedKind == SK_DISPATCH)
{
@@ -732,7 +732,8 @@ private:
public:
// Given a stub address, find the VCSManager that owns it.
static VirtualCallStubManager *FindStubManager(PCODE addr,
- StubKind* wbStubKind = NULL);
+ StubKind* wbStubKind = NULL,
+ BOOL usePredictStubKind = TRUE);
#ifndef DACCESS_COMPILE
// insert a linked list of indirection cells at the beginning of m_RecycledIndCellList
diff --git a/src/vm/win32threadpool.cpp b/src/vm/win32threadpool.cpp
index eabbcb93ae..97c020a4b6 100644
--- a/src/vm/win32threadpool.cpp
+++ b/src/vm/win32threadpool.cpp
@@ -103,6 +103,7 @@ DWORD ThreadpoolMgr::NextCompletedWorkRequestsTime;
LARGE_INTEGER ThreadpoolMgr::CurrentSampleStartTime;
+unsigned int ThreadpoolMgr::WorkerThreadSpinLimit;
int ThreadpoolMgr::ThreadAdjustmentInterval;
#define INVALID_HANDLE ((HANDLE) -1)
@@ -136,8 +137,8 @@ CLREvent * ThreadpoolMgr::RetiredCPWakeupEvent; // wakeup event for comple
CrstStatic ThreadpoolMgr::WaitThreadsCriticalSection;
ThreadpoolMgr::LIST_ENTRY ThreadpoolMgr::WaitThreadsHead;
-ThreadpoolMgr::UnfairSemaphore* ThreadpoolMgr::WorkerSemaphore;
-CLRSemaphore* ThreadpoolMgr::RetiredWorkerSemaphore;
+CLRLifoSemaphore* ThreadpoolMgr::WorkerSemaphore;
+CLRLifoSemaphore* ThreadpoolMgr::RetiredWorkerSemaphore;
CrstStatic ThreadpoolMgr::TimerQueueCriticalSection;
HANDLE ThreadpoolMgr::TimerThread=NULL;
@@ -353,6 +354,7 @@ BOOL ThreadpoolMgr::Initialize()
EX_TRY
{
+ WorkerThreadSpinLimit = CLRConfig::GetConfigValue(CLRConfig::INTERNAL_ThreadPool_UnfairSemaphoreSpinLimit);
ThreadAdjustmentInterval = CLRConfig::GetConfigValue(CLRConfig::INTERNAL_HillClimbing_SampleIntervalLow);
pADTPCount->InitResources();
@@ -370,26 +372,26 @@ BOOL ThreadpoolMgr::Initialize()
RetiredCPWakeupEvent->CreateAutoEvent(FALSE);
_ASSERTE(RetiredCPWakeupEvent->IsValid());
- int spinLimitPerProcessor = CLRConfig::GetConfigValue(CLRConfig::INTERNAL_ThreadPool_UnfairSemaphoreSpinLimit);
- WorkerSemaphore = new UnfairSemaphore(ThreadCounter::MaxPossibleCount, spinLimitPerProcessor);
+ WorkerSemaphore = new CLRLifoSemaphore();
+ WorkerSemaphore->Create(0, ThreadCounter::MaxPossibleCount);
- RetiredWorkerSemaphore = new CLRSemaphore();
+ RetiredWorkerSemaphore = new CLRLifoSemaphore();
RetiredWorkerSemaphore->Create(0, ThreadCounter::MaxPossibleCount);
- //ThreadPool_CPUGroup
- if (CPUGroupInfo::CanEnableGCCPUGroups() && CPUGroupInfo::CanEnableThreadUseAllCpuGroups())
+ //ThreadPool_CPUGroup
+ if (CPUGroupInfo::CanEnableGCCPUGroups() && CPUGroupInfo::CanEnableThreadUseAllCpuGroups())
RecycledLists.Initialize( CPUGroupInfo::GetNumActiveProcessors() );
else
- RecycledLists.Initialize( g_SystemInfo.dwNumberOfProcessors );
- /*
- {
- SYSTEM_INFO sysInfo;
+ RecycledLists.Initialize( g_SystemInfo.dwNumberOfProcessors );
+ /*
+ {
+ SYSTEM_INFO sysInfo;
- ::GetSystemInfo( &sysInfo );
+ ::GetSystemInfo( &sysInfo );
- RecycledLists.Initialize( sysInfo.dwNumberOfProcessors );
- }
- */
+ RecycledLists.Initialize( sysInfo.dwNumberOfProcessors );
+ }
+ */
}
EX_CATCH
{
@@ -1034,9 +1036,7 @@ void ThreadpoolMgr::MaybeAddWorkingWorker()
if (toUnretire > 0)
{
- LONG previousCount;
- INDEBUG(BOOL success =) RetiredWorkerSemaphore->Release((LONG)toUnretire, &previousCount);
- _ASSERTE(success);
+ RetiredWorkerSemaphore->Release(toUnretire);
}
if (toRelease > 0)
@@ -2055,10 +2055,7 @@ Retire:
while (true)
{
RetryRetire:
- DWORD result = RetiredWorkerSemaphore->Wait(AppX::IsAppXProcess() ? WorkerTimeoutAppX : WorkerTimeout, FALSE);
- _ASSERTE(WAIT_OBJECT_0 == result || WAIT_TIMEOUT == result);
-
- if (WAIT_OBJECT_0 == result)
+ if (RetiredWorkerSemaphore->Wait(AppX::IsAppXProcess() ? WorkerTimeoutAppX : WorkerTimeout))
{
foundWork = true;
@@ -2134,59 +2131,57 @@ WaitForWork:
FireEtwThreadPoolWorkerThreadWait(counts.NumActive, counts.NumRetired, GetClrInstanceId());
RetryWaitForWork:
- if (!WorkerSemaphore->Wait(AppX::IsAppXProcess() ? WorkerTimeoutAppX : WorkerTimeout))
+ if (WorkerSemaphore->Wait(AppX::IsAppXProcess() ? WorkerTimeoutAppX : WorkerTimeout, WorkerThreadSpinLimit, NumberOfProcessors))
{
- if (!IsIoPending())
- {
- //
- // We timed out, and are about to exit. This puts us in a very similar situation to the
- // retirement case above - someone may think we're still waiting, and go ahead and:
- //
- // 1) Increment NumWorking
- // 2) Signal WorkerSemaphore
- //
- // The solution is much like retirement; when we're decrementing NumActive, we need to make
- // sure it doesn't drop below NumWorking. If it would, then we need to go back and wait
- // again.
- //
+ foundWork = true;
+ goto Work;
+ }
- DangerousNonHostedSpinLockHolder tal(&ThreadAdjustmentLock);
+ if (!IsIoPending())
+ {
+ //
+ // We timed out, and are about to exit. This puts us in a very similar situation to the
+ // retirement case above - someone may think we're still waiting, and go ahead and:
+ //
+ // 1) Increment NumWorking
+ // 2) Signal WorkerSemaphore
+ //
+ // The solution is much like retirement; when we're decrementing NumActive, we need to make
+ // sure it doesn't drop below NumWorking. If it would, then we need to go back and wait
+ // again.
+ //
- // counts volatile read paired with CompareExchangeCounts loop set
- counts = WorkerCounter.DangerousGetDirtyCounts();
- while (true)
- {
- if (counts.NumActive == counts.NumWorking)
- {
- goto RetryWaitForWork;
- }
+ DangerousNonHostedSpinLockHolder tal(&ThreadAdjustmentLock);
- newCounts = counts;
- newCounts.NumActive--;
+ // counts volatile read paired with CompareExchangeCounts loop set
+ counts = WorkerCounter.DangerousGetDirtyCounts();
+ while (true)
+ {
+ if (counts.NumActive == counts.NumWorking)
+ {
+ goto RetryWaitForWork;
+ }
- // if we timed out while active, then Hill Climbing needs to be told that we need fewer threads
- newCounts.MaxWorking = max(MinLimitTotalWorkerThreads, min(newCounts.NumActive, newCounts.MaxWorking));
+ newCounts = counts;
+ newCounts.NumActive--;
- oldCounts = WorkerCounter.CompareExchangeCounts(newCounts, counts);
+ // if we timed out while active, then Hill Climbing needs to be told that we need fewer threads
+ newCounts.MaxWorking = max(MinLimitTotalWorkerThreads, min(newCounts.NumActive, newCounts.MaxWorking));
- if (oldCounts == counts)
- {
- HillClimbingInstance.ForceChange(newCounts.MaxWorking, ThreadTimedOut);
- goto Exit;
- }
+ oldCounts = WorkerCounter.CompareExchangeCounts(newCounts, counts);
- counts = oldCounts;
+ if (oldCounts == counts)
+ {
+ HillClimbingInstance.ForceChange(newCounts.MaxWorking, ThreadTimedOut);
+ goto Exit;
}
- }
- else
- {
- goto RetryWaitForWork;
+
+ counts = oldCounts;
}
}
else
{
- foundWork = true;
- goto Work;
+ goto RetryWaitForWork;
}
Exit:
diff --git a/src/vm/win32threadpool.h b/src/vm/win32threadpool.h
index fc5742b494..764c65efdc 100644
--- a/src/vm/win32threadpool.h
+++ b/src/vm/win32threadpool.h
@@ -105,245 +105,6 @@ class ThreadpoolMgr
friend class HillClimbing;
friend struct _DacGlobals;
- //
- // UnfairSemaphore is a more scalable semaphore than CLRSemaphore. It prefers to release threads that have more recently begun waiting,
- // to preserve locality. Additionally, very recently-waiting threads can be released without an addition kernel transition to unblock
- // them, which reduces latency.
- //
- // UnfairSemaphore is only appropriate in scenarios where the order of unblocking threads is not important, and where threads frequently
- // need to be woken. This is true of the ThreadPool's "worker semaphore", but not, for example, of the "retired worker semaphore" which is
- // only rarely signalled.
- //
- // A further optimization that could be done here would be to replace CLRSemaphore with a Win32 IO Completion Port. Completion ports
- // unblock threads in LIFO order, unlike the roughly-FIFO ordering of ordinary semaphores, and that would help to keep the "warm" threads warm.
- // We did not do this in CLR 4.0 because hosts currently have no way of intercepting calls to IO Completion Ports (other than THE completion port
- // behind the I/O thread pool), and we did not have time to explore the implications of this. Also, completion ports are not available on the Mac,
- // though Snow Leopard has something roughly similar (and a regular Semaphore would do on the Mac in a pinch).
- //
- class UnfairSemaphore
- {
- private:
- // padding to ensure we get our own cache line
- BYTE padding1[MAX_CACHE_LINE_SIZE];
-
- //
- // We track everything we care about in a single 64-bit struct to allow us to
- // do CompareExchanges on this for atomic updates.
- //
- union Counts
- {
- struct
- {
- int spinners : 16; //how many threads are currently spin-waiting for this semaphore?
- int countForSpinners : 16; //how much of the semaphore's count is availble to spinners?
- int waiters : 16; //how many threads are blocked in the OS waiting for this semaphore?
- int countForWaiters : 16; //how much count is available to waiters?
- };
-
- LONGLONG asLongLong;
-
- } m_counts;
-
- private:
- // padding to ensure we get our own cache line
- BYTE padding2[MAX_CACHE_LINE_SIZE];
-
- const int m_spinLimitPerProcessor; //used when calculating max spin duration
- CLRSemaphore m_sem; //waiters wait on this
-
- INDEBUG(int m_maxCount;)
-
- bool UpdateCounts(Counts newCounts, Counts currentCounts)
- {
- LIMITED_METHOD_CONTRACT;
- Counts oldCounts;
- oldCounts.asLongLong = FastInterlockCompareExchangeLong(&m_counts.asLongLong, newCounts.asLongLong, currentCounts.asLongLong);
- if (oldCounts.asLongLong == currentCounts.asLongLong)
- {
- // we succesfully updated the counts. Now validate what we put in.
- // Note: we can't validate these unless the CompareExchange succeeds, because
- // on x86 a VolatileLoad of m_counts is not atomic; we could end up getting inconsistent
- // values. It's not until we've successfully stored the new values that we know for sure
- // that the old values were correct (because if they were not, the CompareExchange would have
- // failed.
- _ASSERTE(newCounts.spinners >= 0);
- _ASSERTE(newCounts.countForSpinners >= 0);
- _ASSERTE(newCounts.waiters >= 0);
- _ASSERTE(newCounts.countForWaiters >= 0);
- _ASSERTE(newCounts.countForSpinners + newCounts.countForWaiters <= m_maxCount);
-
- return true;
- }
- else
- {
- // we lost a race with some other thread, and will need to try again.
- return false;
- }
- }
-
- public:
-
- UnfairSemaphore(int maxCount, int spinLimitPerProcessor)
- : m_spinLimitPerProcessor(spinLimitPerProcessor)
- {
- CONTRACTL
- {
- THROWS;
- GC_NOTRIGGER;
- SO_TOLERANT;
- MODE_ANY;
- }
- CONTRACTL_END;
- _ASSERTE(maxCount <= 0x7fff); //counts need to fit in signed 16-bit ints
- INDEBUG(m_maxCount = maxCount;)
-
- m_counts.asLongLong = 0;
- m_sem.Create(0, maxCount);
- }
-
- //
- // no destructor - CLRSemaphore will close itself in its own destructor.
- //
- //~UnfairSemaphore()
- //{
- //}
-
-
- void Release(int countToRelease)
- {
- while (true)
- {
- Counts currentCounts, newCounts;
- currentCounts.asLongLong = VolatileLoad(&m_counts.asLongLong);
- newCounts = currentCounts;
-
- int remainingCount = countToRelease;
-
- // First, prefer to release existing spinners,
- // because a) they're hot, and b) we don't need a kernel
- // transition to release them.
- int spinnersToRelease = max(0, min(remainingCount, currentCounts.spinners - currentCounts.countForSpinners));
- newCounts.countForSpinners += spinnersToRelease;
- remainingCount -= spinnersToRelease;
-
- // Next, prefer to release existing waiters
- int waitersToRelease = max(0, min(remainingCount, currentCounts.waiters - currentCounts.countForWaiters));
- newCounts.countForWaiters += waitersToRelease;
- remainingCount -= waitersToRelease;
-
- // Finally, release any future spinners that might come our way
- newCounts.countForSpinners += remainingCount;
-
- // Try to commit the transaction
- if (UpdateCounts(newCounts, currentCounts))
- {
- // Now we need to release the waiters we promised to release
- if (waitersToRelease > 0)
- {
- LONG previousCount;
- INDEBUG(BOOL success =) m_sem.Release((LONG)waitersToRelease, &previousCount);
- _ASSERTE(success);
- }
- break;
- }
- }
- }
-
-
- bool Wait(DWORD timeout)
- {
- while (true)
- {
- Counts currentCounts, newCounts;
- currentCounts.asLongLong = VolatileLoad(&m_counts.asLongLong);
- newCounts = currentCounts;
-
- // First, just try to grab some count.
- if (currentCounts.countForSpinners > 0)
- {
- newCounts.countForSpinners--;
- if (UpdateCounts(newCounts, currentCounts))
- return true;
- }
- else
- {
- // No count available, become a spinner
- newCounts.spinners++;
- if (UpdateCounts(newCounts, currentCounts))
- break;
- }
- }
-
- //
- // Now we're a spinner.
- //
- int numSpins = 0;
- while (true)
- {
- Counts currentCounts, newCounts;
-
- currentCounts.asLongLong = VolatileLoad(&m_counts.asLongLong);
- newCounts = currentCounts;
-
- if (currentCounts.countForSpinners > 0)
- {
- newCounts.countForSpinners--;
- newCounts.spinners--;
- if (UpdateCounts(newCounts, currentCounts))
- return true;
- }
- else
- {
- double spinnersPerProcessor = (double)currentCounts.spinners / ThreadpoolMgr::NumberOfProcessors;
- int spinLimit = (int)((m_spinLimitPerProcessor / spinnersPerProcessor) + 0.5);
- if (numSpins >= spinLimit)
- {
- newCounts.spinners--;
- newCounts.waiters++;
- if (UpdateCounts(newCounts, currentCounts))
- break;
- }
- else
- {
- //
- // We yield to other threads using SleepEx rather than the more traditional SwitchToThread.
- // This is because SwitchToThread does not yield to threads currently scheduled to run on other
- // processors. On a 4-core machine, for example, this means that SwitchToThread is only ~25% likely
- // to yield to the correct thread in some scenarios.
- // SleepEx has the disadvantage of not yielding to lower-priority threads. However, this is ok because
- // once we've called this a few times we'll become a "waiter" and wait on the CLRSemaphore, and that will
- // yield to anything that is runnable.
- //
- ClrSleepEx(0, FALSE);
- numSpins++;
- }
- }
- }
-
- //
- // Now we're a waiter
- //
- DWORD result = m_sem.Wait(timeout, FALSE);
- _ASSERTE(WAIT_OBJECT_0 == result || WAIT_TIMEOUT == result);
-
- while (true)
- {
- Counts currentCounts, newCounts;
-
- currentCounts.asLongLong = VolatileLoad(&m_counts.asLongLong);
- newCounts = currentCounts;
-
- newCounts.waiters--;
-
- if (result == WAIT_OBJECT_0)
- newCounts.countForWaiters--;
-
- if (UpdateCounts(newCounts, currentCounts))
- return (result == WAIT_OBJECT_0);
- }
- }
- };
-
public:
struct ThreadCounter
{
@@ -1258,6 +1019,7 @@ private:
static LARGE_INTEGER CurrentSampleStartTime;
+ static unsigned int WorkerThreadSpinLimit;
static int ThreadAdjustmentInterval;
SPTR_DECL(WorkRequest,WorkRequestHead); // Head of work request queue
@@ -1286,7 +1048,7 @@ private:
// 2) There is no functional reason why any particular thread should be preferred when waking workers. This only impacts performance,
// and un-fairness helps performance in this case.
//
- static UnfairSemaphore* WorkerSemaphore;
+ static CLRLifoSemaphore* WorkerSemaphore;
//
// RetiredWorkerSemaphore is a regular CLRSemaphore, not an UnfairSemaphore, because if a thread waits on this semaphore is it almost certainly
@@ -1295,7 +1057,7 @@ private:
// down, by constantly re-using the same small set of retired workers rather than round-robining between all of them as CLRSemaphore will do.
// If we go that route, we should add a "no-spin" option to UnfairSemaphore.Wait to avoid wasting CPU.
//
- static CLRSemaphore* RetiredWorkerSemaphore;
+ static CLRLifoSemaphore* RetiredWorkerSemaphore;
static CLREvent * RetiredCPWakeupEvent;
diff --git a/src/zap/zapinfo.cpp b/src/zap/zapinfo.cpp
index b8ef3eab91..01d3a3b7cc 100644
--- a/src/zap/zapinfo.cpp
+++ b/src/zap/zapinfo.cpp
@@ -3704,6 +3704,12 @@ CORINFO_METHOD_HANDLE ZapInfo::resolveVirtualMethod(
return m_pEEJitInfo->resolveVirtualMethod(virtualMethod, implementingClass, ownerType);
}
+CORINFO_CLASS_HANDLE ZapInfo::getDefaultEqualityComparerClass(
+ CORINFO_CLASS_HANDLE elemType)
+{
+ return m_pEEJitInfo->getDefaultEqualityComparerClass(elemType);
+}
+
void ZapInfo::expandRawHandleIntrinsic(
CORINFO_RESOLVED_TOKEN * pResolvedToken,
CORINFO_GENERICHANDLE_RESULT * pResult)
diff --git a/src/zap/zapinfo.h b/src/zap/zapinfo.h
index d533975c79..5bb86dd88a 100644
--- a/src/zap/zapinfo.h
+++ b/src/zap/zapinfo.h
@@ -675,6 +675,10 @@ public:
CORINFO_CONTEXT_HANDLE ownerType
);
+ CORINFO_CLASS_HANDLE getDefaultEqualityComparerClass(
+ CORINFO_CLASS_HANDLE elemType
+ );
+
void expandRawHandleIntrinsic(
CORINFO_RESOLVED_TOKEN * pResolvedToken,
CORINFO_GENERICHANDLE_RESULT * pResult);
diff --git a/tests/arm/Tests.lst b/tests/arm/Tests.lst
index 45882fcf11..a94ba0230c 100644
--- a/tests/arm/Tests.lst
+++ b/tests/arm/Tests.lst
@@ -1513,7 +1513,7 @@ RelativePath=baseservices\threading\generics\threadstart\GThread25\GThread25.cmd
WorkingDir=baseservices\threading\generics\threadstart\GThread25
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091;Pri1
+Categories=EXPECTED_PASS;Pri1
HostStyle=0
[ArraySort9.cmd_191]
@@ -2001,7 +2001,7 @@ RelativePath=Loader\classloader\TypeGeneratorTests\TypeGeneratorTest772\Generate
WorkingDir=Loader\classloader\TypeGeneratorTests\TypeGeneratorTest772\Generated772
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;Pri1
+Categories=EXPECTED_FAIL;13731;Pri1
HostStyle=0
[_il_dbgldc_mul.cmd_252]
@@ -3801,7 +3801,7 @@ RelativePath=GC\Regressions\v2.0-beta1\149926\149926\149926.cmd
WorkingDir=GC\Regressions\v2.0-beta1\149926\149926
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091
+Categories=EXPECTED_PASS
HostStyle=0
[param06.cmd_478]
@@ -4681,7 +4681,7 @@ RelativePath=GC\Regressions\dev10bugs\536168\536168\536168.cmd
WorkingDir=GC\Regressions\dev10bugs\536168\536168
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091;Pri1
+Categories=EXPECTED_PASS;Pri1
HostStyle=0
[ldvirtftn.cmd_589]
@@ -5201,7 +5201,7 @@ RelativePath=JIT\Regression\CLR-x86-JIT\V1.1-M1-Beta1\b143840\b143840\b143840.cm
WorkingDir=JIT\Regression\CLR-x86-JIT\V1.1-M1-Beta1\b143840\b143840
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091
+Categories=EXPECTED_PASS
HostStyle=0
[struct01_static.cmd_654]
@@ -5705,7 +5705,7 @@ RelativePath=CoreMangLib\cti\system\reflection\emit\opcodes\OpCodesLdc_I4_3\OpCo
WorkingDir=CoreMangLib\cti\system\reflection\emit\opcodes\OpCodesLdc_I4_3
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;Pri1
+Categories=EXPECTED_FAIL;13731;Pri1
HostStyle=0
[_relnative.cmd_718]
@@ -6449,7 +6449,7 @@ RelativePath=baseservices\threading\generics\threadstart\GThread01\GThread01.cmd
WorkingDir=baseservices\threading\generics\threadstart\GThread01
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091;Pri1
+Categories=EXPECTED_PASS;Pri1
HostStyle=0
[_relgc_nested.cmd_811]
@@ -7409,7 +7409,7 @@ RelativePath=GC\Scenarios\FinalizeTimeout\FinalizeTimeout\FinalizeTimeout.cmd
WorkingDir=GC\Scenarios\FinalizeTimeout\FinalizeTimeout
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091
+Categories=EXPECTED_PASS
HostStyle=0
[Generated989.cmd_932]
@@ -8609,7 +8609,7 @@ RelativePath=Regressions\coreclr\1514\InterlockExchange\InterlockExchange.cmd
WorkingDir=Regressions\coreclr\1514\InterlockExchange
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091;Pri1
+Categories=EXPECTED_PASS;Pri1
HostStyle=0
[r4div_cs_do.cmd_1082]
@@ -13185,7 +13185,7 @@ RelativePath=Loader\classloader\TypeGeneratorTests\TypeGeneratorTest759\Generate
WorkingDir=Loader\classloader\TypeGeneratorTests\TypeGeneratorTest759\Generated759
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;Pri1
+Categories=EXPECTED_FAIL;13731;Pri1
HostStyle=0
[GCSimulator_26.cmd_1659]
@@ -16617,7 +16617,7 @@ RelativePath=GC\Features\LOHFragmentation\lohfragmentation\lohfragmentation.cmd
WorkingDir=GC\Features\LOHFragmentation\lohfragmentation
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091;Pri1
+Categories=EXPECTED_PASS;Pri1
HostStyle=0
[CharIsLetter1.cmd_2089]
@@ -17121,7 +17121,7 @@ RelativePath=GC\Coverage\LargeObjectAlloc\LargeObjectAlloc.cmd
WorkingDir=GC\Coverage\LargeObjectAlloc
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091
+Categories=EXPECTED_PASS
HostStyle=0
[NestedInterface03.cmd_2152]
@@ -17897,7 +17897,7 @@ RelativePath=Loader\classloader\TypeGeneratorTests\TypeGeneratorTest1387\Generat
WorkingDir=Loader\classloader\TypeGeneratorTests\TypeGeneratorTest1387\Generated1387
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;Pri1
+Categories=EXPECTED_FAIL;13731;Pri1
HostStyle=0
[_il_dbgtest_2b.cmd_2249]
@@ -18633,7 +18633,7 @@ RelativePath=JIT\jit64\hfa\main\testE\hfa_sd0E_r\hfa_sd0E_r.cmd
WorkingDir=JIT\jit64\hfa\main\testE\hfa_sd0E_r
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;12684;Pri1
+Categories=EXPECTED_PASS;Pri1
HostStyle=0
[DevDiv_359736_ro.cmd_2342]
@@ -19729,7 +19729,7 @@ RelativePath=GC\Scenarios\BinTree\thdtreelivingobj\thdtreelivingobj.cmd
WorkingDir=GC\Scenarios\BinTree\thdtreelivingobj
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091
+Categories=EXPECTED_PASS
HostStyle=0
[Generated38.cmd_2479]
@@ -20273,7 +20273,7 @@ RelativePath=JIT\jit64\hfa\main\testE\hfa_sf1E_r\hfa_sf1E_r.cmd
WorkingDir=JIT\jit64\hfa\main\testE\hfa_sf1E_r
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;12684;Pri1
+Categories=EXPECTED_PASS;Pri1
HostStyle=0
[OpCodesCall.cmd_2547]
@@ -20561,7 +20561,7 @@ RelativePath=JIT\Regression\JitBlue\DevDiv_255263\DevDiv_255263\DevDiv_255263.cm
WorkingDir=JIT\Regression\JitBlue\DevDiv_255263\DevDiv_255263
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;12686
+Categories=EXPECTED_PASS
HostStyle=0
[castclass-null013.cmd_2583]
@@ -20897,7 +20897,7 @@ RelativePath=JIT\Regression\JitBlue\DevDiv_199169\DevDiv_199169\DevDiv_199169.cm
WorkingDir=JIT\Regression\JitBlue\DevDiv_199169\DevDiv_199169
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;12686
+Categories=EXPECTED_PASS
HostStyle=0
[CS_ARENullRefEx.cmd_2625]
@@ -22105,7 +22105,7 @@ RelativePath=GC\Scenarios\DoublinkList\doublinknoleak2\doublinknoleak2.cmd
WorkingDir=GC\Scenarios\DoublinkList\doublinknoleak2
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091
+Categories=EXPECTED_PASS
HostStyle=0
[MathFSqrt.cmd_2777]
@@ -22169,7 +22169,7 @@ RelativePath=JIT\Methodical\explicit\rotate\_relrotarg_valref\_relrotarg_valref.
WorkingDir=JIT\Methodical\explicit\rotate\_relrotarg_valref
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS
+Categories=EXPECTED_FAIL;13731
HostStyle=0
[r8rem_cs_r.cmd_2785]
@@ -24009,7 +24009,7 @@ RelativePath=baseservices\threading\interlocked\compareexchange\CompareExchangeT
WorkingDir=baseservices\threading\interlocked\compareexchange\CompareExchangeTClass
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091;Pri1
+Categories=EXPECTED_PASS;Pri1
HostStyle=0
[TimeSpanFromTicks.cmd_3015]
@@ -24769,7 +24769,7 @@ RelativePath=JIT\jit64\regress\vsw\539509\test1\test1.cmd
WorkingDir=JIT\jit64\regress\vsw\539509\test1
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091
+Categories=EXPECTED_PASS
HostStyle=0
[GetHashCode.cmd_3111]
@@ -25161,7 +25161,7 @@ RelativePath=GC\Features\HeapExpansion\plug\plug.cmd
WorkingDir=GC\Features\HeapExpansion\plug
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091
+Categories=EXPECTED_PASS
HostStyle=0
[OpCodesLdloca_S.cmd_3160]
@@ -26217,7 +26217,7 @@ RelativePath=baseservices\threading\regressions\beta2\437017\437017.cmd
WorkingDir=baseservices\threading\regressions\beta2\437017
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091;Pri1
+Categories=EXPECTED_PASS;Pri1
HostStyle=0
[rethrowwithhandlerscatchingbase_d.cmd_3294]
@@ -27033,7 +27033,7 @@ RelativePath=Loader\classloader\regressions\dev10_720779\dev10_720779\dev10_7207
WorkingDir=Loader\classloader\regressions\dev10_720779\dev10_720779
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;Pri1
+Categories=EXPECTED_FAIL;13731;Pri1
HostStyle=0
[StringConcat4.cmd_3396]
@@ -28617,7 +28617,7 @@ RelativePath=GC\Scenarios\THDList\thdlist\thdlist.cmd
WorkingDir=GC\Scenarios\THDList\thdlist
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091
+Categories=EXPECTED_PASS
HostStyle=0
[waitallex1.cmd_3595]
@@ -29177,7 +29177,7 @@ RelativePath=JIT\Performance\CodeQuality\BenchmarksGame\revcomp\revcomp\revcomp.
WorkingDir=JIT\Performance\CodeQuality\BenchmarksGame\revcomp\revcomp
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS
+Categories=EXPECTED_FAIL
HostStyle=0
[ConvertToUInt323.cmd_3665]
@@ -30497,7 +30497,7 @@ RelativePath=GC\Scenarios\muldimjagary\muldimjagary\muldimjagary.cmd
WorkingDir=GC\Scenarios\muldimjagary\muldimjagary
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091
+Categories=EXPECTED_PASS
HostStyle=0
[GCSimulator_261.cmd_3830]
@@ -31593,7 +31593,7 @@ RelativePath=JIT\Regression\CLR-x86-JIT\V1-M11-Beta1\b41129\b41129\b41129.cmd
WorkingDir=JIT\Regression\CLR-x86-JIT\V1-M11-Beta1\b41129\b41129
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;12685
+Categories=EXPECTED_PASS
HostStyle=0
[thread21.cmd_3967]
@@ -33169,7 +33169,7 @@ RelativePath=JIT\Performance\CodeQuality\BenchmarksGame\pidigits\pi-digits\pi-di
WorkingDir=JIT\Performance\CodeQuality\BenchmarksGame\pidigits\pi-digits
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS
+Categories=EXPECTED_FAIL
HostStyle=0
[TextReaderNull_PSC.cmd_4165]
@@ -33209,7 +33209,7 @@ RelativePath=JIT\Methodical\flowgraph\dev10_bug679955\volatileLocal1\volatileLoc
WorkingDir=JIT\Methodical\flowgraph\dev10_bug679955\volatileLocal1
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;12685;Pri1
+Categories=EXPECTED_PASS;Pri1
HostStyle=0
[b21296.cmd_4170]
@@ -33329,7 +33329,7 @@ RelativePath=JIT\Performance\CodeQuality\BenchmarksGame\binarytrees\binarytrees3
WorkingDir=JIT\Performance\CodeQuality\BenchmarksGame\binarytrees\binarytrees3
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS
+Categories=EXPECTED_FAIL
HostStyle=0
[b35354.cmd_4185]
@@ -33401,7 +33401,7 @@ RelativePath=baseservices\exceptions\regressions\whidbeym3.3\302680\302680\30268
WorkingDir=baseservices\exceptions\regressions\whidbeym3.3\302680\302680
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;Pri1
+Categories=EXPECTED_FAIL;13731;Pri1
HostStyle=0
[lim_002.cmd_4194]
@@ -34785,7 +34785,7 @@ RelativePath=GC\Features\BackgroundGC\foregroundgc\foregroundgc.cmd
WorkingDir=GC\Features\BackgroundGC\foregroundgc
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091;Pri1
+Categories=EXPECTED_PASS;Pri1
HostStyle=0
[_il_relldsfld_mul.cmd_4367]
@@ -35201,7 +35201,7 @@ RelativePath=JIT\jit64\mcc\interop\mcc_i66\mcc_i66.cmd
WorkingDir=JIT\jit64\mcc\interop\mcc_i66
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS
+Categories=EXPECTED_FAIL;13730
HostStyle=0
[Generated202.cmd_4419]
@@ -35609,7 +35609,7 @@ RelativePath=Loader\classloader\TypeGeneratorTests\TypeGeneratorTest1219\Generat
WorkingDir=Loader\classloader\TypeGeneratorTests\TypeGeneratorTest1219\Generated1219
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;Pri1
+Categories=EXPECTED_FAIL;13731;Pri1
HostStyle=0
[instance_equalnull_class01.cmd_4470]
@@ -35921,7 +35921,7 @@ RelativePath=JIT\Regression\CLR-x86-JIT\V1-M12-Beta2\b52840\b52840\b52840.cmd
WorkingDir=JIT\Regression\CLR-x86-JIT\V1-M12-Beta2\b52840\b52840
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS
+Categories=EXPECTED_FAIL;13731
HostStyle=0
[gcincatch_r.cmd_4509]
@@ -36705,7 +36705,7 @@ RelativePath=JIT\Methodical\tailcall\_il_relcompat_i_u2\_il_relcompat_i_u2.cmd
WorkingDir=JIT\Methodical\tailcall\_il_relcompat_i_u2
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;Pri1
+Categories=EXPECTED_FAIL;13731;Pri1
HostStyle=0
[SByteEquals2.cmd_4607]
@@ -36745,7 +36745,7 @@ RelativePath=JIT\jit64\regress\vsw\373472\test\test.cmd
WorkingDir=JIT\jit64\regress\vsw\373472\test
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS
+Categories=EXPECTED_FAIL;13731
HostStyle=0
[specific_struct_instance01.cmd_4612]
@@ -37233,7 +37233,7 @@ RelativePath=JIT\Regression\Dev11\External\dev11_239804\ShowLocallocAlignment\Sh
WorkingDir=JIT\Regression\Dev11\External\dev11_239804\ShowLocallocAlignment
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;Pri1
+Categories=EXPECTED_FAIL;13731;Pri1
HostStyle=0
[JTrueGeDbl.cmd_4673]
@@ -37465,7 +37465,7 @@ RelativePath=Loader\classloader\TypeGeneratorTests\TypeGeneratorTest1493\Generat
WorkingDir=Loader\classloader\TypeGeneratorTests\TypeGeneratorTest1493\Generated1493
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;Pri1
+Categories=EXPECTED_FAIL;13731;Pri1
HostStyle=0
[Double_No_Op_cs_r.cmd_4702]
@@ -40681,7 +40681,7 @@ RelativePath=JIT\Performance\CodeQuality\BenchmarksGame\regexdna\regexdna\regexd
WorkingDir=JIT\Performance\CodeQuality\BenchmarksGame\regexdna\regexdna
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS
+Categories=EXPECTED_FAIL
HostStyle=0
[_il_relrefarg_box_f8.cmd_5104]
@@ -43305,7 +43305,7 @@ RelativePath=GC\Coverage\LargeObjectAlloc2\LargeObjectAlloc2.cmd
WorkingDir=GC\Coverage\LargeObjectAlloc2
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091
+Categories=EXPECTED_PASS
HostStyle=0
[DelegStaticFtn.cmd_5433]
@@ -44025,7 +44025,7 @@ RelativePath=JIT\Directed\tailcall\tailcall\tailcall.cmd
WorkingDir=JIT\Directed\tailcall\tailcall
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;GCSTRESS_FAIL;13200
+Categories=EXPECTED_FAIL;13604;GCSTRESS_FAIL;13200
HostStyle=0
[b47093.cmd_5523]
@@ -44649,7 +44649,7 @@ RelativePath=GC\Scenarios\BinTree\thdtreegrowingobj\thdtreegrowingobj.cmd
WorkingDir=GC\Scenarios\BinTree\thdtreegrowingobj
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091
+Categories=EXPECTED_PASS
HostStyle=0
[_speed_dbgselfref.cmd_5602]
@@ -47889,7 +47889,7 @@ RelativePath=JIT\Regression\CLR-x86-JIT\V1-M12-Beta2\b77713\b77713\b77713.cmd
WorkingDir=JIT\Regression\CLR-x86-JIT\V1-M12-Beta2\b77713\b77713
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;Pri1
+Categories=EXPECTED_FAIL;13731;Pri1
HostStyle=0
[invocation_do.cmd_6009]
@@ -48881,7 +48881,7 @@ RelativePath=GC\Regressions\v2.0-beta2\460373\460373\460373.cmd
WorkingDir=GC\Regressions\v2.0-beta2\460373\460373
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091
+Categories=EXPECTED_PASS
HostStyle=0
[waitanyex3.cmd_6133]
@@ -50897,7 +50897,7 @@ RelativePath=baseservices\threading\generics\threadstart\GThread22\GThread22.cmd
WorkingDir=baseservices\threading\generics\threadstart\GThread22
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091;Pri1
+Categories=EXPECTED_PASS;Pri1
HostStyle=0
[b50145c.cmd_6386]
@@ -53649,7 +53649,7 @@ RelativePath=CoreMangLib\cti\system\collections\generic\dictionary\DictionaryICo
WorkingDir=CoreMangLib\cti\system\collections\generic\dictionary\DictionaryICollectionIsReadOnly2
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;Pri1
+Categories=EXPECTED_FAIL;13731;Pri1
HostStyle=0
[PulseNull.cmd_6730]
@@ -55297,7 +55297,7 @@ RelativePath=GC\Scenarios\BinTree\thdtree\thdtree.cmd
WorkingDir=GC\Scenarios\BinTree\thdtree
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091
+Categories=EXPECTED_PASS
HostStyle=0
[add_ovf_i8.cmd_6940]
@@ -56921,7 +56921,7 @@ RelativePath=JIT\Regression\CLR-x86-JIT\V1-M12-Beta2\b59782\b59782\b59782.cmd
WorkingDir=JIT\Regression\CLR-x86-JIT\V1-M12-Beta2\b59782\b59782
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;12685
+Categories=EXPECTED_PASS
HostStyle=0
[Generated1230.cmd_7144]
@@ -57081,7 +57081,7 @@ RelativePath=JIT\jit64\hfa\main\testE\hfa_sf0E_r\hfa_sf0E_r.cmd
WorkingDir=JIT\jit64\hfa\main\testE\hfa_sf0E_r
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;12684;Pri1
+Categories=EXPECTED_PASS;Pri1
HostStyle=0
[Generated399.cmd_7164]
@@ -57865,7 +57865,7 @@ RelativePath=JIT\Methodical\xxblk\initblk3_il_d\initblk3_il_d.cmd
WorkingDir=JIT\Methodical\xxblk\initblk3_il_d
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;12686
+Categories=EXPECTED_PASS
HostStyle=0
[118414.cmd_7262]
@@ -58185,7 +58185,7 @@ RelativePath=JIT\Performance\CodeQuality\BenchmarksGame\binarytrees\binarytrees\
WorkingDir=JIT\Performance\CodeQuality\BenchmarksGame\binarytrees\binarytrees
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS
+Categories=EXPECTED_FAIL
HostStyle=0
[Generated686.cmd_7302]
@@ -59201,7 +59201,7 @@ RelativePath=JIT\jit64\mcc\interop\mcc_i76\mcc_i76.cmd
WorkingDir=JIT\jit64\mcc\interop\mcc_i76
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS
+Categories=EXPECTED_FAIL;13730
HostStyle=0
[GCSimulator_88.cmd_7429]
@@ -59553,7 +59553,7 @@ RelativePath=GC\Scenarios\THDChaos\thdchaos\thdchaos.cmd
WorkingDir=GC\Scenarios\THDChaos\thdchaos
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091
+Categories=EXPECTED_PASS
HostStyle=0
[Generated615.cmd_7473]
@@ -62081,7 +62081,7 @@ RelativePath=JIT\Performance\CodeQuality\BenchmarksGame\spectralnorm\spectralnor
WorkingDir=JIT\Performance\CodeQuality\BenchmarksGame\spectralnorm\spectralnorm
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS
+Categories=EXPECTED_FAIL
HostStyle=0
[ArraySetValue1.cmd_7790]
@@ -62201,7 +62201,7 @@ RelativePath=JIT\Regression\CLR-x86-JIT\V1-M11-Beta1\b47610\b47610\b47610.cmd
WorkingDir=JIT\Regression\CLR-x86-JIT\V1-M11-Beta1\b47610\b47610
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;Pri1
+Categories=EXPECTED_FAIL;13731;Pri1
HostStyle=0
[b92713.cmd_7805]
@@ -64825,7 +64825,7 @@ RelativePath=JIT\jit64\hfa\main\testE\hfa_sd1E_r\hfa_sd1E_r.cmd
WorkingDir=JIT\jit64\hfa\main\testE\hfa_sd1E_r
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;12684;Pri1
+Categories=EXPECTED_PASS;Pri1
HostStyle=0
[Generated948.cmd_8134]
@@ -64953,7 +64953,7 @@ RelativePath=GC\Scenarios\LeakGen\leakgenthrd\leakgenthrd.cmd
WorkingDir=GC\Scenarios\LeakGen\leakgenthrd
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091;Pri1
+Categories=EXPECTED_PASS;Pri1
HostStyle=0
[castclass003.cmd_8150]
@@ -66737,7 +66737,7 @@ RelativePath=baseservices\threading\generics\threadstart\GThread02\GThread02.cmd
WorkingDir=baseservices\threading\generics\threadstart\GThread02
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091;Pri1
+Categories=EXPECTED_PASS;Pri1
HostStyle=0
[nestedTryRegionsWithSameOffset1_o.cmd_8374]
@@ -67473,7 +67473,7 @@ RelativePath=GC\Features\HeapExpansion\bestfit-threaded\bestfit-threaded.cmd
WorkingDir=GC\Features\HeapExpansion\bestfit-threaded
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091
+Categories=EXPECTED_PASS
HostStyle=0
[ConvertToSingle16.cmd_8466]
@@ -69609,7 +69609,7 @@ RelativePath=GC\Regressions\v2.0-beta2\445488\445488\445488.cmd
WorkingDir=GC\Regressions\v2.0-beta2\445488\445488
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091
+Categories=EXPECTED_PASS
HostStyle=0
[_dbgsizeof32.cmd_8733]
@@ -70001,7 +70001,7 @@ RelativePath=JIT\jit64\mcc\interop\mcc_i86\mcc_i86.cmd
WorkingDir=JIT\jit64\mcc\interop\mcc_i86
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS
+Categories=EXPECTED_FAIL;13730
HostStyle=0
[b35486.cmd_8783]
@@ -70993,7 +70993,7 @@ RelativePath=CoreMangLib\cti\system\runtime\interopservices\safehandle\SafeHandl
WorkingDir=CoreMangLib\cti\system\runtime\interopservices\safehandle\SafeHandleHandle_PSC
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;Pri1
+Categories=EXPECTED_FAIL;13731;Pri1
HostStyle=0
[b62498.cmd_8908]
@@ -71833,7 +71833,7 @@ RelativePath=Loader\classloader\TypeGeneratorTests\TypeGeneratorTest574\Generate
WorkingDir=Loader\classloader\TypeGeneratorTests\TypeGeneratorTest574\Generated574
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;Pri1
+Categories=EXPECTED_FAIL;13731;Pri1
HostStyle=0
[_il_relisinst_calli.cmd_9013]
@@ -72193,7 +72193,7 @@ RelativePath=GC\LargeMemory\API\gc\suppressfinalize\suppressfinalize.cmd
WorkingDir=GC\LargeMemory\API\gc\suppressfinalize
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091;Pri1
+Categories=EXPECTED_PASS;Pri1
HostStyle=0
[StringPadLeft.cmd_9058]
@@ -73809,7 +73809,7 @@ RelativePath=JIT\Methodical\xxblk\initblk3_il_r\initblk3_il_r.cmd
WorkingDir=JIT\Methodical\xxblk\initblk3_il_r
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;12686
+Categories=EXPECTED_PASS
HostStyle=0
[Generated721.cmd_9260]
@@ -74777,7 +74777,7 @@ RelativePath=baseservices\threading\interlocked\compareexchange\CompareExchangeT
WorkingDir=baseservices\threading\interlocked\compareexchange\CompareExchangeTString
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091;Pri1
+Categories=EXPECTED_PASS;Pri1
HostStyle=0
[castclass011.cmd_9383]
@@ -75609,7 +75609,7 @@ RelativePath=JIT\Regression\VS-ia64-JIT\V2.0-RTM\b539509\b539509\b539509.cmd
WorkingDir=JIT\Regression\VS-ia64-JIT\V2.0-RTM\b539509\b539509
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091
+Categories=EXPECTED_PASS
HostStyle=0
[DevDiv_816617_ro.cmd_9488]
@@ -79001,7 +79001,7 @@ RelativePath=JIT\jit64\hfa\main\testE\hfa_nf1E_r\hfa_nf1E_r.cmd
WorkingDir=JIT\jit64\hfa\main\testE\hfa_nf1E_r
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;12684;Pri1
+Categories=EXPECTED_PASS;Pri1
HostStyle=0
[box-unbox003.cmd_9916]
@@ -80241,7 +80241,7 @@ RelativePath=GC\Coverage\smalloom\smalloom.cmd
WorkingDir=GC\Coverage\smalloom
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091;Pri1
+Categories=EXPECTED_PASS;Pri1
HostStyle=0
[b12425.cmd_10072]
@@ -80385,7 +80385,7 @@ RelativePath=JIT\jit64\hfa\main\testE\hfa_nf0E_r\hfa_nf0E_r.cmd
WorkingDir=JIT\jit64\hfa\main\testE\hfa_nf0E_r
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;12684;Pri1
+Categories=EXPECTED_PASS;Pri1
HostStyle=0
[Generated237.cmd_10090]
@@ -80697,7 +80697,7 @@ RelativePath=JIT\Performance\CodeQuality\BenchmarksGame\fastaredux\fastaredux\fa
WorkingDir=JIT\Performance\CodeQuality\BenchmarksGame\fastaredux\fastaredux
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS
+Categories=EXPECTED_FAIL
HostStyle=0
[MathTan.cmd_10130]
@@ -82337,7 +82337,7 @@ RelativePath=Regressions\coreclr\0080\delete_next_card_table\delete_next_card_ta
WorkingDir=Regressions\coreclr\0080\delete_next_card_table
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091;Pri1
+Categories=EXPECTED_PASS;Pri1
HostStyle=0
[ArrayInitialize.cmd_10336]
@@ -83185,7 +83185,7 @@ RelativePath=JIT\Regression\CLR-x86-JIT\V1-M09\b15783\b15783\b15783.cmd
WorkingDir=JIT\Regression\CLR-x86-JIT\V1-M09\b15783\b15783
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;Pri1
+Categories=EXPECTED_FAIL;13604;Pri1
HostStyle=0
[bne_opt.cmd_10443]
@@ -83569,7 +83569,7 @@ RelativePath=JIT\jit64\mcc\interop\mcc_i56\mcc_i56.cmd
WorkingDir=JIT\jit64\mcc\interop\mcc_i56
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS
+Categories=EXPECTED_FAIL;13730
HostStyle=0
[NestedGenericClasses.cmd_10491]
@@ -83641,7 +83641,7 @@ RelativePath=JIT\Methodical\Boxing\misc\_dbgenum_cs\_dbgenum_cs.cmd
WorkingDir=JIT\Methodical\Boxing\misc\_dbgenum_cs
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS
+Categories=EXPECTED_FAIL;13731
HostStyle=0
[throwinnestedtryfinally_d.cmd_10500]
@@ -83713,7 +83713,7 @@ RelativePath=Loader\classloader\TypeGeneratorTests\TypeGeneratorTest323\Generate
WorkingDir=Loader\classloader\TypeGeneratorTests\TypeGeneratorTest323\Generated323
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;Pri1
+Categories=EXPECTED_FAIL;13731;Pri1
HostStyle=0
[ListInsertRange.cmd_10510]
@@ -84065,7 +84065,7 @@ RelativePath=JIT\jit64\mcc\interop\mcc_i36\mcc_i36.cmd
WorkingDir=JIT\jit64\mcc\interop\mcc_i36
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS
+Categories=EXPECTED_FAIL;13730
HostStyle=0
[IEnumerableGetEnumerator.cmd_10554]
@@ -84761,7 +84761,7 @@ RelativePath=baseservices\threading\generics\threadstart\GThread23\GThread23.cmd
WorkingDir=baseservices\threading\generics\threadstart\GThread23
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091;Pri1
+Categories=EXPECTED_PASS;Pri1
HostStyle=0
[AbstractBase01.cmd_10641]
@@ -85993,7 +85993,7 @@ RelativePath=baseservices\threading\generics\threadstart\GThread24\GThread24.cmd
WorkingDir=baseservices\threading\generics\threadstart\GThread24
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;8091;Pri1
+Categories=EXPECTED_PASS;Pri1
HostStyle=0
[StackCtor1.cmd_10795]
@@ -86505,7 +86505,7 @@ RelativePath=JIT\IL_Conformance\Old\Conformance_Base\ldarg_r4\ldarg_r4.cmd
WorkingDir=JIT\IL_Conformance\Old\Conformance_Base\ldarg_r4
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;Pri1
+Categories=EXPECTED_FAIL;13731;Pri1
HostStyle=0
[Class2_ImplicitOverrideVirtual.cmd_10859]
@@ -87617,7 +87617,7 @@ RelativePath=JIT\Methodical\Invoke\fptr\_speed_relrecurse\_speed_relrecurse.cmd
WorkingDir=JIT\Methodical\Invoke\fptr\_speed_relrecurse
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;Pri1
+Categories=EXPECTED_FAIL;13731;Pri1
HostStyle=0
[jaggedarr_cs_d.cmd_10999]
@@ -87945,7 +87945,7 @@ RelativePath=JIT\Performance\CodeQuality\BenchmarksGame\fasta\fasta\fasta.cmd
WorkingDir=JIT\Performance\CodeQuality\BenchmarksGame\fasta\fasta
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS
+Categories=EXPECTED_FAIL
HostStyle=0
[dev10_512868.cmd_11040]
@@ -88809,7 +88809,7 @@ RelativePath=JIT\Performance\CodeQuality\BenchmarksGame\nbody\nbody\nbody.cmd
WorkingDir=JIT\Performance\CodeQuality\BenchmarksGame\nbody\nbody
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS
+Categories=EXPECTED_FAIL
HostStyle=0
[StringIConvertibleToChar.cmd_11149]
@@ -88841,7 +88841,7 @@ RelativePath=CoreMangLib\cti\system\convert\ConvertToInt32_5\ConvertToInt32_5.cm
WorkingDir=CoreMangLib\cti\system\convert\ConvertToInt32_5
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;Pri1
+Categories=EXPECTED_FAIL;13731;Pri1
HostStyle=0
[Generated1317.cmd_11153]
@@ -89017,7 +89017,7 @@ RelativePath=JIT\Regression\CLR-x86-JIT\V1-M12-Beta2\b54566\b54566\b54566.cmd
WorkingDir=JIT\Regression\CLR-x86-JIT\V1-M12-Beta2\b54566\b54566
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_FAIL;12685
+Categories=EXPECTED_PASS
HostStyle=0
[rangecheckinfinally_r.cmd_11175]
@@ -89737,7 +89737,7 @@ RelativePath=JIT\Performance\CodeQuality\BenchmarksGame\k-nucleotide\k-nucleotid
WorkingDir=JIT\Performance\CodeQuality\BenchmarksGame\k-nucleotide\k-nucleotide
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS
+Categories=EXPECTED_FAIL
HostStyle=0
[Generated1091.cmd_11266]
@@ -90665,7 +90665,7 @@ RelativePath=JIT\Performance\CodeQuality\BenchmarksGame\mandelbrot\mandelbrot\ma
WorkingDir=JIT\Performance\CodeQuality\BenchmarksGame\mandelbrot\mandelbrot
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;NEW
+Categories=EXPECTED_FAIL;NEW
HostStyle=0
[GitHub_13404.cmd_11383]
@@ -90697,7 +90697,7 @@ RelativePath=JIT\Performance\CodeQuality\BenchmarksGame\fannkuch-redux\fannkuch-
WorkingDir=JIT\Performance\CodeQuality\BenchmarksGame\fannkuch-redux\fannkuch-redux
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;NEW
+Categories=EXPECTED_FAIL;NEW
HostStyle=0
[GitHub_12949_4.cmd_11387]
diff --git a/tests/arm64/Tests.lst b/tests/arm64/Tests.lst
index fb6a19a45d..df2b9726ca 100644
--- a/tests/arm64/Tests.lst
+++ b/tests/arm64/Tests.lst
@@ -61585,7 +61585,7 @@ RelativePath=JIT\Performance\CodeQuality\BenchmarksGame\binarytrees\binarytrees\
WorkingDir=JIT\Performance\CodeQuality\BenchmarksGame\binarytrees\binarytrees
Expected=0
MaxAllowedDurationSeconds=600
-Categories=GCSTRESS_FAIL;LONG_RUNNING;ISSUE_6065;EXPECTED_PASS
+Categories=GCSTRESS_FAIL;LONG_RUNNING;ISSUE_6065;EXPECTED_FAIL
HostStyle=0
[fasta.cmd_8016]
@@ -61593,7 +61593,7 @@ RelativePath=JIT\Performance\CodeQuality\BenchmarksGame\fasta\fasta\fasta.cmd
WorkingDir=JIT\Performance\CodeQuality\BenchmarksGame\fasta\fasta
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS
+Categories=EXPECTED_FAIL
HostStyle=0
[fastaredux.cmd_8017]
@@ -61601,7 +61601,7 @@ RelativePath=JIT\Performance\CodeQuality\BenchmarksGame\fastaredux\fastaredux\fa
WorkingDir=JIT\Performance\CodeQuality\BenchmarksGame\fastaredux\fastaredux
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS
+Categories=EXPECTED_FAIL
HostStyle=0
[nbody.cmd_8018]
@@ -61609,7 +61609,7 @@ RelativePath=JIT\Performance\CodeQuality\BenchmarksGame\nbody\nbody\nbody.cmd
WorkingDir=JIT\Performance\CodeQuality\BenchmarksGame\nbody\nbody
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS
+Categories=EXPECTED_FAIL
HostStyle=0
[pi-digits.cmd_8019]
@@ -61617,7 +61617,7 @@ RelativePath=JIT\Performance\CodeQuality\BenchmarksGame\pidigits\pi-digits\pi-di
WorkingDir=JIT\Performance\CodeQuality\BenchmarksGame\pidigits\pi-digits
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS
+Categories=EXPECTED_FAIL
HostStyle=0
[spectralnorm.cmd_8020]
@@ -61625,7 +61625,7 @@ RelativePath=JIT\Performance\CodeQuality\BenchmarksGame\spectralnorm\spectralnor
WorkingDir=JIT\Performance\CodeQuality\BenchmarksGame\spectralnorm\spectralnorm
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS
+Categories=EXPECTED_FAIL
HostStyle=0
[Burgers.cmd_8021]
@@ -80297,7 +80297,7 @@ RelativePath=JIT\Performance\CodeQuality\BenchmarksGame\revcomp\revcomp\revcomp.
WorkingDir=JIT\Performance\CodeQuality\BenchmarksGame\revcomp\revcomp
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;NEW
+Categories=EXPECTED_FAIL;NEW
HostStyle=0
[DevDiv_216571.cmd_10395]
@@ -82113,7 +82113,7 @@ RelativePath=JIT\Performance\CodeQuality\BenchmarksGame\regexdna\regexdna\regexd
WorkingDir=JIT\Performance\CodeQuality\BenchmarksGame\regexdna\regexdna
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;NEW
+Categories=EXPECTED_FAIL;NEW
HostStyle=0
[Generated504.cmd_10624]
@@ -86329,7 +86329,7 @@ RelativePath=JIT\Performance\CodeQuality\BenchmarksGame\binarytrees\binarytrees3
WorkingDir=JIT\Performance\CodeQuality\BenchmarksGame\binarytrees\binarytrees3
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;NEW
+Categories=EXPECTED_FAIL;NEW
HostStyle=0
[Generated781.cmd_11157]
@@ -90097,7 +90097,7 @@ RelativePath=JIT\Performance\CodeQuality\BenchmarksGame\k-nucleotide\k-nucleotid
WorkingDir=JIT\Performance\CodeQuality\BenchmarksGame\k-nucleotide\k-nucleotide
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;NEW
+Categories=EXPECTED_FAIL;NEW
HostStyle=0
[ArrayObj.cmd_11629]
@@ -90465,7 +90465,7 @@ RelativePath=JIT\Performance\CodeQuality\BenchmarksGame\mandelbrot\mandelbrot\ma
WorkingDir=JIT\Performance\CodeQuality\BenchmarksGame\mandelbrot\mandelbrot
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;NEW
+Categories=EXPECTED_FAIL;NEW
HostStyle=0
[ReadWriteObject.cmd_11676]
@@ -90601,7 +90601,7 @@ RelativePath=JIT\Performance\CodeQuality\BenchmarksGame\fannkuch-redux\fannkuch-
WorkingDir=JIT\Performance\CodeQuality\BenchmarksGame\fannkuch-redux\fannkuch-redux
Expected=0
MaxAllowedDurationSeconds=600
-Categories=EXPECTED_PASS;NEW
+Categories=EXPECTED_FAIL;NEW
HostStyle=0
[GitHub_11508.cmd_11693]
diff --git a/tests/build.proj b/tests/build.proj
index 2ff5f499ae..9f11919923 100644
--- a/tests/build.proj
+++ b/tests/build.proj
@@ -52,10 +52,10 @@
</Target>
<Target Name="RestorePackage">
- <Exec Command="$(DotnetRestoreCommand) $(RestoreProj) $(PackageVersionArg)"
- StandardOutputImportance="Low" />
+ <Exec Condition="'$(RunningOnCore)' == 'false'" Command="$(DotnetRestoreCommand) $(RestoreProj) $(PackageVersionArg)" StandardOutputImportance="Low" />
+ <Exec Condition="'$(RunningOnCore)' == 'true'" Command="$(DotnetRestoreCommand) -r $(__DistroRid) $(RestoreProj) $(PackageVersionArg)" StandardOutputImportance="Low" />
</Target>
<!-- Override RestorePackages from dir.traversal.targets and do a batch restore -->
<Target Name="RestorePackages" DependsOnTargets="BatchRestorePackages" />
-</Project> \ No newline at end of file
+</Project>
diff --git a/tests/issues.targets b/tests/issues.targets
index 1b6ef0d2c9..af769509cd 100644
--- a/tests/issues.targets
+++ b/tests/issues.targets
@@ -184,6 +184,9 @@
<ExcludeList Include="$(XunitTestBinBase)\Loader\classloader\TypeGeneratorTests\TypeGeneratorTest683\Generated683\*">
<Issue>6707</Issue>
</ExcludeList>
+ <ExcludeList Include="$(XunitTestBinBase)\JIT\Regression\JitBlue\GitHub_13910\GitHub_13910\GitHub_13910.cmd">
+ <Issue>13910</Issue>
+ </ExcludeList>
</ItemGroup>
<!-- The following are x86 failures -->
@@ -401,13 +404,22 @@
<ExcludeList Include="$(XunitTestBinBase)\JIT\superpmi\superpmicollect\superpmicollect.cmd">
<Issue>needs triage</Issue>
</ExcludeList>
- <ExcludeList Include="$(XunitTestBinBase)\JIT\Performance\CodeQuality\BenchmarksGame\k-nucleotide\k-nucleotide\k-nucleotide.cmd">
+ <ExcludeList Include="$(XunitTestBinBase)\JIT\Performance\CodeQuality\BenchmarksGame\k-nucleotide\k-nucleotide-1\k-nucleotide-1.cmd">
+ <Issue>9314</Issue>
+ </ExcludeList>
+ <ExcludeList Include="$(XunitTestBinBase)\JIT\Performance\CodeQuality\BenchmarksGame\k-nucleotide\k-nucleotide-9\k-nucleotide-9.cmd">
+ <Issue>9314</Issue>
+ </ExcludeList>
+ <ExcludeList Include="$(XunitTestBinBase)\JIT\Performance\CodeQuality\BenchmarksGame\regex-redux\regex-redux-1\regex-redux-1.cmd">
+ <Issue>9314</Issue>
+ </ExcludeList>
+ <ExcludeList Include="$(XunitTestBinBase)\JIT\Performance\CodeQuality\BenchmarksGame\regex-redux\regex-redux-5\regex-redux-5.cmd">
<Issue>9314</Issue>
</ExcludeList>
- <ExcludeList Include="$(XunitTestBinBase)\JIT\Performance\CodeQuality\BenchmarksGame\regexdna\regexdna\regexdna.cmd">
+ <ExcludeList Include="$(XunitTestBinBase)\JIT\Performance\CodeQuality\BenchmarksGame\reverse-complement\reverse-complement-1\reverse-complement-1.cmd">
<Issue>9314</Issue>
</ExcludeList>
- <ExcludeList Include="$(XunitTestBinBase)\JIT\Performance\CodeQuality\BenchmarksGame\revcomp\revcomp\revcomp.cmd">
+ <ExcludeList Include="$(XunitTestBinBase)\JIT\Performance\CodeQuality\BenchmarksGame\reverse-complement\reverse-complement-6\reverse-complement-6.cmd">
<Issue>9314</Issue>
</ExcludeList>
</ItemGroup>
diff --git a/tests/runtest.cmd b/tests/runtest.cmd
index 936383ea12..84136a455c 100644
--- a/tests/runtest.cmd
+++ b/tests/runtest.cmd
@@ -204,7 +204,7 @@ call :PrecompileFX
if defined __GenerateLayoutOnly (
REM Delete the unecessary mscorlib.ni file.
- del %CORE_ROOT%\mscorlib.ni.dll
+ if exist %CORE_ROOT%\mscorlib.ni.dll del %CORE_ROOT%\mscorlib.ni.dll
exit /b 0
)
@@ -240,7 +240,7 @@ echo %__MsgPrefix%CORE_ROOT that will be used is: %CORE_ROOT%
echo %__MsgPrefix%Starting the test run ...
REM Delete the unecessary mscorlib.ni file.
-del %CORE_ROOT%\mscorlib.ni.dll
+if exist %CORE_ROOT%\mscorlib.ni.dll del %CORE_ROOT%\mscorlib.ni.dll
set __BuildLogRootName=TestRunResults
call :msbuild "%__ProjectFilesDir%\runtest.proj" /p:Runtests=true /clp:showcommandline
diff --git a/tests/runtest.proj b/tests/runtest.proj
index 983223b109..015845c225 100644
--- a/tests/runtest.proj
+++ b/tests/runtest.proj
@@ -12,6 +12,7 @@
<ItemGroup>
<DisabledTestDir Include="Common" />
+ <DisabledTestDir Include="tracing" />
<_SkipTestDir Include="@(DisabledTestDir)" />
</ItemGroup>
diff --git a/tests/scripts/arm32_ci_script.sh b/tests/scripts/arm32_ci_script.sh
index e73e266fdb..aecb3e890a 100755
--- a/tests/scripts/arm32_ci_script.sh
+++ b/tests/scripts/arm32_ci_script.sh
@@ -265,7 +265,7 @@ function cross_build_coreclr_with_docker {
# For armel Tizen, we are going to construct RootFS on the fly.
case $__linuxCodeName in
tizen)
- __dockerImage=" hqueue/dotnetcore:ubuntu1404_cross_prereqs_v4-tizen_rootfs"
+ __dockerImage=" hqueue/dotnet-buildtools-prereqs:ubuntu-14.04-cross-0cd4667-20172211042239-tizen-rootfs-20170925"
__skipRootFS=1
__dockerEnvironmentVariables+=" -e ROOTFS_DIR=/crossrootfs/armel.tizen.build"
__runtimeOS="tizen.4.0.0"
@@ -388,7 +388,7 @@ function run_tests_using_docker {
elif [ "$__buildArch" == "armel" ]; then
case $__linuxCodeName in
tizen)
- __dockerImage=" hqueue/dotnetcore:ubuntu1404_cross_prereqs_v4-tizen_rootfs"
+ __dockerImage=" hqueue/dotnet-buildtools-prereqs:ubuntu-14.04-cross-0cd4667-20172211042239-tizen-rootfs-20170925"
__skipRootFS=1
__dockerEnvironmentVariables=" -e ROOTFS_DIR=/crossrootfs/armel.tizen.test"
;;
diff --git a/tests/scripts/arm64_post_build.py b/tests/scripts/arm64_post_build.py
index 338063a2f5..b731cecc4a 100644
--- a/tests/scripts/arm64_post_build.py
+++ b/tests/scripts/arm64_post_build.py
@@ -34,7 +34,7 @@ from collections import defaultdict
g_arm64ci_path = os.path.join(os.environ["USERPROFILE"], "bin")
g_dotnet_url = "https://clrjit.blob.core.windows.net/arm64ci/dotnet-sdk.zip"
-g_x64_client_url = "https://clrjit.blob.core.windows.net/arm64ci/x64_client_2_0_update.zip"
+g_x64_client_url = "https://clrjit.blob.core.windows.net/arm64ci/x64_client_arm_proxy_change.zip"
################################################################################
# Argument Parser
@@ -50,9 +50,11 @@ parser.add_argument("--force_update", dest="force_update", action="store_true",
parser.add_argument("-repo_root", dest="repo_root", nargs='?', default=None)
parser.add_argument("-arch", dest="arch", nargs='?', default=None)
+parser.add_argument("-testarch", dest="testarch", nargs='?', default=None)
parser.add_argument("-build_type", dest="build_type", nargs='?', default=None)
parser.add_argument("-scenario", dest="scenario", nargs='?', default=None)
parser.add_argument("-key_location", dest="key_location", nargs='?', default=None)
+parser.add_argument("-priority", dest="priority", nargs='?', default="1")
################################################################################
# Helper Functions
@@ -210,12 +212,12 @@ def validate_args(args):
Args:
args (argparser.ArgumentParser): Args parsed by the argument parser.
Returns:
- (workspace, arch, build_type, scenario, force_update): (str,
- str,
- str,
- str,
- str,
- bool)
+ (workspace, arch, testarch, build_type, scenario, force_update): (str,
+ str,
+ str,
+ str,
+ str,
+ bool)
Notes:
If the arguments are valid then return them all in a tuple. If not, raise
an exception stating x argument is incorrect.
@@ -223,9 +225,11 @@ def validate_args(args):
repo_root = args.repo_root
arch = args.arch
+ testarch = args.testarch
build_type = args.build_type
scenario = args.scenario
key_location = args.key_location
+ priority = args.priority
force_update = True
def validate_arg(arg, check):
@@ -245,9 +249,12 @@ def validate_args(args):
raise Exception("Argument: %s is not valid." % (arg))
valid_arches = ["arm", "arm64"]
+ valid_testarches = ["arm", "armlb", "arm64"]
valid_build_types = ["debug", "checked", "release"]
+ valid_priorities = ["0", "1"]
- valid_jit_stress_regs_numbers = ["1", "2", "3", "4", "8", "10", "80"]
+ # Use the same naming scheme as netci.groovy, so, e.g., "0x10" instead of just "10".
+ valid_jit_stress_regs_numbers = ["1", "2", "3", "4", "8", "0x10", "0x80", "0x1000"]
jit_stress_scenarios = ["jitstress1", "jitstress2"]
jitstressregs_scenarios = ["jitstressregs" + item for item in valid_jit_stress_regs_numbers]
@@ -273,7 +280,6 @@ def validate_args(args):
valid_scenarios = ["default",
"pri1r2r",
"minopts",
- "zapdisable",
"tailcallstress",
"zapdisable"]
@@ -287,23 +293,28 @@ def validate_args(args):
validate_arg(repo_root, lambda item: os.path.isdir(item))
validate_arg(arch, lambda item: item.lower() in valid_arches)
+ validate_arg(testarch, lambda item: item.lower() in valid_testarches)
validate_arg(build_type, lambda item: item.lower() in valid_build_types)
validate_arg(scenario, lambda item: item.lower() in valid_scenarios)
validate_arg(key_location, lambda item: os.path.isfile(item))
validate_arg(force_update, lambda item: isinstance(item, bool))
+ validate_arg(priority, lambda item: item in valid_priorities)
arch = arch.lower()
+ testarch = testarch.lower()
build_type = build_type.lower()
scenario = scenario.lower()
- args = (repo_root, arch, build_type, scenario, key_location, force_update)
+ args = (repo_root, arch, testarch, build_type, scenario, key_location, priority, force_update)
log("Passed args: "
"Repo Root: %s, "
"Build Arch: %s, "
+ "Test Arch: %s, "
"Config: %s, "
"Scenario: %s, "
- "Key Location: %s" % (repo_root, arch, build_type, scenario, key_location))
+ "Priority: %s "
+ "Key Location: %s" % (repo_root, arch, testarch, build_type, scenario, priority, key_location))
return args
@@ -314,7 +325,7 @@ def validate_args(args):
def main(args):
global g_arm64ci_path
- repo_root, arch, build_type, scenario, key_location, force_update = validate_args(args)
+ repo_root, arch, testarch, build_type, scenario, key_location, priority, force_update = validate_args(args)
cwd = os.getcwd()
os.chdir(repo_root)
@@ -354,6 +365,13 @@ def main(args):
shutil.copy2(lst_file, core_root)
log("Copied %s to %s." % (lst_file, core_root))
+ # The x64_client has logic to set the appropriate AltJit environment variables for
+ # RyuJIT/arm32, set by prepending the scenario name with "ryujit_".
+ if testarch == "arm":
+ scenario = "ryujit_" + scenario
+
+ scenario = priority + scenario
+
args = ["dotnet",
os.path.join(g_arm64ci_path, "x64_client.dll"),
arch,
diff --git a/tests/src/Common/build_against_pkg_dependencies/build_against_pkg_dependencies.csproj b/tests/src/Common/build_against_pkg_dependencies/build_against_pkg_dependencies.csproj
index f3ae3050fe..6479596c6e 100644
--- a/tests/src/Common/build_against_pkg_dependencies/build_against_pkg_dependencies.csproj
+++ b/tests/src/Common/build_against_pkg_dependencies/build_against_pkg_dependencies.csproj
@@ -28,7 +28,7 @@
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier>
<PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8</PackageTargetFallback>
- <RuntimeIdentifiers>$(TargetRid)</RuntimeIdentifiers>
+ <RuntimeIdentifiers>win-arm;win-arm64;win-x64;win-x86;$(TargetRid)</RuntimeIdentifiers>
<ContainsPackageReferences>true</ContainsPackageReferences>
<PrereleaseResolveNuGetPackages>false</PrereleaseResolveNuGetPackages>
</PropertyGroup>
diff --git a/tests/src/Common/external/external.depproj b/tests/src/Common/external/external.depproj
index 51b36208b6..7a9725176a 100644
--- a/tests/src/Common/external/external.depproj
+++ b/tests/src/Common/external/external.depproj
@@ -21,6 +21,9 @@
<PackageReference Include="Microsoft.CodeAnalysis.Compilers">
<Version>1.1.1</Version>
</PackageReference>
+ <PackageReference Include="CommandLineParser">
+ <Version>2.1.1-beta</Version>
+ </PackageReference>
<PackageReference Include="xunit.performance.api">
<Version>$(XUnitPerformanceApiVersion)</Version>
</PackageReference>
@@ -71,6 +74,7 @@
<PackageToInclude Include="Microsoft.CodeAnalysis.Compilers"/>
<PackageToInclude Include="Microsoft.CodeAnalysis.CSharp"/>
<PackageToInclude Include="Microsoft.CodeAnalysis.VisualBasic"/>
+ <PackageToInclude Include="CommandLineParser"/>
<PackageToInclude Include="$(XUnitRunnerPackageId)" />
</ItemGroup>
diff --git a/tests/src/Common/targeting_pack_ref/targeting_pack_ref.csproj b/tests/src/Common/targeting_pack_ref/targeting_pack_ref.csproj
index 5f6e901bfe..45ef122d92 100644
--- a/tests/src/Common/targeting_pack_ref/targeting_pack_ref.csproj
+++ b/tests/src/Common/targeting_pack_ref/targeting_pack_ref.csproj
@@ -16,7 +16,7 @@
<TargetFramework>netcoreapp1.1</TargetFramework>
<TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier>
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50;portable-net45+win8</PackageTargetFallback>
- <RuntimeIdentifiers>$(TargetRid)</RuntimeIdentifiers>
+ <RuntimeIdentifiers>win-arm;win-arm64;win-x64;win-x86;$(TargetRid)</RuntimeIdentifiers>
<ContainsPackageReferences>true</ContainsPackageReferences>
<PrereleaseResolveNuGetPackages>false</PrereleaseResolveNuGetPackages>
</PropertyGroup>
diff --git a/tests/src/Common/test_dependencies/test_dependencies.csproj b/tests/src/Common/test_dependencies/test_dependencies.csproj
index 0e9426929f..9eefab2f10 100644
--- a/tests/src/Common/test_dependencies/test_dependencies.csproj
+++ b/tests/src/Common/test_dependencies/test_dependencies.csproj
@@ -27,7 +27,7 @@
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier>
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50;netcoreapp1.1;portable-net45+win8</PackageTargetFallback>
- <RuntimeIdentifiers>$(TargetRid)</RuntimeIdentifiers>
+ <RuntimeIdentifiers>win-arm;win-arm64;win-x64;win-x86;$(TargetRid)</RuntimeIdentifiers>
<ContainsPackageReferences>true</ContainsPackageReferences>
<PrereleaseResolveNuGetPackages>false</PrereleaseResolveNuGetPackages>
</PropertyGroup>
diff --git a/tests/src/Common/test_runtime/test_runtime.csproj b/tests/src/Common/test_runtime/test_runtime.csproj
index 05d9986132..a8ae626901 100644
--- a/tests/src/Common/test_runtime/test_runtime.csproj
+++ b/tests/src/Common/test_runtime/test_runtime.csproj
@@ -30,7 +30,7 @@
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier>
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50;portable-net45+win8</PackageTargetFallback>
- <RuntimeIdentifiers>$(TargetRid)</RuntimeIdentifiers>
+ <RuntimeIdentifiers>win-arm;win-arm64;win-x64;win-x86;$(TargetRid)</RuntimeIdentifiers>
<ContainsPackageReferences>true</ContainsPackageReferences>
<PrereleaseResolveNuGetPackages>false</PrereleaseResolveNuGetPackages>
</PropertyGroup>
diff --git a/tests/src/Interop/MarshalAPI/String/StringMarshalingTest.cs b/tests/src/Interop/MarshalAPI/String/StringMarshalingTest.cs
index 29ee83a8c0..2ec0a9c69b 100644
--- a/tests/src/Interop/MarshalAPI/String/StringMarshalingTest.cs
+++ b/tests/src/Interop/MarshalAPI/String/StringMarshalingTest.cs
@@ -231,6 +231,24 @@ public class StringMarshalingTest
}
}
+ private void TestNullString()
+ {
+ if (Marshal.PtrToStringUTF8(IntPtr.Zero) != null)
+ {
+ throw new Exception("IntPtr.Zero not marshaled to null for UTF8 strings");
+ }
+
+ if (Marshal.PtrToStringUni(IntPtr.Zero) != null)
+ {
+ throw new Exception("IntPtr.Zero not marshaled to null for Unicode strings");
+ }
+
+ if (Marshal.PtrToStringAnsi(IntPtr.Zero) != null)
+ {
+ throw new Exception("IntPtr.Zero not marshaled to null for ANSI strings");
+ }
+ }
+
public bool RunTests()
{
StringToBStrToString();
@@ -240,6 +258,7 @@ public class StringMarshalingTest
StringToHGlobalAnsiToString();
StringToHGlobalUniToString();
TestUTF8String();
+ TestNullString();
return true;
}
diff --git a/tests/src/JIT/CodeGenBringUpTests/StructReturn.cs b/tests/src/JIT/CodeGenBringUpTests/StructReturn.cs
new file mode 100644
index 0000000000..488c4b962a
--- /dev/null
+++ b/tests/src/JIT/CodeGenBringUpTests/StructReturn.cs
@@ -0,0 +1,420 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+
+using System;
+using System.Runtime.CompilerServices;
+
+// int
+public struct MyStructInt1
+{
+ public int int1;
+}
+
+public struct MyStructInt2
+{
+ public int int1;
+ public int int2;
+}
+
+public struct MyStructInt4
+{
+ public int int1;
+ public int int2;
+ public int int3;
+ public int int4;
+}
+
+// long
+public struct MyStructLong1
+{
+ public long long1;
+}
+
+public struct MyStructLong2
+{
+ public long long1;
+ public long long2;
+}
+
+public struct MyStructLong4
+{
+ public long long1;
+ public long long2;
+ public long long3;
+ public long long4;
+}
+
+// float
+public struct MyStructFloat1
+{
+ public float float1;
+}
+
+public struct MyStructFloat2
+{
+ public float float1;
+ public float float2;
+}
+
+public struct MyStructFloat3
+{
+ public float float1;
+ public float float2;
+ public float float3;
+}
+
+public struct MyStructFloat4
+{
+ public float float1;
+ public float float2;
+ public float float3;
+ public float float4;
+}
+
+public struct MyStructFloat5
+{
+ public float float1;
+ public float float2;
+ public float float3;
+ public float float4;
+ public float float5;
+}
+
+public struct MyStructFloat8
+{
+ public float float1;
+ public float float2;
+ public float float3;
+ public float float4;
+ public float float5;
+ public float float6;
+ public float float7;
+ public float float8;
+}
+
+// double
+public struct MyStructDouble1
+{
+ public double double1;
+}
+
+public struct MyStructDouble2
+{
+ public double double1;
+ public double double2;
+}
+
+public struct MyStructDouble3
+{
+ public double double1;
+ public double double2;
+ public double double3;
+}
+
+public struct MyStructDouble4
+{
+ public double double1;
+ public double double2;
+ public double double3;
+ public double double4;
+}
+
+public struct MyStructDouble5
+{
+ public double double1;
+ public double double2;
+ public double double3;
+ public double double4;
+ public double double5;
+}
+
+public struct MyStructDouble8
+{
+ public double double1;
+ public double double2;
+ public double double3;
+ public double double4;
+ public double double5;
+ public double double6;
+ public double double7;
+ public double double8;
+}
+
+public class BringUpTest
+{
+ const int Pass = 100;
+ const int Fail = -1;
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static MyStructInt1 returnMyStructInt1(int x)
+ {
+ MyStructInt1 s = new MyStructInt1();
+ s.int1 = x + 1;
+ return s;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static MyStructInt2 returnMyStructInt2(int x)
+ {
+ MyStructInt2 s = new MyStructInt2();
+ s.int1 = x + 1;
+ s.int2 = x + 2;
+ return s;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static MyStructInt4 returnMyStructInt4(int x)
+ {
+ MyStructInt4 s = new MyStructInt4();
+ s.int1 = x + 1;
+ s.int2 = x + 2;
+ s.int3 = x + 3;
+ s.int4 = x + 4;
+ return s;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static MyStructLong1 returnMyStructLong1(long x)
+ {
+ MyStructLong1 s = new MyStructLong1();
+ s.long1 = x + 1;
+ return s;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static MyStructLong2 returnMyStructLong2(long x)
+ {
+ MyStructLong2 s = new MyStructLong2();
+ s.long1 = x + 1;
+ s.long2 = x + 2;
+ return s;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static MyStructLong4 returnMyStructLong4(long x)
+ {
+ MyStructLong4 s = new MyStructLong4();
+ s.long1 = x + 1;
+ s.long2 = x + 2;
+ s.long3 = x + 3;
+ s.long4 = x + 4;
+ return s;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static MyStructFloat1 returnMyStructFloat1(float x)
+ {
+ MyStructFloat1 s = new MyStructFloat1();
+ s.float1 = x + 1.1f;
+ return s;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static MyStructFloat2 returnMyStructFloat2(float x)
+ {
+ MyStructFloat2 s = new MyStructFloat2();
+ s.float1 = x + 1.1f;
+ s.float2 = x + 2.1f;
+ return s;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static MyStructFloat3 returnMyStructFloat3(float x)
+ {
+ MyStructFloat3 s = new MyStructFloat3();
+ s.float1 = x + 1.1f;
+ s.float2 = x + 2.1f;
+ s.float3 = x + 3.1f;
+ return s;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static MyStructFloat4 returnMyStructFloat4(float x)
+ {
+ MyStructFloat4 s = new MyStructFloat4();
+ s.float1 = x + 1.1f;
+ s.float2 = x + 2.1f;
+ s.float3 = x + 3.1f;
+ s.float4 = x + 4.1f;
+ return s;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static MyStructFloat5 returnMyStructFloat5(float x)
+ {
+ MyStructFloat5 s = new MyStructFloat5();
+ s.float1 = x + 1.1f;
+ s.float2 = x + 2.1f;
+ s.float3 = x + 3.1f;
+ s.float4 = x + 4.1f;
+ s.float5 = x + 5.1f;
+ return s;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static MyStructFloat8 returnMyStructFloat8(float x)
+ {
+ MyStructFloat8 s = new MyStructFloat8();
+ s.float1 = x + 1.1f;
+ s.float2 = x + 2.1f;
+ s.float3 = x + 3.1f;
+ s.float4 = x + 4.1f;
+ s.float5 = x + 5.1f;
+ s.float6 = x + 6.1f;
+ s.float7 = x + 7.1f;
+ s.float8 = x + 8.1f;
+ return s;
+ }
+
+ // double
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static MyStructDouble1 returnMyStructDouble1(double x)
+ {
+ MyStructDouble1 s = new MyStructDouble1();
+ s.double1 = x + 1.1;
+ return s;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static MyStructDouble2 returnMyStructDouble2(double x)
+ {
+ MyStructDouble2 s = new MyStructDouble2();
+ s.double1 = x + 1.1;
+ s.double2 = x + 2.1;
+ return s;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static MyStructDouble3 returnMyStructDouble3(double x)
+ {
+ MyStructDouble3 s = new MyStructDouble3();
+ s.double1 = x + 1.1;
+ s.double2 = x + 2.1;
+ s.double3 = x + 3.1;
+ return s;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static MyStructDouble4 returnMyStructDouble4(double x)
+ {
+ MyStructDouble4 s = new MyStructDouble4();
+ s.double1 = x + 1.1;
+ s.double2 = x + 2.1;
+ s.double3 = x + 3.1;
+ s.double4 = x + 4.1;
+ return s;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static MyStructDouble5 returnMyStructDouble5(double x)
+ {
+ MyStructDouble5 s = new MyStructDouble5();
+ s.double1 = x + 1.1;
+ s.double2 = x + 2.1;
+ s.double3 = x + 3.1;
+ s.double4 = x + 4.1;
+ s.double5 = x + 5.1;
+ return s;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static MyStructDouble8 returnMyStructDouble8(double x)
+ {
+ MyStructDouble8 s = new MyStructDouble8();
+ s.double1 = x + 1.1;
+ s.double2 = x + 2.1;
+ s.double3 = x + 3.1;
+ s.double4 = x + 4.1;
+ s.double5 = x + 5.1;
+ s.double6 = x + 6.1;
+ s.double7 = x + 7.1;
+ s.double8 = x + 8.1;
+ return s;
+ }
+
+
+ public static int Main()
+ {
+ // int
+ MyStructInt1 sI1 = returnMyStructInt1(100);
+ if (sI1.int1 != 101) return Fail;
+ Console.WriteLine(sI1);
+
+ MyStructInt2 sI2 = returnMyStructInt2(200);
+ if (sI2.int1 != 201 || sI2.int2 != 202) return Fail;
+ Console.WriteLine(sI2);
+
+ MyStructInt4 sI4 = returnMyStructInt4(400);
+ if (sI4.int1 != 401 || sI4.int2 != 402 || sI4.int3 != 403 || sI4.int4 != 404) return Fail;
+ Console.WriteLine(sI4);
+
+ // long
+ MyStructLong1 sL1 = returnMyStructLong1(100);
+ if (sL1.long1 != 101) return Fail;
+ Console.WriteLine(sL1);
+
+ MyStructLong2 sL2 = returnMyStructLong2(200);
+ if (sL2.long1 != 201 || sL2.long2 != 202) return Fail;
+ Console.WriteLine(sL2);
+
+ MyStructLong4 sL4 = returnMyStructLong4(400);
+ if (sL4.long1 != 401 || sL4.long2 != 402 || sL4.long3 != 403 || sL4.long4 != 404) return Fail;
+ Console.WriteLine(sL4);
+
+
+ // float
+ MyStructFloat1 sF1 = returnMyStructFloat1(100.0f);
+ if (sF1.float1 != 101.1f) return Fail;
+ Console.WriteLine(sF1);
+
+ MyStructFloat2 sF2 = returnMyStructFloat2(200.0f);
+ if (sF2.float1 != 201.1f || sF2.float2 != 202.1f) return Fail;
+ Console.WriteLine(sF2);
+
+ MyStructFloat3 sF3 = returnMyStructFloat3(300.0f);
+ if (sF3.float1 != 301.1f || sF3.float2 != 302.1f || sF3.float3 != 303.1f) return Fail;
+ Console.WriteLine(sF3);
+
+ MyStructFloat4 sF4 = returnMyStructFloat4(400.0f);
+ if (sF4.float1 != 401.1f || sF4.float2 != 402.1f || sF4.float3 != 403.1f || sF4.float4 != 404.1f) return Fail;
+ Console.WriteLine(sF4);
+
+ MyStructFloat5 sF5 = returnMyStructFloat5(500.0f);
+ if (sF5.float1 != 501.1f || sF5.float2 != 502.1f || sF5.float3 != 503.1f || sF5.float4 != 504.1f || sF5.float5 != 505.1f) return Fail;
+ Console.WriteLine(sF5);
+
+ MyStructFloat8 sF8 = returnMyStructFloat8(800.0f);
+ if (sF8.float1 != 801.1f || sF8.float2 != 802.1f || sF8.float3 != 803.1f || sF8.float4 != 804.1f || sF8.float5 != 805.1f || sF8.float6 != 806.1f || sF8.float7 != 807.1f || sF8.float8 != 808.1f) return Fail;
+ Console.WriteLine(sF8);
+
+ // double
+ MyStructDouble1 sD1 = returnMyStructDouble1(100.0d);
+ if (sD1.double1 != 101.1d) return Fail;
+ Console.WriteLine(sD1);
+
+ MyStructDouble2 sD2 = returnMyStructDouble2(200.0d);
+ if (sD2.double1 != 201.1d || sD2.double2 != 202.1d) return Fail;
+ Console.WriteLine(sD2);
+
+ MyStructDouble3 sD3 = returnMyStructDouble3(300.0d);
+ if (sD3.double1 != 301.1d || sD3.double2 != 302.1d || sD3.double3 != 303.1d) return Fail;
+ Console.WriteLine(sD3);
+
+ MyStructDouble4 sD4 = returnMyStructDouble4(400.0d);
+ if (sD4.double1 != 401.1d || sD4.double2 != 402.1d || sD4.double3 != 403.1d || sD4.double4 != 404.1d) return Fail;
+ Console.WriteLine(sD4);
+
+ MyStructDouble5 sD5 = returnMyStructDouble5(500.0d);
+ if (sD5.double1 != 501.1d || sD5.double2 != 502.1d || sD5.double3 != 503.1d || sD5.double4 != 504.1d || sD5.double5 != 505.1d) return Fail;
+ Console.WriteLine(sD5);
+
+ MyStructDouble8 sD8 = returnMyStructDouble8(800.0d);
+ if (sD8.double1 != 801.1d || sD8.double2 != 802.1d || sD8.double3 != 803.1d || sD8.double4 != 804.1d || sD8.double5 != 805.1d || sD8.double6 != 806.1d || sD8.double7 != 807.1d || sD8.double8 != 808.1d) return Fail;
+ Console.WriteLine(sD8);
+
+ return Pass;
+ }
+}
diff --git a/tests/src/JIT/CodeGenBringUpTests/StructReturn.csproj b/tests/src/JIT/CodeGenBringUpTests/StructReturn.csproj
new file mode 100644
index 0000000000..c25676edbe
--- /dev/null
+++ b/tests/src/JIT/CodeGenBringUpTests/StructReturn.csproj
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{657784FD-AA42-4B81-B14E-FD667C00533C}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <CLRTestPriority>1</CLRTestPriority>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "></PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="StructReturn.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+</Project>
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/README.TXT b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/README.TXT
index b95d43c361..beec4d959b 100644
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/README.TXT
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/README.TXT
@@ -5,9 +5,13 @@ The benchmarks in these sub-directories are based on
See the adjoining LICENSE.TXT file for license terms.
-Our intention with these tests is to provide interesting test cases
-for jit developers to use in daily development practice -- not to
-produce variants that give the maximum possible performance.
+Our intention with these tests is twofold:
+ 1 - To track .NET Core's performance on these benchmarks in the
+ same benchmarking system used for other internal .NET Core
+ performance benchmarks.
+ 2 - To make these available for daily JIT (and runtime) development,
+ as a factor in assessing the performance impact of compiler
+ (and runtime) changes.
The benchmarks have been modified to fit into the CoreCLR test and
performance test framework, as follows:
@@ -19,19 +23,15 @@ performance test framework, as follows:
xunit-performance iteration is approximately 1 second on modern x64
hardware
- reducing verbosity when run as a benchmark
- - reformatting (via the codeformatter tool)
+ - calling different APIs in a few places to allow compiling against
+ netstandard1.4
+ - reformatting
+ - in the case of pidigits, implementing on top of .NET's BigInteger
+ type rather than p/invokes to the native GMP library
These benchmarks are just a subset of the benchmarks available in C# from
-the Benchmarks Game site. We've selected variants that do not rely on
-multiple threads to ensure relative benchmark stability across a
-variety of machines.
-
-We've excluded two benchmarks that are inherently multitheaded:
-chamenosredux and threadring. We may revisit this as we improve our
-ability to harness threading tests in a stable way.
-
-We've also excluded benchmarks that read in large input files:
-knucleotide, regexdna, revcomp.
-
-
-
+the Benchmarks Game site. The highest-scoring C# .NET Core variant of each
+benchmark is included, and in the (common) case of benchmarks where the
+best-scoring variant uses multiple threads, we've also selected variants
+that do not rely on multiple threads, to ensure relative benchmark stability
+across a variety of machines.
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/binarytrees/binarytrees-2.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/binarytrees/binarytrees-2.cs
new file mode 100644
index 0000000000..bf0b307721
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/binarytrees/binarytrees-2.cs
@@ -0,0 +1,122 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// Adapted from binary-trees C# .NET Core #2 program
+// http://benchmarksgame.alioth.debian.org/u64q/program.php?test=binarytrees&lang=csharpcore&id=2
+// aka (as of 2017-09-01) rev 1.3 of https://alioth.debian.org/scm/viewvc.php/benchmarksgame/bench/binarytrees/binarytrees.csharp-2.csharp?root=benchmarksgame&view=log
+// Best-scoring single-threaded C# .NET Core version as of 2017-09-01
+
+/* The Computer Language Benchmarks Game
+ http://benchmarksgame.alioth.debian.org/
+
+ contributed by Marek Safar
+ *reset*
+*/
+
+using System;
+using Microsoft.Xunit.Performance;
+
+[assembly: OptimizeForBenchmarks]
+[assembly: MeasureGCCounts]
+
+namespace BenchmarksGame
+{
+ public class BinaryTrees_2
+ {
+ const int minDepth = 4;
+
+ public static int Main(String[] args)
+ {
+ int n = 0;
+ if (args.Length > 0) n = Int32.Parse(args[0]);
+
+ int check = Bench(n, true);
+ int expected = 4398;
+
+ // Return 100 on success, anything else on failure.
+ return check - expected + 100;
+ }
+
+ [Benchmark(InnerIterationCount = 7)]
+ public static void RunBench()
+ {
+ Benchmark.Iterate(() => Bench(16, false));
+ }
+
+ static int Bench(int n, bool verbose)
+ {
+ int maxDepth = Math.Max(minDepth + 2, n);
+ int stretchDepth = maxDepth + 1;
+
+ int check = (TreeNode.bottomUpTree(stretchDepth)).itemCheck();
+ int checkSum = check;
+ if (verbose) Console.WriteLine("stretch tree of depth {0}\t check: {1}", stretchDepth, check);
+
+ TreeNode longLivedTree = TreeNode.bottomUpTree(maxDepth);
+
+ for (int depth = minDepth; depth <= maxDepth; depth += 2)
+ {
+ int iterations = 1 << (maxDepth - depth + minDepth);
+
+ check = 0;
+ for (int i = 1; i <= iterations; i++)
+ {
+ check += (TreeNode.bottomUpTree(depth)).itemCheck();
+ }
+ checkSum += check;
+
+ if (verbose)
+ Console.WriteLine("{0}\t trees of depth {1}\t check: {2}", iterations, depth, check);
+ }
+
+ check = longLivedTree.itemCheck();
+ checkSum += check;
+
+ if (verbose)
+ Console.WriteLine("long lived tree of depth {0}\t check: {1}", maxDepth, check);
+
+ return checkSum;
+ }
+
+
+ struct TreeNode
+ {
+ class Next
+ {
+ public TreeNode left, right;
+ }
+
+ private Next next;
+
+ internal static TreeNode bottomUpTree(int depth)
+ {
+ if (depth > 0)
+ {
+ return new TreeNode(
+ bottomUpTree(depth - 1)
+ , bottomUpTree(depth - 1)
+ );
+ }
+ else
+ {
+ return new TreeNode();
+ }
+ }
+
+ TreeNode(TreeNode left, TreeNode right)
+ {
+ this.next = new Next();
+ this.next.left = left;
+ this.next.right = right;
+ }
+
+ internal int itemCheck()
+ {
+ // if necessary deallocate here
+ if (next == null) return 1;
+ else return 1 + next.left.itemCheck() + next.right.itemCheck();
+ }
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/binarytrees/binarytrees.csproj b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/binarytrees/binarytrees-2.csproj
index d10772f2af..e032f83eb6 100644
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/binarytrees/binarytrees.csproj
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/binarytrees/binarytrees-2.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
@@ -31,7 +31,7 @@
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
- <Compile Include="binarytrees.csharp.cs" />
+ <Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
<PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/binarytrees/binarytrees-5.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/binarytrees/binarytrees-5.cs
new file mode 100644
index 0000000000..6b4e092b0e
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/binarytrees/binarytrees-5.cs
@@ -0,0 +1,147 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// Adapted from binary-trees C# .NET Core #5 program
+// http://benchmarksgame.alioth.debian.org/u64q/program.php?test=binarytrees&lang=csharpcore&id=5
+// aka (as of 2017-09-01) rev 1.1 of https://alioth.debian.org/scm/viewvc.php/benchmarksgame/bench/binarytrees/binarytrees.csharp-5.csharp?root=benchmarksgame&view=log
+// Best-scoring C# .NET Core version as of 2017-09-01
+
+/* The Computer Language Benchmarks Game
+ http://benchmarksgame.alioth.debian.org/
+
+ contributed by Marek Safar
+ *reset*
+ concurrency added by Peperud
+ minor improvements by Alex Yakunin
+*/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+using Microsoft.Xunit.Performance;
+
+[assembly: OptimizeForBenchmarks]
+[assembly: MeasureGCCounts]
+
+namespace BenchmarksGame
+{
+ public sealed class BinaryTrees_5
+ {
+ public const int MinDepth = 4;
+
+ public static int Main(string[] args)
+ {
+ var n = args.Length == 0 ? 0 : int.Parse(args[0]);
+
+ int check = Bench(n, true);
+ int expected = 4398;
+
+ // Return 100 on success, anything else on failure.
+ return check - expected + 100;
+ }
+
+ [Benchmark(InnerIterationCount = 7)]
+ public static void RunBench()
+ {
+ Benchmark.Iterate(() => Bench(16, false));
+ }
+
+ static int Bench(int n, bool verbose)
+ {
+ var maxDepth = n < (MinDepth + 2) ? MinDepth + 2 : n;
+ var stretchDepth = maxDepth + 1;
+
+ var stretchDepthTask = Task.Run(() => TreeNode.CreateTree(stretchDepth).CountNodes());
+ var maxDepthTask = Task.Run(() => TreeNode.CreateTree(maxDepth).CountNodes());
+
+ var tasks = new Task<string>[(maxDepth - MinDepth) / 2 + 1];
+ for (int depth = MinDepth, ti = 0; depth <= maxDepth; depth += 2, ti++)
+ {
+ var iterationCount = 1 << (maxDepth - depth + MinDepth);
+ var depthCopy = depth; // To make sure closure value doesn't change
+ tasks[ti] = Task.Run(() =>
+ {
+ var count = 0;
+ if (depthCopy >= 17)
+ {
+ // Parallelized computation for relatively large tasks
+ var miniTasks = new Task<int>[iterationCount];
+ for (var i = 0; i < iterationCount; i++)
+ miniTasks[i] = Task.Run(() => TreeNode.CreateTree(depthCopy).CountNodes());
+ Task.WaitAll(miniTasks);
+ for (var i = 0; i < iterationCount; i++)
+ count += miniTasks[i].Result;
+ }
+ else
+ {
+ // Sequential computation for smaller tasks
+ for (var i = 0; i < iterationCount; i++)
+ count += TreeNode.CreateTree(depthCopy).CountNodes();
+ }
+ return $"{iterationCount}\t trees of depth {depthCopy}\t check: {count}";
+ });
+ }
+ Task.WaitAll(tasks);
+
+ if (verbose)
+ {
+ int count = 0;
+ Action<string> printAndSum = (string s) =>
+ {
+ Console.WriteLine(s);
+ count += int.Parse(s.Substring(s.LastIndexOf(':') + 1).TrimStart());
+ };
+
+ printAndSum(String.Format("stretch tree of depth {0}\t check: {1}",
+ stretchDepth, stretchDepthTask.Result));
+ foreach (var task in tasks)
+ printAndSum(task.Result);
+ printAndSum(String.Format("long lived tree of depth {0}\t check: {1}",
+ maxDepth, maxDepthTask.Result));
+
+ return count;
+ }
+
+ return 0;
+ }
+ }
+
+ public struct TreeNode
+ {
+ public sealed class NodeData
+ {
+ public TreeNode Left, Right;
+
+ public NodeData(TreeNode left, TreeNode right)
+ {
+ Left = left;
+ Right = right;
+ }
+ }
+
+ public NodeData Data;
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public TreeNode(TreeNode left, TreeNode right)
+ {
+ Data = new NodeData(left, right);
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static TreeNode CreateTree(int depth)
+ {
+ return depth <= 0
+ ? default(TreeNode)
+ : new TreeNode(CreateTree(depth - 1), CreateTree(depth - 1));
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public int CountNodes()
+ {
+ if (ReferenceEquals(Data, null))
+ return 1;
+ return 1 + Data.Left.CountNodes() + Data.Right.CountNodes();
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/binarytrees/binarytrees3.csproj b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/binarytrees/binarytrees-5.csproj
index 3dffd5e4bf..e032f83eb6 100644
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/binarytrees/binarytrees3.csproj
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/binarytrees/binarytrees-5.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
@@ -31,7 +31,7 @@
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
- <Compile Include="binarytrees.csharp3.cs" />
+ <Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
<PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/binarytrees/binarytrees.csharp.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/binarytrees/binarytrees.csharp.cs
deleted file mode 100644
index 6e44629499..0000000000
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/binarytrees/binarytrees.csharp.cs
+++ /dev/null
@@ -1,154 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-/* The Computer Language Benchmarks Game
- http://benchmarksgame.alioth.debian.org/
-
- contributed by Marek Safar
-
- modified for use with xunit-performance
-*/
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-[assembly: MeasureGCCounts]
-
-namespace BenchmarksGame
-{
-public class BinaryTrees
-{
- private const int minDepth = 4;
- private const int Iterations = 1;
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static bool Bench(bool verbose = false)
- {
- int n = 16;
- int maxDepth = Math.Max(minDepth + 2, n);
- int stretchDepth = maxDepth + 1;
- int t = 0;
-
- int check = (TreeNode.bottomUpTree(0, stretchDepth)).itemCheck();
- if (verbose)
- {
- Console.WriteLine("stretch tree of depth {0}\t check: {1}", stretchDepth, check);
- }
- t += check;
-
- TreeNode longLivedTree = TreeNode.bottomUpTree(0, maxDepth);
-
- for (int depth = minDepth; depth <= maxDepth; depth += 2)
- {
- int iterations = 1 << (maxDepth - depth + minDepth);
-
- check = 0;
- for (int i = 1; i <= iterations; i++)
- {
- check += (TreeNode.bottomUpTree(i, depth)).itemCheck();
- check += (TreeNode.bottomUpTree(-i, depth)).itemCheck();
- }
-
- if (verbose)
- {
- Console.WriteLine("{0}\t trees of depth {1}\t check: {2}",
- iterations * 2, depth, check);
- }
-
- t += check;
- }
-
- if (verbose)
- {
- Console.WriteLine("long lived tree of depth {0}\t check: {1}",
- maxDepth, longLivedTree.itemCheck());
- }
-
- t += check;
-
- return (t == -174785);
- }
-
- private struct TreeNode
- {
- private class Next
- {
- public TreeNode left, right;
- }
-
- private Next _next;
- private int _item;
-
- private TreeNode(int item)
- {
- _item = item;
- _next = null;
- }
-
- internal static TreeNode bottomUpTree(int item, int depth)
- {
- if (depth > 0)
- {
- return new TreeNode(
- bottomUpTree(2 * item - 1, depth - 1)
- , bottomUpTree(2 * item, depth - 1)
- , item
- );
- }
- else
- {
- return new TreeNode(item);
- }
- }
-
- private TreeNode(TreeNode left, TreeNode right, int item)
- {
- _next = new Next();
- _next.left = left;
- _next.right = right;
- _item = item;
- }
-
- internal int itemCheck()
- {
- // if necessary deallocate here
- if (_next == null) return _item;
- else return _item + _next.left.itemCheck() - _next.right.itemCheck();
- }
- }
-
- [Benchmark]
- public static void Test()
- {
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- for (int i = 0; i < Iterations; i++)
- {
- Bench();
- }
- }
- }
- }
-
- private static bool TestBase()
- {
- bool result = true;
- for (int i = 0; i < Iterations; i++)
- {
- result &= Bench(true);
- }
- return result;
- }
-
- public static int Main()
- {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/binarytrees/binarytrees.csharp3.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/binarytrees/binarytrees.csharp3.cs
deleted file mode 100644
index 0cc239274b..0000000000
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/binarytrees/binarytrees.csharp3.cs
+++ /dev/null
@@ -1,141 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-/* The Computer Language Benchmarks Game
- http://benchmarksgame.alioth.debian.org/
-
- Based on code originally contributed by Marek Safar
- and optimized by kasthack
-
- modified for use with xunit-performance
-*/
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-[assembly: MeasureGCCounts]
-
-namespace BenchmarksGame
-{
-public class BinaryTrees3
-{
- private const int minDepth = 4;
- private const int Iterations = 1;
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static bool Bench(bool verbose = false)
- {
- int n = 16;
- int maxDepth = Math.Max(minDepth + 2, n);
- int stretchDepth = maxDepth + 1;
- int t = 0;
-
- int check = (TreeNode.bottomUpTree(0, stretchDepth)).itemCheck();
- if (verbose)
- {
- Console.WriteLine("stretch tree of depth {0}\t check: {1}", stretchDepth, check);
- }
- t += check;
-
- TreeNode longLivedTree = TreeNode.bottomUpTree(0, maxDepth);
-
- for (int depth = minDepth; depth <= maxDepth; depth += 2)
- {
- int iterations = 1 << (maxDepth - depth + minDepth);
-
- check = 0;
- for (int i = 1; i <= iterations; i++)
- {
- check += (TreeNode.bottomUpTree(i, depth)).itemCheck();
- check += (TreeNode.bottomUpTree(-i, depth)).itemCheck();
- }
-
- if (verbose)
- {
- Console.WriteLine("{0}\t trees of depth {1}\t check: {2}",
- iterations * 2, depth, check);
- }
-
- t += check;
- }
-
- if (verbose)
- {
- Console.WriteLine("long lived tree of depth {0}\t check: {1}",
- maxDepth, longLivedTree.itemCheck());
- }
-
- t += check;
-
- return (t == -174785);
- }
-
- private class TreeNode
- {
- private TreeNode left, right;
- private int item;
-
- private TreeNode(int item)
- {
- this.item = item;
- }
-
- internal static TreeNode bottomUpTree(int item, int depth)
- {
- TreeNode t;
- ChildTreeNodes(out t, item, depth - 1);
- return t;
- }
-
- static void ChildTreeNodes(out TreeNode node, int item, int depth)
- {
- node = new TreeNode(item);
- if ( depth > 0 )
- {
- ChildTreeNodes(out node.left, 2 * item - 1, depth - 1);
- ChildTreeNodes(out node.right, 2 * item, depth - 1);
- }
- }
-
- internal int itemCheck()
- {
- if (right == null) return item;
- else return item + left.itemCheck() - right.itemCheck();
- }
- }
-
- [Benchmark]
- public static void Test()
- {
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- for (int i = 0; i < Iterations; i++)
- {
- Bench();
- }
- }
- }
- }
-
- private static bool TestBase()
- {
- bool result = true;
- for (int i = 0; i < Iterations; i++)
- {
- result &= Bench(true);
- }
- return result;
- }
-
- public static int Main()
- {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fannkuch-redux/fannkuch-redux.csharp.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fannkuch-redux/fannkuch-redux-2.cs
index ea7a189e0b..f7a8154ee7 100644
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fannkuch-redux/fannkuch-redux.csharp.cs
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fannkuch-redux/fannkuch-redux-2.cs
@@ -1,29 +1,29 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+
+// Adapted from fannkuch-redux C# .NET Core #2 program
+// http://benchmarksgame.alioth.debian.org/u64q/program.php?test=fannkuchredux&lang=csharpcore&id=2
+// aka (as of 2017-09-01) rev 1.2 of https://alioth.debian.org/scm/viewvc.php/benchmarksgame/bench/fannkuchredux/fannkuchredux.csharp-2.csharp?root=benchmarksgame&view=log
+// Best-scoring single-threaded C# .NET Core version as of 2017-09-01
+
/* The Computer Language Benchmarks Game
http://benchmarksgame.alioth.debian.org/
- contributed by Isaac Gouy, transliterated from Mike Pall's Lua program
-
- posted to Benchmarks Game as fannkuck-redux C# .NET Core #2
- (http://benchmarksgame.alioth.debian.org/u64q/program.php?test=fannkuchredux&lang=csharpcore&id=2)
- modified for use with xunit-performance
+ contributed by Isaac Gouy, transliterated from Mike Pall's Lua program
*/
-using System.Reflection;
-using System.Runtime.CompilerServices;
+using System;
using Microsoft.Xunit.Performance;
-using Microsoft.Xunit.Performance.Api;
using Xunit;
+[assembly: OptimizeForBenchmarks]
+
namespace BenchmarksGame
{
- public class FannkuchRedux
+ public class FannkuchRedux_2
{
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static int[] Bench(int n, bool verbose = false)
+ public static int[] fannkuch(int n)
{
int[] p = new int[n], q = new int[n], s = new int[n];
int sign = 1, maxflips = 0, sum = 0, m = n - 1;
@@ -76,45 +76,27 @@ namespace BenchmarksGame
} while (true);
}
- // Commented out data left in source to provide checksums for each case
- // Checksums calculated from the origonal source referenced at top of this source
-
- [Benchmark(InnerIterationCount = 7)]
- //[InlineData(7, 228)]
- //[InlineData(8, 1616)]
- //[InlineData(9, 8629)]
- [InlineData(10, 73196)]
- //[InlineData(11, 556355)]
- //[InlineData(12, 3968050)]
- public static void Test(int n, int checksum)
+ static int Main(string[] args)
{
- foreach (var iteration in Benchmark.Iterations)
- {
- int[] pfannkuchen = null;
- using (iteration.StartMeasurement())
- {
- for (int i = 0; i < Benchmark.InnerIterationCount; ++i)
- {
- pfannkuchen = Bench(n);
- }
- }
- Assert.Equal(checksum, pfannkuchen[0]);
- }
- }
+ int n = (args.Length > 0) ? Int32.Parse(args[0]) : 7;
+ var pf = fannkuch(n);
+ Console.Write("{0}\nPfannkuchen({1}) = {2}\n", pf[0], n, pf[1]);
- public static bool VerifyBench(int n, int checksum)
- {
- int[] pfannkuchen = Bench(n);
- return pfannkuchen[0] == checksum;
+ int expected = 228;
+
+ // Return 100 on success, anything else on failure.
+ return pf[0] - expected + 100;
}
- public static int Main(string[] args)
+ [Benchmark(InnerIterationCount = 7)]
+ [InlineData(10, 73196)]
+ public static void RunBench(int n, int expectedSum)
{
- const int n = 7;
- const int checksum = 228;
-
- bool verified = VerifyBench(n, checksum);
- return (verified ? 100 : -1);
+ Benchmark.Iterate(() =>
+ {
+ var pf = fannkuch(n);
+ Assert.Equal(expectedSum, pf[0]);
+ });
}
}
}
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fasta/fasta.csproj b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fannkuch-redux/fannkuch-redux-2.csproj
index 5d5c7f72c6..56d2c065b9 100644
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fasta/fasta.csproj
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fannkuch-redux/fannkuch-redux-2.csproj
@@ -5,7 +5,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <ProjectGuid>{E4AA647E-10E6-40E1-BD01-3BA97AA204BC}</ProjectGuid>
<OutputType>Exe</OutputType>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
@@ -28,7 +28,7 @@
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
- <Compile Include="fasta.csharp-2.cs" />
+ <Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
<PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fannkuch-redux/fannkuch-redux-5.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fannkuch-redux/fannkuch-redux-5.cs
new file mode 100644
index 0000000000..562a62468f
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fannkuch-redux/fannkuch-redux-5.cs
@@ -0,0 +1,158 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// Adapted from fannkuch-redux C# .NET Core #5 program
+// http://benchmarksgame.alioth.debian.org/u64q/program.php?test=fannkuchredux&lang=csharpcore&id=5
+// aka (as of 2017-09-01) rev 1.6 of https://alioth.debian.org/scm/viewvc.php/benchmarksgame/bench/fannkuchredux/fannkuchredux.csharp-5.csharp?root=benchmarksgame&view=log
+// Best-scoring C# .NET Core version as of 2017-09-01
+
+/* The Computer Language Benchmarks Game
+ http://benchmarksgame.alioth.debian.org/
+
+ contributed by Isaac Gouy, transliterated from Oleg Mazurov's Java program
+ concurrency fix and minor improvements by Peperud
+ parallel and small optimisations by Anthony Lloyd
+*/
+
+using System;
+using System.Threading;
+using System.Runtime.CompilerServices;
+using Microsoft.Xunit.Performance;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace BenchmarksGame
+{
+ public static class FannkuchRedux_5
+ {
+ static int[] fact, chkSums, maxFlips;
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ static void firstPermutation(int[] p, int[] pp, int[] count, int idx)
+ {
+ for (int i = 0; i < p.Length; ++i) p[i] = i;
+ for (int i = count.Length - 1; i > 0; --i)
+ {
+ int d = idx / fact[i];
+ count[i] = d;
+ if (d > 0)
+ {
+ idx = idx % fact[i];
+ for (int j = i; j >= 0; --j) pp[j] = p[j];
+ for (int j = 0; j <= i; ++j) p[j] = pp[(j + d) % (i + 1)];
+ }
+ }
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ static int nextPermutation(int[] p, int[] count)
+ {
+ int first = p[1];
+ p[1] = p[0];
+ p[0] = first;
+ int i = 1;
+ while (++count[i] > i)
+ {
+ count[i++] = 0;
+ int next = p[1];
+ p[0] = next;
+ for (int j = 1; j < i;) p[j] = p[++j];
+ p[i] = first;
+ first = next;
+ }
+ return first;
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ static int countFlips(int first, int[] p, int[] pp)
+ {
+ if (first == 0) return 0;
+ if (p[first] == 0) return 1;
+ for (int i = 0; i < pp.Length; i++) pp[i] = p[i];
+ int flips = 2;
+ while (true)
+ {
+ for (int lo = 1, hi = first - 1; lo < hi; lo++, hi--)
+ {
+ int t = pp[lo];
+ pp[lo] = pp[hi];
+ pp[hi] = t;
+ }
+ int tp = pp[first];
+ if (pp[tp] == 0) return flips;
+ pp[first] = first;
+ first = tp;
+ flips++;
+ }
+ }
+
+ static void run(int n, int taskId, int taskSize)
+ {
+ int[] p = new int[n], pp = new int[n], count = new int[n];
+ firstPermutation(p, pp, count, taskId * taskSize);
+ int chksum = countFlips(p[0], p, pp);
+ int maxflips = chksum;
+ while (--taskSize > 0)
+ {
+ var flips = countFlips(nextPermutation(p, count), p, pp);
+ chksum += (1 - (taskSize % 2) * 2) * flips;
+ if (flips > maxflips) maxflips = flips;
+ }
+ chkSums[taskId] = chksum;
+ maxFlips[taskId] = maxflips;
+ }
+
+ public static int Main(string[] args)
+ {
+ int n = args.Length > 0 ? int.Parse(args[0]) : 7;
+ int sum = Bench(n, true);
+
+ int expected = 16;
+
+ // Return 100 on success, anything else on failure.
+ return sum - expected + 100;
+ }
+
+ [Benchmark(InnerIterationCount = 20)]
+ [InlineData(10, 38)]
+ public static void RunBench(int n, int expectedSum)
+ {
+ Benchmark.Iterate(() =>
+ {
+ int sum = Bench(n, false);
+ Assert.Equal(expectedSum, sum);
+ });
+ }
+
+ static int Bench(int n, bool verbose)
+ {
+ fact = new int[n + 1];
+ fact[0] = 1;
+ var factn = 1;
+ for (int i = 1; i < fact.Length; i++) { fact[i] = factn *= i; }
+
+ int nTasks = Environment.ProcessorCount;
+ chkSums = new int[nTasks];
+ maxFlips = new int[nTasks];
+ int taskSize = factn / nTasks;
+ var threads = new Thread[nTasks];
+ for (int i = 1; i < nTasks; i++)
+ {
+ int j = i;
+ (threads[j] = new Thread(() => run(n, j, taskSize))).Start();
+ }
+ run(n, 0, taskSize);
+ int chksum = chkSums[0], maxflips = maxFlips[0];
+ for (int i = 1; i < threads.Length; i++)
+ {
+ threads[i].Join();
+ chksum += chkSums[i];
+ if (maxFlips[i] > maxflips) maxflips = maxFlips[i];
+ }
+ if (verbose) Console.Out.WriteLineAsync(chksum + "\nPfannkuchen(" + n + ") = " + maxflips);
+
+ return maxflips;
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/nbody/nbody.csproj b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fannkuch-redux/fannkuch-redux-5.csproj
index 5df299a93e..147e656df5 100644
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/nbody/nbody.csproj
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fannkuch-redux/fannkuch-redux-5.csproj
@@ -5,7 +5,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <ProjectGuid>{F49D82D3-9D13-47B5-83F8-52B1FE3FF452}</ProjectGuid>
<OutputType>Exe</OutputType>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
@@ -28,11 +28,11 @@
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
- <Compile Include="nbody.csharp-3.cs" />
+ <Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
<PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
<PropertyGroup>
<ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
</PropertyGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fasta/fasta-1.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fasta/fasta-1.cs
new file mode 100644
index 0000000000..0535c21adf
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fasta/fasta-1.cs
@@ -0,0 +1,307 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// Adapted from fasta C# .NET Core program
+// http://benchmarksgame.alioth.debian.org/u64q/program.php?test=fasta&lang=csharpcore&id=1
+// aka (as of 2017-09-01) rev 1.1 of https://alioth.debian.org/scm/viewvc.php/benchmarksgame/bench/fasta/fasta.csharp?root=benchmarksgame&view=log
+// Best-scoring C# .NET Core version as of 2017-09-01
+
+/* The Computer Language Benchmarks Game
+ http://benchmarksgame.alioth.debian.org/
+
+ contributed by Serge Smith
+ further optimized (rewrote threading, random generation loop) by Jan de Vaan
+ modified by Josh Goldfoot (fasta-repeat buffering)
+*/
+
+using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.Xunit.Performance;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace BenchmarksGame
+{
+ public class Fasta_1
+ {
+ const int LineLength = 60;
+
+ const int IM = 139968;
+ const int IA = 3877;
+ const int IC = 29573;
+ static int seed = 42;
+
+ public static int Main(string[] args)
+ {
+ int n = args.Length > 0 ? Int32.Parse(args[0]) : 1000;
+
+ Bench(n, true);
+ return 100;
+ }
+
+ [Benchmark(InnerIterationCount = 4000)]
+ public static void RunBench()
+ {
+ Benchmark.Iterate(() => Bench(5000, false));
+ }
+
+ static void Bench(int n, bool verbose)
+ {
+ MakeCumulative(IUB);
+ MakeCumulative(HomoSapiens);
+
+ using (var s = (verbose ? Console.OpenStandardOutput() : Stream.Null))
+ {
+ MakeRepeatFasta("ONE", "Homo sapiens alu", Encoding.ASCII.GetBytes(ALU), n * 2, s);
+ MakeRandomFasta("TWO", "IUB ambiguity codes", IUB, n * 3, s);
+ MakeRandomFasta("THREE", "Homo sapiens frequency", HomoSapiens, n * 5, s);
+ }
+ }
+
+
+
+ public static IEnumerable<R> TransformQueue<T, R>(BlockingCollection<T> queue,
+ Func<T, R> transform, int threadCount)
+ {
+ var tasks = new Task<R>[threadCount];
+
+ for (int i = 0; i < threadCount; ++i)
+ {
+ T input;
+ if (!queue.TryTake(out input, Timeout.Infinite))
+ break;
+
+ tasks[i] = Task.Run(() => transform(input));
+ }
+
+ int pos = 0;
+ while (true)
+ {
+ if (tasks[pos] == null)
+ break;
+
+ yield return tasks[pos].Result;
+
+ T input;
+ tasks[pos] = queue.TryTake(out input, Timeout.Infinite)
+ ? Task.Run(() => transform(input))
+ : null;
+
+ pos = (pos + 1) % threadCount;
+ }
+ }
+
+
+
+ static void MakeRandomFasta(string id, string desc,
+ Frequency[] a, int n, Stream s)
+ {
+ var queue = new BlockingCollection<int[]>(2);
+
+ var bufferCount = Environment.ProcessorCount + 4;
+
+ Task.Run(() =>
+ {
+ var len = LineLength * 40;
+ var buffers = Enumerable.Range(0, bufferCount)
+ .Select(i => new int[len]).ToArray();
+ var index = 0;
+ for (var i = 0; i < n; i += len)
+ {
+ var buffer = n - i < len
+ ? new int[n - i]
+ : buffers[index++ % buffers.Length];
+
+ FillRandom(buffer);
+ queue.Add(buffer);
+ }
+ queue.CompleteAdding();
+ });
+
+ byte[] descStr = Encoding.ASCII.GetBytes(">" + id + " " + desc + "\n");
+ s.Write(descStr, 0, descStr.Length);
+
+ foreach (var r in TransformQueue(queue,
+ rnd => SelectNucleotides(a, rnd), Environment.ProcessorCount))
+ {
+ s.Write(r, 0, r.Length);
+ }
+
+ }
+
+ private static byte[] SelectNucleotides(Frequency[] a, int[] rnd)
+ {
+ var resLength = (rnd.Length / LineLength) * (LineLength + 1);
+ if (rnd.Length % LineLength != 0)
+ {
+ resLength += rnd.Length % LineLength + 1;
+ }
+
+ var buf = new byte[resLength];
+ var index = 0;
+ for (var i = 0; i < rnd.Length; i += LineLength)
+ {
+ var len = Math.Min(LineLength, rnd.Length - i);
+ for (var j = 0; j < len; ++j)
+ buf[index++] = SelectRandom(a, (int)rnd[i + j]);
+ buf[index++] = (byte)'\n';
+ }
+ return buf;
+ }
+
+ static void MakeRepeatFasta(string id, string desc,
+ byte[] alu, int n, Stream s)
+ {
+ byte[] descStr = Encoding.ASCII.GetBytes(">" + id + " " + desc + "\n");
+ s.Write(descStr, 0, descStr.Length);
+
+ /* JG: fasta_repeat repeats every len(alu) * line-length = 287 * 61 = 17507 characters.
+ So, calculate this once, then just print that buffer over and over. */
+
+ byte[] sequence;
+ int sequenceLength;
+ using (var unstandardOut = new MemoryStream(alu.Length * (LineLength + 1) + 1))
+ {
+ MakeRepeatFastaBuffer(alu, alu.Length * LineLength, unstandardOut);
+ sequenceLength = (int)unstandardOut.Length;
+ sequence = new byte[sequenceLength];
+ unstandardOut.Seek(0, SeekOrigin.Begin);
+ unstandardOut.Read(sequence, 0, sequenceLength);
+ }
+ int outputBytes = n + n / 60;
+ while (outputBytes >= sequenceLength)
+ {
+ s.Write(sequence, 0, sequenceLength);
+ outputBytes -= sequenceLength;
+ }
+ if (outputBytes > 0)
+ {
+ s.Write(sequence, 0, outputBytes);
+ s.WriteByte((byte)'\n');
+ }
+ }
+
+ static void MakeRepeatFastaBuffer(byte[] alu, int n, Stream s)
+ {
+ var index = 0;
+ int m = 0;
+ int k = 0;
+ int kn = alu.Length;
+ var buf = new byte[1024];
+
+ while (n > 0)
+ {
+ m = n < LineLength ? n : LineLength;
+
+ if (buf.Length - index < m)
+ {
+ s.Write(buf, 0, index);
+ index = 0;
+ }
+
+ for (int i = 0; i < m; i++)
+ {
+ if (k == kn)
+ k = 0;
+
+ buf[index++] = alu[k];
+ k++;
+ }
+
+ buf[index++] = (byte)'\n';
+ n -= LineLength;
+ }
+
+ if (index != 0)
+ s.Write(buf, 0, index);
+ }
+
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ static byte SelectRandom(Frequency[] a, int r)
+ {
+ for (int i = 0; i < a.Length - 1; i++)
+ if (r < a[i].p)
+ return a[i].c;
+
+ return a[a.Length - 1].c;
+ }
+
+ static void MakeCumulative(Frequency[] a)
+ {
+ double cp = 0;
+ for (int i = 0; i < a.Length; i++)
+ {
+ cp += a[i].p;
+ a[i].p = cp;
+ }
+ }
+
+ static string ALU =
+ "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG" +
+ "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA" +
+ "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT" +
+ "ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA" +
+ "GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG" +
+ "AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC" +
+ "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA";
+
+ struct Frequency
+ {
+ public readonly byte c;
+ public double p;
+
+ public Frequency(char c, double p)
+ {
+ this.c = (byte)c;
+ this.p = (p * IM);
+ }
+ }
+
+ static Frequency[] IUB = {
+ new Frequency ('a', 0.27),
+ new Frequency ('c', 0.12),
+ new Frequency ('g', 0.12),
+ new Frequency ('t', 0.27),
+
+ new Frequency ('B', 0.02),
+ new Frequency ('D', 0.02),
+ new Frequency ('H', 0.02),
+ new Frequency ('K', 0.02),
+ new Frequency ('M', 0.02),
+ new Frequency ('N', 0.02),
+ new Frequency ('R', 0.02),
+ new Frequency ('S', 0.02),
+ new Frequency ('V', 0.02),
+ new Frequency ('W', 0.02),
+ new Frequency ('Y', 0.02)
+ };
+
+ static Frequency[] HomoSapiens = {
+ new Frequency ('a', 0.3029549426680),
+ new Frequency ('c', 0.1979883004921),
+ new Frequency ('g', 0.1975473066391),
+ new Frequency ('t', 0.3015094502008)
+ };
+
+
+ private static void FillRandom(int[] result)
+ {
+ var s = seed;
+ for (var i = 0; i < result.Length; i++)
+ {
+ s = (s * IA + IC) % IM;
+ result[i] = s;
+ }
+ seed = s;
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fannkuch-redux/fannkuch-redux.csproj b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fasta/fasta-1.csproj
index aed483ba91..8deda2377e 100644
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fannkuch-redux/fannkuch-redux.csproj
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fasta/fasta-1.csproj
@@ -5,7 +5,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <ProjectGuid>{E85110FB-64D0-44E7-B040-1862B62A6EAC}</ProjectGuid>
<OutputType>Exe</OutputType>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
@@ -28,7 +28,7 @@
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
- <Compile Include="fannkuch-redux.csharp.cs" />
+ <Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
<PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fasta/fasta-2.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fasta/fasta-2.cs
new file mode 100644
index 0000000000..3694e5de47
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fasta/fasta-2.cs
@@ -0,0 +1,210 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// Adapted from fasta C# .NET Core #2 program
+// http://benchmarksgame.alioth.debian.org/u64q/program.php?test=fasta&lang=csharpcore&id=2
+// aka (as of 2017-09-01) rev 1.2 of https://alioth.debian.org/scm/viewvc.php/benchmarksgame/bench/fasta/fasta.csharp-2.csharp?root=benchmarksgame&view=log
+// Best-scoring single-threaded C# .NET Core version as of 2017-09-01
+
+/* The Computer Language Benchmarks Game
+ http://benchmarksgame.alioth.debian.org/
+
+ contributed by Isaac Gouy
+ optimizations by Alp Toker <alp@atoker.com>
+*/
+
+using System;
+using System.IO;
+using System.Text;
+using Microsoft.Xunit.Performance;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace BenchmarksGame
+{
+ public class Fasta_2
+ {
+ static int Main(string[] args)
+ {
+ int n = args.Length > 0 ? Int32.Parse(args[0]) : 1000;
+
+ Bench(n, true);
+ return 100;
+ }
+
+ [Benchmark(InnerIterationCount = 2500)]
+ public static void RunBench()
+ {
+ Benchmark.Iterate(() => Bench(5000, false));
+ }
+
+ static void Bench(int n, bool verbose)
+ {
+ MakeCumulative(HomoSapiens);
+ MakeCumulative(IUB);
+
+ using (Stream s = (verbose ? Console.OpenStandardOutput() : Stream.Null))
+ {
+ MakeRepeatFasta("ONE", "Homo sapiens alu", Encoding.ASCII.GetBytes(ALU), n * 2, s);
+ MakeRandomFasta("TWO", "IUB ambiguity codes", IUB, n * 3, s);
+ MakeRandomFasta("THREE", "Homo sapiens frequency", HomoSapiens, n * 5, s);
+ }
+ }
+
+ // The usual pseudo-random number generator
+
+ const int IM = 139968;
+ const int IA = 3877;
+ const int IC = 29573;
+ static int seed = 42;
+
+ static double random(double max)
+ {
+ return max * ((seed = (seed * IA + IC) % IM) * (1.0 / IM));
+ }
+
+ // Weighted selection from alphabet
+
+ static string ALU =
+ "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG" +
+ "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA" +
+ "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT" +
+ "ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA" +
+ "GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG" +
+ "AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC" +
+ "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA";
+
+ class Frequency
+ {
+ public byte c;
+ public double p;
+
+ public Frequency(char c, double p)
+ {
+ this.c = (byte)c;
+ this.p = p;
+ }
+ }
+
+ static Frequency[] IUB = {
+ new Frequency ('a', 0.27),
+ new Frequency ('c', 0.12),
+ new Frequency ('g', 0.12),
+ new Frequency ('t', 0.27),
+
+ new Frequency ('B', 0.02),
+ new Frequency ('D', 0.02),
+ new Frequency ('H', 0.02),
+ new Frequency ('K', 0.02),
+ new Frequency ('M', 0.02),
+ new Frequency ('N', 0.02),
+ new Frequency ('R', 0.02),
+ new Frequency ('S', 0.02),
+ new Frequency ('V', 0.02),
+ new Frequency ('W', 0.02),
+ new Frequency ('Y', 0.02)
+ };
+
+ static Frequency[] HomoSapiens = {
+ new Frequency ('a', 0.3029549426680),
+ new Frequency ('c', 0.1979883004921),
+ new Frequency ('g', 0.1975473066391),
+ new Frequency ('t', 0.3015094502008)
+ };
+
+ static void MakeCumulative(Frequency[] a)
+ {
+ double cp = 0.0;
+ for (int i = 0; i < a.Length; i++)
+ {
+ cp += a[i].p;
+ a[i].p = cp;
+ }
+ }
+
+ // naive
+ static byte SelectRandom(Frequency[] a)
+ {
+ double r = random(1.0);
+
+ for (int i = 0; i < a.Length; i++)
+ if (r < a[i].p)
+ return a[i].c;
+
+ return a[a.Length - 1].c;
+ }
+
+ const int LineLength = 60;
+ static int index = 0;
+ static byte[] buf = new byte[1024];
+
+ static void MakeRandomFasta(string id, string desc, Frequency[] a, int n, Stream s)
+ {
+ index = 0;
+ int m = 0;
+
+ byte[] descStr = Encoding.ASCII.GetBytes(">" + id + " " + desc + "\n");
+ s.Write(descStr, 0, descStr.Length);
+
+ while (n > 0)
+ {
+ m = n < LineLength ? n : LineLength;
+
+ if (buf.Length - index < m)
+ {
+ s.Write(buf, 0, index);
+ index = 0;
+ }
+
+ for (int i = 0; i < m; i++)
+ {
+ buf[index++] = SelectRandom(a);
+ }
+
+ buf[index++] = (byte)'\n';
+ n -= LineLength;
+ }
+
+ if (index != 0)
+ s.Write(buf, 0, index);
+ }
+
+ static void MakeRepeatFasta(string id, string desc, byte[] alu, int n, Stream s)
+ {
+ index = 0;
+ int m = 0;
+ int k = 0;
+ int kn = alu.Length;
+
+ byte[] descStr = Encoding.ASCII.GetBytes(">" + id + " " + desc + "\n");
+ s.Write(descStr, 0, descStr.Length);
+
+ while (n > 0)
+ {
+ m = n < LineLength ? n : LineLength;
+
+ if (buf.Length - index < m)
+ {
+ s.Write(buf, 0, index);
+ index = 0;
+ }
+
+ for (int i = 0; i < m; i++)
+ {
+ if (k == kn)
+ k = 0;
+
+ buf[index++] = alu[k];
+ k++;
+ }
+
+ buf[index++] = (byte)'\n';
+ n -= LineLength;
+ }
+
+ if (index != 0)
+ s.Write(buf, 0, index);
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fasta/fasta-2.csproj b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fasta/fasta-2.csproj
new file mode 100644
index 0000000000..94e4bedd0e
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fasta/fasta-2.csproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{BC31B732-E7E4-4458-8D14-3DBF63A4A576}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="$(MSBuildProjectName).cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project> \ No newline at end of file
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fasta/fasta.csharp-2.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fasta/fasta.csharp-2.cs
deleted file mode 100644
index 3e97d64429..0000000000
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fasta/fasta.csharp-2.cs
+++ /dev/null
@@ -1,222 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-/* The Computer Language Benchmarks Game
- http://benchmarksgame.alioth.debian.org/
-
- contributed by Isaac Gouy
- optimizations by Alp Toker <alp@atoker.com>
-
- modified for use with xunit-performance
-*/
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.IO;
-using System.Text;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace BenchmarksGame
-{
-public class Fasta
-{
-#if DEBUG
- private const int Iterations = 1;
-#else
- const int Iterations = 800;
-#endif
-
- public static int Main(string[] args)
- {
- MakeCumulative(s_homoSapiens);
- MakeCumulative(s_IUB);
-
- int n = args.Length > 0 ? Int32.Parse(args[0]) : 1000;
-
- using (Stream s = Console.OpenStandardOutput())
- {
- MakeRepeatFasta("ONE", "Homo sapiens alu", Encoding.ASCII.GetBytes(s_ALU), n * 2, s);
- MakeRandomFasta("TWO", "IUB ambiguity codes", s_IUB, n * 3, s);
- MakeRandomFasta("THREE", "Homo sapiens frequency", s_homoSapiens, n * 5, s);
- }
- return 100;
- }
-
- [Benchmark]
- public static void Bench()
- {
- int n = 5000;
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- for (int i = 0; i < Iterations; i++)
- {
- using (Stream s = Stream.Null)
- {
- MakeRepeatFasta("ONE", "Homo sapiens alu", Encoding.ASCII.GetBytes(s_ALU), n * 2, s);
- MakeRandomFasta("TWO", "IUB ambiguity codes", s_IUB, n * 3, s);
- MakeRandomFasta("THREE", "Homo sapiens frequency", s_homoSapiens, n * 5, s);
- }
- }
- }
- }
- }
-
- // The usual pseudo-random number generator
-
- private const int IM = 139968;
- private const int IA = 3877;
- private const int IC = 29573;
- private static int s_seed = 42;
-
- private static double random(double max)
- {
- return max * ((s_seed = (s_seed * IA + IC) % IM) * (1.0 / IM));
- }
-
- // Weighted selection from alphabet
-
- private static string s_ALU =
- "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG" +
- "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA" +
- "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT" +
- "ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA" +
- "GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG" +
- "AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC" +
- "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA";
-
- private class Frequency
- {
- public byte c;
- public double p;
-
- public Frequency(char c, double p)
- {
- this.c = (byte)c;
- this.p = p;
- }
- }
-
- private static Frequency[] s_IUB = {
- new Frequency ('a', 0.27)
- ,new Frequency ('c', 0.12)
- ,new Frequency ('g', 0.12)
- ,new Frequency ('t', 0.27)
-
- ,new Frequency ('B', 0.02)
- ,new Frequency ('D', 0.02)
- ,new Frequency ('H', 0.02)
- ,new Frequency ('K', 0.02)
- ,new Frequency ('M', 0.02)
- ,new Frequency ('N', 0.02)
- ,new Frequency ('R', 0.02)
- ,new Frequency ('S', 0.02)
- ,new Frequency ('V', 0.02)
- ,new Frequency ('W', 0.02)
- ,new Frequency ('Y', 0.02)
- };
-
- private static Frequency[] s_homoSapiens = {
- new Frequency ('a', 0.3029549426680)
- ,new Frequency ('c', 0.1979883004921)
- ,new Frequency ('g', 0.1975473066391)
- ,new Frequency ('t', 0.3015094502008)
- };
-
- private static void MakeCumulative(Frequency[] a)
- {
- double cp = 0.0;
- for (int i = 0; i < a.Length; i++)
- {
- cp += a[i].p;
- a[i].p = cp;
- }
- }
-
- // naive
- private static byte SelectRandom(Frequency[] a)
- {
- double r = random(1.0);
-
- for (int i = 0; i < a.Length; i++)
- if (r < a[i].p)
- return a[i].c;
-
- return a[a.Length - 1].c;
- }
-
- private const int LineLength = 60;
- private static int s_index = 0;
- private static byte[] s_buf = new byte[1024];
-
- private static void MakeRandomFasta(string id, string desc, Frequency[] a, int n, Stream s)
- {
- s_index = 0;
- int m = 0;
-
- byte[] descStr = Encoding.ASCII.GetBytes(">" + id + " " + desc + "\n");
- s.Write(descStr, 0, descStr.Length);
-
- while (n > 0)
- {
- m = n < LineLength ? n : LineLength;
-
- if (s_buf.Length - s_index < m)
- {
- s.Write(s_buf, 0, s_index);
- s_index = 0;
- }
-
- for (int i = 0; i < m; i++)
- {
- s_buf[s_index++] = SelectRandom(a);
- }
-
- s_buf[s_index++] = (byte)'\n';
- n -= LineLength;
- }
-
- if (s_index != 0)
- s.Write(s_buf, 0, s_index);
- }
-
- private static void MakeRepeatFasta(string id, string desc, byte[] alu, int n, Stream s)
- {
- s_index = 0;
- int m = 0;
- int k = 0;
- int kn = alu.Length;
-
- byte[] descStr = Encoding.ASCII.GetBytes(">" + id + " " + desc + "\n");
- s.Write(descStr, 0, descStr.Length);
-
- while (n > 0)
- {
- m = n < LineLength ? n : LineLength;
-
- if (s_buf.Length - s_index < m)
- {
- s.Write(s_buf, 0, s_index);
- s_index = 0;
- }
-
- for (int i = 0; i < m; i++)
- {
- if (k == kn)
- k = 0;
-
- s_buf[s_index++] = alu[k];
- k++;
- }
-
- s_buf[s_index++] = (byte)'\n';
- n -= LineLength;
- }
-
- if (s_index != 0)
- s.Write(s_buf, 0, s_index);
- }
-}
-}
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fastaredux/fastaredux.csharp.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fastaredux/fastaredux.csharp.cs
deleted file mode 100644
index c7a786a77e..0000000000
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fastaredux/fastaredux.csharp.cs
+++ /dev/null
@@ -1,186 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-/* The Computer Language Benchmarks Game
- http://benchmarksgame.alioth.debian.org/
-
- contributed by Robert F. Tobler
- optimized based on java & C# by Enotus, Isaac Gouy, and Alp Toker
-
- modified for use with xunit-performance
-*/
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.IO;
-using System.Text;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace BenchmarksGame
-{
-public static class FastaRedux
-{
-#if DEBUG
- private const int Iterations = 1;
-#else
- const int Iterations = 5;
-#endif
-
- public static int Main(string[] args)
- {
- AccumulateAndScale(s_homoSapiens);
- AccumulateAndScale(s_IUB);
- int n = args.Length > 0 ? Int32.Parse(args[0]) : 2500;
- using (Stream s = Console.OpenStandardOutput())
- {
- s.WriteRepeatFasta("ONE", "Homo sapiens alu", Encoding.ASCII.GetBytes(s_ALU), n * 2);
- s.WriteRandomFasta("TWO", "IUB ambiguity codes", s_IUB, n * 3);
- s.WriteRandomFasta("THREE", "Homo sapiens frequency", s_homoSapiens, n * 5);
- }
- return 100;
- }
-
- [Benchmark]
- public static void Bench()
- {
- int n = 2500000;
- AccumulateAndScale(s_homoSapiens);
- AccumulateAndScale(s_IUB);
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- using (Stream s = Stream.Null)
- {
- for (int i = 0; i < Iterations; i++)
- {
- s.WriteRepeatFasta("ONE", "Homo sapiens alu", Encoding.ASCII.GetBytes(s_ALU), n * 2);
- s.WriteRandomFasta("TWO", "IUB ambiguity codes", s_IUB, n * 3);
- s.WriteRandomFasta("THREE", "Homo sapiens frequency", s_homoSapiens, n * 5);
- }
- }
- }
- }
- }
-
- private const int LINE_LEN = 60;
- private const int BUF_LEN = 64 * 1024;
- private const byte LF = (byte)'\n';
-
- private const int LOOKUP_LEN = 1024;
- private const double LOOKUP_SCALE = LOOKUP_LEN - 1;
-
- private static readonly string s_ALU =
- "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG" +
- "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA" +
- "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT" +
- "ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA" +
- "GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG" +
- "AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC" +
- "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA";
-
- private struct Freq
- {
- public double P;
- public byte C;
-
- public Freq(char c, double p) { C = (byte)c; P = p; }
- }
-
- private static Freq[] s_IUB = {
- new Freq('a', 0.27), new Freq('c', 0.12), new Freq('g', 0.12),
- new Freq('t', 0.27), new Freq('B', 0.02), new Freq('D', 0.02),
- new Freq('H', 0.02), new Freq('K', 0.02), new Freq('M', 0.02),
- new Freq('N', 0.02), new Freq('R', 0.02), new Freq('S', 0.02),
- new Freq('V', 0.02), new Freq('W', 0.02), new Freq('Y', 0.02),
- };
-
- private static Freq[] s_homoSapiens = {
- new Freq ('a', 0.3029549426680), new Freq ('c', 0.1979883004921),
- new Freq ('g', 0.1975473066391), new Freq ('t', 0.3015094502008),
- };
-
- private static void AccumulateAndScale(Freq[] a)
- {
- double cp = 0.0;
- for (int i = 0; i < a.Length; i++)
- a[i].P = (cp += a[i].P) * LOOKUP_SCALE;
- a[a.Length - 1].P = LOOKUP_SCALE;
- }
-
- private static byte[] s_buf = new byte[BUF_LEN];
-
- private static int WriteDesc(this byte[] buf, string id, string desc)
- {
- var ds = Encoding.ASCII.GetBytes(">" + id + " " + desc + "\n");
- for (int i = 0; i < ds.Length; i++) buf[i] = ds[i];
- return BUF_LEN - ds.Length;
- }
-
- private static int Min(int a, int b) { return a < b ? a : b; }
-
- private static void WriteRepeatFasta(
- this Stream s, string id, string desc, byte[] alu, int nr)
- {
- int alen = alu.Length;
- int ar = alen, br = s_buf.WriteDesc(id, desc), lr = LINE_LEN;
- while (nr > 0)
- {
- int r = Min(Min(nr, lr), Min(ar, br));
- for (int ai = alen - ar, bi = BUF_LEN - br, be = bi + r;
- bi < be; bi++, ai++)
- s_buf[bi] = alu[ai];
- nr -= r; lr -= r; br -= r; ar -= r;
- if (ar == 0) ar = alen;
- if (br == 0) { s.Write(s_buf, 0, BUF_LEN); br = BUF_LEN; }
- if (lr == 0) { s_buf[BUF_LEN - (br--)] = LF; lr = LINE_LEN; }
- if (br == 0) { s.Write(s_buf, 0, BUF_LEN); br = BUF_LEN; }
- }
- if (lr < LINE_LEN) s_buf[BUF_LEN - (br--)] = LF;
- if (br < BUF_LEN) s.Write(s_buf, 0, BUF_LEN - br);
- }
-
- private static Freq[] s_lookup = new Freq[LOOKUP_LEN];
-
- private static void CreateLookup(Freq[] fr)
- {
- for (int i = 0, j = 0; i < LOOKUP_LEN; i++)
- {
- while (fr[j].P < i) j++;
- s_lookup[i] = fr[j];
- }
- }
-
- private const int IM = 139968;
- private const int IA = 3877;
- private const int IC = 29573;
- private const double SCALE = LOOKUP_SCALE / IM;
-
- private static int s_last = 42;
-
- private static void WriteRandomFasta(
- this Stream s, string id, string desc, Freq[] fr, int nr)
- {
- CreateLookup(fr);
- int br = s_buf.WriteDesc(id, desc), lr = LINE_LEN;
- while (nr > 0)
- {
- int r = Min(Min(nr, lr), br);
- for (int bi = BUF_LEN - br, be = bi + r; bi < be; bi++)
- {
- double p = SCALE * (s_last = (s_last * IA + IC) % IM);
- int ai = (int)p; if (s_lookup[ai].P < p) ai++;
- s_buf[bi] = s_lookup[ai].C;
- }
- nr -= r; lr -= r; br -= r;
- if (br == 0) { s.Write(s_buf, 0, BUF_LEN); br = BUF_LEN; }
- if (lr == 0) { s_buf[BUF_LEN - (br--)] = LF; lr = LINE_LEN; }
- if (br == 0) { s.Write(s_buf, 0, BUF_LEN); br = BUF_LEN; }
- }
- if (lr < LINE_LEN) s_buf[BUF_LEN - (br--)] = LF;
- if (br < BUF_LEN) s.Write(s_buf, 0, BUF_LEN - br);
- }
-}
-}
-
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/harness-helpers.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/harness-helpers.cs
new file mode 100644
index 0000000000..d7b9a5754c
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/harness-helpers.cs
@@ -0,0 +1,102 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// Helper functionality to locate inputs and find outputs for
+// k-nucleotide benchmark in CoreCLR test harness
+
+using System;
+using System.IO;
+using System.Text;
+
+namespace BenchmarksGame
+{
+ class TestHarnessHelpers
+ {
+ public string InputFile;
+ public int[] expectedCountLetter;
+ public int[] expectedCountPairs;
+ public int[] expectedCountFragments;
+ public int[][] expectedFrequencies;
+
+ public TestHarnessHelpers(bool bigInput, [System.Runtime.CompilerServices.CallerFilePath] string csFileName = "")
+ {
+ if (bigInput)
+ {
+ InputFile = FindInputFile("knucleotide-input-big.txt", csFileName);
+ expectedCountLetter = new int[] { 302923, 301375, 198136, 197566 };
+ expectedCountPairs = new int[] { 91779, 91253, 91225, 90837, 60096, 60030, 59889, 59795, 59756, 59713, 59572, 59557, 39203, 39190, 39081, 39023 };
+ expectedCountFragments = new int[] { 11765, 3572, 380, 7, 7 };
+ }
+ else
+ {
+ InputFile = FindInputFile("knucleotide-input.txt", csFileName);
+ expectedCountLetter = new int[] { 1576, 1480, 974, 970 };
+ expectedCountPairs = new int[] { 496, 480, 470, 420, 316, 315, 310, 302, 298, 292, 273, 272, 202, 201, 185, 167 };
+ expectedCountFragments = new int[] { 54, 24, 4, 0, 0 };
+ }
+ expectedFrequencies = new int[][] { expectedCountLetter, expectedCountPairs };
+ }
+
+ public string FindInputFile(string inputFile, string csFileName)
+ {
+ string CoreRoot = System.Environment.GetEnvironmentVariable("CORE_ROOT");
+
+ if (CoreRoot == null)
+ {
+ Console.WriteLine("This benchmark requries CORE_ROOT to be set");
+ return null;
+ }
+
+ // The convention is that the csproj file has the same name as the cs file.
+ string projectName = Path.GetFileNameWithoutExtension(csFileName);
+ int slashIndex = projectName.LastIndexOfAny(new char[] { '/', '\\' });
+ if (slashIndex != -1)
+ {
+ // csFileName was generated by the C# compiler, which may have run on
+ // a different host system with different path separator than the
+ // currently executing host, which dictates GetFileNameWithoutExtension's
+ // behavior... so hope that the slash here is a cross-host path separator,
+ // and chop of what were likely direcotires.
+ projectName = projectName.Substring(slashIndex + 1);
+ }
+
+ // Normal testing -- input file will end up next to the assembly
+ // and CoreRoot points at the test overlay dir
+ string[] pathPartsNormal = new string[] {
+ CoreRoot, "..", "..", "JIT", "Performance",
+ "CodeQuality", "BenchmarksGame", "k-nucleotide", projectName, inputFile
+ };
+
+ string inputPathNormal = Path.Combine(pathPartsNormal);
+
+ // Perf testing -- input file will end up next to the assembly
+ // and CoreRoot points at this directory
+ string[] pathPartsPerf = new string[] { CoreRoot, inputFile };
+
+ string inputPathPerf = Path.Combine(pathPartsPerf);
+
+ string inputPath = null;
+
+ if (File.Exists(inputPathNormal))
+ {
+ inputPath = inputPathNormal;
+ }
+ else if (File.Exists(inputPathPerf))
+ {
+ inputPath = inputPathPerf;
+ }
+
+ if (inputPath != null)
+ {
+ Console.WriteLine("Using input file {0}", inputFile);
+ }
+ else
+ {
+ throw new Exception($"Unable to find input file {inputFile}. Tried {inputPathNormal} and {inputPathPerf}; csFileName was {csFileName}, so projectName was {projectName}.");
+ }
+
+ return inputPath;
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/k-nucleotide-1.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/k-nucleotide-1.cs
new file mode 100644
index 0000000000..96d49f702e
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/k-nucleotide-1.cs
@@ -0,0 +1,230 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// Adapted from k-nucleotide C# .NET Core program
+// http://benchmarksgame.alioth.debian.org/u64q/program.php?test=knucleotide&lang=csharpcore&id=1
+// aka (as of 2017-09-01) rev 1.2 of https://alioth.debian.org/scm/viewvc.php/benchmarksgame/bench/knucleotide/knucleotide.csharp?root=benchmarksgame&view=log
+// Best-scoring single-threaded C# .NET Core version as of 2017-09-01
+
+/* The Computer Language Benchmarks Game
+ http://benchmarksgame.alioth.debian.org/
+ *
+ * byte processing version using C# *3.0 idioms by Robert F. Tobler
+ */
+
+using System;
+using System.IO;
+using System.Collections.Generic;
+using System.Text;
+using Microsoft.Xunit.Performance;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+[assembly: MeasureGCCounts]
+
+namespace BenchmarksGame
+{
+
+ public struct ByteString : IEquatable<ByteString>
+ {
+ public byte[] Array;
+ public int Start;
+ public int Length;
+
+ public ByteString(byte[] array, int start, int length)
+ {
+ Array = array; Start = start; Length = length;
+ }
+
+ public ByteString(string text)
+ {
+ Start = 0; Length = text.Length;
+ Array = Encoding.ASCII.GetBytes(text);
+ }
+
+ public override int GetHashCode()
+ {
+ if (Length < 1) return 0;
+ int hc = Length ^ (Array[Start] << 24); if (Length < 2) return hc;
+ hc ^= Array[Start + Length - 1] << 20; if (Length < 3) return hc;
+ for (int c = Length - 2; c > 0; c--)
+ hc ^= Array[Start + c] << (c & 0xf);
+ return hc;
+ }
+
+ public bool Equals(ByteString other)
+ {
+ if (Length != other.Length) return false;
+ for (int i = 0; i < Length; i++)
+ if (Array[Start + i] != other.Array[other.Start + i]) return false;
+ return true;
+ }
+
+ public override string ToString()
+ {
+ return Encoding.ASCII.GetString(Array, Start, Length);
+ }
+ }
+
+ public static class Extensions
+ {
+ public static byte[] GetBytes(this List<string> input)
+ {
+ int count = 0;
+ for (int i = 0; i < input.Count; i++) count += input[i].Length;
+ var byteArray = new byte[count];
+ count = 0;
+ for (int i = 0; i < input.Count; i++)
+ {
+ string line = input[i];
+ Encoding.ASCII.GetBytes(line, 0, line.Length, byteArray, count);
+ count += line.Length;
+ }
+ return byteArray;
+ }
+ }
+
+ public class KNucleotide_1
+ {
+
+ public static int Main(string[] args)
+ {
+ var helpers = new TestHarnessHelpers(bigInput: false);
+
+ using (var inputFile = new FileStream(helpers.InputFile, FileMode.Open))
+ {
+ if (!Bench(inputFile, helpers, true))
+ {
+ return -1;
+ }
+ }
+
+ return 100;
+ }
+
+ [Benchmark(InnerIterationCount = 3)]
+ public static void RunBench()
+ {
+ var helpers = new TestHarnessHelpers(bigInput: true);
+ bool ok = true;
+
+ Benchmark.Iterate(() =>
+ {
+ using (var inputFile = new FileStream(helpers.InputFile, FileMode.Open))
+ {
+ ok &= Bench(inputFile, helpers, false);
+ }
+ });
+ Assert.True(ok);
+ }
+
+ static bool Bench(Stream inputStream, TestHarnessHelpers helpers, bool verbose)
+ {
+ string line;
+ StreamReader source = new StreamReader(inputStream);
+ var input = new List<string>();
+
+ while ((line = source.ReadLine()) != null)
+ if (line[0] == '>' && line.Substring(1, 5) == "THREE")
+ break;
+
+ while ((line = source.ReadLine()) != null)
+ {
+ char c = line[0];
+ if (c == '>') break;
+ if (c != ';') input.Add(line.ToUpper());
+ }
+
+ KNucleotide kn = new KNucleotide(input.GetBytes());
+ input = null;
+ bool ok = true;
+ for (int f = 1; f < 3; f++)
+ ok &= kn.WriteFrequencies(f, helpers.expectedFrequencies[f - 1], verbose);
+ int i = 0;
+ foreach (var seq in
+ new[] { "GGT", "GGTA", "GGTATT", "GGTATTTTAATT",
+ "GGTATTTTAATTTATAGT"})
+ ok &= kn.WriteCount(seq, helpers.expectedCountFragments[i++], verbose);
+
+ return ok;
+ }
+ }
+
+ public class KNucleotide
+ {
+
+ private class Count
+ {
+ public int V;
+ public Count(int v) { V = v; }
+ }
+
+ private Dictionary<ByteString, Count> frequencies
+ = new Dictionary<ByteString, Count>();
+ private byte[] sequence;
+
+ public KNucleotide(byte[] s) { sequence = s; }
+
+ public bool WriteFrequencies(int length, int[] expectedCounts, bool verbose)
+ {
+ GenerateFrequencies(length);
+ var items = new List<KeyValuePair<ByteString, Count>>(frequencies);
+ items.Sort(SortByFrequencyAndCode);
+ double percent = 100.0 / (sequence.Length - length + 1);
+ bool ok = true;
+ int i = 0;
+ foreach (var item in items)
+ {
+ ok &= (item.Value.V == expectedCounts[i++]);
+ if (verbose)
+ {
+ Console.WriteLine("{0} {1:f3}",
+ item.Key.ToString(), item.Value.V * percent);
+ }
+ }
+ if (verbose) Console.WriteLine();
+ return ok;
+ }
+
+ public bool WriteCount(string fragment, int expectedCount, bool verbose)
+ {
+ GenerateFrequencies(fragment.Length);
+ Count count;
+ if (!frequencies.TryGetValue(new ByteString(fragment), out count))
+ count = new Count(0);
+ if (verbose) Console.WriteLine("{0}\t{1}", count.V, fragment);
+ return (count.V == expectedCount);
+ }
+
+ private void GenerateFrequencies(int length)
+ {
+ frequencies.Clear();
+ for (int frame = 0; frame < length; frame++)
+ KFrequency(frame, length);
+ }
+
+ private void KFrequency(int frame, int k)
+ {
+ int n = sequence.Length - k + 1;
+ for (int i = frame; i < n; i += k)
+ {
+ var key = new ByteString(sequence, i, k);
+ Count count;
+ if (frequencies.TryGetValue(key, out count))
+ count.V++;
+ else
+ frequencies[key] = new Count(1);
+ }
+ }
+
+ int SortByFrequencyAndCode(
+ KeyValuePair<ByteString, Count> i0,
+ KeyValuePair<ByteString, Count> i1)
+ {
+ int order = i1.Value.V.CompareTo(i0.Value.V);
+ if (order != 0) return order;
+ return i0.Key.ToString().CompareTo(i1.Key.ToString());
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/k-nucleotide.csproj b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/k-nucleotide-1.csproj
index 89c8ad5c47..d65aaae57d 100644
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/k-nucleotide.csproj
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/k-nucleotide-1.csproj
@@ -1,11 +1,11 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <ProjectGuid>{72C2713D-C5A4-4BE0-82F3-3B7EEB4DB574}</ProjectGuid>
<OutputType>Exe</OutputType>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
@@ -30,7 +30,8 @@
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
- <Compile Include="k-nucleotide.cs" />
+ <Compile Include="$(MSBuildProjectName).cs" />
+ <Compile Include="harness-helpers.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="knucleotide-input.txt">
@@ -45,4 +46,4 @@
<PropertyGroup>
<ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
</PropertyGroup>
-</Project> \ No newline at end of file
+</Project>
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/k-nucleotide-9.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/k-nucleotide-9.cs
new file mode 100644
index 0000000000..e6dd21243f
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/k-nucleotide-9.cs
@@ -0,0 +1,333 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// Adapted from k-nucleotide C# .NET Core #9 program
+// http://benchmarksgame.alioth.debian.org/u64q/program.php?test=knucleotide&lang=csharpcore&id=9
+// aka (as of 2017-09-01) rev 1.1 of https://alioth.debian.org/scm/viewvc.php/benchmarksgame/bench/knucleotide/knucleotide.csharp-9.csharp?root=benchmarksgame&view=log
+// Best-scoring C# .NET Core version as of 2017-09-01
+
+/* The Computer Language Benchmarks Game
+ http://benchmarksgame.alioth.debian.org/
+
+ submitted by Josh Goldfoot
+ Modified to reduce memory and do more in parallel by Anthony Lloyd
+ */
+
+using System;
+using System.IO;
+using System.Text;
+using System.Linq;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using System.Runtime.CompilerServices;
+using Microsoft.Xunit.Performance;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+[assembly: MeasureGCCounts]
+
+namespace BenchmarksGame
+{
+ class Wrapper { public int v = 1; }
+ public static class KNucleotide_9
+ {
+ const int BLOCK_SIZE = 1024 * 1024 * 8;
+ static List<byte[]> threeBlocks = new List<byte[]>();
+ static int threeStart, threeEnd;
+ static byte[] tonum = new byte[256];
+ static char[] tochar = new char[] { 'A', 'C', 'G', 'T' };
+
+ static int read(Stream stream, byte[] buffer, int offset, int count)
+ {
+ var bytesRead = stream.Read(buffer, offset, count);
+ return bytesRead == count ? offset + count
+ : bytesRead == 0 ? offset
+ : read(stream, buffer, offset + bytesRead, count - bytesRead);
+ }
+
+ static int find(byte[] buffer, byte[] toFind, int i, ref int matchIndex)
+ {
+ if (matchIndex == 0)
+ {
+ i = Array.IndexOf(buffer, toFind[0], i);
+ if (i == -1) return -1;
+ matchIndex = 1;
+ return find(buffer, toFind, i + 1, ref matchIndex);
+ }
+ else
+ {
+ int bl = buffer.Length, fl = toFind.Length;
+ while (i < bl && matchIndex < fl)
+ {
+ if (buffer[i++] != toFind[matchIndex++])
+ {
+ matchIndex = 0;
+ return find(buffer, toFind, i, ref matchIndex);
+ }
+ }
+ return matchIndex == fl ? i : -1;
+ }
+ }
+
+ static void loadThreeData(Stream stream)
+ {
+ // find three sequence
+ int matchIndex = 0;
+ var toFind = new[] { (byte)'>', (byte)'T', (byte)'H', (byte)'R', (byte)'E', (byte)'E' };
+ var buffer = new byte[BLOCK_SIZE];
+ do
+ {
+ threeEnd = read(stream, buffer, 0, BLOCK_SIZE);
+ threeStart = find(buffer, toFind, 0, ref matchIndex);
+ } while (threeStart == -1);
+
+ // Skip to end of line
+ matchIndex = 0;
+ toFind = new[] { (byte)'\n' };
+ threeStart = find(buffer, toFind, threeStart, ref matchIndex);
+ while (threeStart == -1)
+ {
+ threeEnd = read(stream, buffer, 0, BLOCK_SIZE);
+ threeStart = find(buffer, toFind, 0, ref matchIndex);
+ }
+ threeBlocks.Add(buffer);
+
+ if (threeEnd != BLOCK_SIZE) // Needs to be at least 2 blocks
+ {
+ var bytes = threeBlocks[0];
+ for (int i = threeEnd; i < bytes.Length; i++)
+ bytes[i] = 255;
+ threeEnd = 0;
+ threeBlocks.Add(Array.Empty<byte>());
+ return;
+ }
+
+ // find next seq or end of input
+ matchIndex = 0;
+ toFind = new[] { (byte)'>' };
+ threeEnd = find(buffer, toFind, threeStart, ref matchIndex);
+ while (threeEnd == -1)
+ {
+ buffer = new byte[BLOCK_SIZE];
+ var bytesRead = read(stream, buffer, 0, BLOCK_SIZE);
+ threeEnd = bytesRead == BLOCK_SIZE ? find(buffer, toFind, 0, ref matchIndex)
+ : bytesRead;
+ threeBlocks.Add(buffer);
+ }
+
+ if (threeStart + 18 > BLOCK_SIZE) // Key needs to be in the first block
+ {
+ byte[] block0 = threeBlocks[0], block1 = threeBlocks[1];
+ Buffer.BlockCopy(block0, threeStart, block0, threeStart - 18, BLOCK_SIZE - threeStart);
+ Buffer.BlockCopy(block1, 0, block0, BLOCK_SIZE - 18, 18);
+ for (int i = 0; i < 18; i++) block1[i] = 255;
+ }
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ static void check(Dictionary<long, Wrapper> dict, ref long rollingKey, byte nb, long mask)
+ {
+ if (nb == 255) return;
+ rollingKey = ((rollingKey & mask) << 2) | nb;
+ Wrapper w;
+ if (dict.TryGetValue(rollingKey, out w))
+ w.v++;
+ else
+ dict[rollingKey] = new Wrapper();
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ static void checkEnding(Dictionary<long, Wrapper> dict, ref long rollingKey, byte b, byte nb, long mask)
+ {
+ if (nb == b)
+ {
+ Wrapper w;
+ if (dict.TryGetValue(rollingKey, out w))
+ w.v++;
+ else
+ dict[rollingKey] = new Wrapper();
+ rollingKey = ((rollingKey << 2) | nb) & mask;
+ }
+ else if (nb != 255)
+ {
+ rollingKey = ((rollingKey << 2) | nb) & mask;
+ }
+ }
+
+ static Task<string> count(int l, long mask, Func<Dictionary<long, Wrapper>, string> summary)
+ {
+ return Task.Run(() =>
+ {
+ long rollingKey = 0;
+ var firstBlock = threeBlocks[0];
+ var start = threeStart;
+ while (--l > 0) rollingKey = (rollingKey << 2) | firstBlock[start++];
+ var dict = new Dictionary<long, Wrapper>();
+ for (int i = start; i < firstBlock.Length; i++)
+ check(dict, ref rollingKey, firstBlock[i], mask);
+
+ int lastBlockId = threeBlocks.Count - 1;
+ for (int bl = 1; bl < lastBlockId; bl++)
+ {
+ var bytes = threeBlocks[bl];
+ for (int i = 0; i < bytes.Length; i++)
+ check(dict, ref rollingKey, bytes[i], mask);
+ }
+
+ var lastBlock = threeBlocks[lastBlockId];
+ for (int i = 0; i < threeEnd; i++)
+ check(dict, ref rollingKey, lastBlock[i], mask);
+ return summary(dict);
+ });
+ }
+
+ static Dictionary<long, Wrapper> countEnding(int l, long mask, byte b)
+ {
+ long rollingKey = 0;
+ var firstBlock = threeBlocks[0];
+ var start = threeStart;
+ while (--l > 0) rollingKey = (rollingKey << 2) | firstBlock[start++];
+ var dict = new Dictionary<long, Wrapper>();
+ for (int i = start; i < firstBlock.Length; i++)
+ checkEnding(dict, ref rollingKey, b, firstBlock[i], mask);
+
+ int lastBlockId = threeBlocks.Count - 1;
+ for (int bl = 1; bl < lastBlockId; bl++)
+ {
+ var bytes = threeBlocks[bl];
+ for (int i = 0; i < bytes.Length; i++)
+ checkEnding(dict, ref rollingKey, b, bytes[i], mask);
+ }
+
+ var lastBlock = threeBlocks[lastBlockId];
+ for (int i = 0; i < threeEnd; i++)
+ checkEnding(dict, ref rollingKey, b, lastBlock[i], mask);
+ return dict;
+ }
+
+ static Task<string> count4(int l, long mask, Func<Dictionary<long, Wrapper>, string> summary)
+ {
+ return Task.Factory.ContinueWhenAll(
+ new[] {
+ Task.Run(() => countEnding(l, mask, 0)),
+ Task.Run(() => countEnding(l, mask, 1)),
+ Task.Run(() => countEnding(l, mask, 2)),
+ Task.Run(() => countEnding(l, mask, 3))
+ }
+ , dicts =>
+ {
+ var d = new Dictionary<long, Wrapper>(dicts.Sum(i => i.Result.Count));
+ for (int i = 0; i < dicts.Length; i++)
+ foreach (var kv in dicts[i].Result)
+ d[(kv.Key << 2) | (long)i] = kv.Value;
+ return summary(d);
+ });
+ }
+
+ static string writeFrequencies(Dictionary<long, Wrapper> freq, int fragmentLength, int[] expected, ref bool ok)
+ {
+ var sb = new StringBuilder();
+ double percent = 100.0 / freq.Values.Sum(i => i.v);
+ int idx = 0;
+ foreach (var kv in freq.OrderByDescending(i => i.Value.v))
+ {
+ ok &= (kv.Value.v == expected[idx++]);
+ var keyChars = new char[fragmentLength];
+ var key = kv.Key;
+ for (int i = keyChars.Length - 1; i >= 0; --i)
+ {
+ keyChars[i] = tochar[key & 0x3];
+ key >>= 2;
+ }
+ sb.Append(keyChars);
+ sb.Append(" ");
+ sb.AppendLine((kv.Value.v * percent).ToString("F3"));
+ }
+ return sb.ToString();
+ }
+
+ static string writeCount(Dictionary<long, Wrapper> dictionary, string fragment, int expected, ref bool ok)
+ {
+ long key = 0;
+ for (int i = 0; i < fragment.Length; ++i)
+ key = (key << 2) | tonum[fragment[i]];
+ Wrapper w;
+ var n = dictionary.TryGetValue(key, out w) ? w.v : 0;
+ ok &= (n == expected);
+ return string.Concat(n.ToString(), "\t", fragment);
+ }
+
+ public static int Main(string[] args)
+ {
+ var helpers = new TestHarnessHelpers(bigInput: false);
+ bool ok = Bench(helpers, true);
+
+ return (ok ? 100 : -1);
+ }
+
+ [Benchmark(InnerIterationCount = 10)]
+ public static void RunBench()
+ {
+ var helpers = new TestHarnessHelpers(bigInput: true);
+ bool ok = true;
+
+ Benchmark.Iterate(() =>
+ {
+ ok &= Bench(helpers, false);
+ });
+ Assert.True(ok);
+ }
+
+ static bool Bench(TestHarnessHelpers helpers, bool verbose)
+ {
+ // Reset static state
+ threeBlocks.Clear();
+ threeStart = 0;
+ threeEnd = 0;
+
+ tonum['c'] = 1; tonum['C'] = 1;
+ tonum['g'] = 2; tonum['G'] = 2;
+ tonum['t'] = 3; tonum['T'] = 3;
+ tonum['\n'] = 255; tonum['>'] = 255; tonum[255] = 255;
+
+ using (var inputStream = new FileStream(helpers.InputFile, FileMode.Open))
+ {
+ loadThreeData(inputStream);
+ }
+
+ Parallel.ForEach(threeBlocks, bytes =>
+ {
+ for (int i = 0; i < bytes.Length; i++)
+ bytes[i] = tonum[bytes[i]];
+ });
+
+ bool ok = true;
+
+ var task18 = count4(18, 0x7FFFFFFFF, d => writeCount(d, "GGTATTTTAATTTATAGT", helpers.expectedCountFragments[4], ref ok));
+ var task12 = count4(12, 0x7FFFFF, d => writeCount(d, "GGTATTTTAATT", helpers.expectedCountFragments[3], ref ok));
+ var task6 = count(6, 0x3FF, d => writeCount(d, "GGTATT", helpers.expectedCountFragments[2], ref ok));
+ var task4 = count(4, 0x3F, d => writeCount(d, "GGTA", helpers.expectedCountFragments[1], ref ok));
+ var task3 = count(3, 0xF, d => writeCount(d, "GGT", helpers.expectedCountFragments[0], ref ok));
+ var task2 = count(2, 0x3, d => writeFrequencies(d, 2, helpers.expectedFrequencies[1], ref ok));
+ var task1 = count(1, 0, d => writeFrequencies(d, 1, helpers.expectedFrequencies[0], ref ok));
+
+ if (verbose)
+ {
+ Console.Out.WriteLineAsync(task1.Result);
+ Console.Out.WriteLineAsync(task2.Result);
+ Console.Out.WriteLineAsync(task3.Result);
+ Console.Out.WriteLineAsync(task4.Result);
+ Console.Out.WriteLineAsync(task6.Result);
+ Console.Out.WriteLineAsync(task12.Result);
+ Console.Out.WriteLineAsync(task18.Result);
+ }
+ else
+ {
+ Task.WaitAll(task1, task2, task3, task4, task6, task12, task18);
+ }
+
+ return ok;
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/k-nucleotide-9.csproj b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/k-nucleotide-9.csproj
new file mode 100644
index 0000000000..9e72ba4a0f
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/k-nucleotide-9.csproj
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{06749069-420D-4F3E-8977-49B720EFE4CB}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="$(MSBuildProjectName).cs" />
+ <Compile Include="harness-helpers.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="knucleotide-input.txt">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="knucleotide-input-big.txt">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/k-nucleotide.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/k-nucleotide.cs
deleted file mode 100644
index 3325a61926..0000000000
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/k-nucleotide.cs
+++ /dev/null
@@ -1,311 +0,0 @@
-/* The Computer Language Benchmarks Game
- http://benchmarksgame.alioth.debian.org/
- *
- * submitted by Josh Goldfoot
- *
- */
-
-using System;
-using System.IO;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.Xunit.Performance;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-[assembly: MeasureGCCounts]
-
-namespace BenchmarksGame
-{
-
-public class knucleotide
-{
-#if DEBUG
- const int Iterations = 1;
- const string InputFile = "knucleotide-input.txt";
- static int[] expectedCountLetter = new int[] { 1480, 974, 970, 1576 };
- static int[] expectedCountPairs = new int[] { 420, 272, 292, 496, 273, 202, 201, 298, 316, 185, 167, 302, 470, 315, 310, 480 };
- static int[] expectedCountFragments = new int[] { 54, 24, 4, 0, 0 };
-#else
- const int Iterations = 10;
- const string InputFile = "knucleotide-input-big.txt";
- static int[] expectedCountLetter = new int[] { 302923, 198136, 197566, 301375 };
- static int[] expectedCountPairs = new int[] { 91779, 60030, 59889, 91225, 60096, 39203, 39081, 59756, 59795, 39190, 39023, 59557, 91253, 59713, 59572, 90837 };
- static int[] expectedCountFragments = new int[] { 11765, 3572, 380, 7, 7 };
-#endif
-
-
- static string FindInput(string s)
- {
- string CoreRoot = System.Environment.GetEnvironmentVariable("CORE_ROOT");
-
- if (CoreRoot == null)
- {
- Console.WriteLine("This benchmark requries CORE_ROOT to be set");
- return null;
- }
-
- string inputFile = s ?? InputFile;
-
- // Normal testing -- input file will end up next to the assembly
- // and CoreRoot points at the test overlay dir
- string[] pathPartsNormal = new string[] {
- CoreRoot, "..", "..", "JIT", "Performance",
- "CodeQuality", "BenchmarksGame", "k-nucleotide", "k-nucleotide", inputFile
- };
-
- string inputPathNormal = Path.Combine(pathPartsNormal);
-
- // Perf testing -- input file will end up next to the assembly
- // and CoreRoot points at this directory
- string[] pathPartsPerf = new string[] { CoreRoot, inputFile };
-
- string inputPathPerf = Path.Combine(pathPartsPerf);
-
- string inputPath = null;
-
- if (File.Exists(inputPathNormal))
- {
- inputPath = inputPathNormal;
- }
- else if (File.Exists(inputPathPerf))
- {
- inputPath = inputPathPerf;
- }
-
- if (inputPath != null)
- {
- Console.WriteLine("Using input file {0}", inputPath);
- }
- else
- {
- Console.WriteLine("Unable to find input file {0}", inputFile);
- }
-
- return inputPath;
- }
-
- public static int Main(string[] args)
- {
- int iterations = Iterations;
-
- string inputFile = FindInput(InputFile);
- if (inputFile == null)
- {
- throw new Exception("unable to find input");
- }
-
- PrepareLookups();
- var source = new FileStream(inputFile, FileMode.Open);
- var buffer = GetBytesForThirdSequence(source);
- var fragmentLengths = new[] { 1, 2, 3, 4, 6, 12, 18 };
- var dicts =
- (from fragmentLength in fragmentLengths.AsParallel()
- select CountFrequency(buffer, fragmentLength)).ToArray();
- source.Dispose();
- int res = 100;
- for (ulong i = 0; i < 4; ++i){
- if (dicts[0][i].V != expectedCountLetter[i]){
- res = -1;
- }
- }
- for (ulong i = 0; i < 16; ++i){
- if (dicts[1][i].V != expectedCountPairs[i]){
- res = -1;
- }
- }
- int buflen = dicts[0].Values.Sum(x => x.V);
- WriteFrequencies(dicts[0], buflen, 1);
- WriteFrequencies(dicts[1], buflen, 2);
- if (WriteCount(dicts[2], "GGT") != expectedCountFragments[0]) { res = -1; }
- if (WriteCount(dicts[3], "GGTA") != expectedCountFragments[1]) { res = -1; }
- if (WriteCount(dicts[4], "GGTATT") != expectedCountFragments[2]) { res = -1; }
- if (WriteCount(dicts[5], "GGTATTTTAATT") != expectedCountFragments[3]) { res = -1; }
- if (WriteCount(dicts[6], "GGTATTTTAATTTATAGT") != expectedCountFragments[4]) { res = -1; }
- //Console.ReadKey();
- return res;
- }
-
- private static void WriteFrequencies(Dictionary<ulong, Wrapper> freq, int buflen, int fragmentLength)
- {
-
- double percent = 100.0 / (buflen - fragmentLength + 1);
- foreach (var line in (from k in freq.Keys
- orderby freq[k].V descending
- select string.Format("{0} {1:f3}", PrintKey(k, fragmentLength),
- (freq.ContainsKey(k) ? freq[k].V : 0) * percent)))
- Console.WriteLine(line);
- Console.WriteLine();
- }
-
- private static int WriteCount(Dictionary<ulong, Wrapper> dictionary, string fragment)
- {
- ulong key = 0;
- var keybytes = Encoding.ASCII.GetBytes(fragment.ToLower());
- for (int i = 0; i < keybytes.Length; i++)
- {
- key <<= 2;
- key |= tonum[keybytes[i]];
- }
- Wrapper w;
- int count = dictionary.TryGetValue(key, out w) ? w.V : 0;
- Console.WriteLine("{0}\t{1}",
- count,
- fragment);
- return count;
- }
-
- private static string PrintKey(ulong key, int fragmentLength)
- {
- char[] items = new char[fragmentLength];
- for (int i = 0; i < fragmentLength; ++i)
- {
- items[fragmentLength - i - 1] = tochar[key & 0x3];
- key >>= 2;
- }
- return new string(items);
- }
-
- private static Dictionary<ulong, Wrapper> CountFrequency(byte[] buffer, int fragmentLength)
- {
- var dictionary = new Dictionary<ulong, Wrapper>();
- ulong rollingKey = 0;
- ulong mask = 0;
- int cursor;
- for (cursor = 0; cursor < fragmentLength - 1; cursor++)
- {
- rollingKey <<= 2;
- rollingKey |= tonum[buffer[cursor]];
- mask = (mask << 2) + 3;
- }
- mask = (mask << 2) + 3;
- int stop = buffer.Length;
- Wrapper w;
- byte cursorByte;
- while (cursor < stop)
- {
- if ((cursorByte = buffer[cursor++]) < (byte)'a')
- cursorByte = buffer[cursor++];
- rollingKey = ((rollingKey << 2) & mask) | tonum[cursorByte];
- if (dictionary.TryGetValue(rollingKey, out w))
- w.V++;
- else
- dictionary.Add(rollingKey, new Wrapper(1));
- }
- return dictionary;
- }
-
- private static byte[] GetBytesForThirdSequence(FileStream source)
- {
- const int buffersize = 2500120;
- byte[] threebuffer = null;
- var buffer = new byte[buffersize];
- int amountRead, threebuflen, indexOfFirstByteInThreeSequence, indexOfGreaterThan, threepos, tocopy;
- amountRead = threebuflen = indexOfFirstByteInThreeSequence = indexOfGreaterThan = threepos = tocopy = 0;
- bool threeFound = false;
- //var source = new FileStream(inputFile, FileMode.Open);
- source.Seek(0, SeekOrigin.Begin);
- while (!threeFound && (amountRead = source.Read(buffer, 0, buffersize)) > 0)
- {
- indexOfGreaterThan = Array.LastIndexOf(buffer, (byte)'>');
- threeFound = (indexOfGreaterThan > -1 &&
- buffer[indexOfGreaterThan + 1] == (byte)'T' &&
- buffer[indexOfGreaterThan + 2] == (byte)'H');
- if (threeFound)
- {
- threepos += indexOfGreaterThan;
- threebuflen = threepos - 48;
- threebuffer = new byte[threebuflen];
- indexOfFirstByteInThreeSequence = Array.IndexOf<byte>(buffer, 10, indexOfGreaterThan) + 1;
- tocopy = amountRead - indexOfFirstByteInThreeSequence;
- if (amountRead < buffersize)
- tocopy -= 1;
- Buffer.BlockCopy(buffer, indexOfFirstByteInThreeSequence, threebuffer, 0, tocopy);
- buffer = null;
- }
- else
- threepos += amountRead;
- }
- int toread = threebuflen - tocopy;
- source.Read(threebuffer, tocopy, toread);
- return threebuffer;
- }
-
- private static byte[] tonum = new byte[256];
- private static char[] tochar = new char[4];
- private static void PrepareLookups()
- {
- tonum['a'] = 0;
- tonum['c'] = 1;
- tonum['g'] = 2;
- tonum['t'] = 3;
- tochar[0] = 'A';
- tochar[1] = 'C';
- tochar[2] = 'G';
- tochar[3] = 'T';
- }
-
- [Benchmark(InnerIterationCount=Iterations)]
- public static void Bench_Parallel()
- {
- PrepareLookups();
- string inputFile = FindInput(InputFile);
- var source = new FileStream(inputFile, FileMode.Open);
-
- if (inputFile == null)
- {
- throw new Exception("unable to find input");
- }
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- for (int i = 0; i < Benchmark.InnerIterationCount; ++i)
- {
- var buffer = GetBytesForThirdSequence(source);
- var fragmentLengths = new[] { 1, 2, 3, 4, 6, 12, 18 };
- var dicts =
- (from fragmentLength in fragmentLengths.AsParallel()
- select CountFrequency(buffer, fragmentLength)).ToArray();
- }
- }
- }
- source.Dispose();
- }
- [Benchmark(InnerIterationCount=Iterations)]
- public static void Bench_No_Parallel()
- {
- string inputFile = FindInput(InputFile);
- var source = new FileStream(inputFile, FileMode.Open);
-
- if (inputFile == null)
- {
- throw new Exception("unable to find input");
- }
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- for (int i = 0; i < Benchmark.InnerIterationCount; ++i)
- {
- PrepareLookups();
- var buffer = GetBytesForThirdSequence(source);
- var fragmentLengths = new[] { 1, 2, 3, 4, 6, 12, 18 };
- var dicts =
- (from fragmentLength in fragmentLengths
- select CountFrequency(buffer, fragmentLength)).ToArray();
- }
- }
- }
- source.Dispose();
- }
-}
-
-public class Wrapper
-{
- public int V;
- public Wrapper(int v) { V = v; }
-}
-
-} \ No newline at end of file
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/mandelbrot/mandelbrot-2.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/mandelbrot/mandelbrot-2.cs
new file mode 100644
index 0000000000..fa55666be5
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/mandelbrot/mandelbrot-2.cs
@@ -0,0 +1,138 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// Adapted from mandelbrot C# .NET Core #2 program
+// http://benchmarksgame.alioth.debian.org/u64q/program.php?test=mandelbrot&lang=csharpcore&id=2
+// aka (as of 2017-09-01) rev 1.2 of https://alioth.debian.org/scm/viewvc.php/benchmarksgame/bench/mandelbrot/mandelbrot.csharp-2.csharp?root=benchmarksgame&view=log
+// Best-scoring single-threaded C# .NET Core version as of 2017-09-01
+
+/* The Computer Language Benchmarks Game
+ http://benchmarksgame.alioth.debian.org/
+ *
+ * Adapted by Antti Lankila from the earlier Isaac Gouy's implementation
+ */
+
+using System;
+using System.IO;
+using System.Security.Cryptography;
+using Microsoft.Xunit.Performance;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace BenchmarksGame
+{
+ public class Mandelbrot_2
+ {
+ public static int Main(String[] args)
+ {
+ int width = 80;
+ if (args.Length > 0)
+ width = Int32.Parse(args[0]);
+
+ int lineLen = (width - 1) / 8 + 1;
+ var bytes = new byte[width * lineLen];
+ var memStream = new MemoryStream(bytes);
+
+ DoBench(width, memStream, true);
+
+ if (!MatchesChecksum(bytes, "3B-EF-65-05-1D-39-7F-9B-96-8D-EF-98-BF-06-CE-74"))
+ {
+ return -1;
+ }
+ return 100;
+ }
+
+ // Commented out data left in source to provide checksums for each case
+
+ [Benchmark]
+ //[InlineData(1000, "B2-13-51-CE-B0-29-2C-4E-75-5E-91-19-18-E4-0C-D9")]
+ //[InlineData(2000, "5A-21-55-9B-7B-18-2F-34-9B-33-C5-F9-B5-2C-40-56")]
+ //[InlineData(3000, "E5-82-85-0A-3C-89-69-B1-A8-21-63-52-75-B3-C8-33")]
+ [InlineData(4000, "C7-E6-66-43-66-73-F8-A8-D3-B4-D7-97-2F-FC-A1-D3")]
+ //[InlineData(5000, "6D-36-F1-F6-37-8F-34-EB-52-F9-2D-11-89-12-B2-2F")]
+ //[InlineData(6000, "8B-05-78-EB-2E-0E-98-F2-C7-39-76-ED-0F-A9-D2-B8")]
+ //[InlineData(7000, "01-F8-F2-2A-AB-70-C7-BA-E3-64-19-E7-D2-84-DF-57")]
+ //[InlineData(8000, "C8-ED-D7-FB-65-66-3A-D9-C6-04-9E-96-E8-CA-4F-2C")]
+ public static void Bench(int width, string checksum)
+ {
+ int lineLen = (width - 1) / 8 + 1;
+ byte[] bytes = null;
+
+ Benchmark.Iterate(() =>
+ {
+ bytes = new byte[width * lineLen];
+ var memStream = new MemoryStream(bytes);
+
+ DoBench(width, memStream, false);
+ });
+
+ Assert.True(MatchesChecksum(bytes, checksum));
+ }
+
+ static bool MatchesChecksum(byte[] bytes, string checksum)
+ {
+ using (var md5 = MD5.Create())
+ {
+ byte[] hash = md5.ComputeHash(bytes);
+ return (checksum == BitConverter.ToString(hash));
+ }
+ }
+
+ static void DoBench(int width, MemoryStream s, bool verbose)
+ {
+ int height = width;
+ int maxiter = 50;
+ double limit = 4.0;
+
+ if (verbose)
+ {
+ Console.WriteLine("P4");
+ Console.WriteLine("{0} {1}", width, height);
+ }
+
+ for (int y = 0; y < height; y++)
+ {
+ int bits = 0;
+ int xcounter = 0;
+ double Ci = 2.0 * y / height - 1.0;
+
+ for (int x = 0; x < width; x++)
+ {
+ double Zr = 0.0;
+ double Zi = 0.0;
+ double Cr = 2.0 * x / width - 1.5;
+ int i = maxiter;
+
+ bits = bits << 1;
+ do
+ {
+ double Tr = Zr * Zr - Zi * Zi + Cr;
+ Zi = 2.0 * Zr * Zi + Ci;
+ Zr = Tr;
+ if (Zr * Zr + Zi * Zi > limit)
+ {
+ bits |= 1;
+ break;
+ }
+ } while (--i > 0);
+
+ if (++xcounter == 8)
+ {
+ s.WriteByte((byte)(bits ^ 0xff));
+ bits = 0;
+ xcounter = 0;
+ }
+ }
+ if (xcounter != 0)
+ s.WriteByte((byte)((bits << (8 - xcounter)) ^ 0xff));
+ }
+
+ if (verbose)
+ {
+ s.WriteTo(Console.OpenStandardOutput());
+ }
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/mandelbrot/mandelbrot.csproj b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/mandelbrot/mandelbrot-2.csproj
index 0ef3cdf927..c84799234f 100644
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/mandelbrot/mandelbrot.csproj
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/mandelbrot/mandelbrot-2.csproj
@@ -5,7 +5,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <ProjectGuid>{18ED6F79-05F2-4302-B2B5-543A33C9A517}</ProjectGuid>
<OutputType>Exe</OutputType>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
@@ -28,7 +28,7 @@
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
- <Compile Include="mandelbrot.csharp.cs" />
+ <Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
<PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/mandelbrot/mandelbrot.csharp.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/mandelbrot/mandelbrot-4.cs
index aa38976cb7..e63ed29504 100644
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/mandelbrot/mandelbrot.csharp.cs
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/mandelbrot/mandelbrot-4.cs
@@ -1,31 +1,34 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+
+// Adapted from mandelbrot C# .NET Core #4 program
+// http://benchmarksgame.alioth.debian.org/u64q/program.php?test=mandelbrot&lang=csharpcore&id=4
+// aka (as of 2017-09-01) rev 1.3 of https://alioth.debian.org/scm/viewvc.php/benchmarksgame/bench/mandelbrot/mandelbrot.csharp-4.csharp?root=benchmarksgame&view=log
+// Best-scoring C# .NET Core version as of 2017-09-01
+
/* The Computer Language Benchmarks Game
http://benchmarksgame.alioth.debian.org/
-
+
started with Java #2 program (Krause/Whipkey/Bennet/AhnTran/Enotus/Stalcup)
adapted for C# by Jan de Vaan
simplified and optimised to use TPL by Anthony Lloyd
-
- posted to Benchmarks Game as mandelbrot C# .NET Core #4
- (http://benchmarksgame.alioth.debian.org/u64q/program.php?test=mandelbrot&lang=csharpcore&id=4)
- modified to remove concurrency and operate with xunit-performance
*/
using System;
-using System.Reflection;
+using System.Threading.Tasks;
+using System.IO;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using Microsoft.Xunit.Performance;
-using Microsoft.Xunit.Performance.Api;
using Xunit;
+[assembly: OptimizeForBenchmarks]
+
namespace BenchmarksGame
{
- public class Mandelbrot
+ public class MandelBrot_4
{
-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static byte getByte(double[] Crb, double Ciby, int x, int y)
{
@@ -48,57 +51,31 @@ namespace BenchmarksGame
Zi2 = Zr2 * Zi2 + Zr2 * Zi2 + Ciby;
Zr2 = nZr2;
- if (Zr1 * Zr1 + Zi1 * Zi1 > 4)
- {
- b |= 2;
- if (b == 3)
- break;
- }
- if (Zr2 * Zr2 + Zi2 * Zi2 > 4)
- {
- b |= 1;
- if (b == 3)
- break;
- }
+ if (Zr1 * Zr1 + Zi1 * Zi1 > 4) { b |= 2; if (b == 3) break; }
+ if (Zr2 * Zr2 + Zi2 * Zi2 > 4) { b |= 1; if (b == 3) break; }
} while (--j > 0);
res = (res << 2) + b;
}
return (byte)(res ^ -1);
}
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static byte[] Bench(int n, bool verbose = false)
+ public static int Main(String[] args)
{
- double invN = 2.0 / n;
- var Crb = new double[n + 7];
- for (int i = 0; i < n; i++)
- {
- Crb[i] = i * invN - 1.5;
- }
- int lineLen = (n - 1) / 8 + 1;
- var data = new byte[n * lineLen];
- for (int i = 0; i < n; i++)
- {
- var Cibi = i * invN - 1.0;
- var offset = i * lineLen;
- for (int x = 0; x < lineLen; x++)
- data[offset + x] = getByte(Crb, Cibi, x * 8, i);
- };
+ var n = args.Length > 0 ? Int32.Parse(args[0]) : 80;
+ var data = DoBench(n);
+ Console.Out.WriteLine("P4\n{0} {0}", n);
+ Console.OpenStandardOutput().Write(data, 0, data.Length);
- if (verbose)
+ if (!MatchesChecksum(data, "3B-EF-65-05-1D-39-7F-9B-96-8D-EF-98-BF-06-CE-74"))
{
- Console.Out.WriteLine("P4\n{0} {0}", n);
- Console.OpenStandardOutput().Write(data, 0, data.Length);
+ return -1;
}
-
- return data;
+ return 100;
}
// Commented out data left in source to provide checksums for each case
- // Checksums calculated from the origonal source referenced at top of this source
- [Benchmark]
- //[InlineData(500, "54-01-EE-C8-46-9B-AB-FA-54-9F-45-CE-98-89-66-A9")]
+ [Benchmark(InnerIterationCount = 7)]
//[InlineData(1000, "B2-13-51-CE-B0-29-2C-4E-75-5E-91-19-18-E4-0C-D9")]
//[InlineData(2000, "5A-21-55-9B-7B-18-2F-34-9B-33-C5-F9-B5-2C-40-56")]
//[InlineData(3000, "E5-82-85-0A-3C-89-69-B1-A8-21-63-52-75-B3-C8-33")]
@@ -107,40 +84,42 @@ namespace BenchmarksGame
//[InlineData(6000, "8B-05-78-EB-2E-0E-98-F2-C7-39-76-ED-0F-A9-D2-B8")]
//[InlineData(7000, "01-F8-F2-2A-AB-70-C7-BA-E3-64-19-E7-D2-84-DF-57")]
//[InlineData(8000, "C8-ED-D7-FB-65-66-3A-D9-C6-04-9E-96-E8-CA-4F-2C")]
- public static void Test(int n, string checksum)
+ public static void Bench(int n, string checksum)
{
- foreach (var iteration in Benchmark.Iterations)
+ byte[] bytes = null;
+
+ Benchmark.Iterate(() =>
{
- byte[] bitmap = null;
- using (iteration.StartMeasurement())
- {
- bitmap = Bench(n);
- }
- using (var md5 = MD5.Create())
- {
- byte[] hash = md5.ComputeHash(bitmap);
- Assert.Equal(checksum, BitConverter.ToString(hash));
- }
- }
+ bytes = DoBench(n);
+ });
+
+ Assert.True(MatchesChecksum(bytes, checksum));
}
- public static bool VerifyBench(int n, string checksum)
+ static bool MatchesChecksum(byte[] bytes, string checksum)
{
- byte[] bitmap = Bench(n);
using (var md5 = MD5.Create())
{
- byte[] hash = md5.ComputeHash(bitmap);
- return checksum == BitConverter.ToString(hash);
+ byte[] hash = md5.ComputeHash(bytes);
+ return (checksum == BitConverter.ToString(hash));
}
}
- public static int Main(string[] args)
+ static byte[] DoBench(int n)
{
- const int n = 500;
- const string checksum = "54-01-EE-C8-46-9B-AB-FA-54-9F-45-CE-98-89-66-A9";
-
- bool verified = VerifyBench(n, checksum);
- return (verified ? 100 : -1);
+ double invN = 2.0 / n;
+ var Crb = new double[n + 7];
+ for (int i = 0; i < n; i++) { Crb[i] = i * invN - 1.5; }
+ int lineLen = (n - 1) / 8 + 1;
+ var data = new byte[n * lineLen];
+ Parallel.For(0, n, y =>
+ {
+ var Ciby = y * invN - 1.0;
+ var offset = y * lineLen;
+ for (int x = 0; x < lineLen; x++)
+ data[offset + x] = getByte(Crb, Ciby, x * 8, y);
+ });
+ return data;
}
}
}
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/mandelbrot/mandelbrot-4.csproj b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/mandelbrot/mandelbrot-4.csproj
new file mode 100644
index 0000000000..3ab35800e2
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/mandelbrot/mandelbrot-4.csproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{4BF33255-0CAD-42CA-81F0-60E536BA4E9D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="$(MSBuildProjectName).cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project> \ No newline at end of file
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/n-body/n-body-3.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/n-body/n-body-3.cs
new file mode 100644
index 0000000000..9be89da2f0
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/n-body/n-body-3.cs
@@ -0,0 +1,160 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// Adapted from n-body C# .NET Core #3 program
+// http://benchmarksgame.alioth.debian.org/u64q/program.php?test=nbody&lang=csharpcore&id=3
+// aka (as of 2017-09-01) rev 1.2 of https://alioth.debian.org/scm/viewvc.php/benchmarksgame/bench/nbody/nbody.csharp-3.csharp?root=benchmarksgame&view=log
+// Best-scoring C# .NET Core version as of 2017-09-01
+// (also best-scoring single-threaded C# .NET Core version as of 2017-09-01)
+
+/* The Computer Language Benchmarks Game
+ http://benchmarksgame.alioth.debian.org/
+
+ contributed by Isaac Gouy, optimization and use of more C# idioms by Robert F. Tobler
+*/
+
+using System;
+using Microsoft.Xunit.Performance;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace BenchmarksGame
+{
+ public class NBody_3
+ {
+ public static int Main(String[] args)
+ {
+ int n = args.Length > 0 ? Int32.Parse(args[0]) : 10000;
+ bool success = Bench(n, true);
+ return (success ? 100 : -1);
+ }
+
+ [Benchmark(InnerIterationCount = 2)]
+ public static void RunBench()
+ {
+ Benchmark.Iterate(() => Bench(5000000, false));
+ }
+
+ static bool Bench(int n, bool verbose)
+ {
+ NBodySystem bodies = new NBodySystem();
+ double initialEnergy = bodies.Energy();
+ if (verbose) Console.WriteLine("{0:f9}", initialEnergy);
+ for (int i = 0; i < n; i++) bodies.Advance(0.01);
+ double finalEnergy = bodies.Energy();
+ if (verbose) Console.WriteLine("{0:f9}", finalEnergy);
+ double deltaEnergy = Math.Abs(initialEnergy - finalEnergy);
+ bool result = deltaEnergy < 1e-4;
+ if (verbose) Console.WriteLine("Energy {0} conserved", result ? "was" : "was not");
+ return result;
+ }
+ }
+
+ class Body { public double x, y, z, vx, vy, vz, mass; }
+ class Pair { public Body bi, bj; }
+
+ class NBodySystem
+ {
+ private Body[] bodies;
+ private Pair[] pairs;
+
+ const double Pi = 3.141592653589793;
+ const double Solarmass = 4 * Pi * Pi;
+ const double DaysPeryear = 365.24;
+
+ public NBodySystem()
+ {
+ bodies = new Body[] {
+ new Body() { // Sun
+ mass = Solarmass,
+ },
+ new Body() { // Jupiter
+ x = 4.84143144246472090e+00,
+ y = -1.16032004402742839e+00,
+ z = -1.03622044471123109e-01,
+ vx = 1.66007664274403694e-03 * DaysPeryear,
+ vy = 7.69901118419740425e-03 * DaysPeryear,
+ vz = -6.90460016972063023e-05 * DaysPeryear,
+ mass = 9.54791938424326609e-04 * Solarmass,
+ },
+ new Body() { // Saturn
+ x = 8.34336671824457987e+00,
+ y = 4.12479856412430479e+00,
+ z = -4.03523417114321381e-01,
+ vx = -2.76742510726862411e-03 * DaysPeryear,
+ vy = 4.99852801234917238e-03 * DaysPeryear,
+ vz = 2.30417297573763929e-05 * DaysPeryear,
+ mass = 2.85885980666130812e-04 * Solarmass,
+ },
+ new Body() { // Uranus
+ x = 1.28943695621391310e+01,
+ y = -1.51111514016986312e+01,
+ z = -2.23307578892655734e-01,
+ vx = 2.96460137564761618e-03 * DaysPeryear,
+ vy = 2.37847173959480950e-03 * DaysPeryear,
+ vz = -2.96589568540237556e-05 * DaysPeryear,
+ mass = 4.36624404335156298e-05 * Solarmass,
+ },
+ new Body() { // Neptune
+ x = 1.53796971148509165e+01,
+ y = -2.59193146099879641e+01,
+ z = 1.79258772950371181e-01,
+ vx = 2.68067772490389322e-03 * DaysPeryear,
+ vy = 1.62824170038242295e-03 * DaysPeryear,
+ vz = -9.51592254519715870e-05 * DaysPeryear,
+ mass = 5.15138902046611451e-05 * Solarmass,
+ },
+ };
+
+ pairs = new Pair[bodies.Length * (bodies.Length - 1) / 2];
+ int pi = 0;
+ for (int i = 0; i < bodies.Length - 1; i++)
+ for (int j = i + 1; j < bodies.Length; j++)
+ pairs[pi++] = new Pair() { bi = bodies[i], bj = bodies[j] };
+
+ double px = 0.0, py = 0.0, pz = 0.0;
+ foreach (var b in bodies)
+ {
+ px += b.vx * b.mass; py += b.vy * b.mass; pz += b.vz * b.mass;
+ }
+ var sol = bodies[0];
+ sol.vx = -px / Solarmass; sol.vy = -py / Solarmass; sol.vz = -pz / Solarmass;
+ }
+
+ public void Advance(double dt)
+ {
+ foreach (var p in pairs)
+ {
+ Body bi = p.bi, bj = p.bj;
+ double dx = bi.x - bj.x, dy = bi.y - bj.y, dz = bi.z - bj.z;
+ double d2 = dx * dx + dy * dy + dz * dz;
+ double mag = dt / (d2 * Math.Sqrt(d2));
+ bi.vx -= dx * bj.mass * mag; bj.vx += dx * bi.mass * mag;
+ bi.vy -= dy * bj.mass * mag; bj.vy += dy * bi.mass * mag;
+ bi.vz -= dz * bj.mass * mag; bj.vz += dz * bi.mass * mag;
+ }
+ foreach (var b in bodies)
+ {
+ b.x += dt * b.vx; b.y += dt * b.vy; b.z += dt * b.vz;
+ }
+ }
+
+ public double Energy()
+ {
+ double e = 0.0;
+ for (int i = 0; i < bodies.Length; i++)
+ {
+ var bi = bodies[i];
+ e += 0.5 * bi.mass * (bi.vx * bi.vx + bi.vy * bi.vy + bi.vz * bi.vz);
+ for (int j = i + 1; j < bodies.Length; j++)
+ {
+ var bj = bodies[j];
+ double dx = bi.x - bj.x, dy = bi.y - bj.y, dz = bi.z - bj.z;
+ e -= (bi.mass * bj.mass) / Math.Sqrt(dx * dx + dy * dy + dz * dz);
+ }
+ }
+ return e;
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fastaredux/fastaredux.csproj b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/n-body/n-body-3.csproj
index 9260a22668..da46bac201 100644
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/fastaredux/fastaredux.csproj
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/n-body/n-body-3.csproj
@@ -28,11 +28,11 @@
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
- <Compile Include="fastaredux.csharp.cs" />
+ <Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
<PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
<PropertyGroup>
<ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
</PropertyGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/nbody/nbody.csharp-3.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/nbody/nbody.csharp-3.cs
deleted file mode 100644
index 60e083ad11..0000000000
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/nbody/nbody.csharp-3.cs
+++ /dev/null
@@ -1,158 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-/* The Computer Language Benchmarks Game
- http://benchmarksgame.alioth.debian.org/
-
- contributed by Isaac Gouy, optimization and use of more C# idioms by Robert F. Tobler
-
- modified for use with xunit-performance
-*/
-
-using Microsoft.Xunit.Performance;
-using System;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace BenchmarksGame
-{
-public class NBody
-{
- public static int Main(String[] args)
- {
- int n = args.Length > 0 ? Int32.Parse(args[0]) : 10000;
- NBodySystem bodies = new NBodySystem();
- double initialEnergy = bodies.Energy();
- Console.WriteLine("{0:f9}", initialEnergy);
- for (int i = 0; i < n; i++) bodies.Advance(0.01);
- double finalEnergy = bodies.Energy();
- Console.WriteLine("{0:f9}", finalEnergy);
- double deltaEnergy = Math.Abs(initialEnergy - finalEnergy);
- bool result = deltaEnergy < 1e-4;
- Console.WriteLine("Energy {0} conserved", result ? "was" : "was not");
- return (result ? 100 : -1);
- }
-
- [Benchmark]
- public static void Bench()
- {
- int n = 5000000;
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- NBodySystem bodies = new NBodySystem();
- for (int i = 0; i < n; i++) bodies.Advance(0.01);
- }
- }
- }
-}
-
-internal class Body { public double x, y, z, vx, vy, vz, mass; }
-internal class Pair { public Body bi, bj; }
-
-internal class NBodySystem
-{
- private Body[] _bodies;
- private Pair[] _pairs;
-
- private const double Pi = 3.141592653589793;
- private const double Solarmass = 4 * Pi * Pi;
- private const double DaysPeryear = 365.24;
-
- public NBodySystem()
- {
- _bodies = new Body[] {
- new Body() { // Sun
- mass = Solarmass,
- },
- new Body() { // Jupiter
- x = 4.84143144246472090e+00,
- y = -1.16032004402742839e+00,
- z = -1.03622044471123109e-01,
- vx = 1.66007664274403694e-03 * DaysPeryear,
- vy = 7.69901118419740425e-03 * DaysPeryear,
- vz = -6.90460016972063023e-05 * DaysPeryear,
- mass = 9.54791938424326609e-04 * Solarmass,
- },
- new Body() { // Saturn
- x = 8.34336671824457987e+00,
- y = 4.12479856412430479e+00,
- z = -4.03523417114321381e-01,
- vx = -2.76742510726862411e-03 * DaysPeryear,
- vy = 4.99852801234917238e-03 * DaysPeryear,
- vz = 2.30417297573763929e-05 * DaysPeryear,
- mass = 2.85885980666130812e-04 * Solarmass,
- },
- new Body() { // Uranus
- x = 1.28943695621391310e+01,
- y = -1.51111514016986312e+01,
- z = -2.23307578892655734e-01,
- vx = 2.96460137564761618e-03 * DaysPeryear,
- vy = 2.37847173959480950e-03 * DaysPeryear,
- vz = -2.96589568540237556e-05 * DaysPeryear,
- mass = 4.36624404335156298e-05 * Solarmass,
- },
- new Body() { // Neptune
- x = 1.53796971148509165e+01,
- y = -2.59193146099879641e+01,
- z = 1.79258772950371181e-01,
- vx = 2.68067772490389322e-03 * DaysPeryear,
- vy = 1.62824170038242295e-03 * DaysPeryear,
- vz = -9.51592254519715870e-05 * DaysPeryear,
- mass = 5.15138902046611451e-05 * Solarmass,
- },
- };
-
- _pairs = new Pair[_bodies.Length * (_bodies.Length - 1) / 2];
- int pi = 0;
- for (int i = 0; i < _bodies.Length - 1; i++)
- for (int j = i + 1; j < _bodies.Length; j++)
- _pairs[pi++] = new Pair() { bi = _bodies[i], bj = _bodies[j] };
-
- double px = 0.0, py = 0.0, pz = 0.0;
- foreach (var b in _bodies)
- {
- px += b.vx * b.mass; py += b.vy * b.mass; pz += b.vz * b.mass;
- }
- var sol = _bodies[0];
- sol.vx = -px / Solarmass; sol.vy = -py / Solarmass; sol.vz = -pz / Solarmass;
- }
-
- public void Advance(double dt)
- {
- foreach (var p in _pairs)
- {
- Body bi = p.bi, bj = p.bj;
- double dx = bi.x - bj.x, dy = bi.y - bj.y, dz = bi.z - bj.z;
- double d2 = dx * dx + dy * dy + dz * dz;
- double mag = dt / (d2 * Math.Sqrt(d2));
- bi.vx -= dx * bj.mass * mag; bj.vx += dx * bi.mass * mag;
- bi.vy -= dy * bj.mass * mag; bj.vy += dy * bi.mass * mag;
- bi.vz -= dz * bj.mass * mag; bj.vz += dz * bi.mass * mag;
- }
- foreach (var b in _bodies)
- {
- b.x += dt * b.vx; b.y += dt * b.vy; b.z += dt * b.vz;
- }
- }
-
- public double Energy()
- {
- double e = 0.0;
- for (int i = 0; i < _bodies.Length; i++)
- {
- var bi = _bodies[i];
- e += 0.5 * bi.mass * (bi.vx * bi.vx + bi.vy * bi.vy + bi.vz * bi.vz);
- for (int j = i + 1; j < _bodies.Length; j++)
- {
- var bj = _bodies[j];
- double dx = bi.x - bj.x, dy = bi.y - bj.y, dz = bi.z - bj.z;
- e -= (bi.mass * bj.mass) / Math.Sqrt(dx * dx + dy * dy + dz * dz);
- }
- }
- return e;
- }
-}
-}
-
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/pidigits/pi-digits.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/pidigits/pi-digits.cs
deleted file mode 100644
index 3c79a89edc..0000000000
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/pidigits/pi-digits.cs
+++ /dev/null
@@ -1,116 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-/* The Computer Language Benchmarks Game
- * http://benchmarksgame.alioth.debian.org/
- *
- * Port of the C code that uses GMP
- * Just switched it to use C#'s BigInteger instead
- *
- * To compile use csc /o+ /r:System.Numerics.dll
- *
- * modified for use with xunit-performance
-*/
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Numerics;
-using System.Text;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace BenchmarksGame
-{
-public class pidigits
-{
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 50;
-#endif
-
- private BigInteger _acc,_den,_num;
-
- public pidigits()
- {
- _acc = BigInteger.Zero;
- _den = BigInteger.One;
- _num = BigInteger.One;
- }
-
- public uint extract_digit(uint nth)
- {
- return (uint)((_num * nth + _acc) / _den);
- }
-
- public void eliminate_digit(uint d)
- {
- _acc -= _den * d;
- _acc *= 10;
- _num *= 10;
- }
-
- public void next_term(uint k)
- {
- uint k2 = k * 2 + 1;
- _acc += _num * 2;
- _acc *= k2;
- _den *= k2;
- _num *= k;
- }
-
- public void Calculate(int n, bool verbose = false)
- {
- StringBuilder sb = new StringBuilder(20);
- uint d, k, i;
- for (i = k = 0; i < n;)
- {
- next_term(++k);
- if (_num > _acc)
- continue;
- d = extract_digit(3);
- if (d != extract_digit(4))
- continue;
- sb.Append((char)('0' + d));
- if (++i % 10 == 0)
- {
- if (verbose)
- {
- Console.WriteLine("{0}\t:{1}", sb, i);
- }
- sb.Clear();
- }
- eliminate_digit(d);
- }
- }
-
- public static int Main(String[] args)
- {
- int length = args.Length == 0 ? 10 : Int32.Parse(args[0]);
- for (int i = 0; i < Iterations; i++)
- {
- pidigits p = new pidigits();
- p.Calculate(length, true);
- }
- return 100;
- }
-
- [Benchmark]
- public static void Bench()
- {
- int length = 600;
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- for (int i = 0; i < Iterations; i++)
- {
- pidigits p = new pidigits();
- p.Calculate(length);
- }
- }
- }
- }
-}
-}
-
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/pidigits/pidigits-3.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/pidigits/pidigits-3.cs
new file mode 100644
index 0000000000..0f97c277d5
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/pidigits/pidigits-3.cs
@@ -0,0 +1,160 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// Adapted from pidigits C# .NET Core #3 program
+// http://benchmarksgame.alioth.debian.org/u64q/program.php?test=pidigits&lang=csharpcore&id=3
+// aka (as of 2017-09-01) rev 1.2 of https://alioth.debian.org/scm/viewvc.php/benchmarksgame/bench/pidigits/pidigits.csharp-3.csharp?root=benchmarksgame&view=log
+// Best-scoring C# .NET Core version as of 2017-09-01
+// (also best-scoring single-threaded C# .NET Core version as of 2017-09-01)
+// **** Version #3 on website pinvokes to native GMP library; this has been modified to
+// use .NET's System.Numerics.BigInteger type instead ****
+
+/* The Computer Language Benchmarks Game
+ http://benchmarksgame.alioth.debian.org/
+ *
+ * Port of the Java port that uses native GMP to use native GMP with C#
+ * contributed by Miguel de Icaza, based on the Java version, that was:
+ * contributed by Mike Pall
+ * java port by Stefan Krause
+*/
+using System;
+using System.Numerics;
+using System.Text;
+using Microsoft.Xunit.Performance;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace BenchmarksGame
+{
+
+ public class pidigits
+ {
+ BigInteger q = new BigInteger(), r = new BigInteger(), s = new BigInteger(), t = new BigInteger();
+ BigInteger u = new BigInteger(), v = new BigInteger(), w = new BigInteger();
+
+ int i;
+ StringBuilder strBuf = new StringBuilder(40), lastBuf = null;
+ int n;
+
+ pidigits(int n)
+ {
+ this.n = n;
+ }
+
+ private void compose_r(int bq, int br, int bs, int bt)
+ {
+ u = r * bs;
+ r *= bq;
+ v = t * br;
+ r += v;
+ t *= bt;
+ t += u;
+ s *= bt;
+ u = q * bs;
+ s += u;
+ q *= bq;
+ }
+
+ /* Compose matrix with numbers on the left. */
+ private void compose_l(int bq, int br, int bs, int bt)
+ {
+ r *= bt;
+ u = q * br;
+ r += u;
+ u = t * bs;
+ t *= bt;
+ v = s * br;
+ t += v;
+ s *= bq;
+ s += u;
+ q *= bq;
+ }
+
+ /* Extract one digit. */
+ private int extract(int j)
+ {
+ u = q * j;
+ u += r;
+ v = s * j;
+ v += t;
+ w = u / v;
+ return (int)w;
+ }
+
+ /* Print one digit. Returns 1 for the last digit. */
+ private bool prdigit(int y, bool verbose)
+ {
+ strBuf.Append(y);
+ if (++i % 10 == 0 || i == n)
+ {
+ if (i % 10 != 0)
+ for (int j = 10 - (i % 10); j > 0; j--)
+ { strBuf.Append(" "); }
+ strBuf.Append("\t:");
+ strBuf.Append(i);
+ if (verbose) Console.WriteLine(strBuf);
+ lastBuf = strBuf;
+ strBuf = new StringBuilder(40);
+ }
+ return i == n;
+ }
+
+ /* Generate successive digits of PI. */
+ void Run(bool verbose)
+ {
+ int k = 1;
+ i = 0;
+ q = 1;
+ r = 0;
+ s = 0;
+ t = 1;
+ for (; ; )
+ {
+ int y = extract(3);
+ if (y == extract(4))
+ {
+ if (prdigit(y, verbose))
+ return;
+ compose_r(10, -10 * y, 0, 1);
+ }
+ else
+ {
+ compose_l(k, 4 * k + 2, 0, 2 * k + 1);
+ k++;
+ }
+ }
+ }
+
+ public static int Main(String[] args)
+ {
+ int n = (args.Length > 0 ? Int32.Parse(args[0]) : 10);
+ string result = Bench(n, true).ToString();
+ if (result != "3141592653\t:10")
+ {
+ return -1;
+ }
+ return 100;
+ }
+
+ public static StringBuilder Bench(int n, bool verbose)
+ {
+ pidigits m = new pidigits(n);
+ m.Run(verbose);
+ return m.lastBuf;
+ }
+ }
+
+ public class PiDigits_3
+ {
+ [Benchmark]
+ [InlineData(3000, "8649423196\t:3000")]
+ public static void RunBench(int n, string expected)
+ {
+ StringBuilder result = null;
+ Benchmark.Iterate(() => result = pidigits.Bench(n, false));
+ Assert.Equal(expected, result.ToString());
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/pidigits/pidigits-3.csproj b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/pidigits/pidigits-3.csproj
new file mode 100644
index 0000000000..55a5ee7ef7
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/pidigits/pidigits-3.csproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{E37DE574-AFEC-40E8-B513-FBB09D5EFFFF}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="$(MSBuildProjectName).cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project> \ No newline at end of file
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/harness-helpers.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/harness-helpers.cs
new file mode 100644
index 0000000000..25627bad5a
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/harness-helpers.cs
@@ -0,0 +1,94 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// Helper functionality to locate inputs and find outputs for
+// regex-redux benchmark in CoreCLR test harness
+
+using System;
+using System.IO;
+using System.Text;
+
+namespace BenchmarksGame
+{
+ class TestHarnessHelpers
+ {
+ public string InputFile;
+ public int ExpectedLength;
+
+ public TestHarnessHelpers(bool bigInput, [System.Runtime.CompilerServices.CallerFilePath] string csFileName = "")
+ {
+ if (bigInput)
+ {
+ InputFile = FindInputFile("regexdna-input25000.txt", csFileName);
+ ExpectedLength = 136381;
+ }
+ else
+ {
+ InputFile = FindInputFile("regexdna-input25.txt", csFileName);
+ ExpectedLength = 152;
+ }
+ }
+
+ public string FindInputFile(string inputFile, string csFileName)
+ {
+ string CoreRoot = System.Environment.GetEnvironmentVariable("CORE_ROOT");
+
+ if (CoreRoot == null)
+ {
+ Console.WriteLine("This benchmark requries CORE_ROOT to be set");
+ return null;
+ }
+
+ // The convention is that the csproj file has the same name as the cs file.
+ string projectName = Path.GetFileNameWithoutExtension(csFileName);
+ int slashIndex = projectName.LastIndexOfAny(new char[] { '/', '\\' });
+ if (slashIndex != -1)
+ {
+ // csFileName was generated by the C# compiler, which may have run on
+ // a different host system with different path separator than the
+ // currently executing host, which dictates GetFileNameWithoutExtension's
+ // behavior... so hope that the slash here is a cross-host path separator,
+ // and chop of what were likely direcotires.
+ projectName = projectName.Substring(slashIndex + 1);
+ }
+
+ // Normal testing -- input file will end up next to the assembly
+ // and CoreRoot points at the test overlay dir
+ string[] pathPartsNormal = new string[] {
+ CoreRoot, "..", "..", "JIT", "Performance",
+ "CodeQuality", "BenchmarksGame", "regex-redux", projectName, inputFile
+ };
+
+ string inputPathNormal = Path.Combine(pathPartsNormal);
+
+ // Perf testing -- input file will end up next to the assembly
+ // and CoreRoot points at this directory
+ string[] pathPartsPerf = new string[] { CoreRoot, inputFile };
+
+ string inputPathPerf = Path.Combine(pathPartsPerf);
+
+ string inputPath = null;
+
+ if (File.Exists(inputPathNormal))
+ {
+ inputPath = inputPathNormal;
+ }
+ else if (File.Exists(inputPathPerf))
+ {
+ inputPath = inputPathPerf;
+ }
+
+ if (inputPath != null)
+ {
+ Console.WriteLine("Using input file {0}", inputFile);
+ }
+ else
+ {
+ throw new Exception($"Unable to find input file {inputFile}. Tried {inputPathNormal} and {inputPathPerf}; csFileName was {csFileName}, so projectName was {projectName}.");
+ }
+
+ return inputPath;
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/regex-redux-1.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/regex-redux-1.cs
new file mode 100644
index 0000000000..730100284e
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/regex-redux-1.cs
@@ -0,0 +1,131 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// Adapted from regex-redux C# .NET Core program
+// http://benchmarksgame.alioth.debian.org/u64q/program.php?test=regexredux&lang=csharpcore&id=1
+// aka (as of 2017-09-01) rev 1.3 of https://alioth.debian.org/scm/viewvc.php/benchmarksgame/bench/regexredux/regexredux.csharp?root=benchmarksgame&view=log
+// Best-scoring single-threaded C# .NET Core version as of 2017-09-01
+
+/* The Computer Language Benchmarks Game
+ http://benchmarksgame.alioth.debian.org/
+ *
+ * regex-dna program contributed by Isaac Gouy
+ * converted from regex-dna program
+ *
+*/
+
+using System;
+using System.IO;
+using System.Text.RegularExpressions;
+using Microsoft.Xunit.Performance;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace BenchmarksGame
+{
+ public class RegexRedux_1
+ {
+ static int Main(string[] args)
+ {
+ var helpers = new TestHarnessHelpers(bigInput: false);
+
+ using (var inputStream = new FileStream(helpers.InputFile, FileMode.Open))
+ using (var input = new StreamReader(inputStream))
+ {
+ if (Bench(input, true) != helpers.ExpectedLength)
+ {
+ return -1;
+ }
+ }
+
+ return 100;
+ }
+
+ [Benchmark(InnerIterationCount = 5)]
+ public static void RunBench()
+ {
+ var helpers = new TestHarnessHelpers(bigInput: true);
+
+ Benchmark.Iterate(() =>
+ {
+ using (var inputStream = new FileStream(helpers.InputFile, FileMode.Open))
+ using (var input = new StreamReader(inputStream))
+ {
+ Assert.Equal(helpers.ExpectedLength, Bench(input, false));
+ }
+ });
+ }
+
+ static int Bench(TextReader inputReader, bool verbose)
+ {
+ // read FASTA sequence
+ String sequence = inputReader.ReadToEnd();
+ int initialLength = sequence.Length;
+
+ // remove FASTA sequence descriptions and new-lines
+ Regex r = new Regex(">.*\n|\n", RegexOptions.Compiled);
+ sequence = r.Replace(sequence, "");
+ int codeLength = sequence.Length;
+
+
+ // regex match
+ string[] variants = {
+ "agggtaaa|tttaccct",
+ "[cgt]gggtaaa|tttaccc[acg]",
+ "a[act]ggtaaa|tttacc[agt]t",
+ "ag[act]gtaaa|tttac[agt]ct",
+ "agg[act]taaa|ttta[agt]cct",
+ "aggg[acg]aaa|ttt[cgt]ccct",
+ "agggt[cgt]aa|tt[acg]accct",
+ "agggta[cgt]a|t[acg]taccct",
+ "agggtaa[cgt]|[acg]ttaccct"
+ };
+
+ int count;
+ foreach (string v in variants)
+ {
+ count = 0;
+ r = new Regex(v, RegexOptions.Compiled);
+
+ for (Match m = r.Match(sequence); m.Success; m = m.NextMatch()) count++;
+ if (verbose)
+ Console.WriteLine("{0} {1}", v, count);
+ }
+
+
+ // regex substitution
+ IUB[] codes = {
+ new IUB("tHa[Nt]", "<4>"),
+ new IUB("aND|caN|Ha[DS]|WaS", "<3>"),
+ new IUB("a[NSt]|BY", "<2>"),
+ new IUB("<[^>]*>", "|"),
+ new IUB("\\|[^|][^|]*\\|" , "-")
+ };
+
+ foreach (IUB iub in codes)
+ {
+ r = new Regex(iub.code, RegexOptions.Compiled);
+ sequence = r.Replace(sequence, iub.alternatives);
+ }
+ if (verbose)
+ Console.WriteLine("\n{0}\n{1}\n{2}", initialLength, codeLength, sequence.Length);
+
+ return sequence.Length;
+ }
+
+
+ struct IUB
+ {
+ public string code;
+ public string alternatives;
+
+ public IUB(string code, string alternatives)
+ {
+ this.code = code;
+ this.alternatives = alternatives;
+ }
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regexdna/regexdna.csproj b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/regex-redux-1.csproj
index e7b9d42bd0..a2acf1f1fe 100644
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regexdna/regexdna.csproj
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/regex-redux-1.csproj
@@ -5,7 +5,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <ProjectGuid>{EFF6D8FE-2713-41B7-BF77-8DD03BADFAB6}</ProjectGuid>
<OutputType>Exe</OutputType>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
@@ -30,7 +30,8 @@
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
- <Compile Include="regexdna.csharp-6.cs" />
+ <Compile Include="$(MSBuildProjectName).cs" />
+ <Compile Include="harness-helpers.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="regexdna-input25.txt">
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/regex-redux-5.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/regex-redux-5.cs
new file mode 100644
index 0000000000..8eb5f9ed82
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/regex-redux-5.cs
@@ -0,0 +1,123 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// Adapted from regex-redux C# .NET Core #5 program
+// http://benchmarksgame.alioth.debian.org/u64q/program.php?test=regexredux&lang=csharpcore&id=5
+// aka (as of 2017-09-01) rev 1.3 of https://alioth.debian.org/scm/viewvc.php/benchmarksgame/bench/regexredux/regexredux.csharp-5.csharp?root=benchmarksgame&view=log
+// Best-scoring C# .NET Core version as of 2017-09-01
+
+/* The Computer Language Benchmarks Game
+ http://benchmarksgame.alioth.debian.org/
+
+ Regex-Redux by Josh Goldfoot
+ order variants by execution time by Anthony Lloyd
+*/
+
+using System;
+using System.IO;
+using System.Threading.Tasks;
+using System.Text.RegularExpressions;
+using Microsoft.Xunit.Performance;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace BenchmarksGame
+{
+ public class RegexRedux_5
+ {
+ static Regex regex(string re)
+ {
+ // Not compiled on .Net Core, hence poor benchmark results.
+ return new Regex(re, RegexOptions.Compiled);
+ }
+
+ static string regexCount(string s, string r)
+ {
+ int c = 0;
+ var m = regex(r).Match(s);
+ while (m.Success) { c++; m = m.NextMatch(); }
+ return r + " " + c;
+ }
+
+ public static int Main(string[] args)
+ {
+ var helpers = new TestHarnessHelpers(bigInput: false);
+
+ using (var inputStream = new FileStream(helpers.InputFile, FileMode.Open))
+ using (var input = new StreamReader(inputStream))
+ {
+ if (Bench(input, true) != helpers.ExpectedLength)
+ {
+ return -1;
+ }
+ }
+
+ return 100;
+ }
+
+ [Benchmark(InnerIterationCount = 14)]
+ public static void RunBench()
+ {
+ var helpers = new TestHarnessHelpers(bigInput: true);
+
+ Benchmark.Iterate(() =>
+ {
+ using (var inputStream = new FileStream(helpers.InputFile, FileMode.Open))
+ using (var input = new StreamReader(inputStream))
+ {
+ Assert.Equal(helpers.ExpectedLength, Bench(input, false));
+ }
+ });
+ }
+
+ static int Bench(TextReader inputReader, bool verbose)
+ {
+ var sequences = inputReader.ReadToEnd();
+ var initialLength = sequences.Length;
+ sequences = Regex.Replace(sequences, ">.*\n|\n", "");
+
+ var magicTask = Task.Run(() =>
+ {
+ var newseq = regex("tHa[Nt]").Replace(sequences, "<4>");
+ newseq = regex("aND|caN|Ha[DS]|WaS").Replace(newseq, "<3>");
+ newseq = regex("a[NSt]|BY").Replace(newseq, "<2>");
+ newseq = regex("<[^>]*>").Replace(newseq, "|");
+ newseq = regex("\\|[^|][^|]*\\|").Replace(newseq, "-");
+ return newseq.Length;
+ });
+
+ var variant2 = Task.Run(() => regexCount(sequences, "[cgt]gggtaaa|tttaccc[acg]"));
+ var variant3 = Task.Run(() => regexCount(sequences, "a[act]ggtaaa|tttacc[agt]t"));
+ var variant7 = Task.Run(() => regexCount(sequences, "agggt[cgt]aa|tt[acg]accct"));
+ var variant6 = Task.Run(() => regexCount(sequences, "aggg[acg]aaa|ttt[cgt]ccct"));
+ var variant4 = Task.Run(() => regexCount(sequences, "ag[act]gtaaa|tttac[agt]ct"));
+ var variant5 = Task.Run(() => regexCount(sequences, "agg[act]taaa|ttta[agt]cct"));
+ var variant1 = Task.Run(() => regexCount(sequences, "agggtaaa|tttaccct"));
+ var variant9 = Task.Run(() => regexCount(sequences, "agggtaa[cgt]|[acg]ttaccct"));
+ var variant8 = Task.Run(() => regexCount(sequences, "agggta[cgt]a|t[acg]taccct"));
+
+ if (verbose)
+ {
+ Console.Out.WriteLineAsync(variant1.Result);
+ Console.Out.WriteLineAsync(variant2.Result);
+ Console.Out.WriteLineAsync(variant3.Result);
+ Console.Out.WriteLineAsync(variant4.Result);
+ Console.Out.WriteLineAsync(variant5.Result);
+ Console.Out.WriteLineAsync(variant6.Result);
+ Console.Out.WriteLineAsync(variant7.Result);
+ Console.Out.WriteLineAsync(variant8.Result);
+ Console.Out.WriteLineAsync(variant9.Result);
+ Console.Out.WriteLineAsync("\n" + initialLength + "\n" + sequences.Length);
+ Console.Out.WriteLineAsync(magicTask.Result.ToString());
+ }
+ else
+ {
+ Task.WaitAll(variant1, variant2, variant3, variant4, variant5, variant6, variant7, variant8, variant9);
+ }
+
+ return magicTask.Result;
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/regex-redux-5.csproj b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/regex-redux-5.csproj
new file mode 100644
index 0000000000..cd45a0937c
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/regex-redux-5.csproj
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{FCEF2E71-7E24-4306-9CCA-56BD251FB66E}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="$(MSBuildProjectName).cs" />
+ <Compile Include="harness-helpers.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="regexdna-input25.txt">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="regexdna-input25000.txt">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regexdna/regexdna-input25.txt b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/regexdna-input25.txt
index c32ac3c876..c32ac3c876 100644
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regexdna/regexdna-input25.txt
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/regexdna-input25.txt
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regexdna/regexdna-input25000.txt b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/regexdna-input25000.txt
index fd4414b176..fd4414b176 100644
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regexdna/regexdna-input25000.txt
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/regexdna-input25000.txt
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regexdna/regexdna.csharp-6.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regexdna/regexdna.csharp-6.cs
deleted file mode 100644
index 882bfd23f9..0000000000
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/regexdna/regexdna.csharp-6.cs
+++ /dev/null
@@ -1,229 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-/* The Computer Language Benchmarks Game
- http://benchmarksgame.alioth.debian.org/
- *
- * contributed by Jimmy Tang
- *
- * modified for use with xunit-performance
- */
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using System.Linq;
-using System.Text.RegularExpressions;
-using System.Threading;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace BenchmarksGame
-{
-
-public static class Regexdna
-{
-
-#if DEBUG
- const bool Verbose = true;
- const int Iterations = 1;
- const string InputFile = "regexdna-input25.txt";
-#else
- const bool Verbose = false;
- const int Iterations = 6;
- const string InputFile = "regexdna-input25000.txt";
-#endif
-
- static string FindInput(string s)
- {
- string CoreRoot = System.Environment.GetEnvironmentVariable("CORE_ROOT");
-
- if (CoreRoot == null)
- {
- Console.WriteLine("This benchmark requries CORE_ROOT to be set");
- return null;
- }
-
- string inputFile = s ?? InputFile;
-
- // Normal testing -- input file will end up next to the assembly
- // and CoreRoot points at the test overlay dir
- string[] pathPartsNormal = new string[] {
- CoreRoot, "..", "..", "JIT", "Performance",
- "CodeQuality", "BenchmarksGame", "regexdna", "regexdna", inputFile
- };
-
- string inputPathNormal = Path.Combine(pathPartsNormal);
-
- // Perf testing -- input file will end up next to the assembly
- // and CoreRoot points at this directory
- string[] pathPartsPerf = new string[] { CoreRoot, inputFile };
-
- string inputPathPerf = Path.Combine(pathPartsPerf);
-
- string inputPath = null;
-
- if (File.Exists(inputPathNormal))
- {
- inputPath = inputPathNormal;
- }
- else if (File.Exists(inputPathPerf))
- {
- inputPath = inputPathPerf;
- }
-
- if (inputPath != null)
- {
- Console.WriteLine("Using input file {0}", inputPath);
- }
- else
- {
- Console.WriteLine("Unable to find input file {0}", inputFile);
- }
-
- return inputPath;
- }
-
- public static int Main(string[] args)
- {
- string inputFile = InputFile;
- int iterations = Iterations;
- bool verbose = Verbose;
-
- for (int i = 0; i < args.Length; i++)
- {
- if (args[i] == "-v")
- {
- verbose = true;
- }
- else if (args[i] == "-q")
- {
- verbose = false;
- }
- else if (args[i] == "-i")
- {
- i++;
-
- if (i < args.Length)
- {
- Int32.TryParse(args[i], out iterations);
- }
- }
- else
- {
- inputFile = args[i];
- }
- }
-
- string fullInputFile = FindInput(inputFile);
-
- if (fullInputFile == null)
- {
- Console.WriteLine("unable to find input");
- return -1;
- }
-
- if (iterations != Iterations)
- {
- Console.WriteLine("Running {0} iterations", iterations);
- }
-
- using (var r = File.OpenText(fullInputFile))
- {
- string sequence = r.ReadToEnd();
-
- // Warmup
-
- BenchInner(verbose, sequence);
-
- Stopwatch sw = Stopwatch.StartNew();
- for (int j = 0; j < iterations; j++)
- {
- BenchInner(verbose, sequence);
- }
- sw.Stop();
-
- Console.WriteLine("regexdna [{0} iters]: {1}ms", iterations, sw.ElapsedMilliseconds);
- }
-
- return 100;
- }
-
- static void BenchInner(bool verbose, string sequence)
- {
- int initialLength = sequence.Length;
-
- sequence = Regex.Replace(sequence, ">.*\n|\n", "");
- int codeLength = sequence.Length;
-
- string[] variants = {
- "agggtaaa|tttaccct"
- ,"[cgt]gggtaaa|tttaccc[acg]"
- ,"a[act]ggtaaa|tttacc[agt]t"
- ,"ag[act]gtaaa|tttac[agt]ct"
- ,"agg[act]taaa|ttta[agt]cct"
- ,"aggg[acg]aaa|ttt[cgt]ccct"
- ,"agggt[cgt]aa|tt[acg]accct"
- ,"agggta[cgt]a|t[acg]taccct"
- ,"agggtaa[cgt]|[acg]ttaccct"
- };
-
- var flags = variants.Select((v, i) => {
- var flag = new ManualResetEvent(false);
- ThreadPool.QueueUserWorkItem(x => {
- variants[i] += " " + Regex.Matches(sequence, v).Count;
- flag.Set();
- });
- return flag;
- });
- WaitHandle.WaitAll(flags.ToArray());
- if (verbose)
- {
- Console.WriteLine(string.Join("\n", variants));
- }
-
- var dict = new Dictionary<string, string> {
- {"B", "(c|g|t)"}, {"D", "(a|g|t)"}, {"H", "(a|c|t)"}, {"K", "(g|t)"},
- {"M", "(a|c)"}, {"N", "(a|c|g|t)"}, {"R", "(a|g)"}, {"S", "(c|g)"},
- {"V", "(a|c|g)"}, {"W", "(a|t)"}, {"Y", "(c|t)"}
- };
-
- sequence = new Regex("[WYKMSRBDVHN]").Replace(sequence, m => dict[m.Value]);
-
- if (verbose)
- {
- Console.WriteLine("\n{0}\n{1}\n{2}", initialLength, codeLength, sequence.Length);
- }
- }
-
- [Benchmark]
- public static void Bench()
- {
- string fullInputFile = FindInput(InputFile);
-
- if (fullInputFile == null)
- {
- throw new Exception("unable to find input");
- }
-
- using (var r = File.OpenText(fullInputFile))
- {
- string sequence = r.ReadToEnd();
-
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- for (int i = 0; i < Iterations; i++)
- {
- BenchInner(false, sequence);
- }
- }
- }
- }
- }
-}
-
-}
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/revcomp/revcomp.csharp-1.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/revcomp/revcomp.csharp-1.cs
deleted file mode 100644
index bca63bd00e..0000000000
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/revcomp/revcomp.csharp-1.cs
+++ /dev/null
@@ -1,249 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-/* The Computer Language Benchmarks Game
- http://benchmarksgame.alioth.debian.org/
-
- contributed by Robert F. Tobler to process large blocks of byte arrays
-
- modified for use with xunit-performance
-*/
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace BenchmarksGame
-{
-
-public static class Revcomp
-{
-
-#if DEBUG
- const int Iterations = 1;
- const string InputFile = "revcomp-input25.txt";
-#else
- const int Iterations = 800;
- const string InputFile = "revcomp-input25000.txt";
-#endif
-
- struct Block {
- public byte[] Data; public int Count;
- public int Read(BinaryReader r) {
- Data = r.ReadBytes(16384); Count++; return Data.Length;
- }
- public Index IndexOf(byte b, int o) {
- return new Index { Block = Count, Pos = Array.IndexOf(Data, b, o) };
- }
- }
-
- struct Index {
- public int Block; public int Pos;
- public static readonly Index None = new Index { Block = -1, Pos = -1 };
- public bool InBlock(Block b) { return Block == b.Count; }
- }
-
- const byte Gt = (byte)'>';
- const byte Lf = (byte)'\n';
-
- static string FindInput(string s)
- {
- string CoreRoot = System.Environment.GetEnvironmentVariable("CORE_ROOT");
-
- if (CoreRoot == null)
- {
- Console.WriteLine("This benchmark requries CORE_ROOT to be set");
- return null;
- }
-
- string inputFile = s ?? InputFile;
-
- // Normal testing -- input file will end up next to the assembly
- // and CoreRoot points at the test overlay dir
- string[] pathPartsNormal = new string[] {
- CoreRoot, "..", "..", "JIT", "Performance",
- "CodeQuality", "BenchmarksGame", "revcomp", "revcomp", inputFile
- };
-
- string inputPathNormal = Path.Combine(pathPartsNormal);
-
- // Perf testing -- input file will end up next to the assembly
- // and CoreRoot points at this directory
- string[] pathPartsPerf = new string[] { CoreRoot, inputFile };
-
- string inputPathPerf = Path.Combine(pathPartsPerf);
-
- string inputPath = null;
-
- if (File.Exists(inputPathNormal))
- {
- inputPath = inputPathNormal;
- }
- else if (File.Exists(inputPathPerf))
- {
- inputPath = inputPathPerf;
- }
-
- if (inputPath != null)
- {
- Console.WriteLine("Using input file {0}", inputPath);
- }
- else
- {
- Console.WriteLine("Unable to find input file {0}", inputFile);
- }
-
- return inputPath;
- }
-
- static int Main(string[] args)
- {
- bool verbose = false;
- string inputFile = InputFile;
- int iterations = Iterations;
-
- for (int i = 0; i < args.Length; i++)
- {
- if (args[i] == "-v")
- {
- verbose = true;
- }
- if (args[i] == "-i")
- {
- i++;
-
- if (i < args.Length)
- {
- Int32.TryParse(args[i], out iterations);
- }
- }
- else
- {
- inputFile = args[i];
- }
- }
-
- string fullInputFile = FindInput(inputFile);
-
- if (fullInputFile == null)
- {
- return -1;
- }
-
- if (iterations != Iterations)
- {
- Console.WriteLine("Running {0} iterations", iterations);
- }
-
- // Warmup
- BenchInner(false, fullInputFile);
-
- Stopwatch sw = Stopwatch.StartNew();
- for (int j = 0; j < iterations; j++)
- {
- BenchInner(verbose, fullInputFile);
- }
- sw.Stop();
- Console.WriteLine("revcomp [{0} iters]: {1}ms", iterations, sw.ElapsedMilliseconds);
-
- return 100;
- }
-
- static void BenchInner(bool doOutput, string inputFile)
- {
- InitComplements();
- var seq = new List<byte[]>();
- var b = new Block { Count = -1 };
- Index line = Index.None, start = Index.None, end = Index.None;
- using (var r = new BinaryReader(File.OpenRead(inputFile))) {
- using (var w = doOutput ? Console.OpenStandardOutput() : Stream.Null) {
- while (b.Read(r) > 0) {
- seq.Add(b.Data);
- if (line.Pos < 0) line = b.IndexOf(Gt, 0);
- while (line.Pos >= 0) {
- if (start.Pos < 0) {
- var off = line.InBlock(b) ? line.Pos : 0;
- start = b.IndexOf(Lf, off);
- if (start.Pos < 0) {
- w.Write(b.Data, off, b.Data.Length - off);
- seq.Clear(); break;
- }
- w.Write(b.Data, off, start.Pos + 1 - off);
- }
- if (end.Pos < 0) {
- end = b.IndexOf(Gt, start.InBlock(b) ? start.Pos : 0);
- if (end.Pos < 0) break;
- }
- w.Reverse(start.Pos, end.Pos, seq);
- if (seq.Count > 1) seq.RemoveRange(0, seq.Count - 1);
- line = end; end = Index.None; start = Index.None;
- }
- }
- if (start.Pos >= 0 && end.Pos < 0)
- w.Reverse(start.Pos, seq[seq.Count -1].Length, seq);
- }
- }
- }
-
- const string Seq = "ABCDGHKMRTVYabcdghkmrtvy";
- const string Rev = "TVGHCDMKYABRTVGHCDMKYABR";
- static byte[] comp = new byte[256];
-
- static void InitComplements() {
- for (byte i = 0; i < 255; i++) comp[i] = i;
- for (int i = 0; i < Seq.Length; i++)
- comp[(byte)Seq[i]] = (byte)Rev[i];
- comp[Lf] = 0; comp[(byte)' '] = 0;
- }
-
- const int LineLen = 61;
- const int BufSize = LineLen * 269;
- static byte[] buf = new byte[BufSize];
-
- static void Reverse(this Stream w, int si, int ei, List<byte[]> bl) {
- int bi = 0, line = LineLen - 1;
- for (int ri = bl.Count-1; ri >= 0; ri--) {
- var b = bl[ri]; int off = ri == 0 ? si : 0;
- for (int i = (ri == bl.Count-1 ? ei : b.Length)-1; i >= off; i--) {
- var c = comp[b[i]]; if (c > 0) buf[bi++] = c;
- if (bi == line) {
- buf[bi++] = Lf; line += LineLen;
- if (bi == BufSize) {
- w.Write(buf, 0, BufSize); bi = 0; line = LineLen - 1;
- }
- }
- }
- }
- if (bi > 0) {
- if (buf[bi-1] != Lf) buf[bi++] = Lf; w.Write(buf, 0, bi);
- }
- }
-
- [Benchmark]
- public static void Bench()
- {
- string inputFile = FindInput(InputFile);
-
- if (inputFile == null)
- {
- throw new Exception("unable to find input");
- }
-
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- for (int i = 0; i < Iterations; i++)
- {
- BenchInner(false, inputFile);
- }
- }
- }
- }
-}
-
-}
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/harness-helpers.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/harness-helpers.cs
new file mode 100644
index 0000000000..c494982cc9
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/harness-helpers.cs
@@ -0,0 +1,97 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// Helper functionality to locate inputs and find outputs for
+// reverse-complement benchmark in CoreCLR test harness
+
+using System;
+using System.IO;
+using System.Text;
+
+namespace BenchmarksGame
+{
+ class TestHarnessHelpers
+ {
+ public string InputFile;
+ public int FileLength;
+ public string CheckSum;
+
+ public TestHarnessHelpers(bool bigInput, [System.Runtime.CompilerServices.CallerFilePath] string csFileName = "")
+ {
+ if (bigInput)
+ {
+ InputFile = FindInputFile("revcomp-input25000.txt", csFileName);
+ FileLength = 254245;
+ CheckSum = "61-A4-CC-6D-15-8D-26-77-88-93-4F-E2-29-A2-8D-FB";
+ }
+ else
+ {
+ InputFile = FindInputFile("revcomp-input25.txt", csFileName);
+ FileLength = 333;
+ CheckSum = "62-45-8E-09-2E-89-A0-69-8C-17-F5-D8-C7-63-5B-50";
+ }
+ }
+
+ public string FindInputFile(string inputFile, string csFileName)
+ {
+ string CoreRoot = System.Environment.GetEnvironmentVariable("CORE_ROOT");
+
+ if (CoreRoot == null)
+ {
+ Console.WriteLine("This benchmark requries CORE_ROOT to be set");
+ return null;
+ }
+
+ // The convention is that the csproj file has the same name as the cs file.
+ string projectName = Path.GetFileNameWithoutExtension(csFileName);
+ int slashIndex = projectName.LastIndexOfAny(new char[] { '/', '\\' });
+ if (slashIndex != -1)
+ {
+ // csFileName was generated by the C# compiler, which may have run on
+ // a different host system with different path separator than the
+ // currently executing host, which dictates GetFileNameWithoutExtension's
+ // behavior... so hope that the slash here is a cross-host path separator,
+ // and chop of what were likely direcotires.
+ projectName = projectName.Substring(slashIndex + 1);
+ }
+
+ // Normal testing -- input file will end up next to the assembly
+ // and CoreRoot points at the test overlay dir
+ string[] pathPartsNormal = new string[] {
+ CoreRoot, "..", "..", "JIT", "Performance",
+ "CodeQuality", "BenchmarksGame", "reverse-complement", projectName, inputFile
+ };
+
+ string inputPathNormal = Path.Combine(pathPartsNormal);
+
+ // Perf testing -- input file will end up next to the assembly
+ // and CoreRoot points at this directory
+ string[] pathPartsPerf = new string[] { CoreRoot, inputFile };
+
+ string inputPathPerf = Path.Combine(pathPartsPerf);
+
+ string inputPath = null;
+
+ if (File.Exists(inputPathNormal))
+ {
+ inputPath = inputPathNormal;
+ }
+ else if (File.Exists(inputPathPerf))
+ {
+ inputPath = inputPathPerf;
+ }
+
+ if (inputPath != null)
+ {
+ Console.WriteLine("Using input file {0}", inputFile);
+ }
+ else
+ {
+ throw new Exception($"Unable to find input file {inputFile}. Tried {inputPathNormal} and {inputPathPerf}; csFileName was {csFileName}, so projectName was {projectName}.");
+ }
+
+ return inputPath;
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/revcomp/revcomp-input25.txt b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/revcomp-input25.txt
index f749b06ea7..f749b06ea7 100644
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/revcomp/revcomp-input25.txt
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/revcomp-input25.txt
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/revcomp/revcomp-input25000.txt b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/revcomp-input25000.txt
index fd4414b176..fd4414b176 100644
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/revcomp/revcomp-input25000.txt
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/revcomp-input25000.txt
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/reverse-complement-1.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/reverse-complement-1.cs
new file mode 100644
index 0000000000..902aee39ce
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/reverse-complement-1.cs
@@ -0,0 +1,180 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// Adapted from reverse-complement C# .NET Core program
+// http://benchmarksgame.alioth.debian.org/u64q/program.php?test=revcomp&lang=csharpcore&id=1
+// aka (as of 2017-09-01) rev 1.2 of https://alioth.debian.org/scm/viewvc.php/benchmarksgame/bench/revcomp/revcomp.csharp?root=benchmarksgame&view=log
+// Best-scoring single-threaded C# .NET Core version as of 2017-09-01
+
+/* The Computer Language Benchmarks Game
+ http://benchmarksgame.alioth.debian.org/
+
+ contributed by Robert F. Tobler to process large blocks of byte arrays
+*/
+
+using System;
+using System.IO;
+using System.Collections.Generic;
+using System.Security.Cryptography;
+using Microsoft.Xunit.Performance;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace BenchmarksGame
+{
+ public static class ReverseComplement_1
+ {
+ struct Block
+ {
+ public byte[] Data; public int Count;
+ public int Read(BinaryReader r)
+ {
+ Data = r.ReadBytes(16384); Count++; return Data.Length;
+ }
+ public Index IndexOf(byte b, int o)
+ {
+ return new Index { Block = Count, Pos = Array.IndexOf(Data, b, o) };
+ }
+ }
+
+ struct Index
+ {
+ public int Block; public int Pos;
+ public static readonly Index None = new Index { Block = -1, Pos = -1 };
+ public bool InBlock(Block b) { return Block == b.Count; }
+ }
+
+ const byte Gt = (byte)'>';
+ const byte Lf = (byte)'\n';
+
+ static int Main(string[] args)
+ {
+ var helpers = new TestHarnessHelpers(bigInput: false);
+ var outBytes = new byte[helpers.FileLength];
+ using (var input = new FileStream(helpers.InputFile, FileMode.Open))
+ using (var output = new MemoryStream(outBytes))
+ {
+ Bench(input, output);
+ }
+ Console.WriteLine(System.Text.Encoding.UTF8.GetString(outBytes));
+ if (!MatchesChecksum(outBytes, helpers.CheckSum))
+ {
+ return -1;
+ }
+ return 100;
+ }
+
+ [Benchmark(InnerIterationCount = 1500)]
+ public static void RunBench()
+ {
+ var helpers = new TestHarnessHelpers(bigInput: true);
+ var outBytes = new byte[helpers.FileLength];
+
+ Benchmark.Iterate(() =>
+ {
+ using (var input = new FileStream(helpers.InputFile, FileMode.Open))
+ using (var output = new MemoryStream(outBytes))
+ {
+ Bench(input, output);
+ }
+ });
+
+ Assert.True(MatchesChecksum(outBytes, helpers.CheckSum));
+ }
+
+ static bool MatchesChecksum(byte[] bytes, string checksum)
+ {
+ using (var md5 = MD5.Create())
+ {
+ byte[] hash = md5.ComputeHash(bytes);
+ return (checksum == BitConverter.ToString(hash));
+ }
+ }
+
+ static void Bench(Stream input, Stream output)
+ {
+ InitComplements();
+ var seq = new List<byte[]>();
+ var b = new Block { Count = -1 };
+ Index line = Index.None, start = Index.None, end = Index.None;
+ using (var r = new BinaryReader(input))
+ {
+ using (var w = output)
+ {
+ while (b.Read(r) > 0)
+ {
+ seq.Add(b.Data);
+ if (line.Pos < 0) line = b.IndexOf(Gt, 0);
+ while (line.Pos >= 0)
+ {
+ if (start.Pos < 0)
+ {
+ var off = line.InBlock(b) ? line.Pos : 0;
+ start = b.IndexOf(Lf, off);
+ if (start.Pos < 0)
+ {
+ w.Write(b.Data, off, b.Data.Length - off);
+ seq.Clear(); break;
+ }
+ w.Write(b.Data, off, start.Pos + 1 - off);
+ }
+ if (end.Pos < 0)
+ {
+ end = b.IndexOf(Gt, start.InBlock(b) ? start.Pos : 0);
+ if (end.Pos < 0) break;
+ }
+ w.Reverse(start.Pos, end.Pos, seq);
+ if (seq.Count > 1) seq.RemoveRange(0, seq.Count - 1);
+ line = end; end = Index.None; start = Index.None;
+ }
+ }
+ if (start.Pos >= 0 && end.Pos < 0)
+ w.Reverse(start.Pos, seq[seq.Count - 1].Length, seq);
+ }
+ }
+ }
+
+ const string Seq = "ABCDGHKMRTVYabcdghkmrtvy";
+ const string Rev = "TVGHCDMKYABRTVGHCDMKYABR";
+ static byte[] comp = new byte[256];
+
+ static void InitComplements()
+ {
+ for (byte i = 0; i < 255; i++) comp[i] = i;
+ for (int i = 0; i < Seq.Length; i++)
+ comp[(byte)Seq[i]] = (byte)Rev[i];
+ comp[Lf] = 0; comp[(byte)' '] = 0;
+ }
+
+ const int LineLen = 61;
+ const int BufSize = LineLen * 269;
+ static byte[] buf = new byte[BufSize];
+
+ static void Reverse(this Stream w, int si, int ei, List<byte[]> bl)
+ {
+ int bi = 0, line = LineLen - 1;
+ for (int ri = bl.Count - 1; ri >= 0; ri--)
+ {
+ var b = bl[ri]; int off = ri == 0 ? si : 0;
+ for (int i = (ri == bl.Count - 1 ? ei : b.Length) - 1; i >= off; i--)
+ {
+ var c = comp[b[i]]; if (c > 0) buf[bi++] = c;
+ if (bi == line)
+ {
+ buf[bi++] = Lf; line += LineLen;
+ if (bi == BufSize)
+ {
+ w.Write(buf, 0, BufSize); bi = 0; line = LineLen - 1;
+ }
+ }
+ }
+ }
+ if (bi > 0)
+ {
+ if (buf[bi - 1] != Lf) buf[bi++] = Lf; w.Write(buf, 0, bi);
+ }
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/revcomp/revcomp.csproj b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/reverse-complement-1.csproj
index 00789ed3a5..5e0c567553 100644
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/revcomp/revcomp.csproj
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/reverse-complement-1.csproj
@@ -5,7 +5,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <ProjectGuid>{D10015D3-6A09-400C-8CF6-9F50BEED71D2}</ProjectGuid>
<OutputType>Exe</OutputType>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
@@ -30,7 +30,8 @@
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
- <Compile Include="revcomp.csharp-1.cs" />
+ <Compile Include="$(MSBuildProjectName).cs" />
+ <Compile Include="harness-helpers.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="revcomp-input25.txt">
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/reverse-complement-6.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/reverse-complement-6.cs
new file mode 100644
index 0000000000..70d84d4f90
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/reverse-complement-6.cs
@@ -0,0 +1,290 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// Adapted from reverse-complement C# .NET Core #6
+// http://benchmarksgame.alioth.debian.org/u64q/program.php?test=revcomp&lang=csharpcore&id=6
+// aka (as of 2017-09-01) rev 1.4 of https://alioth.debian.org/scm/viewvc.php/benchmarksgame/bench/revcomp/revcomp.csharp-6.csharp?root=benchmarksgame&view=log
+// Best-scoring C# .NET Core version as of 2017-09-01
+
+/* The Computer Language Benchmarks Game
+ http://benchmarksgame.alioth.debian.org/
+
+ Contributed by Peperud
+ Modified to reduce memory use by Anthony Lloyd
+*/
+
+using System;
+using System.IO;
+using System.Collections.Generic;
+using System.Collections.Concurrent;
+using System.Security.Cryptography;
+using System.Threading;
+using Microsoft.Xunit.Performance;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace BenchmarksGame
+{
+ class RevCompSequence
+ {
+ public List<byte[]> Pages;
+ public int StartHeader, EndExclusive;
+ public Thread ReverseThread;
+ }
+
+ public static class ReverseComplement_6
+ {
+ const int READER_BUFFER_SIZE = 1024 * 1024;
+ const byte LF = 10, GT = (byte)'>', SP = 32;
+ static BlockingCollection<byte[]> readQue;
+ static BlockingCollection<RevCompSequence> writeQue;
+ static byte[] map;
+
+ static int read(Stream stream, byte[] buffer, int offset, int count)
+ {
+ var bytesRead = stream.Read(buffer, offset, count);
+ return bytesRead == count ? offset + count
+ : bytesRead == 0 ? offset
+ : read(stream, buffer, offset + bytesRead, count - bytesRead);
+ }
+ static Stream ReaderStream;
+ static void Reader()
+ {
+ using (var stream = ReaderStream)
+ {
+ int bytesRead;
+ do
+ {
+ var buffer = new byte[READER_BUFFER_SIZE];
+ bytesRead = read(stream, buffer, 0, READER_BUFFER_SIZE);
+ readQue.Add(buffer);
+ } while (bytesRead == READER_BUFFER_SIZE);
+ readQue.CompleteAdding();
+ }
+ }
+
+ static bool tryTake<T>(BlockingCollection<T> q, out T t) where T : class
+ {
+ t = null;
+ var wait = new SpinWait();
+ while (!q.IsCompleted && !q.TryTake(out t)) wait.SpinOnce();
+ return t != null;
+ }
+
+ static void Grouper()
+ {
+ // Set up complements map
+ map = new byte[256];
+ for (byte b = 0; b < 255; b++) map[b] = b;
+ map[(byte)'A'] = (byte)'T';
+ map[(byte)'B'] = (byte)'V';
+ map[(byte)'C'] = (byte)'G';
+ map[(byte)'D'] = (byte)'H';
+ map[(byte)'G'] = (byte)'C';
+ map[(byte)'H'] = (byte)'D';
+ map[(byte)'K'] = (byte)'M';
+ map[(byte)'M'] = (byte)'K';
+ map[(byte)'R'] = (byte)'Y';
+ map[(byte)'T'] = (byte)'A';
+ map[(byte)'V'] = (byte)'B';
+ map[(byte)'Y'] = (byte)'R';
+ map[(byte)'a'] = (byte)'T';
+ map[(byte)'b'] = (byte)'V';
+ map[(byte)'c'] = (byte)'G';
+ map[(byte)'d'] = (byte)'H';
+ map[(byte)'g'] = (byte)'C';
+ map[(byte)'h'] = (byte)'D';
+ map[(byte)'k'] = (byte)'M';
+ map[(byte)'m'] = (byte)'K';
+ map[(byte)'r'] = (byte)'Y';
+ map[(byte)'t'] = (byte)'A';
+ map[(byte)'v'] = (byte)'B';
+ map[(byte)'y'] = (byte)'R';
+
+ var startHeader = 0;
+ var i = 0;
+ bool afterFirst = false;
+ var data = new List<byte[]>();
+ byte[] bytes;
+ while (tryTake(readQue, out bytes))
+ {
+ data.Add(bytes);
+ while ((i = Array.IndexOf<byte>(bytes, GT, i + 1)) != -1)
+ {
+ var sequence = new RevCompSequence
+ {
+ Pages = data,
+ StartHeader = startHeader,
+ EndExclusive = i
+ };
+ if (afterFirst)
+ (sequence.ReverseThread = new Thread(() => Reverse(sequence))).Start();
+ else
+ afterFirst = true;
+ writeQue.Add(sequence);
+ startHeader = i;
+ data = new List<byte[]> { bytes };
+ }
+ }
+ i = Array.IndexOf<byte>(data[data.Count - 1], 0, 0);
+ var lastSequence = new RevCompSequence
+ {
+ Pages = data,
+ StartHeader = startHeader,
+ EndExclusive = i == -1 ? data[data.Count - 1].Length : i
+ };
+ Reverse(lastSequence);
+ writeQue.Add(lastSequence);
+ writeQue.CompleteAdding();
+ }
+
+ static void Reverse(RevCompSequence sequence)
+ {
+ var startPageId = 0;
+ var startBytes = sequence.Pages[0];
+ var startIndex = sequence.StartHeader;
+
+ // Skip header line
+ while ((startIndex = Array.IndexOf<byte>(startBytes, LF, startIndex)) == -1)
+ {
+ startBytes = sequence.Pages[++startPageId];
+ startIndex = 0;
+ }
+
+ var endPageId = sequence.Pages.Count - 1;
+ var endIndex = sequence.EndExclusive - 1;
+ if (endIndex == -1) endIndex = sequence.Pages[--endPageId].Length - 1;
+ var endBytes = sequence.Pages[endPageId];
+
+ // Swap in place across pages
+ do
+ {
+ var startByte = startBytes[startIndex];
+ if (startByte < SP)
+ {
+ if (++startIndex == startBytes.Length)
+ {
+ startBytes = sequence.Pages[++startPageId];
+ startIndex = 0;
+ }
+ if (startIndex == endIndex && startPageId == endPageId) break;
+ startByte = startBytes[startIndex];
+ }
+ var endByte = endBytes[endIndex];
+ if (endByte < SP)
+ {
+ if (--endIndex == -1)
+ {
+ endBytes = sequence.Pages[--endPageId];
+ endIndex = endBytes.Length - 1;
+ }
+ if (startIndex == endIndex && startPageId == endPageId) break;
+ endByte = endBytes[endIndex];
+ }
+
+ startBytes[startIndex] = map[endByte];
+ endBytes[endIndex] = map[startByte];
+
+ if (++startIndex == startBytes.Length)
+ {
+ startBytes = sequence.Pages[++startPageId];
+ startIndex = 0;
+ }
+ if (--endIndex == -1)
+ {
+ endBytes = sequence.Pages[--endPageId];
+ endIndex = endBytes.Length - 1;
+ }
+ } while (startPageId < endPageId || (startPageId == endPageId && startIndex < endIndex));
+ if (startIndex == endIndex) startBytes[startIndex] = map[startBytes[startIndex]];
+ }
+
+ static Stream WriterStream;
+ static void Writer()
+ {
+ using (var stream = WriterStream)
+ {
+ bool first = true;
+ RevCompSequence sequence;
+ while (tryTake(writeQue, out sequence))
+ {
+ var startIndex = sequence.StartHeader;
+ var pages = sequence.Pages;
+ if (first)
+ {
+ Reverse(sequence);
+ first = false;
+ }
+ else
+ {
+ sequence.ReverseThread?.Join();
+ }
+ for (int i = 0; i < pages.Count - 1; i++)
+ {
+ var bytes = pages[i];
+ stream.Write(bytes, startIndex, bytes.Length - startIndex);
+ startIndex = 0;
+ }
+ stream.Write(pages[pages.Count - 1], startIndex, sequence.EndExclusive - startIndex);
+ }
+ }
+ }
+
+ static int Main(string[] args)
+ {
+ var helpers = new TestHarnessHelpers(bigInput: false);
+ var outBytes = new byte[helpers.FileLength];
+ using (var input = new FileStream(helpers.InputFile, FileMode.Open))
+ using (var output = new MemoryStream(outBytes))
+ {
+ Bench(input, output);
+ }
+ Console.WriteLine(System.Text.Encoding.UTF8.GetString(outBytes));
+ if (!MatchesChecksum(outBytes, helpers.CheckSum))
+ {
+ return -1;
+ }
+ return 100;
+ }
+
+ [Benchmark(InnerIterationCount = 33)]
+ public static void RunBench()
+ {
+ var helpers = new TestHarnessHelpers(bigInput: true);
+ var outBytes = new byte[helpers.FileLength];
+
+ Benchmark.Iterate(() =>
+ {
+ var input = new FileStream(helpers.InputFile, FileMode.Open);
+ var output = new MemoryStream(outBytes);
+ {
+ Bench(input, output);
+ }
+ });
+
+ Assert.True(MatchesChecksum(outBytes, helpers.CheckSum));
+ }
+
+ static bool MatchesChecksum(byte[] bytes, string checksum)
+ {
+ using (var md5 = MD5.Create())
+ {
+ byte[] hash = md5.ComputeHash(bytes);
+ return (checksum == BitConverter.ToString(hash));
+ }
+ }
+
+ static void Bench(Stream input, Stream output)
+ {
+ readQue = new BlockingCollection<byte[]>();
+ writeQue = new BlockingCollection<RevCompSequence>();
+ ReaderStream = input;
+ WriterStream = output;
+ new Thread(Reader).Start();
+ new Thread(Grouper).Start();
+ Writer();
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/reverse-complement-6.csproj b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/reverse-complement-6.csproj
new file mode 100644
index 0000000000..b1be51cf12
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/reverse-complement-6.csproj
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{9449A6C4-69BD-496B-83AD-55046F464950}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="$(MSBuildProjectName).cs" />
+ <Compile Include="harness-helpers.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="revcomp-input25.txt">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="revcomp-input25000.txt">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm-1.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm-1.cs
new file mode 100644
index 0000000000..117c818673
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm-1.cs
@@ -0,0 +1,115 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// Adapted from spectral-norm C# .NET Core program
+// http://benchmarksgame.alioth.debian.org/u64q/program.php?test=spectralnorm&lang=csharpcore&id=1
+// aka (as of 2017-09-01) rev 1.2 of https://alioth.debian.org/scm/viewvc.php/benchmarksgame/bench/spectralnorm/spectralnorm.csharp?root=benchmarksgame&view=log
+// Best-scoring single-threaded C# .NET Core version as of 2017-09-01
+
+/* The Computer Language Benchmarks Game
+ http://benchmarksgame.alioth.debian.org/
+
+ contributed by Isaac Gouy
+*/
+
+using System;
+using System.Runtime.CompilerServices;
+using Microsoft.Xunit.Performance;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace BenchmarksGame
+{
+ public class SpectralNorm_1
+ {
+ public static int Main(String[] args)
+ {
+ int n = 100;
+ if (args.Length > 0) n = Int32.Parse(args[0]);
+
+ double norm = new SpectralNorm_1().Bench(n);
+ Console.WriteLine("{0:f9}", norm);
+
+ double expected = 1.274219991;
+ bool result = Math.Abs(norm - expected) < 1e-4;
+ return (result ? 100 : -1);
+ }
+
+ [Benchmark(InnerIterationCount = 700)]
+ public static void RunBench()
+ {
+ var obj = new SpectralNorm_1();
+ double norm = 0.0;
+ Benchmark.Iterate(() => { norm = obj.Bench(100); });
+
+ double expected = 1.274219991;
+ Assert.True(Math.Abs(norm - expected) < 1e-4);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ double Bench(int n)
+ {
+ // create unit vector
+ double[] u = new double[n];
+ for (int i = 0; i < n; i++) u[i] = 1;
+
+ // 20 steps of the power method
+ double[] v = new double[n];
+ for (int i = 0; i < n; i++) v[i] = 0;
+
+ for (int i = 0; i < 10; i++)
+ {
+ MultiplyAtAv(n, u, v);
+ MultiplyAtAv(n, v, u);
+ }
+
+ // B=AtA A multiplied by A transposed
+ // v.Bv /(v.v) eigenvalue of v
+ double vBv = 0, vv = 0;
+ for (int i = 0; i < n; i++)
+ {
+ vBv += u[i] * v[i];
+ vv += v[i] * v[i];
+ }
+
+ return Math.Sqrt(vBv / vv);
+ }
+
+
+ /* return element i,j of infinite matrix A */
+ double A(int i, int j)
+ {
+ return 1.0 / ((i + j) * (i + j + 1) / 2 + i + 1);
+ }
+
+ /* multiply vector v by matrix A */
+ void MultiplyAv(int n, double[] v, double[] Av)
+ {
+ for (int i = 0; i < n; i++)
+ {
+ Av[i] = 0;
+ for (int j = 0; j < n; j++) Av[i] += A(i, j) * v[j];
+ }
+ }
+
+ /* multiply vector v by matrix A transposed */
+ void MultiplyAtv(int n, double[] v, double[] Atv)
+ {
+ for (int i = 0; i < n; i++)
+ {
+ Atv[i] = 0;
+ for (int j = 0; j < n; j++) Atv[i] += A(j, i) * v[j];
+ }
+ }
+
+ /* multiply vector v by matrix A and then by matrix A transposed */
+ void MultiplyAtAv(int n, double[] v, double[] AtAv)
+ {
+ double[] u = new double[n];
+ MultiplyAv(n, v, u);
+ MultiplyAtv(n, u, AtAv);
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm-1.csproj b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm-1.csproj
new file mode 100644
index 0000000000..6aa7d71500
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm-1.csproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{2FA952B1-A5C1-435D-918F-F3750714FB92}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="$(MSBuildProjectName).cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project> \ No newline at end of file
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm-3.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm-3.cs
new file mode 100644
index 0000000000..4a1cf85507
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm-3.cs
@@ -0,0 +1,175 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// Adapted from spectral-norm C# .NET Core #3 program
+// http://benchmarksgame.alioth.debian.org/u64q/program.php?test=spectralnorm&lang=csharpcore&id=3
+// aka (as of 2017-09-01) rev 1.1 of https://alioth.debian.org/scm/viewvc.php/benchmarksgame/bench/spectralnorm/spectralnorm.csharp-3.csharp?root=benchmarksgame&view=log
+// Best-scoring C# .NET Core version as of 2017-09-01
+
+/* The Computer Language Benchmarks Game
+ http://benchmarksgame.alioth.debian.org/
+
+ contributed by Isaac Gouy
+ modified by Josh Goldfoot, based on the Java version by The Anh Tran
+*/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.Xunit.Performance;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace BenchmarksGame
+{
+ public class SpectralNorm_3
+ {
+ public static int Main(String[] args)
+ {
+ int n = 100;
+ if (args.Length > 0) n = Int32.Parse(args[0]);
+
+ double norm = Bench(n);
+ Console.WriteLine("{0:f9}", norm);
+
+ double expected = 1.274219991;
+ bool result = Math.Abs(norm - expected) < 1e-4;
+ return (result ? 100 : -1);
+ }
+
+ [Benchmark(InnerIterationCount = 1400)]
+ public static void RunBench()
+ {
+ double norm = 0.0;
+ Benchmark.Iterate(() => { norm = Bench(100); });
+
+ double expected = 1.274219991;
+ Assert.True(Math.Abs(norm - expected) < 1e-4);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static double Bench(int n)
+ {
+ double[] u = new double[n];
+ double[] v = new double[n];
+ double[] tmp = new double[n];
+
+ // create unit vector
+ for (int i = 0; i < n; i++)
+ u[i] = 1.0;
+
+ int nthread = Environment.ProcessorCount;
+ int chunk = n / nthread;
+ var barrier = new Barrier(nthread);
+ Approximate[] ap = new Approximate[nthread];
+
+ for (int i = 0; i < nthread; i++)
+ {
+ int r1 = i * chunk;
+ int r2 = (i < (nthread - 1)) ? r1 + chunk : n;
+ ap[i] = new Approximate(u, v, tmp, r1, r2, barrier);
+ }
+
+ double vBv = 0, vv = 0;
+ for (int i = 0; i < nthread; i++)
+ {
+ ap[i].t.Wait();
+ vBv += ap[i].m_vBv;
+ vv += ap[i].m_vv;
+ }
+
+ return Math.Sqrt(vBv / vv);
+ }
+
+ }
+
+ public class Approximate
+ {
+ private Barrier barrier;
+ public Task t;
+
+ private double[] _u;
+ private double[] _v;
+ private double[] _tmp;
+
+ private int range_begin, range_end;
+ public double m_vBv, m_vv;
+
+ public Approximate(double[] u, double[] v, double[] tmp, int rbegin, int rend, Barrier b)
+ {
+ m_vBv = 0;
+ m_vv = 0;
+ _u = u;
+ _v = v;
+ _tmp = tmp;
+ range_begin = rbegin;
+ range_end = rend;
+ barrier = b;
+ t = Task.Run(() => run());
+ }
+
+ private void run()
+ {
+ // 20 steps of the power method
+ for (int i = 0; i < 10; i++)
+ {
+ MultiplyAtAv(_u, _tmp, _v);
+ MultiplyAtAv(_v, _tmp, _u);
+ }
+
+ for (int i = range_begin; i < range_end; i++)
+ {
+ m_vBv += _u[i] * _v[i];
+ m_vv += _v[i] * _v[i];
+ }
+ }
+
+ /* return element i,j of infinite matrix A */
+ private double eval_A(int i, int j)
+ {
+ return 1.0 / ((i + j) * (i + j + 1) / 2 + i + 1);
+ }
+
+ /* multiply vector v by matrix A, each thread evaluate its range only */
+ private void MultiplyAv(double[] v, double[] Av)
+ {
+ for (int i = range_begin; i < range_end; i++)
+ {
+ double sum = 0;
+ for (int j = 0; j < v.Length; j++)
+ sum += eval_A(i, j) * v[j];
+
+ Av[i] = sum;
+ }
+ }
+
+ /* multiply vector v by matrix A transposed */
+ private void MultiplyAtv(double[] v, double[] Atv)
+ {
+ for (int i = range_begin; i < range_end; i++)
+ {
+ double sum = 0;
+ for (int j = 0; j < v.Length; j++)
+ sum += eval_A(j, i) * v[j];
+
+ Atv[i] = sum;
+ }
+ }
+
+ /* multiply vector v by matrix A and then by matrix A transposed */
+ private void MultiplyAtAv(double[] v, double[] tmp, double[] AtAv)
+ {
+
+ MultiplyAv(v, tmp);
+ // all thread must syn at completion
+ barrier.SignalAndWait();
+ MultiplyAtv(tmp, AtAv);
+ // all thread must syn at completion
+ barrier.SignalAndWait();
+ }
+
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm-3.csproj b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm-3.csproj
new file mode 100644
index 0000000000..3f22766ae7
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm-3.csproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{0B6702EB-3EED-41EB-B034-B3769918A476}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="$(MSBuildProjectName).cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project> \ No newline at end of file
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm.cs
deleted file mode 100644
index 5f2b1aed5f..0000000000
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm.cs
+++ /dev/null
@@ -1,128 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-/* The Computer Language Benchmarks Game
- http://benchmarksgame.alioth.debian.org/
-
- contributed by Isaac Gouy
-
- modified for use with xunit-performance
-*/
-
-using Microsoft.Xunit.Performance;
-using System;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace BenchmarksGame
-{
-public class SpectralNorm
-{
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 300;
-#endif
-
- public static int Main(String[] args)
- {
- int n = 100;
- if (args.Length > 0) n = Int32.Parse(args[0]);
- double norm = new SpectralNorm().Approximate(n);
- Console.WriteLine("Norm={0:f9}", norm);
- double expected = 1.274219991;
- bool result = Math.Abs(norm - expected) < 1e-4;
- return (result ? 100 : -1);
- }
-
- [Benchmark]
- public static void Bench()
- {
- int n = 100;
- foreach (var iteration in Benchmark.Iterations)
- {
- double a = 0;
-
- using (iteration.StartMeasurement())
- {
- for (int i = 0; i < Iterations; i++)
- {
- SpectralNorm s = new SpectralNorm();
- a += s.Approximate(n);
- }
- }
-
- double norm = a / Iterations;
- double expected = 1.274219991;
- bool valid = Math.Abs(norm - expected) < 1e-4;
- if (!valid)
- {
- throw new Exception("Benchmark failed to validate");
- }
- }
- }
-
- private double Approximate(int n)
- {
- // create unit vector
- double[] u = new double[n];
- for (int i = 0; i < n; i++) u[i] = 1;
-
- // 20 steps of the power method
- double[] v = new double[n];
- for (int i = 0; i < n; i++) v[i] = 0;
-
- for (int i = 0; i < 10; i++)
- {
- MultiplyAtAv(n, u, v);
- MultiplyAtAv(n, v, u);
- }
-
- // B=AtA A multiplied by A transposed
- // v.Bv /(v.v) eigenvalue of v
- double vBv = 0, vv = 0;
- for (int i = 0; i < n; i++)
- {
- vBv += u[i] * v[i];
- vv += v[i] * v[i];
- }
-
- return Math.Sqrt(vBv / vv);
- }
-
-
- /* return element i,j of infinite matrix A */
- private double A(int i, int j)
- {
- return 1.0 / ((i + j) * (i + j + 1) / 2 + i + 1);
- }
-
- /* multiply vector v by matrix A */
- private void MultiplyAv(int n, double[] v, double[] Av)
- {
- for (int i = 0; i < n; i++)
- {
- Av[i] = 0;
- for (int j = 0; j < n; j++) Av[i] += A(i, j) * v[j];
- }
- }
-
- /* multiply vector v by matrix A transposed */
- private void MultiplyAtv(int n, double[] v, double[] Atv)
- {
- for (int i = 0; i < n; i++)
- {
- Atv[i] = 0;
- for (int j = 0; j < n; j++) Atv[i] += A(j, i) * v[j];
- }
- }
-
- /* multiply vector v by matrix A and then by matrix A transposed */
- private void MultiplyAtAv(int n, double[] v, double[] AtAv)
- {
- double[] u = new double[n];
- MultiplyAv(n, v, u);
- MultiplyAtv(n, u, AtAv);
- }
-}
-}
diff --git a/tests/src/JIT/Performance/CodeQuality/Devirtualization/DefaultEqualityComparerPerf.cs b/tests/src/JIT/Performance/CodeQuality/Devirtualization/DefaultEqualityComparerPerf.cs
new file mode 100644
index 0000000000..b9da9f17fa
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/Devirtualization/DefaultEqualityComparerPerf.cs
@@ -0,0 +1,207 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Collections.Generic;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+// Performance tests for optimizations related to EqualityComparer<T>.Default
+
+namespace Devirtualization
+{
+ public class EqualityComparerFixture<T> where T : IEquatable<T>
+ {
+ IEqualityComparer<T> comparer;
+
+ public EqualityComparerFixture(IEqualityComparer<T> customComparer = null)
+ {
+ comparer = customComparer ?? EqualityComparer<T>.Default;
+ }
+
+ // Baseline method showing unoptimized performance
+ [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
+ public bool CompareNoOpt(ref T a, ref T b)
+ {
+ return EqualityComparer<T>.Default.Equals(a, b);
+ }
+
+ // The code this method invokes should be well-optimized
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ public bool Compare(ref T a, ref T b)
+ {
+ return EqualityComparer<T>.Default.Equals(a, b);
+ }
+
+ // This models how Dictionary uses a comparer. We're not
+ // yet able to optimize such cases.
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ public bool CompareCached(ref T a, ref T b)
+ {
+ return comparer.Equals(a, b);
+ }
+
+ private static IEqualityComparer<T> Wrapped()
+ {
+ return EqualityComparer<T>.Default;
+ }
+
+ // We would need enhancements to late devirtualization
+ // to optimize this case.
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ public bool CompareWrapped(ref T x, ref T y)
+ {
+ return Wrapped().Equals(x, y);
+ }
+
+ public bool BenchCompareNoOpt(ref T t, long count)
+ {
+ bool result = true;
+ for (int i = 0; i < count; i++)
+ {
+ result &= CompareNoOpt(ref t, ref t);
+ }
+ return result;
+ }
+
+ public bool BenchCompare(ref T t, long count)
+ {
+ bool result = true;
+ for (int i = 0; i < count; i++)
+ {
+ result &= Compare(ref t, ref t);
+ }
+ return result;
+ }
+
+ public bool BenchCompareCached(ref T t, long count)
+ {
+ bool result = true;
+ for (int i = 0; i < count; i++)
+ {
+ result &= CompareCached(ref t, ref t);
+ }
+ return result;
+ }
+
+ public bool BenchCompareWrapped(ref T t, long count)
+ {
+ bool result = true;
+ for (int i = 0; i < count; i++)
+ {
+ result &= CompareWrapped(ref t, ref t);
+ }
+ return result;
+ }
+ }
+
+ public class EqualityComparer
+ {
+
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 150 * 1000 * 1000;
+#endif
+
+ public enum E
+ {
+ RED = 1,
+ BLUE = 2
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static void Consume(bool b) { }
+
+ [Benchmark(InnerIterationCount = Iterations)]
+ public static void ValueTupleCompareNoOpt()
+ {
+ var valueTupleFixture = new EqualityComparerFixture<ValueTuple<byte, E, int>>();
+ var v0 = new ValueTuple<byte, E, int>(3, E.RED, 11);
+ var result = true;
+
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ result &= valueTupleFixture.BenchCompareNoOpt(ref v0, Benchmark.InnerIterationCount);
+ }
+ }
+
+ Consume(result);
+ }
+
+ [Benchmark(InnerIterationCount = Iterations)]
+ public static void ValueTupleCompare()
+ {
+ var valueTupleFixture = new EqualityComparerFixture<ValueTuple<byte, E, int>>();
+ var v0 = new ValueTuple<byte, E, int>(3, E.RED, 11);
+ var result = true;
+
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ result &= valueTupleFixture.BenchCompare(ref v0, Benchmark.InnerIterationCount);
+ }
+ }
+
+ Consume(result);
+ }
+
+ [Benchmark(InnerIterationCount = Iterations)]
+ public static void ValueTupleCompareCached()
+ {
+ var valueTupleFixture = new EqualityComparerFixture<ValueTuple<byte, E, int>>();
+ var v0 = new ValueTuple<byte, E, int>(3, E.RED, 11);
+ var result = true;
+
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ result &= valueTupleFixture.BenchCompareCached(ref v0, Benchmark.InnerIterationCount);
+ }
+ }
+
+ Consume(result);
+ }
+
+ [Benchmark(InnerIterationCount = Iterations)]
+ public static void ValueTupleCompareWrapped()
+ {
+ var valueTupleFixture = new EqualityComparerFixture<ValueTuple<byte, E, int>>();
+ var v0 = new ValueTuple<byte, E, int>(3, E.RED, 11);
+ var result = true;
+
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ result &= valueTupleFixture.BenchCompareWrapped(ref v0, Benchmark.InnerIterationCount);
+ }
+ }
+
+ Consume(result);
+ }
+
+ public static int Main()
+ {
+ var valueTupleFixture = new EqualityComparerFixture<ValueTuple<byte, E, int>>();
+ var v0 = new ValueTuple<byte, E, int>(3, E.RED, 11);
+
+ bool vtCompare = valueTupleFixture.Compare(ref v0, ref v0);
+ bool vtCompareNoOpt = valueTupleFixture.CompareNoOpt(ref v0, ref v0);
+ bool vtCompareCached = valueTupleFixture.CompareCached(ref v0, ref v0);
+ bool vtCompareWrapped = valueTupleFixture.CompareWrapped(ref v0, ref v0);
+
+ bool vtOk = vtCompare & vtCompareNoOpt & vtCompareCached & vtCompareWrapped;
+
+ return vtOk ? 100 : 0;
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/Devirtualization/DefaultEqualityComparerPerf.csproj b/tests/src/JIT/Performance/CodeQuality/Devirtualization/DefaultEqualityComparerPerf.csproj
new file mode 100644
index 0000000000..7f06379d37
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/Devirtualization/DefaultEqualityComparerPerf.csproj
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{C1BFD48A-A83F-4767-8EB2-3E2C50906681}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="DefaultEqualityComparerPerf.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
diff --git a/tests/src/JIT/Regression/JitBlue/DevDiv_491206/DevDiv_491206.il b/tests/src/JIT/Regression/JitBlue/DevDiv_491206/DevDiv_491206.il
new file mode 100644
index 0000000000..6bfe60bebb
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/DevDiv_491206/DevDiv_491206.il
@@ -0,0 +1,70 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern mscorlib {}
+.assembly a {}
+.module a.exe
+
+// This test originally triggered an assert Extra_flags_on_tree, because fgMorphCast did not reset an asignment flag, when
+// its children was optimized in the assertion propogation.
+
+.class ILGEN_CLASS
+{
+ .method public hidebysig static int64 DoubleToInt64(float64 val) cil managed
+ {
+ // Code size 108 (0x6c)
+ .maxstack 2
+ .locals init (float64 V_0)
+ IL_0000: ldarg.0
+ IL_0001: call bool [mscorlib]System.Double::IsNaN(float64)
+ IL_0006: brfalse.s IL_000b
+ IL_0008: ldc.i4.0
+ IL_0009: conv.i8
+ IL_000a: ret
+ IL_000b: ldc.r8 -9.2233720368547758e+018
+ IL_0014: ldarg.0
+ IL_0015: bgt.un.s IL_0026
+ IL_0017: ldarg.0
+ IL_0018: ldc.r8 9.2233720368547758e+018
+ IL_0021: bgt.un.s IL_0026
+ IL_0023: ldarg.0
+ IL_0024: conv.i8
+ IL_0025: ret
+ IL_0026: ldarg.0
+ IL_0027: call bool [mscorlib]System.Double::IsInfinity(float64)
+ IL_002c: brfalse.s IL_0031
+ IL_002e: ldc.i4.0
+ IL_002f: conv.i8
+ IL_0030: ret
+ IL_0031: ldarg.0
+ IL_0032: call int32 [mscorlib]System.Math::Sign(float64)
+ IL_0037: conv.r8
+ IL_0038: ldarg.0
+ IL_0039: call float64 [mscorlib]System.Math::Abs(float64)
+ IL_003e: call float64 [mscorlib]System.Math::Floor(float64)
+ IL_0043: mul
+ IL_0044: ldc.r8 1.8446744073709552e+019
+ IL_004d: call float64 [mscorlib]System.Math::IEEERemainder(float64,
+ float64)
+ IL_0052: stloc.0
+ IL_0053: ldloc.0
+ IL_0054: ldc.r8 9.2233720368547758e+018
+ IL_005d: bne.un.s IL_0069
+ IL_005f: ldc.i8 0x8000000000000000
+ IL_0068: ret
+ IL_0069: ldloc.0
+ IL_006a: conv.i8
+ IL_006b: ret
+ } // end of method DoubleToInt64
+
+ .method public static int32 Main()
+ {
+ .entrypoint
+ ldc.r8 9.2233720368547758e+018
+ call int64 ILGEN_CLASS::DoubleToInt64(float64)
+ pop
+ ldc.i4 100
+ ret
+ }
+} \ No newline at end of file
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/pidigits/pi-digits.csproj b/tests/src/JIT/Regression/JitBlue/DevDiv_491206/DevDiv_491206.ilproj
index 003871e447..a1379c1f7c 100644
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/pidigits/pi-digits.csproj
+++ b/tests/src/JIT/Regression/JitBlue/DevDiv_491206/DevDiv_491206.ilproj
@@ -4,35 +4,31 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <AssemblyName>$(MSBuildProjectName)</AssemblyName>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
<OutputType>Exe</OutputType>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "></PropertyGroup>
<ItemGroup>
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
<Visible>False</Visible>
</CodeAnalysisDependentAssemblyPaths>
</ItemGroup>
+ <PropertyGroup>
+ <DebugType>None</DebugType>
+ <Optimize>True</Optimize>
+ </PropertyGroup>
<ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ <Compile Include="DevDiv_491206.il" />
</ItemGroup>
<ItemGroup>
- <Compile Include="pi-digits.cs" />
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
<PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
</Project> \ No newline at end of file
diff --git a/tests/src/JIT/Regression/JitBlue/DevDiv_495792/DevDiv_495792.il b/tests/src/JIT/Regression/JitBlue/DevDiv_495792/DevDiv_495792.il
new file mode 100644
index 0000000000..84f488d161
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/DevDiv_495792/DevDiv_495792.il
@@ -0,0 +1,140 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern mscorlib {}
+.assembly a {}
+.module a.exe
+
+// This test originally triggered an assert Extra_flags_on_tree, because fgMorphCast did not reset an asignment flag, when
+// its children was optimized in the assertion propogation.
+
+.class ILGEN_CLASS
+{
+ .method static unsigned int64 ILGEN_METHOD(unsigned int8, unsigned int64, int32)
+ {
+ .maxstack 65535
+ .locals init (int8, float64)
+ IL_0000: ldarg.s 0x01
+ IL_0002: ldarg 0x0001
+ IL_0006: ldarg.s 0x01
+ IL_0008: clt.un
+ IL_000a: conv.ovf.i8.un
+ IL_000b: cgt.un
+ IL_000d: ldloc.s 0x01
+ IL_000f: conv.ovf.u1
+ IL_0010: and
+ IL_0011: conv.r8
+ IL_0012: conv.ovf.i8
+ IL_0013: neg
+ IL_0014: conv.i1
+ IL_0015: nop
+ IL_0016: ldloc 0x0001
+ IL_001a: nop
+ IL_001b: dup
+ IL_001c: div
+ IL_001d: conv.ovf.u4
+ IL_001e: ldc.i8 0xf65065040a910acc
+ IL_0027: conv.ovf.i8.un
+ IL_0028: starg.s 0x01
+ IL_002a: rem.un
+ IL_002b: ldloc.s 0x00
+ IL_002d: ldloc 0x0000
+ IL_0031: mul.ovf
+ IL_0032: starg 0x0002
+ IL_0036: ldloc.s 0x01
+ IL_0038: ldarg 0x0001
+ IL_003c: conv.r.un
+ IL_003d: ldloc 0x0001
+ IL_0041: div
+ IL_0042: conv.r4
+ IL_0043: neg
+ IL_0044: add
+ IL_0045: ldc.i4 0x79464b58
+ IL_004a: conv.ovf.i1.un
+ IL_004b: ldarg.s 0x01
+ IL_004d: conv.ovf.i4
+ IL_004e: mul
+ IL_004f: ldloc.s 0x01
+ IL_0051: conv.r4
+ IL_0052: conv.ovf.i
+ IL_0053: ldarg.s 0x00
+ IL_0055: shr.un
+ IL_0056: mul.ovf
+ IL_0057: conv.r8
+ IL_0058: add
+ IL_0059: conv.ovf.i1
+ IL_005a: conv.ovf.i2
+ IL_005b: ldc.i8 0x2b5e7f8df42cece0
+ IL_0064: starg 0x0001
+ IL_0068: neg
+ IL_0069: nop
+ IL_006a: bgt
+ IL_0074
+ IL_006f: ldarg 0x0000
+ IL_0073: pop
+ IL_0074: ldarg.s 0x01
+ IL_0076: ldarg 0x0001
+ IL_007a: ldarg.s 0x00
+ IL_007c: ldloc 0x0001
+ IL_0080: ldloc.s 0x01
+ IL_0082: neg
+ IL_0083: clt.un
+ IL_0085: clt
+ IL_0087: not
+ IL_0088: ldarg.s 0x00
+ IL_008a: ldarg.s 0x00
+ IL_008c: sub.ovf
+ IL_008d: xor
+ IL_008e: ldarg.s 0x02
+ IL_0090: dup
+ IL_0091: rem
+ IL_0092: shl
+ IL_0093: conv.ovf.u2.un
+ IL_0094: shr
+ IL_0095: ldarg 0x0001
+ IL_0099: pop
+ IL_009a: ldarg 0x0001
+ IL_009e: clt
+ IL_00a0: ldc.r8 float64(0x739233eae9c3b79a)
+ IL_00a9: conv.u4
+ IL_00aa: div.un
+ IL_00ab: pop
+ IL_00ac: ret
+ }
+
+ .method private static int32 Main()
+ {
+ .entrypoint
+ .maxstack 3
+ .locals init ([0] class [mscorlib]System.OverflowException e,
+ [1] int32 V_1)
+ IL_0000: nop
+ .try
+ {
+ IL_0001: nop
+ IL_0002: ldc.i4.3
+ IL_0003: ldc.i4.2
+ IL_0004: conv.i8
+ IL_0005: ldc.i4.3
+ IL_0006: call uint64 ILGEN_CLASS::ILGEN_METHOD(uint8,
+ uint64,
+ int32)
+ IL_000b: pop
+ IL_000c: nop
+ IL_000d: leave.s IL_0014
+ } // end .try
+ catch [mscorlib]System.OverflowException
+ {
+ IL_000f: stloc.0
+ IL_0010: nop
+ IL_0011: nop
+ IL_0012: leave.s IL_0014
+ } // end handler
+ IL_0014: ldc.i4.s 100
+ IL_0016: stloc.1
+ IL_0017: br.s IL_0019
+ IL_0019: ldloc.1
+ IL_001a: ret
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm.csproj b/tests/src/JIT/Regression/JitBlue/DevDiv_495792/DevDiv_495792.ilproj
index 3c3e32e986..97b20fb21a 100644
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm.csproj
+++ b/tests/src/JIT/Regression/JitBlue/DevDiv_495792/DevDiv_495792.ilproj
@@ -4,35 +4,32 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <AssemblyName>$(MSBuildProjectName)</AssemblyName>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
<OutputType>Exe</OutputType>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ <CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "></PropertyGroup>
<ItemGroup>
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
<Visible>False</Visible>
</CodeAnalysisDependentAssemblyPaths>
</ItemGroup>
+ <PropertyGroup>
+ <DebugType>None</DebugType>
+ <Optimize>True</Optimize>
+ </PropertyGroup>
<ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ <Compile Include="DevDiv_495792.il" />
</ItemGroup>
<ItemGroup>
- <Compile Include="spectralnorm.cs" />
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
<PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
</Project>
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_13057/GitHub_13057.cs b/tests/src/JIT/Regression/JitBlue/GitHub_13057/GitHub_13057.cs
new file mode 100644
index 0000000000..8076706309
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_13057/GitHub_13057.cs
@@ -0,0 +1,80 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Collections;
+using System.Collections.Generic;
+using System.Resources;
+
+public class Program
+{
+ const int Pass = 100;
+ const int Fail = -1;
+
+ struct RetSt2 {
+ public Object _key;
+ public Object _value;
+
+ public RetSt2(Object value)
+ {
+ _key = "f";
+ _value = value;
+ }
+ }
+
+ class Test {
+ private Object lockObject;
+
+ internal Test(Object reader)
+ {
+ lockObject = reader;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ Object FirstValue()
+ {
+ return "FirstValue";
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ Object SecondValue()
+ {
+ return "SecondValue";
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public RetSt2 foo(int d) {
+ Object value = null;
+ lock (lockObject)
+ {
+ lock (lockObject)
+ {
+ if (d == -1) {
+ value = FirstValue();
+ } else {
+ value = SecondValue();
+ }
+ }
+ }
+ return new RetSt2(value);
+ }
+ }
+
+
+
+ public static int Main()
+ {
+ RetSt2 r = new Test("Lock").foo(-1);
+ Console.WriteLine("r._key: " + r._key);
+ Console.WriteLine("r._value: " + r._value);
+
+ r = new Test("Lock").foo(-2);
+ Console.WriteLine("r._key: " + r._key);
+ Console.WriteLine("r._value: " + r._value);
+
+ return Pass;
+ }
+}
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_13057/GitHub_13057.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_13057/GitHub_13057.csproj
new file mode 100644
index 0000000000..2cafa4cedf
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_13057/GitHub_13057.csproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <AssemblyName>$(MSBuildProjectName)</AssemblyName>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <PropertyGroup>
+ <DebugType></DebugType>
+ <Optimize>True</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="$(MSBuildProjectName).cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+ </PropertyGroup>
+</Project>
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_13568/GitHub_13568.cs b/tests/src/JIT/Regression/JitBlue/GitHub_13568/GitHub_13568.cs
new file mode 100644
index 0000000000..98a136c1e6
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_13568/GitHub_13568.cs
@@ -0,0 +1,168 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Numerics;
+using System.Runtime.CompilerServices;
+using System.Text;
+
+namespace VectorWiden
+{
+ class Program
+ {
+ private static byte[] _asciiBytes = Encoding.ASCII.GetBytes("text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7");
+ private static string _asciiString = new string('\0', _asciiBytes.Length);
+ private static string compareString = "text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7";
+
+ static unsafe int Main(string[] args)
+ {
+ fixed (byte* pBytes = &_asciiBytes[0])
+ fixed (char* pString = _asciiString)
+ {
+ TryGetAsciiStringVectorWiden(pBytes, pString, _asciiBytes.Length);
+ }
+ if (String.Compare(_asciiString, compareString) != 0)
+ {
+ Console.WriteLine("Test Failed. Expected:\n");
+ Console.WriteLine(compareString);
+ Console.WriteLine("Test Failed. Got:\n");
+ Console.WriteLine(_asciiString);
+ return -1;
+ }
+ return 100;
+ }
+
+ public static unsafe bool TryGetAsciiStringVectorWiden(byte* input, char* output, int count)
+
+ {
+ // Calcuate end position
+ var end = input + count;
+
+ // Start as valid
+ var isValid = true;
+
+ do
+ {
+ // If Vector not-accelerated or remaining less than vector size
+ if (!Vector.IsHardwareAccelerated || input > end - Vector<sbyte>.Count)
+ {
+ if (IntPtr.Size == 8) // Use Intrinsic switch for branch elimination
+ {
+ // 64-bit: Loop longs by default
+ while (input <= end - sizeof(long))
+ {
+ isValid &= CheckBytesInAsciiRange(((long*)input)[0]);
+
+ output[0] = (char)input[0];
+ output[1] = (char)input[1];
+ output[2] = (char)input[2];
+ output[3] = (char)input[3];
+ output[4] = (char)input[4];
+ output[5] = (char)input[5];
+ output[6] = (char)input[6];
+ output[7] = (char)input[7];
+
+ input += sizeof(long);
+ output += sizeof(long);
+ }
+ if (input <= end - sizeof(int))
+ {
+ isValid &= CheckBytesInAsciiRange(((int*)input)[0]);
+
+ output[0] = (char)input[0];
+ output[1] = (char)input[1];
+ output[2] = (char)input[2];
+ output[3] = (char)input[3];
+
+ input += sizeof(int);
+ output += sizeof(int);
+ }
+ }
+ else
+ {
+ // 32-bit: Loop ints by default
+ while (input <= end - sizeof(int))
+ {
+ isValid &= CheckBytesInAsciiRange(((int*)input)[0]);
+
+ output[0] = (char)input[0];
+ output[1] = (char)input[1];
+ output[2] = (char)input[2];
+ output[3] = (char)input[3];
+
+ input += sizeof(int);
+ output += sizeof(int);
+ }
+ }
+ if (input <= end - sizeof(short))
+ {
+ isValid &= CheckBytesInAsciiRange(((short*)input)[0]);
+
+ output[0] = (char)input[0];
+ output[1] = (char)input[1];
+
+ input += sizeof(short);
+ output += sizeof(short);
+ }
+ if (input < end)
+ {
+ isValid &= CheckBytesInAsciiRange(((sbyte*)input)[0]);
+ output[0] = (char)input[0];
+ }
+
+ return isValid;
+ }
+
+ // do/while as entry condition already checked
+ do
+ {
+ var vector = Unsafe.AsRef<Vector<sbyte>>(input);
+ isValid &= CheckBytesInAsciiRange(vector);
+ // Vectorized widen, byte vector to two short vectors
+ Vector.Widen(vector, out Unsafe.AsRef<Vector<short>>(output),
+ out Unsafe.AsRef<Vector<short>>(output + Vector<short>.Count));
+ input += Vector<sbyte>.Count;
+ output += Vector<sbyte>.Count;
+ } while (input <= end - Vector<sbyte>.Count);
+
+ // Vector path done, loop back to do non-Vector
+ // If is a exact multiple of vector size, bail now
+ } while (input > end - Vector<sbyte>.Count);
+
+ return isValid;
+ }
+
+ private static bool CheckBytesInAsciiRange(Vector<sbyte> check)
+ {
+ // Vectorized byte range check, signed byte > 0 for 1-127
+ return Vector.GreaterThanAll(check, Vector<sbyte>.Zero);
+ }
+
+ // Validate: bytes != 0 && bytes <= 127
+ // Subtract 1 from all bytes to move 0 to high bits
+ // bitwise or with self to catch all > 127 bytes
+ // mask off high bits and check if 0
+
+ private static bool CheckBytesInAsciiRange(long check)
+ {
+ const long HighBits = unchecked((long)0x8080808080808080L);
+ return (((check - 0x0101010101010101L) | check) & HighBits) == 0;
+ }
+
+ private static bool CheckBytesInAsciiRange(int check)
+ {
+ const int HighBits = unchecked((int)0x80808080);
+ return (((check - 0x01010101) | check) & HighBits) == 0;
+ }
+
+ private static bool CheckBytesInAsciiRange(short check)
+ {
+ const short HighBits = unchecked((short)0x8080);
+ return (((short)(check - 0x0101) | check) & HighBits) == 0;
+ }
+
+ private static bool CheckBytesInAsciiRange(sbyte check)
+ => check > 0;
+ }
+}
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_13568/GitHub_13568.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_13568/GitHub_13568.csproj
new file mode 100644
index 0000000000..17b8a9be17
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_13568/GitHub_13568.csproj
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <AssemblyName>$(MSBuildProjectName)</AssemblyName>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup>
+ <DebugType></DebugType>
+ <Optimize>True</Optimize>
+ <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="$(MSBuildProjectName).cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_13910/GitHub_13910.cs b/tests/src/JIT/Regression/JitBlue/GitHub_13910/GitHub_13910.cs
new file mode 100644
index 0000000000..d1805d1fa0
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_13910/GitHub_13910.cs
@@ -0,0 +1,120 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Runtime.InteropServices;
+
+// Represents a problem with contained nodes chains, that contain lclVar reads, that were moved through lclVar stores.
+// Notice that the project file sets complus_JitStressModeNames.
+
+[StructLayout(LayoutKind.Explicit)]
+internal class AA
+{
+
+ [FieldOffset(8)]
+ public QQ q;
+
+
+ public static AA[] a_init = new AA[101];
+
+ public static AA[] a_zero = new AA[101];
+
+
+ public AA(int qq)
+ {
+
+ this.q = new QQ(qq);
+ }
+
+
+ public static void reset()
+ {
+ AA.a_init[100] = new AA(1);
+ AA.a_zero[100] = new AA(2);
+ }
+}
+
+internal class QQ
+{
+ public int val;
+
+ public QQ(int vv)
+ {
+ this.val = vv;
+ }
+
+ public int ret_code()
+ {
+ return 100;
+ }
+}
+
+internal class TestApp
+{
+
+ private static int test_2_2(int num)
+ {
+ int result;
+ if (AA.a_init[num].q != AA.a_zero[num].q)
+ // Access field with contained IND instruction.
+ // EQ marks its operands as contained too.
+ // AA.a_init[num].q and AA.a_zero[num].q are allocated to the same lclVar.
+ // So we calculate AA.a_init[num].q and store as tmp0, use this temp to do nullCheck.
+ // Then store AA.a_zero[num].q as tmp0, destroy the old value and try to do EQ thinking that
+ // tmp0 is AA.a_init[num].q.
+ // It needs stress (complus_JitStressModeNames=STRESS_NULL_OBJECT_CHECK, STRESS_MAKE_CSE)
+ // to force the compiler to do implicit null checks and store values as local variables.
+// Bad IL example, t53 is set as contained, t143 is set as contained, it means they will be calculated as part of their parent t9.
+// But at that moment V02, that is read in t143 is already modified by [000056].
+// N035 ( 1, 1) [000035] ------------ t35 = LCL_VAR ref V02 tmp0 u:3 eax (last use) REG eax <l:$149, c:$182>
+// /--* t35 ref
+// N037 (???,???) [000143] -c---------- t143 = * LEA(b+12) byref REG NA
+// /--* t143 byref
+// N039 ( 4, 4) [000054] Rc---O------ t54 = * IND ref REG NA <l:$155, c:$184> // This contained flag is invalid because
+// // the value will be read after the store 000056.
+// *********************************************************************************************
+// /--* t117 ref
+// N073 ( 18, 22) [000056] DA-XG------- * STORE_LCL_VAR ref V02 tmp0 d:4 eax REG eax // the store that corrupts t54 value.
+// N075 ( 1, 1) [000057] ------------ t57 = LCL_VAR ref V02 tmp0 u:4 eax REG eax <l:$160, c:$187>
+// /--* t57 ref
+// N077 ( 2, 2) [000058] ---X---N---- * NULLCHECK byte REG NA <l:$166, c:$165>
+// N079 ( 1, 1) [000060] ------------ t60 = LCL_VAR ref V02 tmp0 u:4 eax REG eax <l:$160, c:$187>
+// /--* t60 ref
+// N081 (???,???) [000146] -c---------- t146 = * LEA(b+12) byref REG NA
+// /--* t146 byref
+// N083 ( 4, 4) [000079] R----O------ t79 = * IND ref REG ecx <l:$16b, c:$189>
+// /--* t79 ref
+// N085 ( 4, 4) [000121] DA---O------ * STORE_LCL_VAR ref V07 cse1 ecx REG ecx
+// N087 ( 1, 1) [000122] ------------ t122 = LCL_VAR ref V07 cse1 ecx REG ecx <l:$16b, c:$189>
+// /--* t54 ref // reads V02.
+// +--* t122 ref
+// N089 ( 48, 56) [000009] J--XGO-N---- t9 = * EQ int REG NA <l:$1c5, c:$1c4>
+ {
+ result = 100;
+ }
+ else
+ {
+ result = AA.a_zero[num].q.val;
+ }
+ return result;
+ }
+
+ private static int Main()
+ {
+ AA.reset();
+ int result;
+
+ int r = TestApp.test_2_2(100);
+ if (r != 100)
+ {
+ Console.WriteLine("Failed.");
+ result = 101;
+ }
+ else
+ {
+ Console.WriteLine("Passed.");
+ result = 100;
+ }
+ return result;
+ }
+}
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_13910/GitHub_13910.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_13910/GitHub_13910.csproj
new file mode 100644
index 0000000000..8cb39e1055
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_13910/GitHub_13910.csproj
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <AssemblyName>$(MSBuildProjectName)</AssemblyName>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{E2C84853-0100-4C5D-88C0-355F70483779}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "></PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <PropertyGroup>
+ <DebugType></DebugType>
+ <Optimize>True</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="$(MSBuildProjectName).cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <PropertyGroup>
+ <!-- Set JitStreess variables, Linux requires them to be properly capitalized. -->
+ <CLRTestBatchPreCommands><![CDATA[
+$(CLRTestBatchPreCommands)
+set COMPlus_JitStressModeNames=STRESS_NULL_OBJECT_CHECK, STRESS_MAKE_CSE
+]]></CLRTestBatchPreCommands>
+ <BashCLRTestPreCommands><![CDATA[
+$(BashCLRTestPreCommands)
+export COMPlus_JitStressModeNames=STRESS_NULL_OBJECT_CHECK, STRESS_MAKE_CSE
+]]></BashCLRTestPreCommands>
+ </PropertyGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+</Project> \ No newline at end of file
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_14028/GitHub_14028.cs b/tests/src/JIT/Regression/JitBlue/GitHub_14028/GitHub_14028.cs
new file mode 100644
index 0000000000..dcd57eff99
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_14028/GitHub_14028.cs
@@ -0,0 +1,31 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Numerics;
+
+class GitHub_10215
+{
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool Test(Vector<int> x, Vector<int> y) => x[0] == y[0];
+
+ static int Main()
+ {
+ int returnVal = 100;
+ Vector<int> X0 = new Vector<int>(0);
+ Vector<int> X1 = new Vector<int>(1);
+ Vector<int> Y0 = new Vector<int>(0);
+ if (!Test(X0,Y0))
+ {
+ returnVal = -1;
+ }
+ if (Test(X1,Y0))
+ {
+ returnVal = -1;
+ }
+ return returnVal;
+ }
+}
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_14028/GitHub_14028.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_14028/GitHub_14028.csproj
new file mode 100644
index 0000000000..817a24c9fe
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_14028/GitHub_14028.csproj
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <AssemblyName>$(MSBuildProjectName)</AssemblyName>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <CLRTestPriority>1</CLRTestPriority>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "></PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <PropertyGroup>
+ <DebugType></DebugType>
+ <Optimize>True</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="GitHub_14028.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+</Project>
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_14116/GitHub_14116.il b/tests/src/JIT/Regression/JitBlue/GitHub_14116/GitHub_14116.il
new file mode 100644
index 0000000000..7d3482f684
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_14116/GitHub_14116.il
@@ -0,0 +1,58 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern mscorlib {auto}
+.assembly extern System.Console {auto}
+.assembly GitHub_14116 {}
+
+.class Program
+{
+ .field static int8 s8;
+
+ .method static int32[] Test() noinlining
+ {
+ .maxstack 4
+
+ ldc.i8 0xFFFFFFF1FFFFFFFF
+ conv.i
+ newarr [mscorlib]System.Int32
+ dup
+
+ ldc.i4.0
+ ldc.i4.0
+ stelem.i4
+
+ ret
+ }
+
+ .method static int32 Main()
+ {
+ .entrypoint
+ .maxstack 1
+
+ ldc.i4 -1
+ stsfld int8 Program::s8
+
+ .try
+ {
+ call int32[] Program::Test()
+ leave FAIL
+ }
+ catch [mscorlib]System.OverflowException
+ {
+ pop
+ leave PASS
+ }
+ FAIL:
+ ldstr "FAIL"
+ call void [System.Console]System.Console::WriteLine(string)
+ ldc.i4 1
+ ret
+ PASS:
+ ldstr "PASS"
+ call void [System.Console]System.Console::WriteLine(string)
+ ldc.i4 100
+ ret
+ }
+}
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_14116/GitHub_14116.ilproj b/tests/src/JIT/Regression/JitBlue/GitHub_14116/GitHub_14116.ilproj
new file mode 100644
index 0000000000..d1a0e3027b
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_14116/GitHub_14116.ilproj
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <AssemblyName>$(MSBuildProjectName)</AssemblyName>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <CLRTestPriority>1</CLRTestPriority>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "></PropertyGroup>
+ <PropertyGroup>
+ <DebugType>None</DebugType>
+ <Optimize>True</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="GitHub_14116.il" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+</Project> \ No newline at end of file
diff --git a/tests/src/JIT/opt/FastTailCall/FastTailCallInlining.cs b/tests/src/JIT/opt/FastTailCall/FastTailCallInlining.cs
new file mode 100644
index 0000000000..81ffd72d88
--- /dev/null
+++ b/tests/src/JIT/opt/FastTailCall/FastTailCallInlining.cs
@@ -0,0 +1,39 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.CompilerServices;
+
+public class Test
+{
+ public static int Main()
+ {
+ A(2);
+ return 100;
+ }
+
+ public static void A(int i)
+ {
+ if (i > 0)
+ {
+ B(--i);
+ }
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void B(int i)
+ {
+ C(i);
+ A(--i);
+ }
+
+ public static void C(int i)
+ {
+ Console.WriteLine("In C");
+ if (i==0)
+ {
+ Console.WriteLine("In C");
+ }
+ }
+}
diff --git a/tests/src/JIT/opt/FastTailCall/FastTailCallInlining.csproj b/tests/src/JIT/opt/FastTailCall/FastTailCallInlining.csproj
new file mode 100644
index 0000000000..44812241e0
--- /dev/null
+++ b/tests/src/JIT/opt/FastTailCall/FastTailCallInlining.csproj
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <AssemblyName>$(MSBuildProjectName)</AssemblyName>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <IlasmRoundTrip>true</IlasmRoundTrip>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <PropertyGroup>
+ <!-- Set to 'Full' if the Debug? column is marked in the spreadsheet. Leave blank otherwise. -->
+ <DebugType>None</DebugType>
+ <NoLogo>True</NoLogo>
+ <NoStandardLib>True</NoStandardLib>
+ <Noconfig>True</Noconfig>
+ <Optimize>True</Optimize>
+ <JitOptimizationSensitive>True</JitOptimizationSensitive>
+ <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+ <DefineConstants>$(DefineConstants);CORECLR</DefineConstants>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="FastTailCallInlining.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+ </PropertyGroup>
+</Project>
diff --git a/tests/src/baseservices/threading/commitstackonlyasneeded/StackCommitCommon.cs b/tests/src/baseservices/threading/commitstackonlyasneeded/StackCommitCommon.cs
index fef88b1306..d97f9c2d8e 100644
--- a/tests/src/baseservices/threading/commitstackonlyasneeded/StackCommitCommon.cs
+++ b/tests/src/baseservices/threading/commitstackonlyasneeded/StackCommitCommon.cs
@@ -236,9 +236,19 @@ namespace StackCommitTest
public static void Run(Action action)
{
- new Finalizer(action);
+ //We need to allocate the object inside of a seperate method to ensure that
+ //the reference will be eliminated before GC.Collect is called. Technically
+ //even across methods we probably don't make any formal guarantees but this
+ //is sufficient for current runtime implementations.
+ CreateUnreferencedObject(action);
GC.Collect();
GC.WaitForPendingFinalizers();
}
+
+ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
+ private static void CreateUnreferencedObject(Action action)
+ {
+ new Finalizer(action);
+ }
}
-} \ No newline at end of file
+}
diff --git a/tests/src/dirs.proj b/tests/src/dirs.proj
index 248f86e177..471598d82d 100644
--- a/tests/src/dirs.proj
+++ b/tests/src/dirs.proj
@@ -30,7 +30,6 @@
<DisabledProjects Include="Performance\performance.csproj" />
<DisabledProjects Include="Loader\classloader\generics\regressions\DD117522\Test.csproj" />
<DisabledProjects Include="Loader\classloader\generics\GenericMethods\VSW491668.csproj" /> <!-- issue 5501 -->
- <DisabledProjects Include="tracing\**" Condition="'$(BuildOS)' != 'Linux'" />
</ItemGroup>
<ItemGroup>
diff --git a/tests/src/performance/performance.csproj b/tests/src/performance/performance.csproj
index dd01602826..8133535f45 100644
--- a/tests/src/performance/performance.csproj
+++ b/tests/src/performance/performance.csproj
@@ -7,9 +7,6 @@
<IsTestProject>false</IsTestProject>
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="CommandLineParser">
- <Version>2.1.1-beta</Version>
- </PackageReference>
<PackageReference Include="xunit.performance.api">
<Version>$(XUnitPerformanceApiVersion)</Version>
</PackageReference>
diff --git a/tests/src/sizeondisk/sodbench/SoDBench.cs b/tests/src/sizeondisk/sodbench/SoDBench.cs
new file mode 100644
index 0000000000..ac544aba28
--- /dev/null
+++ b/tests/src/sizeondisk/sodbench/SoDBench.cs
@@ -0,0 +1,702 @@
+using CommandLine;
+using CommandLine.Text;
+using Newtonsoft.Json;
+using Microsoft.Xunit.Performance.Api;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Net.Http;
+using System.Text;
+using System.Reflection;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace SoDBench
+{
+ // A simple tree node for tracking file and directory names and sizes
+ // Does not have to accurately represent the true file system; only what we care about
+ class SizeReportingNode
+ {
+ public SizeReportingNode(string name, long? size=null, bool expand=true)
+ {
+ Name = name;
+ _size = size;
+ Expanded = expand;
+ }
+
+ public SizeReportingNode(FileInfo file, bool expand=true)
+ {
+ Name = file.Name;
+ _size = file.Length;
+ Expanded = expand;
+ }
+
+ // Builds out the tree starting from a directory
+ public SizeReportingNode(DirectoryInfo dir, int? reportingDepth=null)
+ {
+ Name = dir.Name;
+
+ foreach (var childDir in dir.EnumerateDirectories())
+ {
+ AddChild(new SizeReportingNode(childDir));
+ }
+
+ foreach (var childFile in dir.EnumerateFiles())
+ {
+ AddChild(new SizeReportingNode(childFile));
+ }
+
+ if (reportingDepth != null)
+ {
+ LimitReportingDepth(reportingDepth ?? 0);
+ }
+ }
+
+
+ // The directory containing this node
+ public SizeReportingNode Parent { get; set; }
+
+ // All the directories and files this node contains
+ public List<SizeReportingNode> Children {get; private set;} = new List<SizeReportingNode>();
+
+ // The file or directory name
+ public string Name { get; set; }
+
+ public bool Expanded { get; set; } = true;
+
+ // A list version of the path up to the root level we care about
+ public List<string> SegmentedPath {
+ get
+ {
+ if (Parent != null)
+ {
+ var path = Parent.SegmentedPath;
+ path.Add(Name);
+ return path;
+ }
+ return new List<string> { Name };
+ }
+ }
+
+ // The size of the file or directory
+ public long Size {
+ get
+ {
+ if (_size == null)
+ {
+ _size = 0;
+ foreach (var node in Children)
+ {
+ _size += node.Size;
+ }
+ }
+ return _size ?? 0;
+ }
+
+ private set
+ {
+ _size = value;
+ }
+ }
+
+
+ // Add the adoptee node as a child and set the adoptee's parent
+ public void AddChild(SizeReportingNode adoptee)
+ {
+ Children.Add(adoptee);
+ adoptee.Parent = this;
+ _size = null;
+ }
+
+ public void LimitReportingDepth(int depth)
+ {
+ if (depth <= 0)
+ {
+ Expanded = false;
+ }
+
+ foreach (var childNode in Children)
+ {
+ childNode.LimitReportingDepth(depth-1);
+ }
+ }
+
+ // Return a CSV formatted string representation of the tree
+ public string FormatAsCsv()
+ {
+ return FormatAsCsv(new StringBuilder()).ToString();
+ }
+
+ // Add to the string build a csv formatted representation of the tree
+ public StringBuilder FormatAsCsv(StringBuilder builder)
+ {
+ string path = String.Join(",", SegmentedPath.Select(s => Csv.Escape(s)));
+ builder.AppendLine($"{path},{Size}");
+
+ if (Expanded)
+ {
+ foreach (var childNode in Children)
+ {
+ childNode.FormatAsCsv(builder);
+ }
+ }
+
+ return builder;
+ }
+
+ private long? _size = null;
+ }
+
+ class Program
+ {
+ public static readonly string NugetConfig =
+ @"<?xml version='1.0' encoding='utf-8'?>
+ <configuration>
+ <packageSources>
+ <add key='nuget.org' value='https://api.nuget.org/v3/index.json' protocolVersion='3' />
+ <add key='myget.org/dotnet-core' value='https://dotnet.myget.org/F/dotnet-core/api/v3/index.json' protocolVersion='3' />
+ <add key='myget.org/aspnet-core' value='https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json' protocolVersion='3' />
+ </packageSources>
+ </configuration>";
+
+ public static readonly string[] NewTemplates = new string[] {
+ "console",
+ "classlib",
+ "mstest",
+ "xunit",
+ "web",
+ "mvc",
+ "razor",
+ "webapi",
+ "nugetconfig",
+ "webconfig",
+ "sln",
+ "page",
+ "viewimports",
+ "viewstart"
+ };
+
+ public static readonly string[] OperatingSystems = new string[] {
+ "win10-x64",
+ "win10-x86",
+ "ubuntu.16.10-x64",
+ "rhel.7-x64"
+ };
+
+ static FileInfo s_dotnetExe;
+ static DirectoryInfo s_sandboxDir;
+ static DirectoryInfo s_fallbackDir;
+ static DirectoryInfo s_corelibsDir;
+ static bool s_keepArtifacts;
+ static string s_targetArchitecture;
+ static string s_dotnetChannel;
+
+ static void Main(string[] args)
+ {
+ try
+ {
+ var options = SoDBenchOptions.Parse(args);
+
+ s_targetArchitecture = options.TargetArchitecture;
+ s_dotnetChannel = options.DotnetChannel;
+ s_keepArtifacts = options.KeepArtifacts;
+
+ if (!String.IsNullOrWhiteSpace(options.DotnetExecutable))
+ {
+ s_dotnetExe = new FileInfo(options.DotnetExecutable);
+ }
+
+ if (s_sandboxDir == null)
+ {
+ // Truncate the Guid used for anti-collision because a full Guid results in expanded paths over 260 chars (the Windows max)
+ s_sandboxDir = new DirectoryInfo(Path.Combine(Path.GetTempPath(), $"sod{Guid.NewGuid().ToString().Substring(0,13)}"));
+ s_sandboxDir.Create();
+ Console.WriteLine($"** Running inside sandbox directory: {s_sandboxDir}");
+ }
+
+ if (s_dotnetExe == null)
+ {
+ if(!String.IsNullOrEmpty(options.CoreLibariesDirectory))
+ {
+ Console.WriteLine($"** Using core libraries found at {options.CoreLibariesDirectory}");
+ s_corelibsDir = new DirectoryInfo(options.CoreLibariesDirectory);
+ }
+ else
+ {
+ var coreroot = Environment.GetEnvironmentVariable("CORE_ROOT");
+ if (!String.IsNullOrEmpty(coreroot) && Directory.Exists(coreroot))
+ {
+ Console.WriteLine($"** Using core libraries from CORE_ROOT at {coreroot}");
+ s_corelibsDir = new DirectoryInfo(coreroot);
+ }
+ else
+ {
+ Console.WriteLine("** Using default dotnet-cli core libraries");
+ }
+ }
+
+ PrintHeader("Installing Dotnet CLI");
+ s_dotnetExe = SetupDotnet();
+ }
+
+ if (s_fallbackDir == null)
+ {
+ s_fallbackDir = new DirectoryInfo(Path.Combine(s_sandboxDir.FullName, "fallback"));
+ s_fallbackDir.Create();
+ }
+
+ Console.WriteLine($"** Path to dotnet executable: {s_dotnetExe.FullName}");
+
+ PrintHeader("Starting acquisition size test");
+ var acquisition = GetAcquisitionSize();
+
+ PrintHeader("Running deployment size test");
+ var deployment = GetDeploymentSize();
+
+ var root = new SizeReportingNode("Dotnet Total");
+ root.AddChild(acquisition);
+ root.AddChild(deployment);
+
+ var formattedStr = root.FormatAsCsv();
+
+ File.WriteAllText(options.OutputFilename, formattedStr);
+
+ if (options.Verbose)
+ Console.WriteLine($"** CSV Output:\n{formattedStr}");
+ }
+ finally
+ {
+ if (!s_keepArtifacts && s_sandboxDir != null)
+ {
+ PrintHeader("Cleaning up sandbox directory");
+ s_sandboxDir.Delete(true);
+ s_sandboxDir = null;
+ }
+ }
+ }
+
+ private static void PrintHeader(string message)
+ {
+ Console.WriteLine();
+ Console.WriteLine("**********************************************************************");
+ Console.WriteLine($"** {message}");
+ Console.WriteLine("**********************************************************************");
+ }
+
+ private static SizeReportingNode GetAcquisitionSize()
+ {
+ var result = new SizeReportingNode("Acquisition Size");
+
+ // Arbitrary command to trigger first time setup
+ ProcessStartInfo dotnet = new ProcessStartInfo()
+ {
+ WorkingDirectory = s_sandboxDir.FullName,
+ FileName = s_dotnetExe.FullName,
+ Arguments = "new"
+ };
+
+ // Used to set where the packages will be unpacked to.
+ // There is a no gaurentee that this is a stable method, but is the only way currently to set the fallback folder location
+ dotnet.Environment["DOTNET_CLI_TEST_FALLBACKFOLDER"] = s_fallbackDir.FullName;
+
+ LaunchProcess(dotnet, 180000);
+
+ Console.WriteLine("\n** Measuring total size of acquired files");
+
+ result.AddChild(new SizeReportingNode(s_fallbackDir, 1));
+
+ var dotnetNode = new SizeReportingNode(s_dotnetExe.Directory);
+ var reportingDepths = new Dictionary<string, int>
+ {
+ {"additionalDeps", 1},
+ {"host", 0},
+ {"sdk", 2},
+ {"shared", 2},
+ {"store", 3}
+ };
+ foreach (var childNode in dotnetNode.Children)
+ {
+ int depth = 0;
+ if (reportingDepths.TryGetValue(childNode.Name, out depth))
+ {
+ childNode.LimitReportingDepth(depth);
+ }
+ }
+ result.AddChild(dotnetNode);
+
+ return result;
+ }
+
+ private static SizeReportingNode GetDeploymentSize()
+ {
+ // Write the NuGet.Config file
+ var nugetConfFile = new FileInfo(Path.Combine(s_sandboxDir.FullName, "NuGet.Config"));
+ File.WriteAllText(nugetConfFile.FullName, NugetConfig);
+
+ var result = new SizeReportingNode("Deployment Size");
+ foreach (string template in NewTemplates)
+ {
+ var templateNode = new SizeReportingNode(template);
+ result.AddChild(templateNode);
+
+ foreach (var os in OperatingSystems)
+ {
+ Console.WriteLine($"\n\n** Deploying {template}/{os}");
+
+ var deploymentSandbox = new DirectoryInfo(Path.Combine(s_sandboxDir.FullName, template, os));
+ var publishDir = new DirectoryInfo(Path.Combine(deploymentSandbox.FullName, "publish"));
+ deploymentSandbox.Create();
+
+ ProcessStartInfo dotnetNew = new ProcessStartInfo()
+ {
+ FileName = s_dotnetExe.FullName,
+ Arguments = $"new {template}",
+ UseShellExecute = false,
+ WorkingDirectory = deploymentSandbox.FullName
+ };
+ dotnetNew.Environment["DOTNET_CLI_TEST_FALLBACKFOLDER"] = s_fallbackDir.FullName;
+
+ ProcessStartInfo dotnetRestore = new ProcessStartInfo()
+ {
+ FileName = s_dotnetExe.FullName,
+ Arguments = $"restore --runtime {os}",
+ UseShellExecute = false,
+ WorkingDirectory = deploymentSandbox.FullName
+ };
+ dotnetRestore.Environment["DOTNET_CLI_TEST_FALLBACKFOLDER"] = s_fallbackDir.FullName;
+
+ ProcessStartInfo dotnetPublish = new ProcessStartInfo()
+ {
+ FileName = s_dotnetExe.FullName,
+ Arguments = $"publish -c Release --runtime {os} --output {publishDir.FullName}", // "out" is an arbitrary project name
+ UseShellExecute = false,
+ WorkingDirectory = deploymentSandbox.FullName
+ };
+ dotnetPublish.Environment["DOTNET_CLI_TEST_FALLBACKFOLDER"] = s_fallbackDir.FullName;
+
+ try
+ {
+ LaunchProcess(dotnetNew, 180000);
+ if (deploymentSandbox.EnumerateFiles().Any(f => f.Name.EndsWith("proj")))
+ {
+ LaunchProcess(dotnetRestore, 180000);
+ LaunchProcess(dotnetPublish, 180000);
+ }
+ else
+ {
+ Console.WriteLine($"** {template} does not have a project file to restore or publish");
+ }
+ }
+ catch (Exception e)
+ {
+ Console.Error.WriteLine(e.Message);
+ continue;
+ }
+
+ // If we published this project, only report published it's size
+ if (publishDir.Exists)
+ {
+ var publishNode = new SizeReportingNode(publishDir, 0);
+ publishNode.Name = deploymentSandbox.Name;
+ templateNode.AddChild(publishNode);
+ }
+ else
+ {
+ templateNode.AddChild(new SizeReportingNode(deploymentSandbox, 0));
+ }
+ }
+ }
+ return result;
+ }
+
+ private static void DownloadDotnetInstaller()
+ {
+ var psi = new ProcessStartInfo() {
+ WorkingDirectory = s_sandboxDir.FullName,
+ FileName = @"powershell.exe",
+ Arguments = $"wget https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.ps1 -OutFile Dotnet-Install.ps1"
+ };
+ LaunchProcess(psi, 180000);
+ }
+
+ private static void InstallSharedRuntime()
+ {
+ var psi = new ProcessStartInfo() {
+ WorkingDirectory = s_sandboxDir.FullName,
+ FileName = @"powershell.exe",
+ Arguments = $".\\Dotnet-Install.ps1 -SharedRuntime -InstallDir .dotnet -Channel {s_dotnetChannel} -Architecture {s_targetArchitecture}"
+ };
+ LaunchProcess(psi, 180000);
+ }
+
+ private static void InstallDotnet()
+ {
+ var psi = new ProcessStartInfo() {
+ WorkingDirectory = s_sandboxDir.FullName,
+ FileName = @"powershell.exe",
+ Arguments = $".\\Dotnet-Install.ps1 -InstallDir .dotnet -Channel {s_dotnetChannel} -Architecture {s_targetArchitecture}"
+ };
+ LaunchProcess(psi, 180000);
+ }
+
+ private static void ModifySharedFramework()
+ {
+ // Current working directory is the <coreclr repo root>/sandbox directory.
+ Console.WriteLine($"** Modifying the shared framework.");
+
+ var sourcedi = s_corelibsDir;
+
+ // Get the directory containing the newest version of Microsodt.NETCore.App libraries
+ var targetdi = new DirectoryInfo(
+ new DirectoryInfo(Path.Combine(s_sandboxDir.FullName, ".dotnet", "shared", "Microsoft.NETCore.App"))
+ .GetDirectories("*")
+ .OrderBy(s => s.Name)
+ .Last()
+ .FullName);
+
+ Console.WriteLine($"| Source : {sourcedi.FullName}");
+ Console.WriteLine($"| Target : {targetdi.FullName}");
+
+ var compiledBinariesOfInterest = new string[] {
+ "clretwrc.dll",
+ "clrjit.dll",
+ "coreclr.dll",
+ "mscordaccore.dll",
+ "mscordbi.dll",
+ "mscorrc.debug.dll",
+ "mscorrc.dll",
+ "sos.dll",
+ "SOS.NETCore.dll",
+ "System.Private.CoreLib.dll"
+ };
+
+ foreach (var compiledBinaryOfInterest in compiledBinariesOfInterest)
+ {
+ foreach (FileInfo fi in targetdi.GetFiles(compiledBinaryOfInterest))
+ {
+ var sourceFilePath = Path.Combine(sourcedi.FullName, fi.Name);
+ var targetFilePath = Path.Combine(targetdi.FullName, fi.Name);
+
+ if (File.Exists(sourceFilePath))
+ {
+ File.Copy(sourceFilePath, targetFilePath, true);
+ Console.WriteLine($"| Copied file - '{fi.Name}'");
+ }
+ }
+ }
+ }
+
+ private static FileInfo SetupDotnet()
+ {
+ DownloadDotnetInstaller();
+ InstallSharedRuntime();
+ InstallDotnet();
+ if (s_corelibsDir != null)
+ {
+ ModifySharedFramework();
+ }
+
+ var dotnetExe = new FileInfo(Path.Combine(s_sandboxDir.FullName, ".dotnet", "dotnet.exe"));
+ Debug.Assert(dotnetExe.Exists);
+
+ return dotnetExe;
+ }
+
+ private static void LaunchProcess(ProcessStartInfo processStartInfo, int timeoutMilliseconds, IDictionary<string, string> environment = null)
+ {
+ Console.WriteLine();
+ Console.WriteLine($"{System.Security.Principal.WindowsIdentity.GetCurrent().Name}@{Environment.MachineName} \"{processStartInfo.WorkingDirectory}\"");
+ Console.WriteLine($"[{DateTime.Now}] $ {processStartInfo.FileName} {processStartInfo.Arguments}");
+
+ if (environment != null)
+ {
+ foreach (KeyValuePair<string, string> pair in environment)
+ {
+ if (!processStartInfo.Environment.ContainsKey(pair.Key))
+ processStartInfo.Environment.Add(pair.Key, pair.Value);
+ else
+ processStartInfo.Environment[pair.Key] = pair.Value;
+ }
+ }
+
+ using (var p = new Process() { StartInfo = processStartInfo })
+ {
+ p.Start();
+ if (p.WaitForExit(timeoutMilliseconds) == false)
+ {
+ // FIXME: What about clean/kill child processes?
+ p.Kill();
+ throw new TimeoutException($"The process '{processStartInfo.FileName} {processStartInfo.Arguments}' timed out.");
+ }
+
+ if (p.ExitCode != 0)
+ throw new Exception($"{processStartInfo.FileName} exited with error code {p.ExitCode}");
+ }
+ }
+
+ /// <summary>
+ /// Provides an interface to parse the command line arguments passed to the SoDBench.
+ /// </summary>
+ private sealed class SoDBenchOptions
+ {
+ public SoDBenchOptions() { }
+
+ private static string NormalizePath(string path)
+ {
+ if (String.IsNullOrWhiteSpace(path))
+ throw new InvalidOperationException($"'{path}' is an invalid path: cannot be null or whitespace");
+
+ if (path.Any(c => Path.GetInvalidPathChars().Contains(c)))
+ throw new InvalidOperationException($"'{path}' is an invalid path: contains invalid characters");
+
+ return Path.IsPathRooted(path) ? path : Path.GetFullPath(path);
+ }
+
+ [Option('o', Required = false, HelpText = "Specifies the output file name for the csv document")]
+ public string OutputFilename
+ {
+ get { return _outputFilename; }
+
+ set
+ {
+ _outputFilename = NormalizePath(value);
+ }
+ }
+
+ [Option("dotnet", Required = false, HelpText = "Specifies the location of dotnet cli to use.")]
+ public string DotnetExecutable
+ {
+ get { return _dotnetExe; }
+
+ set
+ {
+ _dotnetExe = NormalizePath(value);
+ }
+ }
+
+ [Option("corelibs", Required = false, HelpText = "Specifies the location of .NET Core libaries to patch into dotnet. Cannot be used with --dotnet")]
+ public string CoreLibariesDirectory
+ {
+ get { return _corelibsDir; }
+
+ set
+ {
+ _corelibsDir = NormalizePath(value);
+ }
+ }
+
+ [Option("architecture", Required = false, Default = "x64", HelpText = "JitBench target architecture (It must match the built product that was copied into sandbox).")]
+ public string TargetArchitecture { get; set; }
+
+ [Option("channel", Required = false, Default = "master", HelpText = "Specifies the channel to use when installing the dotnet-cli")]
+ public string DotnetChannel { get; set; }
+
+ [Option('v', Required = false, HelpText = "Sets output to verbose")]
+ public bool Verbose { get; set; }
+
+ [Option("keep-artifacts", Required = false, HelpText = "Specifies that artifacts of this run should be kept")]
+ public bool KeepArtifacts { get; set; }
+
+ public static SoDBenchOptions Parse(string[] args)
+ {
+ using (var parser = new Parser((settings) => {
+ settings.CaseInsensitiveEnumValues = true;
+ settings.CaseSensitive = false;
+ settings.HelpWriter = new StringWriter();
+ settings.IgnoreUnknownArguments = true;
+ }))
+ {
+ SoDBenchOptions options = null;
+ parser.ParseArguments<SoDBenchOptions>(args)
+ .WithParsed(parsed => options = parsed)
+ .WithNotParsed(errors => {
+ foreach (Error error in errors)
+ {
+ switch (error.Tag)
+ {
+ case ErrorType.MissingValueOptionError:
+ throw new ArgumentException(
+ $"Missing value option for command line argument '{(error as MissingValueOptionError).NameInfo.NameText}'");
+ case ErrorType.HelpRequestedError:
+ Console.WriteLine(Usage());
+ Environment.Exit(0);
+ break;
+ case ErrorType.VersionRequestedError:
+ Console.WriteLine(new AssemblyName(typeof(SoDBenchOptions).GetTypeInfo().Assembly.FullName).Version);
+ Environment.Exit(0);
+ break;
+ case ErrorType.BadFormatTokenError:
+ case ErrorType.UnknownOptionError:
+ case ErrorType.MissingRequiredOptionError:
+ case ErrorType.MutuallyExclusiveSetError:
+ case ErrorType.BadFormatConversionError:
+ case ErrorType.SequenceOutOfRangeError:
+ case ErrorType.RepeatedOptionError:
+ case ErrorType.NoVerbSelectedError:
+ case ErrorType.BadVerbSelectedError:
+ case ErrorType.HelpVerbRequestedError:
+ break;
+ }
+ }
+ });
+
+ if (options != null && !String.IsNullOrEmpty(options.DotnetExecutable) && !String.IsNullOrEmpty(options.CoreLibariesDirectory))
+ {
+ throw new ArgumentException("--dotnet and --corlibs cannot be used together");
+ }
+
+ return options;
+ }
+ }
+
+ public static string Usage()
+ {
+ var parser = new Parser((parserSettings) =>
+ {
+ parserSettings.CaseInsensitiveEnumValues = true;
+ parserSettings.CaseSensitive = false;
+ parserSettings.EnableDashDash = true;
+ parserSettings.HelpWriter = new StringWriter();
+ parserSettings.IgnoreUnknownArguments = true;
+ });
+
+ var helpTextString = new HelpText
+ {
+ AddDashesToOption = true,
+ AddEnumValuesToHelpText = true,
+ AdditionalNewLineAfterOption = false,
+ Heading = "SoDBench",
+ MaximumDisplayWidth = 80,
+ }.AddOptions(parser.ParseArguments<SoDBenchOptions>(new string[] { "--help" })).ToString();
+ return helpTextString;
+ }
+
+ private string _dotnetExe;
+ private string _corelibsDir;
+ private string _outputFilename = "measurement.csv";
+ }
+ }
+
+ // A simple class for escaping strings for CSV writing
+ // https://stackoverflow.com/a/769713
+ // Used instead of a package because only these < 20 lines of code are needed
+ public static class Csv
+ {
+ public static string Escape( string s )
+ {
+ if ( s.Contains( QUOTE ) )
+ s = s.Replace( QUOTE, ESCAPED_QUOTE );
+
+ if ( s.IndexOfAny( CHARACTERS_THAT_MUST_BE_QUOTED ) > -1 )
+ s = QUOTE + s + QUOTE;
+
+ return s;
+ }
+
+ private const string QUOTE = "\"";
+ private const string ESCAPED_QUOTE = "\"\"";
+ private static char[] CHARACTERS_THAT_MUST_BE_QUOTED = { ',', '"', '\n' };
+ }
+}
diff --git a/tests/src/sizeondisk/sodbench/SoDBench.csproj b/tests/src/sizeondisk/sodbench/SoDBench.csproj
new file mode 100644
index 0000000000..e61c660307
--- /dev/null
+++ b/tests/src/sizeondisk/sodbench/SoDBench.csproj
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <AssemblyName>SoDBench</AssemblyName>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{507E3CC2-5D95-414D-9F01-2A106FC177DC}</ProjectGuid>
+ <OutputType>exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.5</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.5</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <RestoreOutputPath>.\obj</RestoreOutputPath>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="SoDBench.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="..\..\performance\performance.targets" />
+
+ <PropertyGroup>
+ <ProjectAssetsFile>..\..\performance\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
diff --git a/tests/src/tracing/common/common.csproj b/tests/src/tracing/common/common.csproj
index 0b90eae649..ca34349b16 100644
--- a/tests/src/tracing/common/common.csproj
+++ b/tests/src/tracing/common/common.csproj
@@ -12,6 +12,7 @@
<CLRTestKind>BuildOnly</CLRTestKind>
<DefineConstants>$(DefineConstants);STATIC</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
diff --git a/tests/src/tracing/eventsourcesmoke/eventsourcesmoke.csproj b/tests/src/tracing/eventsourcesmoke/eventsourcesmoke.csproj
index 897ebfd983..a617c6657a 100644
--- a/tests/src/tracing/eventsourcesmoke/eventsourcesmoke.csproj
+++ b/tests/src/tracing/eventsourcesmoke/eventsourcesmoke.csproj
@@ -12,6 +12,7 @@
<CLRTestKind>BuildAndRun</CLRTestKind>
<DefineConstants>$(DefineConstants);STATIC</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
diff --git a/tests/x64_arm64_altjit.cmd b/tests/x64_arm64_altjit.cmd
new file mode 100644
index 0000000000..d6c3fdd483
--- /dev/null
+++ b/tests/x64_arm64_altjit.cmd
@@ -0,0 +1,6 @@
+set COMPlus_AltJit=*
+set COMPlus_AltJitNgen=*
+set COMPlus_AltJitName=protononjit.dll
+set COMPlus_NoGuiOnAssert=1
+set COMPlus_ContinueOnAssert=0
+set COMPlus_AltJitAssertOnNYI=1
diff --git a/tests/x86_arm_altjit.cmd b/tests/x86_arm_altjit.cmd
new file mode 100644
index 0000000000..d6c3fdd483
--- /dev/null
+++ b/tests/x86_arm_altjit.cmd
@@ -0,0 +1,6 @@
+set COMPlus_AltJit=*
+set COMPlus_AltJitNgen=*
+set COMPlus_AltJitName=protononjit.dll
+set COMPlus_NoGuiOnAssert=1
+set COMPlus_ContinueOnAssert=0
+set COMPlus_AltJitAssertOnNYI=1